/* ══════════════════════════════════════════════════════════════════════════
   « Faites vos jeux ! » — feuille de style partagée par les trois pages
   (la catégorie, l'outil de création, le lecteur).

   Charte du site : fond bleu clair de l'accueil (--paper #f2f5fa), Cormorant
   Garamond pour les titres, Montserrat pour le texte.
   ⚠️ CONTRASTE : l'or #b89a5a ne donne que 2,5:1 sur fond clair — il sert aux
   filets et aux aplats, jamais au texte, pour lequel on utilise --gold-txt.
   De même --muted #7a7060 tombe à 4,45:1 sur #f2f5fa (seuil AA 4,5), d'où
   #6e6659.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --ink: #1a1814;
  --paper: #f2f5fa;
  --paper-dark: #e6ecf6;
  --card: #ffffff;
  --brand: #1d3a5f;
  --brand-soft: #dfe7f2;
  --gold: #b89a5a;
  --gold-txt: #7a5d22;
  --muted: #6e6659;
  --rule: #d3dcea;
  --ok: #2f6b3a;
  --ok-bg: #e3efe4;
  --warn: #8a5d10;
  --warn-bg: #f7ecd6;
  --stop: #8d3a2e;
  --stop-bg: #f6e2de;
  --nav-h: 72px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 58, 95, .06), 0 10px 26px -20px rgba(29, 58, 95, .5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: calc(var(--nav-h) + 28px) 20px 64px; }
main.large { max-width: 1240px; }

/* ───────────────────────────── En-tête ───────────────────────────── */
.vj-head { text-align: center; margin-bottom: 32px; }
.vj-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold-txt); margin-bottom: 10px;
}
.vj-head h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600; font-size: clamp(34px, 6vw, 56px); line-height: 1.06;
  text-wrap: balance; margin-bottom: 12px;
}
.vj-lead { max-width: 62ch; margin: 0 auto; color: var(--muted); font-size: 16px; line-height: 1.6; }

/* ───────────────────────────── Onglets ───────────────────────────── */
.vj-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 30px 0 26px; padding: 6px; background: var(--paper-dark);
  border-radius: 999px; width: fit-content; margin-inline: auto; max-width: 100%;
}
.vj-tab {
  border: none; background: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500;
  color: var(--muted); padding: 9px 20px; border-radius: 999px; transition: background .15s, color .15s;
  display: inline-flex; align-items: center; gap: 8px;
}
.vj-tab:hover { color: var(--ink); }
.vj-tab[aria-selected="true"] { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }
.vj-tab .n {
  font-size: 11px; font-weight: 600; background: var(--brand-soft); color: var(--brand);
  border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums;
}
.vj-tab[aria-selected="true"] .n { background: var(--brand); color: #fff; }

/* ───────────────────────────── Cartes de jeu ───────────────────────────── */
.vj-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

.vj-card {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 9px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.vj-card:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: 0 6px 22px -12px rgba(29, 58, 95, .45); }
a.vj-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.vj-card-top { display: flex; align-items: center; gap: 10px; }
.vj-card-emoji { font-size: 26px; line-height: 1; }
.vj-card-theme {
  font-size: 10px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); margin-left: auto;
}
.vj-card-name { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 23px; font-weight: 600; line-height: 1.2; }
.vj-card-desc { font-size: 14px; color: var(--muted); line-height: 1.5; flex: 1; }
.vj-card-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 10px;
}
.vj-card-foot .auteur { font-weight: 500; color: var(--ink); }

/* Pastilles de statut : la forme dit l'état, pas seulement la couleur. */
.vj-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px;
}
.vj-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.vj-chip.brouillon { color: var(--muted); background: var(--paper-dark); }
.vj-chip.soumis    { color: var(--warn); background: var(--warn-bg); }
.vj-chip.publie    { color: var(--ok);   background: var(--ok-bg); }
.vj-chip.retire    { color: var(--muted); background: var(--paper-dark); }
.vj-chip.refuse    { color: var(--stop); background: var(--stop-bg); }
.vj-chip.revision  { color: var(--brand); background: var(--brand-soft); }

