/* =====================================================================
   OSE · Sky · styles/components/sky.css
   ---------------------------------------------------------------------
   Deep space behind a night band: stars at three depths, two faint
   constellations (Bắc Đẩu and Cassiopeia's W, as shapes) and two small
   flat planets. Static and complete without JavaScript or with reduced
   motion; the home hero's through-ring scene flies the camera through it
   by scaling each depth layer on its own (near layers faster). At rest,
   on the full motion path (html.motion), it lives: many stars twinkle
   (three rhythms, three phases), a few bright ones glint, each depth
   drifts on its own there and back (the near one furthest, so the sky
   has depth), and the scene sends a shooting star across now and then. .is-still (set by the
   scene once the visitor scrolls) pauses all of it. Night and
   navy bands only. Component tokens only: --sky-*.

   Markup — generated: write <!-- sky --><!-- /sky --> as the FIRST child
   of a positioned band, then run node scripts/make-sky.mjs:
     <div class="sky" aria-hidden="true">
       <div class="sky__depth sky__depth--far">
         <svg class="sky__layer sky__layer--far" data-depth="far" viewBox="0 0 1600 1000"
              preserveAspectRatio="xMidYMid slice" focusable="false">
           <polyline class="sky__line" points="…"/>
           <circle class="sky__star sky__star--dim | --mid | --bright
                    [sky__star--tw1 | tw2 | tw3 | glint1 | glint2  sky__star--ph1 | ph2 | ph3]" cx cy r/>…
         </svg>
       </div>
       <div class="sky__depth sky__depth--mid"><svg class="sky__layer sky__layer--mid" …>…</svg></div>
       <div class="sky__depth sky__depth--near"><svg class="sky__layer sky__layer--near" …>…</svg></div>
       <div class="sky__fixed">
         <div class="sky__layer sky__layer--mid sky__planets" data-depth="mid"><span class="sky__planet sky__planet--a"></span></div>
         <div class="sky__layer sky__layer--near sky__planets" data-depth="near"><span class="sky__planet sky__planet--b"></span></div>
       </div>
     </div>

   Box      absolute, inset 0 of the band, under its content (--sky-z),
            clips, never takes pointer events. Each layer covers the box
            (slice: phones see the middle strip).
   Stars    cream starlight (never white) at three tones; constellation
            lines one hairline at any zoom (non-scaling stroke); planets
            flat fills, no glow, always whole (John): each in its own
            layer in .sky__fixed (no drift: only the mouse lean moves
            them), placed by layout (never in the cropped SVG): the near
            one just below the nav at the top right, above the O, both
            off the sides by their lean and a margin.
   Scenes   may scale a layer and fade it (transform, opacity), shake the
            whole .sky a few pixels (transform; the band's frame hides the
            edges), and may add
            a <canvas class="sky__streaks"> and a <canvas class="sky__warp">
            (both cover the box), a <span class="sky__glow"> (the light
            ahead in the jump, moved by transform) and a <span
            class="sky__meteor"> (moved by transform).
   Motion   twinkle (opacity), glint (scale) and drift (translate on each
            .sky__depth, never on a layer, so the flight's transforms are
            untouched): only with html.motion and no reduced motion.
            .is-still pauses them.
   ===================================================================== */

