/* Spike Castle — base.css : les jetons de la direction artistique (papiers et encres) et les composants communs.
   Aucun arrondi, aucun dégradé, aucune ombre floue : des ombres pleines décalées, comme une plaque imprimée. */

@font-face { font-family: 'Familjen Grotesk'; src: url('../polices/FamiljenGrotesk-Variable.woff') format('woff'); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('../polices/SpaceMono-Regular.woff') format('woff'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('../polices/SpaceMono-Bold.woff') format('woff'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  /* Papiers */
  --papier: #EDE3CE;
  --papier-clair: #F5EEDF;
  --papier-fonce: #E0D3B6;
  /* Encres */
  --encre: #221E18;
  --encre-douce: #4A4239;
  --encre-pale: #6D655A;
  --trait: #b3a68c;
  --trait-clair: #c4b596;
  /* Équipes et signalement */
  --brique: #A2542A;
  --ardoise: #2F4F5A;
  --alerte: #A8372A;
  --hausse: #3B6474;
  --or: #C08A1E;
  /* Polices */
  --sans: 'Familjen Grotesk', 'Segoe UI', Arial, sans-serif;
  --mono: 'Space Mono', 'Consolas', 'Courier New', monospace;
  /* Échelle typographique */
  --t-micro: 9px; --t-mini: 10.5px; --t-petit: 12px; --t-base: 14px; --t-lisant: 16px;
  --t-titre: 19px; --t-ecran: 22px; --t-affiche: 30px; --t-nombre: 38px;
  /* Espacement */
  --e1: 4px; --e2: 6px; --e3: 9px; --e4: 12px; --e5: 16px; --e6: 22px; --e7: 30px;
  /* Ombres pleines */
  --ombre-1: 3px 3px 0 var(--encre);
  --ombre-2: 4px 4px 0 var(--encre);
  --ombre-3: 6px 6px 0 var(--encre);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Grain papier sur toute l'application : un bruit fin, sans interaction. */
body::before { content: ''; position: fixed; inset: 0; z-index: 2000; pointer-events: none; opacity: .09; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .13  0 0 0 0 .11  0 0 0 0 .09  0 0 0 .9 0'/></filter><rect width='160' height='160' filter='url(%23g)'/></svg>"); }

body {
  margin: 0; min-height: 100vh;
  background: var(--papier); color: var(--encre);
  font-family: var(--sans); font-size: var(--t-base); line-height: 1.4;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ardoise); }
a:hover { color: var(--encre); }
[hidden] { display: none !important; }

/* Grain papier : sur toute l'application, sans jamais intercepter un toucher. */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: .3; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .13 0 0 0 0 .12 0 0 0 0 .09 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media print { body::after { display: none; } }

:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; }

/* ───────── En-tête et page ───────── */
.entete {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--e5);
  padding: var(--e4) var(--e7); border-bottom: 3px solid var(--encre); background: var(--papier);
}
.entete .gauche { display: flex; align-items: baseline; gap: var(--e5); flex-wrap: wrap; }
.marque { font-family: var(--mono); font-weight: 700; font-size: var(--t-lisant); letter-spacing: .16em; color: var(--encre); text-decoration: none; }
.contexte { font-family: var(--mono); font-size: var(--t-mini); letter-spacing: .12em; color: var(--encre-douce); text-transform: uppercase; }
.puces { display: flex; gap: var(--e4); flex-wrap: wrap; font-family: var(--mono); font-size: var(--t-mini); letter-spacing: .12em; text-transform: uppercase; }
.puce { padding: var(--e2) 10px; background: var(--papier-clair); border: 2px solid var(--encre); }
.puce.pointille { background: transparent; border: 2px dashed var(--trait); color: var(--encre-douce); }
.puce.alerte { border-color: var(--alerte); color: var(--alerte); }

.page { padding: 20px var(--e7) var(--e7); display: flex; flex-direction: column; gap: var(--e6); max-width: 1440px; margin: 0 auto; }
.etroite { max-width: 960px; }
.pile { display: flex; flex-direction: column; gap: var(--e3); }
.pile-l { display: flex; flex-direction: column; gap: var(--e5); }
.rangee { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e4); }
.rangee.entre { justify-content: space-between; }
.espace { flex: 1; }

