/* _w2_rapidfire.css — Rapid Fire (lane: Words, spec 06 / lane_words_games.md).
   NEW styles ONLY. Loaded AFTER views.css so it composes on the qx shell.
   Every rule is a modifier / composition of existing qx chrome (FOUNDATION §1 hard
   rule): no new raw container, all color from tokens + the shell's --cv (rose).

   Owns:
     .qx--rapid        — behavioural modifier on .qx (smooth countdown bar, low-time
                         pulse, hot-streak edge glow). REUSES #qx-prog / #qx-streak.
     .qx__card         — a motion modifier on the prompt block (card-snap-in).
     .qx__scoreline    — the one justified live Score / Combo readout under the opts.
     .qx__missed       — the post-game missed-words recap panel (matches the footer look).
     .qx__countin      — the "Get ready" 3-2-1 count-in that occupies #qx-stage.
   All motion collapses to instant state under prefers-reduced-motion (see block below). */

/* ---- time bar: reuse #qx-prog inside .qx__bar, swap to a smooth linear countdown --- */
.qx--rapid .qx__bar i{
  transition:width .1s linear;                 /* smooth per-tick countdown, not the .4s ease */
  background:linear-gradient(90deg, color-mix(in srgb,var(--cv) 60%,var(--mix-base)), var(--cv));
}
/* low-time warning: the bar breathes + shifts toward the alert hue (< 25% left) */
.qx--rapid .qx__bar.is-low i{
  background:linear-gradient(90deg, color-mix(in srgb,var(--rose-500) 70%,var(--mix-base)), var(--rose-500));
  animation:rfBarPulse .6s ease-in-out infinite;
}
@keyframes rfBarPulse{ 0%,100%{ opacity:1; } 50%{ opacity:.5; } }

/* hot-streak edge glow (combo >= 5): a transient inset ring on the shell, re-triggered
   each further correct while hot. */
.qx--rapid.is-hot{ animation:rfHotGlow .5s ease-out; }
@keyframes rfHotGlow{
  from{ box-shadow:inset 0 0 0 3px color-mix(in srgb,var(--cv) 40%,transparent), var(--shadow-lg); }
  to{   box-shadow:var(--shadow-lg); }
}

/* ---- card-snap-in: fast arcade entrance on each new prompt (§6, 0.12s) ------------- */
.qx__card{ animation:rfCardSnap .12s cubic-bezier(.2,.9,.3,1) both; }
@keyframes rfCardSnap{ from{ opacity:0; transform:scale(.96); } to{ opacity:1; transform:none; } }

/* ---- score strip: one flex row, matches .qx__streak chrome so it reads as shell ---- */
.qx__scoreline{
  display:flex; align-items:center; justify-content:space-between; gap:var(--s3);
  width:100%; max-width:520px; margin:var(--s2) auto 0;
  font-size:var(--fs-sm); font-weight:700; color:var(--ink-700);
}
.qx__scoreline b{ color:var(--ink-900); font-weight:800; }
.qx__scoreline .qx__score,
.qx__scoreline .qx__combo{
  background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r-pill);
  padding:6px 14px; display:inline-flex; align-items:center; gap:6px;
}
.qx__scoreline .qx__combo{ color:var(--cv); }
.qx__scoreline .qx__combo b{ color:var(--cv); }
/* a tiny bump when the combo ticks up (class toggled on each correct) */
.qx__scoreline .qx__combo.is-bump{ animation:rfComboBump .18s cubic-bezier(.2,1.6,.4,1); }
@keyframes rfComboBump{ 0%{ transform:scale(1); } 50%{ transform:scale(1.14); } 100%{ transform:scale(1); } }

/* +time / -time flash beside the bar area (a brief floating delta) */
.qx__timedelta{
  position:absolute; top:14px; right:var(--pad); font-weight:800; font-size:var(--fs-sm);
  pointer-events:none; animation:rfDelta .7s ease-out forwards;
}
.qx__timedelta.is-plus{ color:var(--green-500); }
.qx__timedelta.is-minus{ color:var(--rose-500); }
@keyframes rfDelta{ 0%{ opacity:0; transform:translateY(6px); } 20%{ opacity:1; } 100%{ opacity:0; transform:translateY(-10px); } }

/* the shell needs to be a positioning context for the delta */
.qx--rapid{ position:relative; }