/* ───────────────────────────── Boutons ───────────────────────────── */
.vj-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  padding: 10px 20px; border-radius: 999px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; text-decoration: none;
  transition: filter .15s, transform .1s;
}
.vj-btn:hover { filter: brightness(1.12); }
.vj-btn:active { transform: translateY(1px); }
.vj-btn:focus-visible { outline: 2px solid var(--gold-txt); outline-offset: 3px; }
.vj-btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.vj-btn.ghost { background: transparent; color: var(--brand); }
.vj-btn.ghost:hover { background: var(--brand-soft); filter: none; }
.vj-btn.danger { background: transparent; border-color: var(--stop); color: var(--stop); }
.vj-btn.danger:hover { background: var(--stop-bg); filter: none; }
.vj-btn.small { font-size: 13px; padding: 7px 15px; }

.vj-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }

/* ───────────────────────────── Encarts ───────────────────────────── */
.vj-note {
  background: var(--card); border: 1px solid var(--rule); border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 16px 20px; margin: 20px 0;
  font-size: 14.5px; line-height: 1.6; color: inherit;
}
.vj-note strong { font-weight: 600; }
.vj-note.ok   { border-left-color: var(--ok); }
.vj-note.warn { border-left-color: var(--warn); }
.vj-note.stop { border-left-color: var(--stop); }
.vj-note-title {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .13em;
  text-transform: uppercase; color: var(--gold-txt); margin-bottom: 6px;
}

.vj-empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.vj-empty p { margin-bottom: 16px; max-width: 46ch; margin-inline: auto; line-height: 1.6; }

/* ───────────────────────────── Formulaires ───────────────────────────── */
.vj-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.vj-field > label { font-size: 13px; font-weight: 600; }
.vj-field .aide { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.vj-field input[type=text], .vj-field textarea, .vj-field select, .vj-input {
  font: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--rule);
  border-radius: 9px; background: var(--card); color: var(--ink); width: 100%;
}
.vj-field textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; }
.vj-field input:focus, .vj-field textarea:focus, .vj-field select:focus, .vj-input:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
.vj-row { display: flex; flex-wrap: wrap; gap: 16px; }
.vj-row > * { flex: 1 1 200px; }