@layer components {
  .sky {
    position: absolute;
    inset: 0;
    z-index: var(--sky-z);
    overflow: hidden;
    pointer-events: none;
  }

  .sky__depth,
  .sky__fixed,
  .sky__layer,
  .sky__streaks,
  .sky__warp {
    position: absolute;
    inset: 0;
    display: block;
    inline-size: 100%;
    block-size: 100%;
  }

  .sky__star {
    fill: var(--sky-star-color);
  }

  .sky__star--dim {
    opacity: var(--sky-star-opacity-dim);
  }

  .sky__star--mid {
    opacity: var(--sky-star-opacity-mid);
  }

  .sky__star--bright {
    opacity: var(--sky-star-opacity-bright);
  }

  .sky__line {
    fill: none;
    stroke: var(--sky-line-color);
    stroke-width: var(--sky-line-width);
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }

  /* Phones see the quiet middle of the sky, no planets (as when they were
     in the cropped SVG). */
  @media (width < 48em) {
    .sky__planets {
      display: none;
    }
  }

  .sky__planet {
    position: absolute;
    display: block;
    aspect-ratio: var(--sky-planet-ratio);
    border-radius: var(--sky-planet-radius);
  }

  .sky__planet--a {
    inset-block-start: var(--sky-planet-a-y);
    inset-inline-start: clamp(var(--sky-planet-a-clear-x), var(--sky-planet-a-x), calc(100% - var(--sky-planet-a-size) - var(--sky-planet-a-clear-end)));
    inline-size: var(--sky-planet-a-size);
    background-color: var(--sky-planet-a);
  }

  .sky__planet--b {
    inset-block-start: var(--sky-planet-b-clear);
    inset-inline-start: clamp(var(--sky-planet-b-clear-x), var(--sky-planet-b-x), calc(100% - var(--sky-planet-b-size) - var(--sky-planet-b-clear-x)));
    inline-size: var(--sky-planet-b-size);
    background-color: var(--sky-planet-b);
  }

  /* ---- The sky at rest ------------------------------------------- */
  .sky__meteor {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    inline-size: var(--sky-meteor-length);
    block-size: var(--sky-meteor-width);
    border-radius: var(--sky-meteor-radius);
    background-image: linear-gradient(to right, var(--sky-meteor-tail), var(--sky-meteor));
    transform-origin: 100% 50%;
    opacity: 0;
  }

  /* The light ahead in the jump: the scene places, scales and fades it. */
  .sky__glow {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    inline-size: var(--sky-glow-size);
    block-size: var(--sky-glow-size);
    border-radius: var(--sky-glow-radius);
    background-image: radial-gradient(closest-side, var(--sky-glow), var(--sky-glow-clear));
    opacity: 0;
  }

  /* ---- At rest ------------------------------------------------------ */
  @keyframes sky-twinkle {
    to {
      opacity: var(--sky-twinkle-low);
    }
  }

  @keyframes sky-glint {
    from {
      scale: var(--sky-glint-rest);
    }

    to {
      scale: var(--sky-glint-scale);
    }
  }

  @keyframes sky-drift {
    from {
      translate: calc(var(--_x) * -1) calc(var(--_y) * -1);
    }

    to {
      translate: var(--_x) var(--_y);
    }
  }

  .sky__depth--far {
    --_x: var(--sky-drift-far-x);
    --_y: var(--sky-drift-far-y);
    --_drift: var(--sky-drift-far-duration);
  }

  .sky__depth--mid {
    --_x: var(--sky-drift-mid-x);
    --_y: var(--sky-drift-mid-y);
    --_drift: var(--sky-drift-mid-duration);
  }

  .sky__depth--near {
    --_x: var(--sky-drift-near-x);
    --_y: var(--sky-drift-near-y);
    --_drift: var(--sky-drift-near-duration);
  }

  .sky__star--glint1,
  .sky__star--glint2 {
    transform-box: fill-box;
    transform-origin: center;
  }

  @media (prefers-reduced-motion: no-preference) {
    .motion .sky__depth {
      animation: sky-drift var(--_drift) var(--sky-ease) infinite alternate;
    }

    .motion .sky__star--tw1 {
      animation: sky-twinkle var(--sky-twinkle-a) var(--sky-ease) infinite alternate;
    }

    .motion .sky__star--tw2 {
      animation: sky-twinkle var(--sky-twinkle-b) var(--sky-ease) infinite alternate;
    }

    .motion .sky__star--tw3 {
      animation: sky-twinkle var(--sky-twinkle-c) var(--sky-ease) infinite alternate;
    }

    /* A glint: a short flare at the end of a long, quiet rhythm (the exit
       ease stays low until late, alternate brings it back). */
    .motion .sky__star--glint1 {
      animation: sky-glint var(--sky-glint-a) var(--sky-glint-ease) infinite alternate;
    }

    .motion .sky__star--glint2 {
      animation: sky-glint var(--sky-glint-b) var(--sky-glint-ease) infinite alternate;
    }

    .motion .sky__star--ph1 {
      animation-delay: var(--sky-twinkle-phase-1);
    }

    .motion .sky__star--ph2 {
      animation-delay: var(--sky-twinkle-phase-2);
    }

    .motion .sky__star--ph3 {
      animation-delay: var(--sky-twinkle-phase-3);
    }

    .sky.is-still .sky__depth,
    .sky.is-still .sky__star {
      animation-play-state: paused;
    }
  }
}
