/* ===========================================================
   Le Juste Prix en ligne — styles
   Mobile-first, compatible iOS Safari / Android Chrome & Firefox.

   ⚠️  Toutes les couleurs passent par les variables --bg-1/--surface/--text/
   --primary/… : c'est ce qui permet au mode Bénéficiaire AAH de tout
   reprendre en contraste fort (voir public/shared/AAH_MODE.md). Une couleur
   écrite en dur ici serait invisible pour ce mode, sans aucune erreur visible.
   =========================================================== */

:root {
  --bg-1: #eef3fb; --bg-2: #dae6f8; --surface: #ffffff; --surface-alt: #f3f7fd;
  --text: #14243c; --text-dim: #64748b; --primary: #1657b0; --primary-dark: #0f4088;
  --primary-contrast: #ffffff; --accent: #e0a127; --accent-soft: #fdf3dd;
  --success: #17845a; --success-bg: #e3f6ec;
  --danger: #c9333c; --danger-bg: #fdeaec; --border: #dbe6f5;
  --shadow: 0 8px 24px rgba(20, 60, 130, .13);
  --radius: 18px; --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #0b1524; --bg-2: #111f35; --surface: #16233a; --surface-alt: #1c2c46;
    --text: #e9f1fb; --text-dim: #9db0cc; --primary: #5b9bf0; --primary-dark: #7db4f7;
    --primary-contrast: #06122a; --accent: #f2c161; --accent-soft: #2e2716;
    --success: #4dc78c; --success-bg: #10331f;
    --danger: #ff7b85; --danger-bg: #3a1a1e; --border: #2a3d5c;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: radial-gradient(circle at 20% -10%, var(--bg-2), var(--bg-1) 60%);
  -webkit-font-smoothing: antialiased; touch-action: manipulation; overscroll-behavior-y: contain;
}
button, input, select { font-family: inherit; font-size: 16px; }
a { color: var(--primary); }

.app { max-width: 600px; margin: 0 auto; padding: calc(14px + var(--safe-top)) 12px calc(100px + var(--safe-bottom)); min-height: 100dvh; }
.view { display: none; animation: fade-in .25s ease; }
.view.active { display: flex; flex-direction: column; gap: 12px; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }
.center { text-align: center; }