.vj-panel {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.vj-panel > h2 {
  font-family: 'Cormorant Garamond', Georgia, serif; font-size: 26px; font-weight: 600;
  margin-bottom: 6px; line-height: 1.2;
}
.vj-panel > .sous { font-size: 14px; color: var(--muted); margin-bottom: 18px; line-height: 1.55; }

/* Étapes numérotées de l'outil de création : la numérotation encode une vraie
   séquence (on ne peut pas arbitrer des critères avant d'avoir des données). */
.vj-step { counter-increment: etape; }
.vj-step > h2::before {
  content: counter(etape); display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin-right: 12px; border-radius: 50%;
  background: var(--brand); color: #fff; font-family: 'Montserrat', sans-serif;
  font-size: 14px; font-weight: 600; vertical-align: 3px;
}
.vj-steps { counter-reset: etape; }

/* ───────────────────────────── Tableau de données ───────────────────────────── */
.vj-table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.vj-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.vj-table th, .vj-table td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.vj-table thead th { background: var(--paper-dark); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.vj-table tbody tr:last-child td { border-bottom: none; }
.vj-table td.num { text-align: right; }
.vj-table select { font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); color: var(--ink); }

/* ───────────────────────────── Témoin de faisabilité ───────────────────────────── */
.vj-feu {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: 12px; border: 1px solid var(--rule); background: var(--card);
  margin-bottom: 16px;
}
.vj-feu .lampe { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.vj-feu.vert   { border-color: var(--ok);   background: var(--ok-bg); }
.vj-feu.vert   .lampe { background: var(--ok); }
.vj-feu.orange { border-color: var(--warn); background: var(--warn-bg); }
.vj-feu.orange .lampe { background: var(--warn); }
.vj-feu.rouge  { border-color: var(--stop); background: var(--stop-bg); }
.vj-feu.rouge  .lampe { background: var(--stop); }
.vj-feu .txt { flex: 1 1 260px; font-size: 14px; line-height: 1.5; }
.vj-feu .mesures { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.vj-feu .mesures b { display: block; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ───────────────────────────── Liste des critères ───────────────────────────── */
/* La liste des critères est COMPLÈTE : aucune hauteur bornée, on doit tout voir. */
.vj-crits { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); padding-right: 4px; }
.vj-crit { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; background: var(--paper-dark); font-size: 13px; }
.vj-crit input[type=checkbox] { flex: none; width: 16px; height: 16px; accent-color: var(--brand); }
.vj-crit .lab { flex: 1; min-width: 0; }
.vj-crit .lab input { width: 100%; font: inherit; font-size: 13px; border: 1px solid transparent; background: transparent; border-radius: 5px; padding: 2px 5px; color: inherit; }
.vj-crit .lab input:hover { border-color: var(--rule); background: var(--card); }
.vj-crit .lab input:focus { outline: 2px solid var(--brand); background: var(--card); }
.vj-crit .n { font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.vj-crit.off { opacity: .5; }
.vj-crit-dim { grid-column: 1 / -1; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-txt); margin-top: 10px; }

/* ───────────────────────────── Grille de sudoku ───────────────────────────── */
.sk-grid { display: grid; grid-template-columns: minmax(120px, 1.2fr) repeat(3, 1fr); gap: 6px; margin: 0 auto; max-width: 760px; }
.sk-h { display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px 6px; font-size: 12.5px; font-weight: 500; line-height: 1.3; background: var(--brand-soft); color: var(--brand); border-radius: 9px; min-height: 58px; }
.sk-h.corner { background: transparent; }
.sk-h.row { text-align: left; justify-content: flex-start; }
.sk-cell {
  min-height: 76px; border: 1px solid var(--rule); border-radius: 9px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px; cursor: pointer; text-align: center; font: inherit; color: inherit;
  transition: border-color .15s, background .15s;
}
.sk-cell:hover:not(.done) { border-color: var(--brand); background: var(--brand-soft); }
.sk-cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sk-cell.done { background: var(--ok-bg); border-color: var(--ok); cursor: default; }
.sk-cell.active { border-color: var(--gold); border-width: 2px; }
.sk-cell .rep { font-size: 13px; font-weight: 500; line-height: 1.25; }
.sk-cell .plus { font-size: 22px; color: var(--muted); }

/* ───────────────────────────── Quiz ───────────────────────────── */
.qz-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.qz-media {
  width: 100%; max-width: 560px; min-height: 240px; display: flex; align-items: center; justify-content: center;
  background: var(--paper-dark); border-radius: var(--radius); padding: 20px; overflow: hidden;
}
.qz-media img { max-width: 100%; max-height: 380px; width: auto; height: auto; object-fit: contain; border-radius: 8px; }
.qz-texte { font-family: 'Cormorant Garamond', Georgia, serif; font-size: clamp(24px, 4vw, 38px); line-height: 1.25; text-align: center; text-wrap: balance; }
.qz-choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); width: 100%; max-width: 720px; }
.qz-choice {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--rule); background: var(--card); font: inherit; font-size: 14px;
  cursor: pointer; text-align: left; color: inherit; transition: border-color .12s, background .12s;
}
.qz-choice:hover { border-color: var(--brand); }
.qz-choice:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.qz-choice .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.qz-choice.is-correct { background: var(--ok-bg); border-color: var(--ok); }
.qz-choice.is-wrong   { background: var(--stop-bg); border-color: var(--stop); }
.qz-choices.locked { pointer-events: none; }

