/* student/stage.css

   La scène Speaking : entraînement libre et jour de défi. Un seul fond plat
   et sombre, du blanc, et du rouge sur les 10 dernières secondes. Pas de
   dégradé, pas de halo, pas d'ombre colorée.

   Chargé par index.html, juste après student/speaking.css. */

.stage {
  --st-bg: #0B0A16;
  --st-line: rgba(255, 255, 255, .1);
  --st-soft: rgba(255, 255, 255, .06);
  --st-dim: rgba(255, 255, 255, .55);
  --st-red: #FF4D5E;
  --st-accent: #fff;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  max-width: var(--w-lesson);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  background: var(--st-bg);
  color: #fff;
}
.stage[data-heat="hot"] { --st-accent: var(--st-red); }

.stage.is-full {
  position: fixed;
  inset: 0;
  z-index: 1000;
  max-width: none;
  min-height: 0;
  height: 100dvh;
  border-radius: 0;
  /* Sur un écran d'ordinateur portable, la roue et le chrono ne laissaient
     plus de place au bouton « Envoyer », caché sous le bord sans moyen d'y
     accéder. La scène défile désormais si elle ne tient pas. */
  overflow-y: auto;
  overscroll-behavior: contain;
}
.stage.is-full .st-body { flex: 1 0 auto; }


body.stage-open { overflow: hidden; }
.stage:fullscreen { max-width: none; border-radius: 0; }

