/* css/scenes/dark.css · scene 1 `dark`, the dark room (SPEC 2.1 · WP1 gate-and-record) · prefix dark-
   Geometry is held in the scene variables below; colours, type, durations and easings are tokens.
   The cord hangs from the festoon wire (JS writes --dark-cord-x / --dark-wire-y), sways around that
   point, and is one button: the masking-tape flag plus the brass bead under it. */
.scene-ui--dark{
  --dark-cord-x:80vw;
  --dark-wire-y:60px;
  --dark-bead-y:72%;
  --dark-script-x:calc(var(--gutter) + env(safe-area-inset-left));
  --dark-script-top:30%;
  --dark-script-w:min(var(--measure), 68%, calc(var(--dark-cord-x) - var(--dark-script-x) - var(--sp-4)));   /* phone: 68 %, never under the cord */
  --dark-flag-lift:32px;      /* the flag's bottom edge above the bead's centre: a bit of cord shows between */
  --dark-flag-measure:6.4em;  /* phone: "Pull for / the lights" on two lines */
  --dark-flag-inset:calc(var(--gutter) + env(safe-area-inset-right) + var(--sp-4));   /* the focus ring stays clear of the edge at full sway */
  --dark-flag-span:13rem;     /* centred flags: the reach either side of the cord */
  --dark-bead-w:56px;
  --dark-bead-h:72px;         /* the bead's hit box */
  --dark-coil-w:32px;
  --dark-coil-h:80px;
}

/* ---- the script block: upper left, never under the cord ---- */
.scene-ui--dark .dark-script{position:absolute;left:var(--dark-script-x);top:var(--dark-script-top);width:var(--dark-script-w);
  display:flex;flex-direction:column;align-items:flex-start;gap:var(--sp-2);text-align:left}
.scene-ui--dark .dark-script .slugline{margin-bottom:var(--sp-1)}
.scene-ui--dark .dark-script .slugline time{white-space:nowrap}   /* "12:10 AM" never splits */
.scene-ui--dark .dark-script .big-count{margin-top:var(--sp-3)}
.scene-ui--dark .dark-script .direction{text-align:left}

/* ---- the cord: a zero-width line from the wire down to the bead's centre. It sways (±2°, 5 s)
   around the wire, but only its visuals do (the string and the flag + bead group, on the individual
   rotate property): the button's own box stays still, so a tap always lands and tests see it settle ---- */
.scene-ui--dark .dark-cord{position:absolute;left:var(--dark-cord-x);top:calc(env(safe-area-inset-top) + var(--dark-wire-y));width:0;
  height:calc(var(--dark-bead-y) - env(safe-area-inset-top) - var(--dark-wire-y));transition:opacity var(--t-slow) var(--ease-out)}
.scene-ui--dark .dark-cord__string,.scene-ui--dark .dark-cord__pull{
  animation:dark-sway calc(2500ms * var(--t-scale)) var(--ease-inout) calc(-1250ms * var(--t-scale)) infinite alternate both}
.scene-ui--dark .dark-cord.is-held .dark-cord__string,.scene-ui--dark .dark-cord.is-held .dark-cord__pull{animation-play-state:paused}
.scene-ui--dark .dark-cord.is-spent{opacity:.5}
/* once the lights are on, the flag has done its job: it fades and the cord just hangs there, so the
   only tape in the shot is "Put the record on" */
.scene-ui--dark .dark-cord.is-spent .dark-cord__flag{opacity:0}
@keyframes dark-sway{from{rotate:-2deg}to{rotate:2deg}}

.scene-ui--dark .dark-cord__string{position:absolute;left:-1px;top:0;bottom:0;width:2px;border-radius:var(--r-round);
  background:var(--c-smoke);opacity:.85;transform-origin:50% 0}
.scene-ui--dark .dark-cord__string::before{content:"";position:absolute;left:50%;top:0;width:var(--sp-2);height:var(--sp-1);
  margin-left:calc(var(--sp-2) / -2);border-radius:var(--r-round);background:var(--c-smoke)}   /* the knot on the wire */

