/* ==========================================================================
   Composants propres au jeu (par-dessus lapeyre.css) : réponses, résultat, classement.
   Même langage visuel que la charte : sobre, ombres quasi absentes, mouvements courts.
   ========================================================================== */

:root {
  --statbar-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Transitions entre vues --- */
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop     { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes pulse   { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.view { animation: view-in 250ms var(--ease) both; }

/* ==========================================================================
   Écran joueur
   ========================================================================== */
body.player { background: var(--color-bg-white); touch-action: manipulation; }

.player-main {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--spacing-lg) var(--spacing-md) calc(var(--statbar-height) + var(--safe-bottom) + var(--spacing-lg));
}
body.player:not(.has-statbar) .player-main { padding-bottom: var(--spacing-xl); }

.stack-md { display: flex; flex-direction: column; gap: var(--spacing-md); }
.center   { text-align: center; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

/* --- Barre d'état en bas (pseudo · rang · points) --- */
.statbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1100;
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  height: calc(var(--statbar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-bg-white);
  border-top: 0.8px solid var(--color-border);
}
.statbar[hidden] { display: none; }
.statbar__cell { display: flex; flex-direction: column; justify-content: center; padding: 0 var(--spacing-md); min-width: 0; }
.statbar__cell + .statbar__cell { border-left: 0.8px solid var(--color-border); }
.statbar__label { font-size: 11px; font-weight: var(--font-weight-semibold); letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-secondary); }
.statbar__value { font-size: var(--font-size-h3); font-weight: var(--font-weight-black); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statbar__value--rank { color: var(--color-primary); }

/* --- Bannière réseau --- */
.netbanner {
  position: fixed;
  top: 48px; left: 0; right: 0;
  z-index: 1050;
  padding: 8px var(--spacing-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-align: center;
  color: var(--color-warning);
  background: var(--color-warning-bg);
  border-bottom: 0.8px solid var(--color-border);
}
.netbanner[hidden] { display: none; }

/* --- Accueil / attente --- */
.hero { display: flex; flex-direction: column; align-items: center; gap: var(--spacing-md); padding: var(--spacing-xl) 0; text-align: center; }
.hero__title { font-size: 26px; font-weight: var(--font-weight-black); line-height: 1.2; text-transform: uppercase; letter-spacing: 0.01em; }
.hero__kicker { margin-bottom: 4px; font-size: var(--font-size-sm); font-weight: var(--font-weight-black); text-transform: uppercase; letter-spacing: 0.12em; color: var(--color-primary); }
.hero__sub   { color: var(--color-text-secondary); font-weight: var(--font-weight-semibold); }
.hero .spinner { width: 36px; height: 36px; }

.notice { display: flex; align-items: flex-start; gap: var(--spacing-sm); padding: 12px 14px; font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); border-radius: var(--radius-md); background: var(--color-bg-grey-light); }
.notice--error   { color: var(--color-error);   background: var(--color-error-bg); }
.notice--success { color: var(--color-success); background: var(--color-success-bg); }
.notice--warning { color: var(--color-warning); background: var(--color-warning-bg); }
.notice .icon { margin-top: 1px; }

/* --- Décompte de lancement --- */
.cd-phone { display: flex; flex-direction: column; align-items: center; gap: var(--spacing-md); padding: var(--spacing-xl) 0; text-align: center; }
.cd-phone__num { font-size: 140px; font-weight: var(--font-weight-black); line-height: 1; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.cd-phone__num--pop { animation: cd-phone-pop 800ms var(--ease) both; }
@keyframes cd-phone-pop { from { transform: scale(1.35); opacity: 0; } 30% { opacity: 1; } }

/* --- Question --- */
.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-sm); }
.q-text { font-size: 21px; font-weight: var(--font-weight-bold); line-height: 1.3; }
.q-image { display: block; width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--radius-md); background: var(--color-bg-grey-light); }

.timer { display: flex; align-items: center; gap: var(--spacing-md); }
.timer .progress { flex: 1; }
.timer .progress__bar { transition: none; }   /* piloté image par image */
.timer__label { min-width: 64px; text-align: right; font-size: var(--font-size-h3); font-weight: var(--font-weight-black); font-variant-numeric: tabular-nums; }
.timer.is-urgent .timer__label { color: var(--color-primary); animation: pulse 1s ease-in-out infinite; }
.timer.is-idle .progress__bar { background: var(--color-text-disabled); }     /* lecture ou pause : chrono non lancé */
.timer.is-idle .timer__label { color: var(--color-text-secondary); }

/* --- Choix de réponse --- */
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
  text-align: left;
  color: var(--color-text-primary);
  background: var(--color-bg-white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 250ms var(--ease), border-color 250ms var(--ease), opacity 250ms var(--ease), transform 120ms var(--ease);
}
.choice:active:not(:disabled) { transform: scale(0.985); }
.choice__key {
  flex: none;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  font-size: 15px; font-weight: var(--font-weight-black);
  background: var(--color-bg-grey-light);
  border-radius: 50%;
  transition: background-color 250ms var(--ease), color 250ms var(--ease);
}
.choice__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.choice__mark { flex: none; display: none; }
.choice__mark .icon { width: 26px; height: 26px; }

/* Apparition d'une proposition pendant la lecture (le délai est posé par joueur.js) ; état de base = état final */
.choice--reveal { animation: choice-reveal 450ms var(--ease) both; }
@keyframes choice-reveal { from { opacity: 0; transform: translateY(12px); } }

.choice:disabled { cursor: default; }
.choice.is-wait:disabled { opacity: 0.55; }          /* réponses pas encore ouvertes / temps écoulé */

.choice.is-selected { border-color: var(--color-primary); border-width: 2px; background: var(--color-primary-subtle); }
.choice.is-selected .choice__key { color: #fff; background: var(--color-primary); }
.choice.is-dim { opacity: 0.45; }

/* correction */
.choice.is-correct { border-color: var(--color-success); border-width: 2px; background: var(--color-success-bg); }
.choice.is-correct .choice__key { color: #fff; background: var(--color-success); }
.choice.is-correct .choice__mark { display: block; color: var(--color-success); }
.choice.is-wrong { border-color: var(--color-error); border-width: 2px; background: var(--color-error-bg); }
.choice.is-wrong .choice__key { color: #fff; background: var(--color-error); }
.choice.is-wrong .choice__mark { display: block; color: var(--color-error); }

/* --- Résultat --- */
.verdict { display: flex; flex-direction: column; align-items: center; gap: var(--spacing-sm); padding: var(--spacing-lg) 0 var(--spacing-sm); text-align: center; }
.verdict__icon {
  display: grid; place-items: center;
  width: 84px; height: 84px;
  color: #fff; background: var(--color-text-disabled);
  border-radius: 50%;
  animation: pop 420ms var(--ease) both;
}
.verdict__icon .icon { width: 48px; height: 48px; }
.verdict--ok  .verdict__icon { background: var(--color-success); }
.verdict--ko  .verdict__icon { background: var(--color-error); }
.verdict__title  { font-size: 24px; font-weight: var(--font-weight-black); text-transform: uppercase; letter-spacing: 0.01em; }
.verdict--ok .verdict__title { color: var(--color-success); }
.verdict--ko .verdict__title { color: var(--color-error); }
.verdict__points { font-size: 40px; font-weight: var(--font-weight-black); line-height: 1.1; font-variant-numeric: tabular-nums; }
.verdict--ok .verdict__points { color: var(--color-success); }
.verdict__hint { font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }

.rankcard { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-md); }
.rankcard__rank { font-size: 34px; font-weight: var(--font-weight-black); line-height: 1; color: var(--color-primary); }
.rankcard__rank small { font-size: 16px; font-weight: var(--font-weight-bold); color: var(--color-text-primary); }
.rankcard__score { text-align: right; }
.rankcard__score strong { display: block; font-size: 24px; font-weight: var(--font-weight-black); line-height: 1.1; font-variant-numeric: tabular-nums; }

.delta { display: inline-flex; align-items: center; font-size: var(--font-size-xs); font-weight: var(--font-weight-bold); letter-spacing: 0.04em; white-space: nowrap; }
.delta .icon { width: 22px; height: 22px; margin: 0 -3px 0 -5px; }
.delta--up   { color: var(--color-success); }
.delta--down { color: var(--color-error); }
.delta--same { color: var(--color-text-disabled); }

.waitline { display: flex; align-items: center; justify-content: center; gap: var(--spacing-sm); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }
.waitline .spinner { width: 16px; height: 16px; border-width: 2px; }

/* ==========================================================================
   Classement (partagé : téléphone et écran principal)
   ========================================================================== */
.board { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.board__row {
  display: grid;
  grid-template-columns: 40px 1fr auto 56px;
  align-items: center;
  gap: var(--spacing-sm);
  min-height: 52px;
  padding: 6px var(--spacing-sm);
  border-bottom: 0.8px solid var(--color-border);
}
.board__row:last-child { border-bottom: 0; }
.board__row.is-me { background: var(--color-primary-subtle); box-shadow: inset 3px 0 0 var(--color-primary); }
.board__rank {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  font-size: 14px; font-weight: var(--font-weight-black);
  background: var(--color-bg-grey-light);
  border-radius: 50%;
}
.board__row[data-rank="1"] .board__rank { color: #fff; background: var(--color-primary); }
.board__row[data-rank="2"] .board__rank { color: #fff; background: var(--color-bg-dark); }
.board__row[data-rank="3"] .board__rank { color: #fff; background: #616161; }
.board__name { font-weight: var(--font-weight-bold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board__name .badge { margin-left: 8px; vertical-align: middle; }
.board__score { text-align: right; font-weight: var(--font-weight-black); font-variant-numeric: tabular-nums; }
.board__gap { padding: 2px 0; text-align: center; font-weight: var(--font-weight-bold); letter-spacing: 0.2em; color: var(--color-text-disabled); }

/* --- Final --- */
.final-rank { font-size: 72px; font-weight: var(--font-weight-black); line-height: 1; color: var(--color-primary); animation: pop 520ms var(--ease) both; }
.final-rank small { font-size: 28px; color: var(--color-text-primary); }
