/* #night — the pinned night (SECTIONS.md §4).
   One camp, one framing, five times of night: the five frames are stacked and cross-faded by --p (continuous scrub),
   with a single shared slow push-in. 04-night.js adds .night--pinned and writes --p (0..1) on the stage.
   BASE = the static list (no JS, reduced motion, no sticky): heading + 5 cards on the night ground. */
.sec--night { background: var(--night); }

.night-head, .night-beats { inline-size: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }
.night-head { display: grid; gap: 14px; justify-items: center; text-align: center; margin-block-end: clamp(32px, 5vw, 56px); }

/* static list: 5 across ≥ 1100px, 2+2+1 (last one centred) ≥ 761px, one column on phones */
.night-beats { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; }
.beat { flex: 0 1 calc(50% - 10px); display: grid; grid-template-rows: auto 1fr; overflow: hidden; border-radius: var(--r-card); background: var(--night-2); border: 1px solid var(--line-night); }
@media (min-width: 1100px) { .beat { flex: 1 1 0; min-inline-size: 0; } }
@media (max-width: 760px) { .beat { flex: 1 1 100%; } }
.beat-media img { inline-size: 100%; block-size: auto; aspect-ratio: 3 / 2; object-fit: cover; }
.beat-cap { display: grid; gap: 6px; align-content: start; padding: 20px 22px 24px; }
.beat-time { font-family: var(--font-text); font-weight: 600; font-size: var(--t-xl); line-height: var(--lh-display); color: var(--gold); font-variant-numeric: lining-nums; }
.beat-title { font-size: var(--t-lg); }
.beat-line { font-size: var(--t-md); line-height: 1.85; color: var(--star-2); }

/* the arc, tint and scrim only exist while pinned */
.night-tint, .night-scrim, .night-arc { display: none; }

/* ───────────────────────── pinned mode ───────────────────────── */
.night--pinned { padding-block: 0; scroll-margin-block-start: calc(-1 * (var(--header-h) + 8px)); }
.night--pinned .night-track { block-size: 400vh; position: relative; }
.night--pinned .night-stage {
  --p: 0; --arc-h: clamp(96px, 20svh, 200px); --arc-bottom: 20px;
  position: sticky; inset-block-start: 0; block-size: 100vh; block-size: 100svh;
  overflow: clip; isolation: isolate; background: var(--night);
}

/* heading rides the top of the stage over the top scrim */
.night--pinned .night-head {
  position: absolute; inset-block-start: calc(var(--header-h) + 18px); inset-inline: 0; z-index: 3; margin-block-end: 0; gap: 8px;
}

/* layer a: the five frames of ONE camera. Frame 1 is always opaque underneath; frame i (i ≥ 1) fades in over the span
   between beat centres (p = (i-1)/4 → i/4) and then stays → the lower layer is always opaque, so there is no dip. */
.night--pinned .night-beats { position: absolute; inset: 0; inline-size: auto; margin: 0; display: block; }
.night--pinned .beat { position: absolute; inset: 0; display: block; border: 0; border-radius: 0; background: transparent; overflow: visible; pointer-events: none; }
.night--pinned .beat-media { position: absolute; inset: 0; background: var(--night); opacity: 1; will-change: opacity; }
.night--pinned .beat:nth-child(n+2) .beat-media { opacity: clamp(0, calc(var(--p) * 4 - (var(--i) - 1)), 1); }
/* one slow shared push-in (same value on every frame, so the camera never jumps) */
.night--pinned .beat-media img {
  position: absolute; inset: 0; inline-size: 100%; block-size: 100%; aspect-ratio: auto; object-fit: cover; object-position: 50% 50%;
  transform-origin: 50% 62%; scale: calc(1 + .06 * var(--p)); will-change: scale;
}

/* layer b: sky tint follows p — dusk → night (.3–.8) → dawn */
.night--pinned .night-tint { display: block; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.night--pinned .night-tint i { position: absolute; inset: 0; }
.night--pinned .tint-dusk { background: rgba(194, 101, 43, .18); opacity: max(0, calc(1 - var(--p) / .3)); }
.night--pinned .tint-night { background: rgba(10, 11, 20, .25); opacity: max(0, min(1, calc(var(--p) / .3), calc((1 - var(--p)) / .2))); }
.night--pinned .tint-dawn { background: rgba(120, 140, 190, .16); opacity: max(0, calc((var(--p) - .8) / .2)); }

/* layer c: scrims — top under the heading, bottom under caption + arc (type over photos: declared ground + scrim) */
.night--pinned .night-scrim {
  display: block; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10, 11, 20, .9) 0, rgba(10, 11, 20, .74) 14%, rgba(10, 11, 20, .35) 25%, rgba(10, 11, 20, 0) 38%),
    linear-gradient(to top, rgba(10, 11, 20, .92) 0, rgba(10, 11, 20, .8) 22%, rgba(10, 11, 20, .5) 40%, rgba(10, 11, 20, 0) 62%);
}

