/* css/scenes/cake.css · scene 4 `cake`: strike a match, light the candles, make a wish (SPEC 2.4 · WP3 cake-and-wish) · prefix cake-
   The slot .shot-table__cake holds the cake (a midnight silhouette under a lit copy of the same art),
   the flames, one real button per candle, the matchbox and the match. The cake is lit by the room:
   the lit copy's opacity is the light falling on it (--cake-lux), made of the room's --l-* levels and
   the cake's own candles (--cake-own), crossfading over --cake-t, which cake.js sets with each change.
   Geometry is held in the scene variables below; colours, type, durations and easings are tokens.
   Only transform and opacity ever animate. */
.shot-table__cake{
  --cake-own:0;
  --cake-t:0ms;
  --cake-kw:1;            /* how much of the warm cue (the string lights) reaches the cake */
  --cake-ks:.9;           /* the sign's spill at the peak */
  --cake-kp:.7;           /* the follow spot behind the cards */
  --cake-lux:calc(1 - (1 - var(--cake-own)) * (1 - var(--l-warm,0) * var(--cake-kw)) * (1 - var(--l-spill,0) * var(--cake-ks)) * (1 - var(--l-spot,0) * var(--cake-kp)));
  --cake-art-w:124%;      /* the art box: the plate overhangs the slot by 12 % on each side */
  --cake-art-x:-12%;
  --cake-mk:1;            /* the matchbox and match at 88 px = 1 (cake.js) */
  --cake-mu:1px;          /* one cake unit (the cake body is 200 units wide; cake.js) */
}

/* ---- the art: silhouette under, lit copy over ---- */
.shot-table__cake .cake-art{position:relative;display:block;width:var(--cake-art-w);max-width:none;height:auto;margin-left:var(--cake-art-x);
  overflow:visible;pointer-events:none}
.shot-table__cake .cake-art--dark{position:absolute;left:0;top:0}
.shot-table__cake .cake-art--lit{opacity:var(--cake-lux);transition:opacity var(--cake-t) linear}
.shot-table__cake .cake-glow{position:absolute;left:-30%;right:-30%;top:-16%;height:80%;border-radius:var(--r-round);pointer-events:none;
  background:radial-gradient(closest-side, rgba(var(--rgb-tungsten),.24), rgba(var(--rgb-tungsten),.08) 55%, rgba(var(--rgb-tungsten),0));
  opacity:var(--cake-own);transition:opacity var(--cake-t) linear}

/* ---- flames: placed at each wick by cake.js; the body flickers, the lean wrapper leans and shrinks
   while she blows (written per frame), the flame itself grows in and goes out (WAAPI) ---- */
.shot-table__cake .cake-flames,.shot-table__cake .cake-hits{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none}
.shot-table__cake .cake-flame{position:absolute;transform-origin:50% 100%;pointer-events:none}
.shot-table__cake .cake-flame__lean,.shot-table__cake .cake-flame__body{position:absolute;left:0;top:0;width:100%;height:100%;transform-origin:50% 100%}
.shot-table__cake .cake-flame__body{animation:cake-flick calc(1100ms * var(--t-scale)) var(--ease-inout) var(--cake-fd,0s) infinite}
.shot-table__cake.is-blowing .cake-flame__body{animation-duration:calc(240ms * var(--t-scale))}
.shot-table__cake .cake-flame__halo{position:absolute;left:-95%;right:-95%;top:-22%;bottom:-55%;border-radius:var(--r-round);
  background:radial-gradient(closest-side, rgba(var(--rgb-tungsten),.42), rgba(var(--rgb-tungsten),.14) 50%, rgba(var(--rgb-tungsten),0))}
.shot-table__cake .cake-flame__shape{position:absolute;left:0;top:0;width:100%;height:100%;overflow:visible}
@keyframes cake-flick{
  0%,100%{transform:scale(1,1) rotate(0deg)}
  22%{transform:scale(.95,1.06) rotate(-1.6deg)}
  48%{transform:scale(1.04,.96) rotate(1.2deg)}
  74%{transform:scale(.98,1.03) rotate(-.6deg)}
}

/* ---- the candle buttons: a column over each candle, from 24 px above the wick to its foot, centred on the
   wick (left = the wick) and never under 44 px wide (8.1): on a small cake (landscape phone, 200 % zoom) the
   columns overlap, short of each neighbour's wick (cake.js caps it at 2 columns), and a lit or pending candle
   hides its button ---- */