/* ---------- en-tête ---------- */
.st-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; }
.st-close {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--st-line); background: var(--st-soft);
  color: #fff; cursor: pointer;
}
.stage:not(.is-full) .st-close { display: none; }
.st-close .icon, .st-pill .icon { width: 18px; height: 18px; }
.st-title { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.st-title b { font-size: var(--fs-3); font-weight: 650; }
.st-title span { font-size: var(--fs-2); color: var(--st-dim); }
.st-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.st-pill {
  height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; border: 1px solid var(--st-line); background: var(--st-soft);
  color: rgba(255, 255, 255, .85); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.stage:not(.is-full) [data-full] { display: none; }
.st-rec {
  display: none; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  border-radius: 999px; background: rgba(255, 77, 94, .14); color: #FF8A95;
  font-size: 12.5px; font-weight: 750; letter-spacing: .06em;
}
.st-rec i { width: 9px; height: 9px; border-radius: 50%; background: var(--st-red); animation: st-blink 1s infinite; }
.stage[data-phase="rec"]:not(.no-mic) .st-rec { display: inline-flex; }
@keyframes st-blink { 50% { opacity: .2; } }

/* ---------- corps ---------- */
.st-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 8px 22px 28px; text-align: center; }

.st-cats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; }
.st-cat {
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--st-line); background: var(--st-soft);
  color: rgba(255, 255, 255, .75); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.st-cat.on { background: #fff; border-color: #fff; color: var(--st-bg); }
.st-durs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--st-soft); }
.st-durs button { height: 32px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--st-dim); font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer; }
.st-durs button.on { background: #fff; color: var(--st-bg); }
.stage:not([data-phase="idle"]) .st-cats, .stage:not([data-phase="idle"]) .st-durs { display: none; }

/* La roue : trois lignes visibles, la ligne du milieu est la bonne. */
.st-reel-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.st-reel-cat { min-height: 18px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--st-dim); }
.st-reel { position: relative; width: min(900px, 100%); height: 288px; overflow: hidden; }
.st-track { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.st-item {
  height: 96px; padding: 0 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(20px, 3vw, 34px); font-weight: 750; letter-spacing: -0.025em; line-height: 1.15;
  color: rgba(255, 255, 255, .2);
}
.st-item span { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.st-item.win { color: #fff; }
.st-item.win span { -webkit-line-clamp: 2; }
.stage[data-phase="idle"] .st-item.win { color: rgba(255, 255, 255, .55); }
.stage.is-spinning .st-item { color: rgba(255, 255, 255, .5); }
.st-frame {
  position: absolute; left: 0; right: 0; top: 96px; height: 96px;
  border-radius: 18px; border: 1.5px solid var(--st-line);
  pointer-events: none; transition: border-color .2s;
}
.stage:not([data-phase="idle"]):not([data-phase="spinning"]) .st-frame { border-color: var(--st-accent); }
.st-item.flash span { animation: st-flash .5s ease-out; }
@keyframes st-flash { from { transform: scale(1.08); } to { transform: none; } }

/* Le bouton qui lance tout. */
.st-go {
  height: 64px; padding: 0 30px;
  display: inline-flex; align-items: center; gap: 12px;
  border: 0; border-radius: 20px; background: #fff; color: var(--st-bg);
  font: inherit; font-size: 18px; font-weight: 750; cursor: pointer;
  transition: transform .12s;
}
.st-go:hover { transform: translateY(-1px); }
.st-go:active { transform: scale(.98); }
.st-go .icon { width: 22px; height: 22px; }
.st-go kbd { font: inherit; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #ECEBF7; color: #6E6B8A; }
.st-hint { margin: -10px 0 0; font-size: var(--fs-2); color: var(--st-dim); }

/* Le chrono : anneau blanc qui se vide, rouge à la fin. */
.st-clock { position: relative; width: 240px; height: 240px; display: none; }
.stage[data-phase="prep"] .st-clock, .stage[data-phase="rec"] .st-clock, .stage[data-phase="done"] .st-clock, .stage[data-phase="sent"] .st-clock { display: block; }
.st-clock svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.st-ring-bg { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 12; }
.st-ring { fill: none; stroke: var(--st-accent); stroke-width: 12; stroke-linecap: round; transition: stroke .2s, stroke-dashoffset 1s linear; }
.st-clock-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.st-num { font-size: 70px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--st-accent); }
.st-num .icon { width: 64px; height: 64px; }
.stage[data-heat="hot"] .st-num { animation: st-thump 1s infinite; }
@keyframes st-thump { 0% { transform: scale(1.1); } 30% { transform: none; } }
.st-lab { margin-top: 10px; font-size: 12.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--st-dim); }
.stage[data-heat="hot"] .st-lab { color: var(--st-red); }

.st-wave { display: none; align-items: center; gap: 4px; height: 56px; }
.stage[data-phase="rec"]:not(.no-mic) .st-wave { display: flex; }
.st-wave i { width: 5px; height: 6px; border-radius: 3px; background: var(--st-accent); transition: height .08s; }

.st-player { display: none; width: min(480px, 100%); }
.stage[data-phase="done"] .st-player:not(:empty) { display: block; }
.st-player audio { width: 100%; }

.st-err { margin: 0; max-width: 520px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 77, 94, .14); color: #FF9AA4; font-size: var(--fs-3); }
.st-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.st-actions:empty { display: none; }
.st-btn {
  height: 50px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 10px;
  border-radius: 14px; border: 1px solid var(--st-line); background: var(--st-soft);
  color: #fff; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
}
.st-btn .icon { width: 18px; height: 18px; }
.st-btn.is-white { background: #fff; border-color: #fff; color: var(--st-bg); }
.st-btn:disabled { opacity: .6; cursor: wait; }

/* 3, 2, 1 */
.st-big { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 200px; font-weight: 850; letter-spacing: -0.06em; color: #fff; opacity: 0; z-index: 2; }
.stage[data-heat="hot"] .st-big { color: var(--st-red); }
.st-big.show { animation: st-pop .9s ease-out; }
@keyframes st-pop { 0% { opacity: 0; transform: scale(1.5); } 20% { opacity: .9; transform: none; } 100% { opacity: 0; transform: scale(.85); } }

.st-foot { display: flex; justify-content: center; gap: 22px; padding: 0 22px 18px; font-size: 12px; color: rgba(255, 255, 255, .4); }
.st-foot kbd { font: inherit; border: 1px solid var(--st-line); border-radius: 6px; padding: 1px 6px; margin-right: 4px; color: rgba(255, 255, 255, .7); }

.stage :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@media (max-width: 639px) {
  .stage { min-height: 520px; border-radius: var(--r-lg); }
  .stage.is-full { padding-bottom: env(safe-area-inset-bottom); }
  .st-head { padding: 14px; }
  .st-pill span { display: none; }
  .st-reel { height: 240px; }
  .st-item { height: 80px; padding: 0 12px; font-size: 21px; }
  .st-frame { top: 80px; height: 80px; }
  .st-clock { width: 200px; height: 200px; }
  .st-num { font-size: 56px; }
  .st-go { width: 100%; justify-content: center; height: 60px; font-size: 17px; }
  .st-go kbd, .st-foot { display: none; }
  .st-big { font-size: 140px; }
  .st-btn { flex: 1 1 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .st-rec i, .stage[data-heat="hot"] .st-num, .st-big.show, .st-item.flash span { animation: none; }
}

/* Écran peu haut (ordinateur portable, 768 px et moins) : on resserre la
   roue et le chrono pour que tout tienne sans défiler. */
@media (max-height: 820px) and (min-width: 641px) {
  .st-head { padding: 12px 22px; }
  .st-body { gap: 12px; padding-top: 0; padding-bottom: 16px; }
  .st-reel { height: 192px; }
  .st-item { height: 64px; font-size: clamp(18px, 2.2vw, 26px); }
  .st-frame { top: 64px; height: 64px; }
  .st-clock { width: 150px; height: 150px; }
  .st-num { font-size: 46px; }
  .st-num .icon { width: 42px; height: 42px; }
  .st-lab { margin-top: 6px; }
  .st-wave { height: 44px; }
  .st-btn { height: 46px; }
}