.brand { text-align: center; margin-top: 8px; }
.brand-emoji { font-size: 48px; line-height: 1; }
.brand h1 { margin: 4px 0 2px; font-size: 32px; letter-spacing: -0.02em; }
.subtitle { margin: 0; color: var(--text-dim); font-size: 15px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.section-title { font-size: 18px; margin: 4px 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: 13px; color: var(--text-dim); font-weight: 600; }
/* Case à cocher inline (mode AAH) — même motif que les autres jeux. */
.field-inline { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); margin: 12px 0; }
.field-inline input { width: 20px; height: 20px; flex-shrink: 0; }
input[type="text"], input[type="number"], select {
  padding: 12px 13px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface-alt); color: var(--text); outline: none; transition: border-color .15s ease; width: 100%;
}
input:focus, select:focus { border-color: var(--primary); }
/* Les flèches natives des champs numériques volent de la place et invitent au
   clic répété alors qu'on saisit un prix à quatre chiffres. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; border-radius: 14px; border: none; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: transform .08s ease, filter .15s ease; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-big { padding: 16px; font-size: 17px; }
.btn-small { width: auto; padding: 9px 14px; font-size: 14px; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-alt); color: var(--text); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 10px 14px; cursor: pointer; font-size: 15px;
}
.icon-btn.small { padding: 6px 10px; font-size: 14px; }

.landing-actions { display: flex; flex-direction: column; gap: 10px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.hint { color: var(--text-dim); font-size: 13px; line-height: 1.5; margin: 4px 2px; }
.hint.tight { margin: 6px 0 0; }
.credits-link { font-size: 12px; }

.rules-card .rules-list { margin: 0; padding-left: 20px; color: var(--text); font-size: 14px; line-height: 1.55; }
.rules-card .rules-list li { margin-bottom: 8px; }

/* ---------------------------------------------------------- salon d'attente */
.topbar { display: flex; align-items: center; justify-content: center; }
.lobby-game-badge { font-weight: 800; font-size: 17px; }
.room-code-label { margin: 0; font-size: 13px; color: var(--text-dim); }
.room-code-badge { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.room-code-value { font-size: 34px; font-weight: 800; letter-spacing: .16em; color: var(--primary); }
.players-title { margin: 0 0 8px; font-size: 15px; }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player-list li {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface-alt); border-radius: 12px; border: 1px solid var(--border); font-size: 15px;
}
.player-list .pl-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .pl-tag { font-size: 12px; color: var(--text-dim); }
.player-list .pl-off { opacity: .5; }
.round-stepper { display: flex; align-items: center; gap: 14px; }
.round-stepper span { font-size: 22px; font-weight: 800; min-width: 30px; text-align: center; }
.seg-picker { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; padding: 11px 6px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface-alt); color: var(--text); font-weight: 700; cursor: pointer;
}
.seg-btn.on { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---------------------------------------------------------------- en partie */
/* Le bouton retour au hub est fixe en haut à gauche (26 px de large, voir
   public/shared/hub-back.css) : sur mobile il recouvrait le badge d'acte. */
.acte-bar { display: flex; align-items: center; gap: 10px; padding-left: 32px; }
.acte-badge {
  background: var(--primary); color: var(--primary-contrast); font-weight: 800;
  font-size: 13px; padding: 5px 11px; border-radius: 999px; white-space: nowrap;
}
.acte-titre { font-weight: 700; font-size: 16px; flex: 1; }
.manche-compteur { color: var(--text-dim); font-size: 14px; font-weight: 700; }

.timer-bar-wrap { height: 8px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.timer-bar { height: 100%; width: 100%; background: var(--primary); transition: width .95s linear; }
.timer-bar.urgent { background: var(--danger); }

.players-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.player-chip {
  display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; white-space: nowrap; box-shadow: var(--shadow);
}
.player-chip .chip-score { font-weight: 800; color: var(--primary); }
.player-chip.is-me { border-color: var(--primary); }
.player-chip.on-stage { background: var(--accent-soft); border-color: var(--accent); }
.player-chip.has-answered .chip-check { color: var(--success); font-weight: 800; }
.player-chip.off { opacity: .45; }

/* ------------------------------------------------------------ fiche article */
.article-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.article-photo-wrap { position: relative; background: var(--surface-alt); }
/* Les photos viennent de Wikimedia : formats très variables. Hauteur fixe +
   `contain` pour qu'aucune ne soit rognée sur l'objet lui-même. */
.article-photo { display: block; width: 100%; height: 230px; object-fit: contain; background: #ffffff; }
.article-categorie {
  position: absolute; left: 10px; top: 10px; background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700;
}
.article-body { padding: 14px 16px 16px; }
.article-marque { margin: 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); font-weight: 800; }
.article-marque:empty { display: none; }
.article-nom { margin: 2px 0 6px; font-size: 21px; line-height: 1.25; }
.article-description { margin: 0 0 10px; font-size: 14.5px; line-height: 1.5; color: var(--text); }
.article-specs { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; }
.article-specs li { font-size: 12.5px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 4px 9px; color: var(--text-dim); font-weight: 600; }
.article-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.article-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent);
  border-radius: 999px; padding: 4px 10px;
}
.article-origine { margin: 10px 0 0; font-size: 12.5px; color: var(--text-dim); }
.article-origine:empty { display: none; }

