/* The sign-in picture as a living illustration: the storybook hawk breathes, blinks and
 * looks about. Markup comes from hero-hawk.js (the live canvas) and horizonScene() in
 * spots.js (the light over it).
 *
 * The stage is a box with the painting's own proportions, sized and placed to cover its
 * panel the way object-fit: cover would. Everything inside it (the still painting, the live
 * canvas, the sparkles and stars) is positioned in the painting's coordinates, so the layers
 * stay registered at any panel size. --hero-w, --hero-x and --hero-y choose the crop.
 * The colours here belong to the painting, not to the interface, so they are written out. */
.hero-stage { position: absolute; inset: 0; z-index: -2; }
.hero-stage > img, .hero-hawk, .hero-stage > svg {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
}
.hero-stage > img { object-fit: cover; object-position: 62% 72%; }
.hero-hawk { z-index: 1; opacity: 0; }
.hero-hawk.is-live { opacity: 1; }
.hero-stage > svg { z-index: 3; overflow: visible; }

@supports (width: 1cqw) {
  .hero-stage {
    --hero-w: max(100cqw, 100cqh * 896 / 1200);
    --hero-h: calc(var(--hero-w) * 1200 / 896);
    inset: auto; width: var(--hero-w); height: var(--hero-h);
    left: calc((100cqw - var(--hero-w)) * var(--hero-x, 0.62));
    top: max(calc((100cqh - var(--hero-h)) * var(--hero-y, 0.72)), calc(var(--hero-h) * var(--hero-top, -1)));
  }
  /* One column: a wide strip. Fit the hawk and his books (rows 505 to 1085 of 1200) to its
     height, keep him to the right of the lettering, and never crop the top of his head. */
  @media (max-width: 860px) {
    .hero-stage { --hero-w: max(100cqw, 100cqh * 896 / 580); --hero-x: 0.86; --hero-y: 0.82; --hero-top: -0.42; }
  }
}

/* Night: the same painting under moonlight. A deep blue multiplied over the picture (still
   or live alike), then the stars and glints above it, undimmed. */
.hero-stage::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  background:
    radial-gradient(46% 36% at 67% 70%, #cfcdd3 0%, #b4bcd000 100%),
    linear-gradient(180deg, #1f3566 0%, #3b5890 52%, #56719f 100%);
  mix-blend-mode: multiply;
}
:root[data-theme="night"] .hero-stage::after { opacity: 1; }

.horizon-stars { opacity: 0; fill: #fff6d8; }
:root[data-theme="night"] .horizon-stars { opacity: 1; }
.horizon-star { opacity: 0.72; }
.horizon-star.hs-1 { opacity: 0.5; }
.horizon-star.hs-3 { opacity: 0.86; }

/* At rest the glints lie faint on their painted sparkles and the motes are not there. */
.horizon-glint { fill: #fffdf0; opacity: 0.16; transform-box: fill-box; transform-origin: center; }
.horizon-glint-halo { opacity: 0.55; }
.horizon-mote { opacity: 0; }
.horizon-mote-dot { fill: #f7cf6b; }
:root[data-theme="night"] .horizon-glint { opacity: 0.5; }
:root[data-theme="night"] .horizon-mote-dot { fill: #ffe7a3; }

@media (prefers-reduced-motion: no-preference) {
  .hero-hawk { transition: opacity 700ms var(--ease-silk); }

  /* Periods that share no common beat, so the dust never pulses in step. */
  .horizon-glint { animation: horizon-glint 5.3s var(--ease-silk) infinite; }
  .horizon-glint.hg-1 { animation-duration: 7.1s; animation-delay: -2.2s; }
  .horizon-glint.hg-2 { animation-duration: 6.1s; animation-delay: -4.7s; }
  .horizon-glint.hg-3 { animation-duration: 8.3s; animation-delay: -1.3s; }
  .horizon-glint.hg-4 { animation-duration: 6.7s; animation-delay: -5.9s; }
  .horizon-glint.hg-5 { animation-duration: 9.1s; animation-delay: -3.4s; }
  .horizon-glint.hg-6 { animation-duration: 7.9s; animation-delay: -6.8s; }
  .horizon-glint.hg-7 { animation-duration: 10.3s; animation-delay: -0.6s; }

  .horizon-mote { animation: horizon-rise 11s linear infinite; }
  .horizon-mote-dot { animation: horizon-waft 3.7s var(--ease-silk) infinite alternate; }
  .horizon-mote.hm-1 { animation-duration: 13.7s; animation-delay: -4.1s; }
  .horizon-mote.hm-2 { animation-name: horizon-rise-wide; animation-duration: 12.1s; animation-delay: -8.3s; }
  .horizon-mote.hm-3 { animation-duration: 15.3s; animation-delay: -10.9s; }
  .horizon-mote.hm-4 { animation-name: horizon-rise-wide; animation-duration: 10.3s; animation-delay: -2.6s; }
  .horizon-mote.hm-5 { animation-duration: 16.9s; animation-delay: -6.4s; }
  .horizon-mote.hm-6 { animation-name: horizon-rise-wide; animation-duration: 14.3s; animation-delay: -12.2s; }
  .horizon-mote.hm-1 .horizon-mote-dot, .horizon-mote.hm-4 .horizon-mote-dot { animation-duration: 4.9s; }
  .horizon-mote.hm-2 .horizon-mote-dot, .horizon-mote.hm-5 .horizon-mote-dot { animation-duration: 5.7s; animation-delay: -2s; }

  .horizon-star { animation: horizon-twinkle 6.1s var(--ease-silk) infinite; }
  .horizon-star.hs-1 { animation-duration: 7.7s; animation-delay: -3.1s; }
  .horizon-star.hs-2 { animation-duration: 9.3s; animation-delay: -5.2s; }
  .horizon-star.hs-3 { animation-duration: 5.3s; animation-delay: -1.7s; }
}

@keyframes horizon-glint {
  0%, 58%, 100% { opacity: 0.1; transform: scale(0.7) rotate(0deg); }
  72% { opacity: 0.95; transform: scale(1.18) rotate(18deg); }
  84% { opacity: 0.4; transform: scale(0.9) rotate(30deg); }
}
@keyframes horizon-rise {
  0% { opacity: 0; transform: translate(0, 0); }
  14% { opacity: 0.85; }
  62% { opacity: 0.6; }
  100% { opacity: 0; transform: translate(34px, -176px); }
}
@keyframes horizon-rise-wide {
  0% { opacity: 0; transform: translate(0, 0); }
  18% { opacity: 0.8; }
  58% { opacity: 0.55; }
  100% { opacity: 0; transform: translate(72px, -132px); }
}
@keyframes horizon-waft { from { transform: translateX(-7px); } to { transform: translateX(8px); } }
@keyframes horizon-twinkle { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.95; } }