/* layer e: caption, centred above the arc; elements rise 12px + fade on beat change (snaps per beat) */
.night--pinned .beat-cap {
  position: absolute; z-index: 3; inset-inline: var(--gutter); inset-block-end: calc(var(--arc-bottom) + var(--arc-h) + 14px);
  max-inline-size: 38rem; margin-inline: auto; padding: 0; text-align: center; justify-items: center; gap: 4px;
}
/* local plate: keeps the caption >= 4.5:1 over bright scenes (only the active one is drawn) */
.night--pinned .beat-cap::before {
  content: ""; position: absolute; inset: -26px -12%; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .4s ease;
  background: radial-gradient(closest-side, rgba(10, 11, 20, .6) 0, rgba(10, 11, 20, .6) 55%, rgba(10, 11, 20, 0) 100%);
}
.night--pinned .beat.is-active .beat-cap::before { opacity: 1; }
.night--pinned .beat-time { font-size: var(--d-h2); }
.night--pinned .beat-title { font-size: var(--t-xl); }
.night--pinned .beat-line { line-height: 1.85; }
.night--pinned .beat-cap > * { opacity: 0; translate: 0 12px; transition: opacity .25s ease, translate .25s ease; }
.night--pinned .beat.is-active .beat-cap > * { opacity: 1; translate: 0 0; transition: opacity .5s var(--ease-out), translate .5s var(--ease-out); }
.night--pinned .beat.is-active .beat-cap > :nth-child(1) { transition-delay: .2s; }
.night--pinned .beat.is-active .beat-cap > :nth-child(2) { transition-delay: .28s; }
.night--pinned .beat.is-active .beat-cap > :nth-child(3) { transition-delay: .36s; }

/* layer d: horizon arc. Geometry is physical on purpose (path coordinates), the sun/moon dot runs right → left. */
.night--pinned .night-arc {
  display: block; position: absolute; z-index: 3; inset-inline: 0; inset-block-end: var(--arc-bottom);
  inline-size: min(100% - 2 * var(--gutter), 1100px); block-size: var(--arc-h); margin-inline: auto;
}
.night-arc svg { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; overflow: visible; }
.night-arc path { fill: none; stroke: var(--line-night); stroke-width: 1; vector-effect: non-scaling-stroke; }
.night-arc .arc-path { stroke: var(--star-3); }
.arc-tick {
  position: absolute; inline-size: 14px; block-size: 14px; translate: -50% -50%; background: var(--star-3);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); transition: background-color .4s ease;
}
.arc-tick.is-past { background: var(--gold); }
.arc-dot {
  position: absolute; left: 0; top: 0; inline-size: 12px; block-size: 12px; margin: -6px 0 0 -6px; border-radius: var(--r-pill);
  background: var(--gold); box-shadow: 0 0 14px 4px color-mix(in srgb, var(--gold) 60%, transparent); will-change: transform;
}