/* ───────── Textes ───────── */
.titre-ecran { font-size: var(--t-ecran); font-weight: 700; }
.titre-carte { font-size: var(--t-titre); font-weight: 700; }
.affiche { font-size: var(--t-affiche); font-weight: 700; line-height: 1.1; }
.explication { font-size: var(--t-base); color: var(--encre-douce); max-width: 68ch; line-height: 1.5; }
.note { font-size: var(--t-petit); color: var(--encre-douce); }
.etiquette { font-family: var(--mono); font-size: var(--t-mini); letter-spacing: .12em; text-transform: uppercase; color: var(--encre-douce); font-weight: 700; }
.donnee { font-family: var(--mono); letter-spacing: .04em; }

/* ───────── Boutons ───────── */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e3);
  min-height: 38px; padding: 0 14px;
  border: 2px solid var(--encre); background: var(--papier-clair); color: var(--encre);
  box-shadow: var(--ombre-1);
  font-size: var(--t-base); font-weight: 600; line-height: 1.1; text-decoration: none; cursor: pointer;
}
.bouton:hover { background: var(--papier-fonce); color: var(--encre); }
.bouton:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--encre); }
.bouton.principal { background: var(--encre); color: var(--papier); box-shadow: 4px 4px 0 var(--brique); min-height: 46px; padding: 0 20px; font-size: var(--t-lisant); font-weight: 700; }
.bouton.principal:hover { background: var(--encre-douce); color: var(--papier); }
.bouton.petit { min-height: 28px; padding: 0 var(--e3); font-size: var(--t-petit); box-shadow: 2px 2px 0 var(--encre); }
.bouton.danger { border-color: var(--alerte); color: var(--alerte); box-shadow: 3px 3px 0 var(--alerte); }
.bouton.danger.arme { background: var(--alerte); color: var(--papier-clair); }
.bouton:disabled, .bouton[aria-disabled='true'] { background: var(--papier-fonce); color: var(--encre-pale); border-color: var(--trait); box-shadow: none; cursor: not-allowed; transform: none; }
.bouton svg { flex: none; }

/* ───────── Champs ───────── */
.champ { display: flex; flex-direction: column; gap: var(--e1); }
.champ > label, .champ > .nom-champ { font-size: var(--t-petit); font-weight: 600; }
.champ .aide { font-size: var(--t-petit); color: var(--encre-douce); }
.champ .erreur { font-size: var(--t-petit); color: var(--alerte); font-weight: 600; }
input[type='text'], input[type='number'], input[type='search'], select, textarea {
  min-height: 38px; padding: 0 var(--e3); width: 100%;
  border: 2px solid var(--encre); background: var(--papier-clair); border-radius: 0;
  font-size: var(--t-base);
}
textarea { padding: var(--e3); min-height: 140px; resize: vertical; font-family: var(--mono); font-size: var(--t-petit); line-height: 1.5; }
input:disabled, select:disabled { background: var(--papier-fonce); color: var(--encre-pale); border-color: var(--trait); }
input[aria-invalid='true'] { border-color: var(--alerte); }
input[type='checkbox'] { width: 18px; height: 18px; margin: 0; accent-color: var(--encre); }

/* ───────── Surfaces ───────── */
.carte { background: var(--papier-clair); border: 2px solid var(--encre); }
.carte.ombre { box-shadow: var(--ombre-2); }
.carte-corps { padding: var(--e5); display: flex; flex-direction: column; gap: var(--e4); }
.bandeau-carte { display: flex; justify-content: space-between; gap: var(--e4); padding: var(--e3) var(--e5); color: var(--papier-clair); background: var(--encre); font-family: var(--mono); font-size: var(--t-mini); letter-spacing: .12em; font-weight: 700; text-transform: uppercase; }
.bandeau-carte.brique { background: var(--brique); }
.bandeau-carte.ardoise { background: var(--ardoise); }
.encadre { padding: var(--e4) var(--e5); border-left: 3px solid var(--encre-douce); background: rgba(74, 66, 57, .08); font-size: var(--t-petit); color: var(--encre-douce); display: flex; flex-direction: column; gap: var(--e2); }
.encadre.alerte { border-left-color: var(--alerte); background: rgba(168, 55, 42, .08); color: var(--encre); }
.encadre.info { border-left-color: var(--hausse); background: rgba(59, 100, 116, .08); }
.vide { padding: var(--e5); border: 2px dashed var(--trait); color: var(--encre-douce); }