/* ------------------------------------------------------------- propositions */
.mise-form { display: flex; gap: 8px; align-items: stretch; }
.mise-input-wrap { position: relative; flex: 1; }
.mise-input-wrap input { padding-right: 34px; font-size: 20px; font-weight: 800; text-align: right; }
.mise-euro { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--text-dim); }
.mise-form .btn { width: auto; padding: 12px 18px; }
.mise-etat { margin: 10px 0 0; font-size: 14px; font-weight: 700; color: var(--success); }
.mise-etat:empty { display: none; }
.mise-recues { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---------------------------------------------------------------- reveals */
.prix-reveal { text-align: center; }
.prix-reveal-label { margin: 0; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.prix-reveal-valeur { margin: 4px 0 0; font-size: 44px; font-weight: 900; color: var(--primary); letter-spacing: -.02em; }
.juste-prix-banner {
  margin: 10px 0 0; padding: 10px; border-radius: 12px; font-weight: 900; letter-spacing: .04em;
  background: var(--accent-soft); color: var(--text); border: 2px solid var(--accent);
  animation: pulse-badge .7s ease infinite alternate;
}
@keyframes pulse-badge { from { transform: scale(1); } to { transform: scale(1.03); } }
.depasse-banner { margin: 10px 0 0; padding: 9px; border-radius: 12px; background: var(--danger-bg); color: var(--danger); font-weight: 700; font-size: 14px; }
.scene-verdict { margin: 10px 0 0; font-size: 15px; font-weight: 700; }

.results-list { display: flex; flex-direction: column; gap: 8px; }
.result-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 15px;
}
.result-row.winner { border-color: var(--accent); background: var(--accent-soft); }
.result-row.over { opacity: .75; }
.result-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-mise { font-weight: 800; }
.result-points { font-weight: 800; color: var(--success); min-width: 54px; text-align: right; }
.result-note { font-size: 12px; color: var(--text-dim); }

/* --------------------------------------------------- acte 2 : sur la scène */
.scene-indice {
  text-align: center; font-size: 30px; font-weight: 900; letter-spacing: .04em;
  padding: 16px; border-radius: var(--radius); border: 2px solid var(--primary);
  background: var(--surface); color: var(--primary); box-shadow: var(--shadow);
  animation: fade-in .2s ease;
}
.scene-indice.plus { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.scene-indice.moins { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.scene-indice.exact { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.scene-qui { margin: 0; text-align: center; font-size: 15px; font-weight: 700; }
.scene-fourchette { margin: 0; text-align: center; font-size: 14px; color: var(--text-dim); font-weight: 700; }
.essais-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.essais-titre { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); font-weight: 800; }
.essais-restants { float: right; text-transform: none; letter-spacing: 0; }
.essais-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.essais-liste li { display: flex; align-items: center; gap: 8px; font-size: 15px; padding: 7px 10px; border-radius: 10px; background: var(--surface-alt); }
.essais-liste .essai-valeur { font-weight: 800; min-width: 90px; }
.essais-liste .essai-indice { font-weight: 800; font-size: 13px; }
.essais-liste .plus .essai-indice { color: var(--success); }
.essais-liste .moins .essai-indice { color: var(--danger); }
.essais-liste .exact .essai-indice { color: var(--accent); }

/* -------------------------------------------------------- acte 3 : vitrine */
.vitrine-entete { text-align: center; }
.vitrine-consigne { margin: 0; font-size: 14.5px; line-height: 1.5; }
.vitrine-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vitrine-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.vitrine-item img { display: block; width: 100%; height: 110px; object-fit: contain; background: #ffffff; }
.vitrine-item .vi-body { padding: 8px 10px 10px; }
.vitrine-item .vi-nom { font-size: 13px; font-weight: 700; line-height: 1.3; }
.vitrine-item .vi-desc { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }
.vitrine-item .vi-prix { font-size: 15px; font-weight: 900; color: var(--primary); margin-top: 6px; }
.vitrine-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* -------------------------------------------------------------- divers */
.event-log { display: flex; flex-direction: column; gap: 5px; }
.event-log .log-line { font-size: 13px; color: var(--text-dim); padding: 7px 10px; background: var(--surface-alt); border-radius: 10px; }
.confetti-emoji { font-size: 54px; text-align: center; }
.round-footer { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--surface); padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60; max-width: 92vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.connection-banner {
  position: fixed; top: calc(8px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; z-index: 60;
}

.react-fab {
  position: fixed; right: 14px; bottom: calc(18px + var(--safe-bottom)); width: 52px; height: 52px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 24px;
  box-shadow: var(--shadow); cursor: pointer; z-index: 40;
}
.reaction-picker {
  position: fixed; right: 14px; bottom: calc(80px + var(--safe-bottom)); display: flex; flex-wrap: wrap;
  gap: 6px; max-width: 220px; padding: 10px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); z-index: 40;
}
.reaction-picker button { font-size: 24px; background: none; border: none; cursor: pointer; padding: 4px; }
#reaction-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.floating-reaction { position: absolute; font-size: 34px; animation: float-up 2.4s ease-out forwards; }
.floating-reaction .fr-name { font-size: 11px; display: block; text-align: center; color: var(--text-dim); }
@keyframes float-up {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { transform: translateY(-20px) scale(1); opacity: 1; }
  100% { transform: translateY(-190px) scale(1); opacity: 0; }
}

/* ------------------------------------------------------------ page crédits */
.credits-page { max-width: 900px; margin: 0 auto; padding: calc(20px + var(--safe-top)) 14px 40px; }
.credits-page h1 { font-size: 24px; }
.credits-note { color: var(--text-dim); font-size: 13px; }
.credits-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.credits-table th, .credits-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.credits-table img { border-radius: 6px; object-fit: contain; background: var(--surface-alt); }

/* ---------------------------------------------------------------- mode AAH */
/* `--accent-soft` est une variable PROPRE À CE JEU : la feuille partagée
   (public/shared/aah-mode.css) ne la connaît pas et ne la remplace donc pas.
   Sans cette reprise, les fonds crème (ligne gagnante, bannière « Juste
   prix ! », pastilles de label) restaient clairs sous du texte devenu blanc —
   illisible, et invisible en test automatique. Voir AAH_MODE.md : toute
   nouvelle couleur doit passer par une variable reprise ici. */
html.jel-aah {
  --accent-soft: #1a1500 !important;   /* fond sombre, l'accent jaune reste porté par la bordure */
}
html.jel-aah .article-photo,
html.jel-aah .vitrine-item img { background: #ffffff !important; }  /* les photos gardent leur fond blanc : les détourer en noir les rendrait illisibles */

@media (min-width: 620px) {
  .acte-bar { padding-left: 0; }   /* l'application est centrée : plus de recouvrement */
  .article-photo { height: 280px; }
  .vitrine-item img { height: 140px; }
}
