/* ─────────────────────────────────────────────────────────────
   base.css — jetons de design, reset, éléments communs
   ───────────────────────────────────────────────────────────── */

:root {
  /* Fonds — bleu nuit */
  --bg:          #070d1a;
  --bg-2:        #0c1626;
  --surface:     #101c2e;
  --surface-2:   #16263c;
  --surface-3:   #1e3350;
  --border:      #244065;

  /* Texte */
  --text:        #eef4fb;
  --text-dim:    #9db3cd;
  --text-faint:  #64809f;

  /* Marque — bleu */
  --accent:      #2563eb;
  --accent-2:    #22d3ee;
  --accent-soft: #2563eb40;

  /* Sémantique */
  --ok:          #22c55e;
  --ko:          #ef4444;
  --warn:        #f59e0b;
  --info:        #38bdf8;

  /* Réponses A / B / C / D — quatre teintes distinctes, aucune proche du bleu de la marque */
  --opt-a:       #ef4444;
  --opt-b:       #8b5cf6;
  --opt-c:       #f59e0b;
  --opt-d:       #10b981;

  /* Mesures */
  --r-sm:  8px;
  --r:     14px;
  --r-lg:  22px;
  --gap:   16px;
  --shadow:    0 10px 40px #00000066;
  --shadow-lg: 0 24px 70px #000000aa;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 600px at 12% -5%,  #2563eb33, transparent 60%),
    radial-gradient(900px 600px at 105% 10%, #22d3ee22, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 2.6vw, 1.7rem); }
p  { margin: 0 0 1em; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; display: block; }

::selection { background: var(--accent); color: #fff; }

:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }

/* ── Mise en page ───────────────────────────────────────────── */
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.stack   { display: flex; flex-direction: column; gap: var(--gap); }
.row     { display: flex; align-items: center; gap: 12px; }
.row-end { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.wrap-row{ display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer  { flex: 1; }
.center  {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px 16px;
}
.hidden  { display: none !important; }
[hidden]  { display: none !important; }   /* l'attribut HTML prime sur les display: flex/grid */
.muted   { color: var(--text-dim); }
.faint   { color: var(--text-faint); font-size: .86rem; }
.mono    { font-variant-numeric: tabular-nums; }
.tiny    { font-size: .8rem; }
.ellipsis{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── En-tête ────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: #070d1acc;
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 1rem;
  box-shadow: 0 6px 18px var(--accent-soft);
}

/* ── Boutons ────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, filter .15s ease, background .15s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  --btn-bg: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 24px var(--accent-soft);
}
.btn-ghost   { --btn-bg: transparent; }
.btn-danger  { --btn-bg: #ef444422; color: #fca5a5; border-color: #ef444455; }
.btn-ok      { --btn-bg: #22c55e22; color: #86efac; border-color: #22c55e55; }
.btn-lg      { padding: 15px 26px; font-size: 1.05rem; border-radius: var(--r-lg); }
.btn-sm      { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn-icon    { padding: 8px; width: 36px; height: 36px; }
.btn-block   { width: 100%; }

/* ── Champs ─────────────────────────────────────────────────── */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; color: var(--text-dim); }

.input, .select, .textarea {
  width: 100%; padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r);
  font: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 84px; }
.select { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 38px; }

.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--accent-2); cursor: pointer; }

/* ── Cartes ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow);
}
.card-tight { padding: 16px; border-radius: var(--r); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-dim);
  font-size: .76rem; font-weight: 700; letter-spacing: .02em;
}
.badge-accent { background: var(--accent-soft); color: #a5d8ff; }
.badge-ok     { background: #22c55e22; color: #86efac; }
.badge-ko     { background: #ef444422; color: #fca5a5; }
.badge-warn   { background: #f59e0b22; color: #fcd34d; }

/* ── Notifications ──────────────────────────────────────────── */
#toasts {
  position: fixed; z-index: 100; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px));
}
.toast {
  padding: 13px 16px; border-radius: var(--r); background: var(--surface-2);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-lg); font-weight: 600; font-size: .92rem;
  animation: toast-in .25s ease;
}
.toast.ok   { border-left-color: var(--ok); }
.toast.ko   { border-left-color: var(--ko); }
.toast.warn { border-left-color: var(--warn); }
.toast.out  { animation: toast-out .25s ease forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateX(30px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(30px); } }

/* ── Modale ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: #030913cc; backdrop-filter: blur(6px); padding: 20px;
  animation: fade .18s ease;
}
.modal {
  width: min(560px, 100%); max-height: 88dvh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 26px; box-shadow: var(--shadow-lg);
}
@keyframes fade { from { opacity: 0; } }

/* ── Divers ─────────────────────────────────────────────────── */
.empty { text-align: center; padding: 56px 20px; color: var(--text-dim); }
.empty .emoji { font-size: 3rem; display: block; margin-bottom: 12px; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--accent-2);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Éléments partagés par plusieurs pages ─────────────────── */
.code-input {
  width: 100%; padding: 16px; text-align: center;
  font-size: clamp(2rem, 9vw, 2.8rem); font-weight: 900; letter-spacing: .22em;
  text-transform: uppercase; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--text);
  border: 2px dashed var(--border); border-radius: var(--r);
  font-family: var(--font);
}
.code-input::placeholder { color: var(--text-faint); letter-spacing: .18em; }
.code-input:focus { outline: none; border-color: var(--accent-2); border-style: solid; box-shadow: 0 0 0 4px var(--accent-soft); }

.form-error { min-height: 20px; margin: 4px 0 12px; color: #fca5a5; font-size: .88rem; font-weight: 600; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--surface-2); padding: 5px; border-radius: var(--r); }
.tab {
  flex: 1; padding: 10px 14px; border: none; border-radius: 10px;
  background: transparent; color: var(--text-dim); font: inherit; font-weight: 700; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 10px #0006; }

.tabs-line { background: none; padding: 0; border-bottom: 1px solid var(--border); border-radius: 0; gap: 4px; }
.tabs-line .tab { flex: 0 0 auto; border-radius: 10px 10px 0 0; border-bottom: 3px solid transparent; }
.tabs-line .tab.is-active { background: var(--surface); border-bottom-color: var(--accent-2); box-shadow: none; }

/* Classements */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border);
}
.rank-item:nth-child(1) { border-color: #facc1566; background: #facc1512; }
.rank-item:nth-child(2) { border-color: #cbd5e155; }
.rank-item:nth-child(3) { border-color: #f9731655; }
.rank-pos  { font-weight: 900; color: var(--text-faint); min-width: 34px; font-variant-numeric: tabular-nums; }
.rank-name { font-weight: 700; max-width: 45%; }

.team-scores { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.team-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border-left: 4px solid var(--accent);
}
.team-name { font-weight: 800; }
.team-rouge { border-left-color: #e11d48; }
.team-bleu  { border-left-color: #2563eb; }
.team-vert  { border-left-color: #16a34a; }
.team-jaune { border-left-color: #f59e0b; }

/* ── Marque ─────────────────────────────────────────────────── */
img.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: none; box-shadow: 0 6px 18px var(--accent-soft);
  transition: transform .3s cubic-bezier(.2, 1.4, .4, 1);
}
.brand:hover img.brand-mark { transform: rotate(-8deg) scale(1.08); }

/* ── Animations réutilisables ───────────────────────────────── */
.bump { animation: bump .4s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes bump { 40% { transform: scale(1.22); } }

.count-pop { display: inline-block; }

/* Confettis : purement décoratif, jamais cliquable. */
.confetti-canvas {
  position: fixed; inset: 0; z-index: 90;
  pointer-events: none; width: 100%; height: 100%;
}