/* ───────── Accueil ───────── */
.entrees { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--e5); }
.entree {
  display: flex; flex-direction: column; gap: var(--e3); min-height: 150px; padding: var(--e5);
  background: var(--papier-clair); border: 2px solid var(--encre); box-shadow: var(--ombre-2);
  color: var(--encre); text-decoration: none; text-align: left; cursor: pointer;
}
.entree:hover { background: var(--papier-fonce); color: var(--encre); }
.entree:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--encre); }
.entree.inactive { border-style: dashed; border-color: var(--trait); box-shadow: none; color: var(--encre-pale); cursor: default; background: transparent; }
.entree.inactive:hover { background: transparent; color: var(--encre-pale); }
.entree .texte { font-size: var(--t-base); color: var(--encre-douce); }

/* ───────── Listes ───────── */
.lignes { display: flex; flex-direction: column; background: var(--papier-clair); border: 2px solid var(--encre); }
.ligne { display: flex; align-items: center; gap: var(--e4); padding: var(--e2) var(--e4); border-bottom: 1px solid var(--trait-clair); min-height: 44px; }
.ligne:last-child { border-bottom: 0; }
.ligne .nom { flex: 1; min-width: 0; font-size: var(--t-base); }
.ligne.absent .nom { color: var(--encre-pale); text-decoration: line-through; }
.coche { display: flex; align-items: center; gap: var(--e4); width: 100%; min-height: 44px; padding: var(--e2) var(--e4); background: none; border: 0; border-bottom: 1px solid var(--trait-clair); text-align: left; cursor: pointer; }
.coche:last-child { border-bottom: 0; }
.coche[aria-pressed='false'] .nom { color: var(--encre-pale); text-decoration: line-through; }
.coche .case { width: 22px; height: 22px; flex: none; border: 2px solid var(--encre); background: var(--papier); display: flex; align-items: center; justify-content: center; }
.coche[aria-pressed='true'] .case { background: var(--encre); color: var(--papier); }
.grille-eleves { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* ───────── Constitution des binômes ───────── */
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--e5); }
.mode {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--e3); min-height: 170px; padding: var(--e5);
  text-align: left; cursor: pointer;
  border: 2px solid var(--encre); background: var(--papier-clair); color: var(--encre); box-shadow: var(--ombre-1);
}
.mode[aria-pressed='true'] { background: var(--encre); color: var(--papier); box-shadow: 4px 4px 0 var(--or); }
.mode:disabled { background: transparent; border: 2px dashed var(--trait); color: var(--encre-pale); box-shadow: none; cursor: not-allowed; }
.mode .haut { display: flex; justify-content: space-between; align-items: center; gap: var(--e3); font-family: var(--mono); font-size: var(--t-mini); letter-spacing: .12em; font-weight: 700; }
.mode .haut .etat { font-size: var(--t-micro); }
.mode .nom-mode { font-size: var(--t-titre); font-weight: 700; }
.mode .texte { font-size: var(--t-base); line-height: 1.45; }
.mode .bas { margin-top: auto; padding-top: var(--e3); border-top: 1px solid var(--trait-clair); font-family: var(--mono); font-size: var(--t-mini); letter-spacing: .04em; display: flex; align-items: center; justify-content: space-between; gap: var(--e3); }
.mode[aria-pressed='true'] .bas { border-top-color: var(--encre-douce); }

