/* ==========================================================================
   ASTRA LEXICA — SITE OPENER: ALOp14 · SCRUB
   --------------------------------------------------------------------------
   SOURCE OF TRUTH: design-spec/openers/ALOp14-Scrub.dc.html (the retimed
   5.6s review board). Its header carries the beat map; that beat map is the
   contract and every keyframe percentage below is copied from it VERBATIM.

   This file is the CANVAS -> VIEWPORT half of the integration. The board is a
   fixed 1280x980 stage with px-resolved geometry and a four-phase review LOOP.
   The live opener is a full-viewport overlay that PLAYS ONCE. Three surgeries,
   and nothing else:

   1. LOOP -> ONCE.  Every `infinite` became `1 both`. Durations and keyframe
      percentages are untouched, so every beat still lands on the same
      millisecond it did on the board. The board's `cycle` seam animation
      (0-1.07% / 97.15-100% opacity dip) is DELETED — its own header calls it
      "the review-loop seam only, not part of the opener".

   2. TAIL REMOVED.  The board's chooser end-state (.routes/.tile/.beam/.disc)
      and its review caption (.op-cap) do not exist here: the REAL chooser is
      already rendered underneath this overlay and is what the handover reveals.
      Duplicating tiles and a crown over the page's own would be the defect.
      Everything up to and including the 80%->89% handover choreography (track
      contracts, detents scale out, strip clears, head runs off the right edge,
      crown lifts) is kept, and plays underneath the stub's 500ms fade.

   3. PX -> FLUID.  The board resolved to a 1280x980 artboard; the live opener
      has to hold from a 344px Fold cover screen to a 1920px desktop. The
      mapping, in one place so it can be checked against the board:

        board (1280x980)                 live
        ------------------------------   -----------------------------------
        track  left 164, width 952       --al-track: min(1040px, 74.4vw),
                                         centred. 952/1280 = 74.4%, and the
                                         164px inset is 12.8% each side, so
                                         the proportion is exact at any width.
        detents at 164/481/799/1116      0% / 33.33% / 66.67% / 100% of --al-track
        head legs 0/317/635/952          0 / t/3 / 2t/3 / t   (317 = 952/3)
        head run-off 1180                calc(t * 1.24)       (1180/952 = 1.2395)
        wordmark 88px, nib travel 708px  --al-title: clamp(28px,6.875vw,104px)
                                         (88/1280 = 6.875vw); the nib is rebased
                                         to EM of the title (708/88 = 8.045em,
                                         354/88 = 4.023em) so it tracks the type
                                         at every size instead of drifting.
        strip 8 cells, 112w / 120 pitch  flex row, 8 x flex:1, gap 8px.
                                         (952 - 7*8)/8 = 112 exactly at 1280.
        cell children at px left/height  percentages of 112 x 46 (built in JS)
        vertical stack at fixed tops     a centred flex column: crown, then the
                                         band (eras + rail + strip + caption).
                                         The board's own gaps become clamps on
                                         the same ratios (49/32/24/22px at 980).
        motes: box-shadow coordinates    tiled repeating radial-gradients on the
               laid out for 1280x980     same coprime 47s/71s clocks. This is the
                                         house idiom — see the .stars comment in
                                         index.html: box-shadow starfields are
                                         laid out for ONE canvas size and go bald
                                         on any other viewport.

   FONTS: none loaded here. The board's Google Fonts <link> is deliberately not
   carried over — the root posture is zero third-party origins, and index.html
   already self-hosts the same three faces via /fonts/fonts.css. The tokens
   (--serif/--sans/--mono/--ease/--gold/...) come from /shared/tokens.css and
   are NOT redeclared; --scrub is the one token the board added and it is
   scoped to the overlay rather than pushed into :root.

   REDUCED MOTION: there is no reduced-motion block in this file BY DESIGN. The
   opener declares no playsUnderReducedMotion, so index.html's stub refuses to
   render it at all and the chooser is interactive immediately — which is the
   page's existing behaviour and strictly better than a static title card.

   NO CONTROLS: nothing in here is an <a>, <button> or <input>. The single
   interaction is tap-anywhere-to-skip, which the stub owns.
   ========================================================================== */