.shot-table__cake .cake-candle{position:absolute;min-width:44px;translate:-50% 0;margin:0;padding:0;border:0;border-radius:var(--r-focus);background:none;cursor:pointer;
  pointer-events:auto;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.shot-table__cake .cake-candle:focus{outline:none}
.shot-table__cake .cake-candle:focus-visible{outline:var(--focus-ring);outline-offset:2px}

/* ---- the matchbox (88 × 64 or larger) and the match, placed in px by cake.js ---- */
.shot-table__cake .cake-matchbox{position:absolute;cursor:pointer;touch-action:none;-webkit-tap-highlight-color:transparent;
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.shot-table__cake .cake-matchbox svg{position:absolute;left:0;top:0;display:block;width:100%;height:100%;overflow:visible}   /* sized by cake.js */
.shot-table__cake .cake-mb-lit{opacity:var(--cake-lux);transition:opacity var(--cake-t) linear}   /* over its own silhouette */
.shot-table__cake .cake-matchbox.is-spent{pointer-events:none;cursor:default}
.shot-table__cake .cake-match{position:absolute;width:0;height:0;pointer-events:none}
.shot-table__cake .cake-match__tilt{position:absolute;left:0;top:0;width:0;height:0;rotate:20deg}
.shot-table__cake .cake-match__stick{position:absolute;left:calc(var(--cake-mk) * -6px);top:calc(var(--cake-mk) * -6px);
  width:calc(var(--cake-mk) * 12px);height:calc(var(--cake-mk) * 62px);overflow:visible;opacity:var(--cake-lux);transition:opacity var(--cake-t) linear}
.shot-table__cake .cake-flame--match{left:calc(var(--cake-mu) * -4.5);top:calc(var(--cake-mu) * -17.5);width:calc(var(--cake-mu) * 9);height:calc(var(--cake-mu) * 17)}
.shot-table__cake .cake-flare{position:absolute;left:calc(var(--cake-mu) * -28);top:calc(var(--cake-mu) * -34);width:calc(var(--cake-mu) * 56);
  height:calc(var(--cake-mu) * 56);border-radius:var(--r-round);opacity:0;pointer-events:none;
  background:radial-gradient(closest-side, rgba(var(--rgb-wick),.95), rgba(var(--rgb-tungsten),.55) 35%, rgba(var(--rgb-tungsten),0))}

/* ---- carry the flame: a press anywhere on the shot (outside the controls) while the match is lit ---- */
.shot-table__cake .cake-carry{position:fixed;left:0;top:0;width:100%;height:100%;touch-action:none;-webkit-tap-highlight-color:transparent}
@supports (touch-action:pinch-zoom){ .shot-table__cake .cake-carry{touch-action:pinch-zoom} }

/* ---- the dock: the wish line keeps its place while the hold tape and the mic rise into theirs ---- */
.scene-ui--cake{
  --cake-hold-h:64px;     /* the hold tape on two lines (phones) */
  --cake-mic-h:calc(44px + 1em);
  --cake-tuck:calc(var(--sp-3) * -1);   /* the note sits inside the ghost's 44 px hit area */
}
.scene-ui--cake .cake-wish{text-wrap:balance}
.scene-ui--cake .cake-holdslot{width:calc(100% + var(--sp-2));margin-inline:calc(var(--sp-1) * -1);display:flex;align-items:center;justify-content:center;
  min-height:var(--cake-hold-h)}   /* 4 px into the gutters: the label stays on one line down to 360 px */
.scene-ui--cake .cake-holdslot .tape--hold{--tilt:-1deg;width:100%}
.scene-ui--cake .cake-micslot{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:var(--sp-1);min-height:var(--cake-mic-h)}
.scene-ui--cake .cake-micslot .note{pointer-events:none}
.scene-ui--cake .cake-micslot .ghost:not([hidden]) ~ .note{margin-top:var(--cake-tuck)}   /* only the ghost's hit area has room to spare */
@media (min-width:600px){
  .scene-ui--cake{--cake-hold-h:52px}
  .scene-ui--cake .cake-holdslot .tape--hold{width:auto;min-width:min(100%, 24rem)}
}
/* The wish dock (line, hold tape, ghost + note) is the scene's tallest. Where the shot reserves
   less than it needs (172 px on short screens, 176 on desktops) its rows close up, so the wish
   line keeps clear of the pushed-in table's lip: the ghost's 44 px hit area already holds its
   own air above the words, and the last row may use half the dock's bottom padding. */
@media (max-height:700px){   /* short phones (a short desktop takes the desktop rules below) */
  .scene-ui--cake{--cake-mic-h:calc(44px + var(--sp-1) + var(--cake-tuck) + 1.4 * var(--step--1))}   /* exactly the ghost + its tucked note */
  .scene-ui--cake .cake-holdslot{margin-top:calc(var(--sp-1) * -1.5)}
  .scene-ui--cake .cake-micslot{margin-top:calc(var(--sp-2) * -1);margin-bottom:calc(var(--sp-3) * -1)}
  /* words in the ghost's place (listening, or the mic failed) get back the air its hit area held;
     two lines of it still fit the slot's reserve */
  .scene-ui--cake .cake-micslot .ghost[hidden] + .direction{margin-top:var(--sp-2)}
}
@media (min-width:760px){   /* the desktop dock: the mic ghost and its note share one row */
  .scene-ui--cake{--cake-mic-h:44px;--cake-tuck:0}
  .scene-ui--cake .cake-hint{max-width:min(100%, 46rem)}   /* the light hint on one line, so the counter keeps clear of the table */
  .scene-ui--cake .cake-holdslot{margin-top:calc(var(--sp-1) * -1)}
  .scene-ui--cake .cake-micslot{flex-direction:row;flex-wrap:wrap;justify-content:center;align-items:center;gap:0 var(--sp-4);
    margin-top:calc(var(--sp-2) * -1);margin-bottom:calc(var(--sp-3) * -1)}
  .scene-ui--cake .cake-micslot .ghost[hidden] + .direction{margin-top:0}
}

@media (prefers-reduced-motion:reduce){
  .shot-table__cake .cake-flame__body{animation:none}
}