.camps { display: flex; flex-wrap: wrap; gap: var(--e6); align-items: flex-start; }
.camp { flex: 1 1 400px; min-width: 0; background: var(--papier-clair); border: 2px solid var(--encre); box-shadow: var(--ombre-2); }
.camp .binomes { padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--e3); }
.binome { display: flex; align-items: stretch; gap: 10px; padding: var(--e3); background: var(--papier-clair); border: 2px solid var(--encre); }
.binome.brique { box-shadow: 2px 2px 0 var(--brique); }
.binome.ardoise { box-shadow: 2px 2px 0 var(--ardoise); }
.binome.choisi { outline: 3px solid var(--or); outline-offset: 3px; }
.binome .code { width: 40px; flex: none; border: 2px solid var(--encre); cursor: pointer; font-family: var(--mono); font-size: var(--t-petit); font-weight: 700; color: var(--papier-clair); }
.binome.brique .code { background: var(--brique); }
.binome.ardoise .code { background: var(--ardoise); }
.binome.choisi .code { background: var(--or); color: var(--encre); }
.binome .eleves { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--e1); }
.eleve { width: 100%; min-height: 32px; padding: 3px var(--e3); text-align: left; cursor: pointer; background: var(--papier); border: 2px solid transparent; font-size: var(--t-base); }
.eleve.choisi { background: var(--encre); color: var(--papier); border-color: var(--encre); }
.eleve.cible, .place-libre { border: 2px dashed var(--trait); background: transparent; color: var(--encre-douce); }
.eleve.cible:hover, .place-libre:hover { border-color: var(--encre); color: var(--encre); background: var(--papier-fonce); }
.place-libre { cursor: pointer; min-height: 32px; padding: 3px var(--e3); text-align: left; font-size: var(--t-petit); }
.reserve-pool { display: flex; flex-direction: column; gap: var(--e3); padding: 14px; border: 2px dashed var(--trait); }
.reserve-pool.cible { border-color: var(--encre); background: var(--papier-fonce); cursor: pointer; }
.jetons { display: flex; flex-wrap: wrap; gap: var(--e2); }
.jeton { padding: var(--e2) var(--e3); border: 2px solid var(--encre); box-shadow: 2px 2px 0 var(--encre); background: var(--papier-clair); cursor: pointer; font-size: var(--t-base); }
.jeton.choisi { background: var(--encre); color: var(--papier); }
.jauge { display: flex; gap: var(--e1); }
.jauge span { width: 34px; height: 12px; border: 2px solid var(--trait); }
.jauge span.actif { background: var(--encre); border-color: var(--encre); }
.rail { flex: 0 1 270px; min-width: 230px; display: flex; flex-direction: column; gap: var(--e5); }

/* ───────── Formulaire de réglages ───────── */
.grille-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--e5); }

/* ───────── Messages et erreurs ───────── */
.statut { min-height: 1.4em; font-size: var(--t-petit); color: var(--encre-douce); }
.statut.ok { color: var(--hausse); font-weight: 600; }
.statut.alerte { color: var(--alerte); font-weight: 600; }
.ecran-erreur { max-width: 640px; margin: 60px auto; padding: 0 var(--e5); display: flex; flex-direction: column; gap: var(--e5); }
.ecran-erreur pre { margin: 0; padding: var(--e4); background: var(--papier-clair); border: 2px solid var(--alerte); font-family: var(--mono); font-size: var(--t-petit); white-space: pre-wrap; overflow-wrap: anywhere; }
.chargement { padding: 60px var(--e7); font-family: var(--mono); letter-spacing: .12em; color: var(--encre-douce); }

.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; }

/* Tablette et téléphone : cibles plus larges, colonnes qui s'empilent. */
@media (pointer: coarse) {
  .bouton { min-height: 44px; }
  .bouton.petit { min-height: 36px; }
  .eleve, .place-libre { min-height: 40px; }
}
@media (max-width: 900px) {
  .modes { grid-template-columns: 1fr; }
  .mode { min-height: 0; }
  .camp .binomes { grid-template-columns: 1fr; }
  .rail { flex-basis: 100%; }
  .entete, .page { padding-left: var(--e5); padding-right: var(--e5); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Avis de nouvelle version (hors-ligne) */
.bandeau-maj { position: fixed; left: var(--e4); right: var(--e4); bottom: var(--e4); z-index: 1500; display: flex; flex-wrap: wrap; align-items: center; gap: var(--e4); padding: var(--e4) var(--e5); background: var(--papier-clair); border: 3px solid var(--encre); box-shadow: 4px 4px 0 var(--or); font-size: var(--t-base); }
.bandeau-maj span { flex: 1 1 280px; }