.qz-bar { display: flex; gap: 20px; justify-content: center; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qz-bar b { color: var(--ink); font-weight: 600; }

.qz-credit { font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.4; }
.qz-credit a { color: var(--gold-txt); }

/* ───────────────────────────── Résultat & classement ───────────────────────────── */
.vj-score { text-align: center; margin-bottom: 22px; }
.vj-score .big { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 64px; font-weight: 600; line-height: 1; color: var(--brand); }
.vj-score .big small { font-size: 26px; color: var(--muted); }
.vj-score .tps { font-size: 15px; color: var(--muted); margin-top: 6px; }

.vj-board { width: 100%; border-collapse: collapse; font-size: 14px; }
.vj-board th, .vj-board td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left; }
.vj-board thead th { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.vj-board td.num { text-align: right; font-variant-numeric: tabular-nums; }
.vj-board tr.moi { background: var(--brand-soft); font-weight: 600; }
.vj-board .av { width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; margin-right: 7px; }

.vj-msg { text-align: center; font-size: 14px; color: var(--muted); margin: 14px 0; min-height: 1.4em; }
.vj-msg a { color: var(--gold-txt); }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ───────────────────────────── Recherche Commons ───────────────────────────── */
.cm-results { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin-top: 12px; max-height: 320px; overflow-y: auto; }
.cm-hit { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--card); cursor: pointer; padding: 0; }
.cm-hit img { width: 100%; height: 90px; object-fit: cover; display: block; }
.cm-hit .t { font-size: 10.5px; padding: 5px 6px; color: var(--muted); line-height: 1.3; word-break: break-word; }
.cm-hit:hover { border-color: var(--brand); }
.cm-hit:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.cm-hit.pick { border-color: var(--ok); border-width: 2px; }

/* ───────────────────────────── Fenêtre modale ───────────────────────────── */
.vj-modal { position: fixed; inset: 0; background: rgba(26, 24, 20, .55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1200; }
.vj-modal-box { background: var(--card); border-radius: var(--radius); padding: 24px; max-width: 560px; width: 100%; max-height: 86vh; overflow-y: auto; box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .5); }
.vj-modal-box h3 { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 25px; font-weight: 600; margin-bottom: 12px; }

@media (max-width: 620px) {
  .sk-grid { grid-template-columns: minmax(84px, 1fr) repeat(3, 1fr); gap: 4px; }
  .sk-h { font-size: 11px; padding: 6px 4px; min-height: 52px; }
  .sk-cell { min-height: 66px; }
  .vj-panel { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ───────────────────────── Mémo des types de colonnes ───────────────────────── */
.vj-memo td { white-space: normal; vertical-align: top; }
.vj-memo td:first-child { white-space: nowrap; }
.vj-memo em { color: var(--muted); font-style: italic; }

/* ───────────────────────── Grille modifiable ───────────────────────── */
.vj-grille-barre {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; font-size: 13px; color: var(--muted);
}
.vj-grille-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.vj-grille { max-height: 460px; overflow: auto; }
.vj-grille thead th { position: sticky; top: 0; z-index: 2; }
.vj-grille th { min-width: 150px; vertical-align: top; }
.vj-grille td input[type=text],
.vj-grille .vj-col-nom {
  font: inherit; font-size: 13px; width: 100%; min-width: 110px;
  border: 1px solid transparent; background: transparent; border-radius: 5px;
  padding: 3px 6px; color: inherit;
}
.vj-grille .vj-col-nom { font-weight: 600; text-transform: none; letter-spacing: 0; margin-bottom: 4px; }
.vj-grille td input[type=text]:hover, .vj-grille .vj-col-nom:hover { border-color: var(--rule); background: var(--card); }
.vj-grille td input[type=text]:focus, .vj-grille .vj-col-nom:focus { outline: 2px solid var(--brand); background: var(--card); }
.vj-grille th select { width: 100%; }
.vj-grille td { padding: 2px 6px; }
.vj-grille .vj-num { color: var(--muted); font-size: 11px; text-align: right; width: 1%; white-space: nowrap; }
.vj-x {
  border: none; background: none; cursor: pointer; color: var(--muted);
  font-size: 13px; line-height: 1; padding: 2px 5px; border-radius: 4px;
}
.vj-x:hover { color: var(--stop); background: var(--stop-bg); }
.vj-x:focus-visible { outline: 2px solid var(--brand); }

/* ───────────────────────── Liste des critères ───────────────────────── */
.vj-crit.mort { opacity: .42; }
.vj-crit.mort .lab { padding: 2px 5px; }
.vj-dim-n { font-weight: 400; color: var(--muted); letter-spacing: 0; text-transform: none; }