#al-opener{
  /* a scrub eases in and out of every detent — the board's own extra token */
  --scrub:cubic-bezier(0.45,0,0.35,1);

  --al-track:min(1040px,74.4vw);       /* 952/1280 = 74.4% */
  --al-title:clamp(28px,6.875vw,104px);/* 88/1280 = 6.875vw */
  --al-det:clamp(9px,0.86vw,11px);     /* 11px detent */
  --al-head:clamp(7px,0.70vw,9px);     /* 9px playhead */
  --al-flare:clamp(120px,18vw,230px);  /* 230px landing flare */
  --al-eraw:clamp(76px,9.4vw,120px);   /* 120px era label box */
  --al-erah:clamp(24px,2.9vh,30px);    /* era label block height */
  --al-railgap:clamp(14px,2.2vh,22px); /* era block -> rail (616-594) */
  --al-cellh:clamp(26px,4.7vh,46px);   /* 46px frame height */
  --al-cellgap:clamp(4px,0.62vw,8px);  /* 120 pitch - 112 width */
  --al-stripgap:clamp(22px,3.3vh,32px);/* rail -> strip (648-616) */
  --al-labgap:clamp(16px,2.4vh,24px);  /* strip -> caption (718-694) */
  --al-crowngap:clamp(28px,5vh,49px);  /* crown -> era block (566-517) */
}

/* ---------------- the beat clock ----------------
   The handover has to fire on the SAME timeline the beats run on, and a JS
   timer does not. Measured on this page under software rasterisation, the
   overlay's first animated frame lands 78-592ms after DOMContentLoaded — the
   cost of painting the field, the grain and the strip for the first time, and
   a mid-range phone is far closer to that than to a desktop GPU. A timer
   started at requestAnimationFrame would then call done() while the head was
   still parked and the crown had not begun to lift: the hold clipped and the
   exit choreography cut off entirely.

   So the clock is an animation like every other beat — zero-visual, 4480ms
   (beats + hold), sharing the document timeline with the scrub — and
   opener-scrub.js hands over on its animationend. As a bonus this is also
   the correct behaviour in a backgrounded tab, where a timer would burn the
   opener down while nothing was on screen. */
.alop-clock{position:absolute;left:0;top:0;width:0;height:0;opacity:0;pointer-events:none;
  animation:alopBeatClock 4480ms linear 1 both;}
@keyframes alopBeatClock{from{opacity:0}to{opacity:0}}

/* the board. .op (the mount) already supplies fixed/inset:0/overflow:hidden. */
.alop-board{
  position:absolute;inset:0;overflow:hidden;
  background:#05060C;color:var(--n-fg);font-family:var(--sans);
  display:flex;flex-direction:column;align-items:center;justify-content:center;
}

/* ==========================================================================
   AMBIENT ZONE — one positioned layer, exactly as on the board.
   The post-launch video loop lands HERE and nowhere else; the scrub above it
   is untouched by that swap (MIGRATION-PLAN, Cinematic tier). The page's own
   chooser background is a separate, untouched thing — this ambient is
   self-contained and leaves with the overlay.
   Clocks stay coprime (37 / 59 / 47 / 71 / 0.74) so the composite never
   visibly repeats inside a 5s opener or a 10-minute idle.
   ========================================================================== */