/* ---- count-in: "Get ready" 3-2-1 Go, occupies #qx-stage before the clock --------- */
.qx__countin{ text-align:center; display:flex; flex-direction:column; align-items:center; gap:var(--s3); }
.qx__countin__cap{ color:var(--ink-500); font-weight:600; font-size:var(--fs-md); }
.qx__countin__n{
  font-family:var(--font-display); font-weight:800; line-height:1;
  font-size:clamp(72px,18vw,140px); color:var(--cv);
  animation:rfCount .5s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes rfCount{ from{ opacity:0; transform:scale(.7); } to{ opacity:1; transform:none; } }

/* ---- results: Rapid-Fire stat block + missed-words recap -------------------------- */
.qx__rfstats{ display:flex; gap:var(--s3); justify-content:center; flex-wrap:wrap; margin:var(--s4) 0; }
.qx__pb{                                        /* new personal-best banner */
  margin:0 auto var(--s3); max-width:420px; text-align:center;
  color:var(--green-600); font-weight:700; font-size:var(--fs-sm);
  background:color-mix(in srgb,var(--green-500) 10%,var(--mix-base));
  border:1px solid color-mix(in srgb,var(--green-500) 30%,transparent);
  border-radius:var(--r-md); padding:10px 16px;
}
/* the recap panel reuses the feedback-footer visual language (bordered surface-2) */
.qx__missed{
  margin:var(--s4) auto 0; max-width:520px; text-align:left;
  background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r-lg);
  padding:var(--s4); box-shadow:var(--shadow-sm);
}
.qx__missed__h{ font-weight:800; font-size:var(--fs-sm); color:var(--ink-700); margin:0 0 var(--s3); }
.qx__missed__list{ display:flex; flex-direction:column; gap:2px; margin-bottom:var(--s3); }
.qx__missed__row{
  display:flex; align-items:center; gap:var(--s3); padding:8px 4px;
  border-bottom:1px solid var(--line);
}
.qx__missed__row:last-child{ border-bottom:0; }
.qx__missed__thai{ font-family:var(--font-thai); font-size:var(--fs-lg); font-weight:600; flex:0 0 auto; }
.qx__missed__en{ flex:1; min-width:0; color:var(--ink-500); font-size:var(--fs-sm); }
.qx__missed__row .qx__play{ width:38px; height:38px; flex:0 0 auto; }
.qx__missed__row .qx__play .ico{ width:16px; height:16px; }
.qx__missed__tick{ color:var(--green-600); font-weight:700; font-size:var(--fs-xs); flex:0 0 auto; }
.qx__missed .btn{ width:100%; }

/* ---- LANDSCAPE PHONES: side-by-side recap (owner note) --------------------------------
   Short + wide viewports can't stack the whole game-over recap. Use the width: put the
   trophy/icon + the % score in a LEFT column and flow the rest of the recap (tier line,
   stats, missed-words panel, actions) down a wider RIGHT column, so those elements get
   more room. Scoped to .qx--rapid so it only affects Rapid Fire's results; the flat
   sibling list from qx.results is arranged purely by explicit grid placement (order- and
   optional-`next`-independent). Portrait / desktop keep the default centered stack. */
@media (max-height:560px) and (orientation:landscape){
  .qx--rapid .q2-res{
    display:grid;
    grid-template-columns:auto minmax(0,1fr);
    column-gap:clamp(20px,4vw,48px);
    row-gap:2px;
    align-items:start;
    justify-items:start;
    text-align:left;
    max-width:none;
    padding:var(--s3) var(--s4);
  }
  /* LEFT column: the icon + the % score */
  .qx--rapid .q2-res__ring{ grid-column:1; grid-row:1; margin:0 0 var(--s2); }
  .qx--rapid .q2-res__pct { grid-column:1; grid-row:2; align-self:start; }
  /* RIGHT column: tier line, stats + missed recap, next hint, actions — stacked, roomier */
  .qx--rapid .q2-res__t     { grid-column:2; grid-row:1; margin-top:0; }
  .qx--rapid .q2-res__sub   { grid-column:2; grid-row:2; margin-top:2px; width:100%; }
  .qx--rapid .q2-res__next  { grid-column:2; grid-row:3; }
  .qx--rapid .q2-res__actions{ grid-column:2; grid-row:4; justify-content:flex-start; margin-top:var(--s3); }
  /* let the recap blocks fill the right column and sit left-aligned instead of centered */
  .qx--rapid .q2-res__sub .qx__pb{ margin:0 0 var(--s2); max-width:none; text-align:left; }
  .qx--rapid .q2-res__sub .qx__rfstats{ justify-content:flex-start; margin:var(--s2) 0; }
  .qx--rapid .q2-res__sub .qx__missed{ margin:var(--s2) 0 0; max-width:none; }
}

/* ---- reduced motion: collapse all movement to instant state (keep color/info) ---- */
@media (prefers-reduced-motion: reduce){
  .qx--rapid .qx__bar i{ transition:none; }              /* discrete steps, still counts */
  .qx--rapid .qx__bar.is-low i{ animation:none; opacity:1; }
  .qx--rapid.is-hot{ animation:none; }
  .qx__card{ animation:none; }
  .qx__scoreline .qx__combo.is-bump{ animation:none; }
  .qx__timedelta{ animation:none; opacity:0; }           /* drop the float; state is in the bar */
  .qx__countin__n{ animation:none; }
}