/* the button = the flag; phone: its right edge sits on the gutter and the cord runs behind its right third */
.scene-ui--dark .cord{position:absolute;bottom:var(--dark-flag-lift);
  right:calc(var(--dark-cord-x) + var(--dark-flag-inset) - 100vw);width:max-content;
  margin:0;padding:0;border:0;border-radius:var(--r-focus);background:none;color:inherit;cursor:grab;
  touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.scene-ui--dark .cord:focus{outline:none}
.scene-ui--dark .cord:focus-visible .dark-cord__flag{outline:var(--focus-ring);outline-offset:6px}   /* the ring rides on the swaying flag */
.scene-ui--dark .cord[aria-disabled="true"]{cursor:default}
.scene-ui--dark .dark-cord.is-held .cord{cursor:grabbing}
.scene-ui--dark .dark-cord__pull{position:relative;display:flex;justify-content:flex-end;
  transform-origin:calc(100% - (100vw - var(--dark-cord-x) - var(--dark-flag-inset))) calc(100% + var(--dark-flag-lift) - var(--dark-cord-len, 0px))}
.scene-ui--dark .dark-cord__flag{--tilt:-3deg;
  transition:transform var(--t-fast) var(--ease-out),filter var(--t-fast) var(--ease-out),opacity var(--t-slow) var(--ease-out)}
.scene-ui--dark .dark-cord__label{display:block;max-width:var(--dark-flag-measure);text-wrap:balance}
.scene-ui--dark .dark-cord__bead{position:absolute;top:calc(100% + var(--dark-flag-lift) - var(--dark-bead-h) / 2);
  width:var(--dark-bead-w);height:var(--dark-bead-h);
  right:calc(100vw - var(--dark-cord-x) - var(--dark-flag-inset) - var(--dark-bead-w) / 2)}
.scene-ui--dark .dark-cord__bead svg,.scene-ui--dark .dark-coil svg{display:block;width:100%;height:100%;overflow:visible}

/* locked: the cord is coiled and tied up at the wire, out of reach, so the lock copy may take the full
   measure (a count of many days stays on one line on a 360 px phone) */
.scene-ui--dark .dark-script--lock{width:min(var(--measure), calc(100% - 2 * var(--dark-script-x)))}
.scene-ui--dark .dark-coil{position:absolute;left:calc(var(--dark-cord-x) - var(--dark-coil-w) / 2);
  top:calc(env(safe-area-inset-top) + var(--dark-wire-y));width:var(--dark-coil-w);height:var(--dark-coil-h);color:var(--c-smoke)}

/* ---- wide: the diagonal (words upper left, the pull lower right); the flag centres on the cord ---- */
@media (min-width:760px){
  /* the cord is long here: at full sway it moves ±12 px level with the script, so the measure stops 32 px short */
  .scene-ui--dark{--dark-bead-y:62%;--dark-script-top:32%;--dark-script-x:8%;--dark-flag-measure:14em;
    --dark-script-w:min(var(--measure), calc(var(--dark-cord-x) - var(--dark-script-x) - var(--sp-6)))}
}
@media (min-width:760px),(orientation:landscape) and (max-height:500px){
  .scene-ui--dark .cord{left:calc(-1 * var(--dark-flag-span));right:calc(-1 * var(--dark-flag-span));margin:0 auto}
  .scene-ui--dark .dark-cord__pull{justify-content:center;transform-origin:50% calc(100% + var(--dark-flag-lift) - var(--dark-cord-len, 0px))}
  .scene-ui--dark .dark-cord__bead{right:auto;left:calc(50% - var(--dark-bead-w) / 2)}
}
/* ---- landscape phones: the script in the left half, the cord in the right third; the dock (empty
   until the pull, when the script is gone) takes the left half's foot so it never meets the cord ---- */
@media (orientation:landscape) and (max-height:500px){
  .scene-ui--dark{--dark-bead-y:76%;--dark-script-top:28%;--dark-script-x:calc(var(--gutter) + env(safe-area-inset-left));
    --dark-script-w:min(var(--measure), calc(50% - var(--dark-script-x)));--dark-flag-measure:6.4em}
  .scene-ui--dark .dock{left:0;right:auto;top:var(--chrome-h);width:50%;justify-content:flex-end}
}

@media (prefers-reduced-motion:reduce){
  .scene-ui--dark .dark-cord__string,.scene-ui--dark .dark-cord__pull{animation:none}
  .scene-ui--dark .dark-cord__flag{transition:opacity var(--t-slow) var(--ease-out)}
}