@media (max-width: 760px) {
  .night--pinned .night-track { block-size: 360vh; }
  /* the mobile sticky CTA bar (~68px) lives at the bottom edge: lift the arc above it */
  .night--pinned .night-stage { --arc-h: clamp(84px, 13svh, 110px); --arc-bottom: 84px; }
  .night--pinned .beat-title { font-size: var(--t-lg); }
  /* portrait: the scene lives in the upper 70% so its subject stays clear of the caption; the edge melts into the night.
     One shared crop (same camera): telescope, fire and the middle tents stay in frame. */
  .night--pinned .beat-media { inset-block-end: 30%; -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent); mask-image: linear-gradient(to bottom, #000 72%, transparent); }
  .night--pinned .beat-media img { object-position: 44% 50%; transform-origin: 44% 60%; }
  .night--pinned .night-head { gap: 4px; }
  .arc-tick { inline-size: 12px; block-size: 12px; }
}
@media (max-height: 640px) and (min-width: 761px) {
  .night--pinned .night-stage { --arc-h: 84px; }
  .night--pinned .beat-line { font-size: var(--t-md); }
}
@media (prefers-reduced-motion: reduce) {
  .night--pinned .beat-cap > * { transition: none; }
}

/* round 2 — the hero's constellation returns over the same camp (desktop): lines draw at 8:30, your star blooms
   at 11:00 with its thread to the tent, the other seven go out at dawn. Same push-in as the frames. */
.night-const { display: none; }
@media (min-width: 761px) {
  .night--pinned .night-const {
    display: block; position: absolute; inset: 0; inline-size: 100%; block-size: 100%; z-index: 2; pointer-events: none;
    transform-origin: 50% 62%; scale: calc(1 + .06 * var(--p));
  }
  .nseg { fill: none; stroke: rgba(246, 231, 200, .5); stroke-width: 1.4; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .5s var(--ease-io) calc(var(--i) * .07s), opacity .6s ease; }
  .nthread { fill: none; stroke: rgba(242, 199, 126, .7); stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .6s var(--ease-io) .2s; }
  .ncs { fill: var(--star); opacity: 0; transform-box: fill-box; transform-origin: center; scale: .3; transition: opacity .45s ease calc(var(--i) * .07s), scale .45s var(--ease-io) calc(var(--i) * .07s); }
  .ncs--you { fill: var(--gold); }
  .night-stage[data-beat="2"] .ncs, .night-stage[data-beat="3"] .ncs { opacity: 1; scale: 1; }
  .night-stage[data-beat="2"] .nseg, .night-stage[data-beat="3"] .nseg { stroke-dashoffset: 0; }
  .night-stage[data-beat="3"] .ncs--you { scale: 1.35; transition: scale .5s var(--ease-spring); }
  .night-stage[data-beat="3"] .nthread, .night-stage[data-beat="4"] .nthread { stroke-dashoffset: 0; }
  .night-stage[data-beat="4"] .ncs--you { opacity: 1; scale: 1.1; }
  .night-stage[data-beat="4"] .nseg { stroke-dashoffset: 0; opacity: 0; }
}
/* the sun/moon dot was a cursor-sized speck at 1440 */
.arc-dot { inline-size: 18px !important; block-size: 18px !important; margin: -9px 0 0 -9px; }

/* 7:00 — the first star of your constellation appears (the copy says it) */
@media (min-width: 761px) { .night-stage[data-beat="1"] .ncs[style*="--i:0"] { opacity: 1; scale: 1; } }

@media (max-width: 760px) {
  .night--pinned .beat-media img { object-position: 50% 50%; transform-origin: 50% 62%; }
  .night--pinned .night-const {
    display: block; position: absolute; inset: 0 0 30% 0; inline-size: 100%; block-size: 70%; z-index: 2; pointer-events: none;
    transform-origin: 50% 62%; scale: calc(1 + .06 * var(--p));
  }
  .nseg { fill: none; stroke: rgba(246, 231, 200, .5); stroke-width: 2.4; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .5s var(--ease-io) calc(var(--i) * .07s), opacity .6s ease; }
  .nthread { fill: none; stroke: rgba(242, 199, 126, .75); stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .6s var(--ease-io) .2s; }
  .ncs { fill: var(--star); opacity: 0; transform-box: fill-box; transform-origin: center; scale: .3; transition: opacity .45s ease calc(var(--i) * .07s), scale .45s var(--ease-io) calc(var(--i) * .07s); }
  .ncs--you { fill: var(--gold); }
  .night-stage[data-beat="2"] .ncs, .night-stage[data-beat="3"] .ncs { opacity: 1; scale: 1; }
  .night-stage[data-beat="2"] .nseg, .night-stage[data-beat="3"] .nseg { stroke-dashoffset: 0; }
  .night-stage[data-beat="3"] .ncs--you { scale: 1.35; transition: scale .5s var(--ease-spring); }
  .night-stage[data-beat="3"] .nthread, .night-stage[data-beat="4"] .nthread { stroke-dashoffset: 0; }
  .night-stage[data-beat="4"] .ncs--you { opacity: 1; scale: 1.1; }
  .night-stage[data-beat="4"] .nseg { stroke-dashoffset: 0; opacity: 0; }
}