.alop-zone{position:absolute;inset:0;z-index:0;}
.alop-field{
  position:absolute;inset:-8%;z-index:0;
  background:
    radial-gradient(42% 40% at 24% 34%, rgba(201,178,106,0.19) 0%, rgba(201,178,106,0.05) 46%, rgba(201,178,106,0) 74%),
    radial-gradient(44% 40% at 78% 40%, rgba(127,180,216,0.18) 0%, rgba(127,180,216,0.05) 46%, rgba(127,180,216,0) 74%),
    radial-gradient(56% 26% at 50% 68%, rgba(201,160,232,0.11) 0%, rgba(201,160,232,0) 72%),
    radial-gradient(ellipse 80% 70% at 50% 46%, #15182B 0%, #0A0C18 56%, #05060C 100%);
  animation:alopFieldDrift 37s ease-in-out infinite, alopFieldHue 59s ease-in-out infinite;
}
@keyframes alopFieldDrift{
  0%{transform:scale(1.02) translate3d(0,0,0)}
  50%{transform:scale(1.06) translate3d(-20px,16px,0)}
  100%{transform:scale(1.02) translate3d(0,0,0)}
}
@keyframes alopFieldHue{0%{filter:hue-rotate(0deg)}50%{filter:hue-rotate(6deg)}100%{filter:hue-rotate(0deg)}}

/* motes: tiled, not box-shadow-plotted (see PX -> FLUID note above). Two
   layers on the board's own 47s / 71s counter-drift, at its own opacities. */
.alop-motes{position:absolute;inset:-80px;z-index:1;pointer-events:none;background-repeat:repeat;}
.alop-mote-a{
  opacity:0.56;
  background-image:
    radial-gradient(1.2px 1.2px at 18% 22%, #FFFFFF, rgba(255,255,255,0) 60%),
    radial-gradient(1px 1px     at 62% 12%, #DDE4FF, rgba(221,228,255,0) 60%),
    radial-gradient(1.3px 1.3px at 84% 54%, #FFFFFF, rgba(255,255,255,0) 60%),
    radial-gradient(1px 1px     at 33% 71%, #C9CFE8, rgba(201,207,232,0) 60%),
    radial-gradient(1.1px 1.1px at 8%  58%, #FFFFFF, rgba(255,255,255,0) 60%),
    radial-gradient(1px 1px     at 51% 43%, #DDE4FF, rgba(221,228,255,0) 60%);
  background-size:317px 271px, 431px 353px, 523px 419px, 613px 487px, 379px 293px, 691px 557px;
  animation:alopMoteA 47s linear infinite;
}
.alop-mote-b{
  opacity:0.30;
  background-image:
    radial-gradient(1.1px 1.1px at 27% 64%, #9AA3C4, rgba(154,163,196,0) 60%),
    radial-gradient(1px 1px     at 71% 29%, #FFFFFF, rgba(255,255,255,0) 60%),
    radial-gradient(1.2px 1.2px at 12% 41%, #9AA3C4, rgba(154,163,196,0) 60%),
    radial-gradient(1px 1px     at 88% 77%, #FFFFFF, rgba(255,255,255,0) 60%),
    radial-gradient(1px 1px     at 44% 8%,  #9AA3C4, rgba(154,163,196,0) 60%);
  background-size:409px 347px, 557px 463px, 293px 251px, 647px 521px, 479px 397px;
  animation:alopMoteB 71s linear infinite;
}
@keyframes alopMoteA{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(32px,-28px,0)}}
@keyframes alopMoteB{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(-26px,30px,0)}}

.alop-grain{
  position:absolute;inset:-60px;z-index:2;pointer-events:none;opacity:0.05;mix-blend-mode:overlay;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.84' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='150' height='150' filter='url(%23n)'/%3E%3C/svg%3E");
  animation:alopGrain 0.74s steps(6) infinite;
}
@keyframes alopGrain{
  0%{background-position:0 0}17%{background-position:29px -45px}34%{background-position:-43px 22px}
  51%{background-position:18px 39px}68%{background-position:-31px -26px}85%{background-position:45px 14px}
  100%{background-position:0 0}
}

/* ==========================================================================
   STAGE — the board's fixed tops become one centred flex column.
   ========================================================================== */
.alop-stage{
  position:relative;z-index:4;
  display:flex;flex-direction:column;align-items:center;
  width:100%;padding:0 var(--gutter);
}

/* ---------------- crown: eyebrow + wordmark + lead ----------------
   It lifts at the handover exactly as it does on the board (80% -> 89%),
   underneath the stub's fade. It does NOT seat: the page's own hero is
   what the fade reveals. */
.alop-crown{
  display:flex;flex-direction:column;align-items:center;text-align:center;
  animation:alopCrown 5.6s var(--ease) 1 both;
}
@keyframes alopCrown{0%,80%{transform:translateY(0)}89%,100%{transform:translateY(-146px)}}

.alop-eyebrow{
  font-family:var(--mono);font-size:clamp(9px,0.82vw,10.5px);letter-spacing:0.42em;color:var(--gold);
  opacity:0;animation:alopEyeIn 5.6s var(--ease) 1 both;
}
@keyframes alopEyeIn{0%,42.5%{opacity:0}53%,100%{opacity:1}}

/* TITLE TREATMENT — the name is WRITTEN in the playhead's wake. A clip chases
   the head across the letters and a gold nib rides the leading edge, so the
   title is the output of the scrub rather than a beat of its own.
   --al-title lives on .alop-wm so the nib's em offsets resolve against it. */
.alop-wm{position:relative;margin-top:clamp(12px,2vh,20px);font-size:var(--al-title);line-height:1.045;}
.alop-wm b{
  display:block;font-family:var(--serif);font-weight:500;font-size:1em;line-height:1.045;
  letter-spacing:0.13em;padding-left:0.13em;white-space:nowrap;
  color:var(--gold-lt);text-shadow:0 0 44px rgba(201,178,106,0.28);
  clip-path:inset(0 100% 0 0);animation:alopWrite 5.6s var(--scrub) 1 both;
}
@keyframes alopWrite{
  0%,12%{clip-path:inset(0 100% 0 0)}
  25.5%{clip-path:inset(0 66% 0 0)}
  36.5%{clip-path:inset(0 34% 0 0)}
  49%,100%{clip-path:inset(0 0 0 0)}
}
.alop-nib{
  position:absolute;left:50%;top:0.136em;width:2px;height:0.773em;margin-left:-4.023em;z-index:1;opacity:0;
  background:linear-gradient(180deg,rgba(255,246,216,0),#FFF6D8,rgba(255,246,216,0));
  animation:alopNib 5.6s var(--scrub) 1 both;
}
@keyframes alopNib{
  0%,12%{transform:translateX(0);opacity:0}
  15.5%{opacity:1}
  25.5%{transform:translateX(2.727em)}
  36.5%{transform:translateX(5.307em)}
  47%{transform:translateX(8.045em);opacity:1}
  52%,100%{transform:translateX(8.045em);opacity:0}
}

.alop-lead{
  margin:clamp(14px,2.2vh,22px) 0 0 0;max-width:min(640px,100%);
  font-size:clamp(13.5px,1.25vw,16px);font-weight:300;line-height:1.7;color:var(--n-dim);
  text-wrap:pretty;
  opacity:0;animation:alopLeadIn 5.6s var(--ease) 1 both;
}
@keyframes alopLeadIn{0%,53.5%{opacity:0;transform:translateY(16px)}64%,100%{opacity:1;transform:translateY(0)}}

/* ==========================================================================
   THE BAND — era labels, the track, its detents, the head, and the strip of
   frames the head is scrubbing. Everything here is positioned against
   --al-track, so the whole mechanism stays proportional at every viewport.
   ========================================================================== */
.alop-band{position:relative;width:var(--al-track);max-width:100%;margin-top:var(--al-crowngap);}

.alop-railwrap{position:relative;width:100%;height:calc(var(--al-erah) + var(--al-railgap));}

.alop-rail{
  position:absolute;left:0;bottom:0;width:100%;height:1px;z-index:4;transform-origin:left;
  background:linear-gradient(90deg,rgba(201,178,106,0.5) 0%,rgba(230,212,154,0.62) 46%,rgba(127,180,216,0.5) 100%);
  animation:alopTrackIn 5.6s var(--ease) 1 both;
}
@keyframes alopTrackIn{0%{transform:scaleX(0)}10%,80%{transform:scaleX(1)}89%,100%{transform:scaleX(0)}}

/* the four detents: era stops the head eases into.
   centred on the 1px rail with margins, never transforms — the transform
   channel belongs to the scale-in beat. */
.alop-det{
  position:absolute;bottom:calc(0.5px - var(--al-det) / 2);z-index:5;
  width:var(--al-det);height:var(--al-det);margin-left:calc(var(--al-det) / -2);border-radius:50%;
  border:1px solid rgba(201,178,106,0.5);background:#080A14;
}
.alop-d1,.alop-e1{left:0;animation:alopDet1 5.6s var(--ease) 1 both}
.alop-d2,.alop-e2{left:33.3333%;animation:alopDet2 5.6s var(--ease) 1 both}
.alop-d3,.alop-e3{left:66.6667%;animation:alopDet3 5.6s var(--ease) 1 both}
.alop-d4,.alop-e4{left:100%;animation:alopDet4 5.6s var(--ease) 1 both}
@keyframes alopDet1{0%,5%{opacity:0;transform:scale(0.6)}10%,80%{opacity:1;transform:scale(1)}89%,100%{opacity:0;transform:scale(0.6)}}
@keyframes alopDet2{0%,17.5%{opacity:0;transform:scale(0.6)}22.5%,80%{opacity:1;transform:scale(1)}89%,100%{opacity:0;transform:scale(0.6)}}
@keyframes alopDet3{0%,30%{opacity:0;transform:scale(0.6)}35%,80%{opacity:1;transform:scale(1)}89%,100%{opacity:0;transform:scale(0.6)}}
@keyframes alopDet4{0%,42.5%{opacity:0;transform:scale(0.6)}47.5%,80%{opacity:1;transform:scale(1)}89%,100%{opacity:0;transform:scale(0.6)}}

.alop-era{
  position:absolute;top:0;z-index:5;width:var(--al-eraw);margin-left:calc(var(--al-eraw) / -2);
  text-align:center;font-family:var(--mono);font-size:clamp(9px,0.82vw,10.5px);
  letter-spacing:0.3em;color:var(--gold);opacity:0;
}
.alop-era small{display:block;margin-top:5px;font-size:clamp(8px,0.70vw,9px);letter-spacing:0.24em;color:#6E7488;}

/* the playhead: a comet on the track, never a handle */
.alop-head{
  position:absolute;left:0;bottom:calc(0.5px - var(--al-head) / 2);z-index:6;
  width:var(--al-head);height:var(--al-head);margin-left:calc(var(--al-head) / -2);border-radius:50%;
  background:#FFF6D8;box-shadow:0 0 14px 3px rgba(255,246,216,0.6),-26px 0 18px -5px rgba(230,212,154,0.55);
  animation:alopHead 5.6s var(--scrub) 1 both;
}
@keyframes alopHead{
  0%,7.5%{transform:translateX(0);opacity:1}
  20%{transform:translateX(calc(var(--al-track) / 3))}
  32.5%{transform:translateX(calc(var(--al-track) / 3 * 2))}
  45%{transform:translateX(var(--al-track))}
  52%,80%{transform:translateX(var(--al-track));opacity:1}
  89%,100%{transform:translateX(calc(var(--al-track) * 1.24));opacity:0}
}
.alop-landing{
  position:absolute;left:100%;bottom:0;z-index:5;pointer-events:none;
  width:var(--al-flare);height:var(--al-flare);
  margin:0 0 calc(var(--al-flare) / -2) calc(var(--al-flare) / -2);
  border-radius:50%;opacity:0;
  background:radial-gradient(circle,rgba(255,246,216,0.42) 0%,rgba(230,212,154,0) 66%);
  animation:alopLanding 5.6s var(--ease) 1 both;
}
@keyframes alopLanding{0%,42.5%{opacity:0;transform:scale(0.4)}49.5%{opacity:1;transform:scale(1)}66.5%,100%{opacity:0;transform:scale(1.3)}}

/* ---------------- the strip of frames the head is scrubbing ---------------- */
.alop-strip{display:flex;gap:var(--al-cellgap);margin-top:var(--al-stripgap);width:100%;}
.alop-cell{
  position:relative;flex:1 1 0;min-width:0;height:var(--al-cellh);z-index:5;border-radius:3px;
  border:1px solid rgba(232,233,242,0.09);background:rgba(232,233,242,0.02);overflow:hidden;opacity:0;
}
/* children carry percentage geometry (of the board's 112 x 46 cell), written
   by opener-scrub.js from the board's own px table. */
.alop-cell i{position:absolute;bottom:19.6%;width:1px;background:rgba(201,178,106,0.6);}
.alop-cell u{position:absolute;width:3px;height:3px;border-radius:50%;background:rgba(127,180,216,0.8);}
.alop-cell s{position:absolute;left:7.14%;right:7.14%;height:1px;background:rgba(127,180,216,0.22);text-decoration:none;}
.alop-c1{animation:alopC1 5.6s var(--ease) 1 both}
.alop-c2{animation:alopC2 5.6s var(--ease) 1 both}
.alop-c3{animation:alopC3 5.6s var(--ease) 1 both}
.alop-c4{animation:alopC4 5.6s var(--ease) 1 both}
.alop-c5{animation:alopC5 5.6s var(--ease) 1 both}
.alop-c6{animation:alopC6 5.6s var(--ease) 1 both}
.alop-c7{animation:alopC7 5.6s var(--ease) 1 both}
.alop-c8{animation:alopC8 5.6s var(--ease) 1 both}
@keyframes alopC1{0%,10%{opacity:0;transform:translateY(9px)}16.5%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}
@keyframes alopC2{0%,14.5%{opacity:0;transform:translateY(9px)}21%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}
@keyframes alopC3{0%,19%{opacity:0;transform:translateY(9px)}25.5%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}
@keyframes alopC4{0%,23.5%{opacity:0;transform:translateY(9px)}30%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}
@keyframes alopC5{0%,29%{opacity:0;transform:translateY(9px)}35.5%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}
@keyframes alopC6{0%,34.5%{opacity:0;transform:translateY(9px)}41%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}
@keyframes alopC7{0%,40%{opacity:0;transform:translateY(9px)}46.5%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}
@keyframes alopC8{0%,45%{opacity:0;transform:translateY(9px)}51.5%,80%{opacity:1;transform:translateY(0)}89%,100%{opacity:0;transform:translateY(0)}}

.alop-striplab{
  margin-top:var(--al-labgap);text-align:center;z-index:5;
  font-family:var(--mono);font-size:clamp(8px,0.74vw,9.5px);letter-spacing:0.3em;line-height:1.8;
  color:#5F6478;opacity:0;animation:alopStriplab 5.6s var(--ease) 1 both;
}
@keyframes alopStriplab{0%,36.5%{opacity:0}52%,73.5%{opacity:1}84%,100%{opacity:0}}

/* ---------------- skip hint ----------------
   Its 640ms entry is ABSOLUTE, not proportional (board note): a longer opener
   makes the escape hatch matter more, so it is on screen by ~0.8s. */
.alop-hint{
  position:absolute;left:50%;bottom:clamp(24px,5.3vh,52px);transform:translateX(-50%);z-index:12;
  white-space:nowrap;font-family:var(--mono);font-size:clamp(9px,0.78vw,10px);letter-spacing:0.22em;
  color:var(--n-dim);opacity:0;animation:alopHint 5.6s var(--ease) 1 both;
}
@keyframes alopHint{0%,11.5%{opacity:0}17%,75.5%{opacity:0.72}82.5%,100%{opacity:0}}

/* ==========================================================================
   FOLD — 344x748. The name must never clip and the skip hint must stay on
   screen: tracking is the first thing to give, never the type size.
   ========================================================================== */
@media (max-width:560px){
  .alop-striplab{letter-spacing:0.18em;}
  .alop-era{letter-spacing:0.22em;}
  .alop-eyebrow{letter-spacing:0.3em;}
}
@media (max-width:420px){
  /* the board's frame is 112x46 — landscape. At the fold a cell is ~28px wide
     and holding that ratio would leave a 12px sliver with nothing readable in
     it, so the frame goes square rather than illegible: the shelves and the
     chart dots stay the point of the strip. */
  #al-opener{--al-eraw:clamp(60px,20vw,76px);--al-cellh:clamp(22px,3.6vh,30px);}
  .alop-hint{letter-spacing:0.16em;}
  .alop-era small{letter-spacing:0.16em;}
}
