/* Échapper — l'habillage.
   Copyright (c) 2026 Tristan Cazenave. Tous droits réservés — voir LICENSE.

   UN JEU DE PLATEAU EN BOIS, comme « Out of the Box » : un cadre de bois
   sombre, un damier chaud, des cartes de papier crème posées dessus, et l'or
   pour ce qui se gagne. Tout est dessiné en CSS — aucune image, net à toutes
   les tailles, et rien à télécharger.

   LES PIÈCES SONT CELLES DE DAPHNÉE (`daphnee/public/js/echiquier.js`), aux
   mêmes noms de variables : qui passe d'un jeu d'échecs du site à l'autre doit
   reconnaître la pièce. Ce sont les glyphes PLEINS pour une pièce blanche,
   remplis en clair et cernés de sombre — un glyphe creux n'est qu'un contour,
   et ce contour disparaît sur une case claire.

   Tout tient dans `--c`, la taille d'une case ; le reste en découle. */

:root {
  color-scheme: light dark;
  --encre: #2b2118; --encre-2: #5b4a3a; --encre-3: #8a7866;
  --carte: #fffbf2; --carte-2: #f6ecd8; --ligne: rgba(70, 45, 20, .16);
  --fond-1: #fbf0d8; --fond-2: #e8c48f;
  --bois-1: #8a5d33; --bois-2: #6e4524; --bois-3: #4a2c14;
  --claire: #f2e3c4; --sombre: #c09563;
  --piece-blanche: #FBF8F2; --piece-noire: #1A1714; --piece-trait: #00000055;
  --roi: #c0392b;
  --porte: #2a9a58; --porte-clair: #4cc47e;
  --accent: #2f63d6; --accent-2: #1d3f94;
  --or: #f5b82e; --or-2: #d99610;
  --bon: #23874d; --mauvais: #c43d2c;
  --police: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Varela Round",
            "Nunito", "Trebuchet MS", system-ui, -apple-system, "Segoe UI", sans-serif;
  --c: 92px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --encre: #f1e7d8; --encre-2: #cdbca6; --encre-3: #9b8b78;
    --carte: #241c16; --carte-2: #2e241c; --ligne: rgba(255, 235, 200, .14);
    --fond-1: #2a2018; --fond-2: #16100b;
    --bois-1: #5d3e22; --bois-2: #452d18; --bois-3: #2a1a0d;
    --claire: #b59a74; --sombre: #7d5e3c;
    --piece-blanche: #F2EEE6; --piece-noire: #0C0B0A; --piece-trait: #00000066;
    --roi: #e05a46;
    --porte: #3fae6b; --porte-clair: #63d593;
    --accent: #6f9bf0; --accent-2: #9dbcf5;
    --bon: #58c58b; --mauvais: #e58a7b;
  }
}

* { box-sizing: border-box; }
/* `hidden` NE FAIT RIEN CONTRE UN `display: flex`. La leçon vient de Déraper,
   où le harnais lisait l'attribut et passait pendant que tout restait à
   l'écran ; ici c'est l'annonce « un nouveau problème du jour » qui s'affichait
   en plein tutoriel. Une seule ligne, et elle vaut pour toute la page. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  color: var(--encre);
  font: 600 16px/1.45 var(--police);
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .30) 1.2px, transparent 1.6px) 0 0 / 24px 24px,
    radial-gradient(ellipse at 30% -10%, var(--fond-1) 0%, transparent 70%),
    linear-gradient(160deg, var(--fond-1), var(--fond-2));
  background-color: var(--fond-2);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
/* RIEN NE ZOOME TOUT SEUL SUR UN ÉCRAN TACTILE : deux appuis rapprochés sur
   « Annuler » sont lus par Safari comme un ordre de grossir, et le plateau sort
   du cadre au moment précis où l'on voulait revenir en arrière. */
html, body { touch-action: manipulation; }
button, select, input, a, label, summary { touch-action: manipulation; }

.page { max-width: 1020px; margin: 0 auto; padding: 14px 14px 30px; }

header.tete { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pousse { margin-left: auto; }
h1 { font-size: 23px; margin: 0; letter-spacing: .2px; }

.langues {
  display: inline-flex; border: 1px solid var(--ligne); border-radius: 999px;
  overflow: hidden; background: var(--carte);
}
.langues button {
  font: inherit; font-size: 13px; line-height: 1; padding: 7px 11px;
  border: 0; background: none; color: var(--encre-2); cursor: pointer;
}
.langues button + button { border-left: 1px solid var(--ligne); }
.langues button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* Les boutons ont une épaisseur : une ombre portée courte et un enfoncement au
   clic. C'est ce qui distingue un jouet d'un formulaire. */
.btn {
  font: inherit; font-size: 15px; color: var(--encre); background: var(--carte);
  border: 1px solid var(--ligne); border-radius: 12px; padding: 9px 15px;
  cursor: pointer; box-shadow: 0 2px 0 var(--ligne);
  transition: transform .06s, box-shadow .06s, background .15s;
}
.btn:hover:not(:disabled) { background: var(--carte-2); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
.btn.primaire {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent; box-shadow: 0 3px 0 rgba(0, 0, 0, .22);
}
.btn.discret { background: none; border-color: transparent; box-shadow: none;
  color: var(--encre-3); font-size: 14px; text-decoration: underline; }

.jeu { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.colonne { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* LA COLONNE DU JEU A UNE LARGEUR, et ce n'est pas une coquetterie.
   Dans une colonne flex, chaque enfant impose sa largeur de CONTENU MAXIMAL —
   et un paragraphe, lui, veut tenir sur une seule ligne. La phrase d'aide
   faisait donc 452 px là où le plateau en fait 412, et c'est elle, non le
   plateau, qui poussait le tableau d'honneur dessous dès qu'on rétrécissait la
   fenêtre. Bornée, elle se replie sur deux lignes et le tableau reste à
   droite. */
.colonne { width: min(100%, 420px); }


/* ── les cartes de papier ─────────────────────────────────────────────── */

.bandeau, .cote, .fin, .attente {
  background: var(--carte); border: 1px solid var(--ligne);
  border-radius: 16px; padding: 13px 16px;
  box-shadow: 0 3px 0 rgba(70, 45, 20, .10), 0 10px 24px rgba(70, 45, 20, .10);
}
.bandeau { width: 100%; }
.bandeau h2 { margin: 0 0 4px; font-size: 18px; }
.bandeau .date { color: var(--encre-2); font-weight: 700; }
.bandeau .numero { color: var(--encre-3); font-size: 14px; margin-left: 6px; }
.bandeau .avance { margin: 0 0 4px; font-size: 13px; color: var(--encre-3);
  text-transform: uppercase; letter-spacing: .06em; }
.bandeau .quoi { margin: 0; font-size: 16.5px; color: var(--encre); }
.bandeau .boutons { margin: 10px 0 0; display: flex; gap: 10px; align-items: center; }
.bandeau .mien { margin: 0; font-size: 14px; color: var(--bon); }

/* ── le plateau, dans son cadre de bois ───────────────────────────────── */

.cadre {
  padding: 14px; border-radius: 20px;
  background: linear-gradient(160deg, var(--bois-1), var(--bois-2) 55%, var(--bois-3));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22),
              inset 0 -3px 8px rgba(0, 0, 0, .35),
              0 10px 26px rgba(40, 24, 10, .34);
}
.plateau {
  display: grid; gap: 0;
  grid-template-columns: repeat(var(--colonnes, 3), var(--c));
  width: max-content;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .25), inset 0 0 22px rgba(60, 35, 12, .30);
}
.case {
  width: var(--c); height: var(--c); position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--c) * .80); line-height: 1;
  background: var(--claire);
}
.case.sombre { background: var(--sombre); }
/* LA SORTIE EST UNE CASE, PAS UN DEHORS : le roi gagne en s'y posant. Le
   liseré vert et la lueur disent seulement par où l'on sort. */
.case.sortie {
  background-image: radial-gradient(circle at 50% 50%,
    color-mix(in srgb, var(--porte-clair) 42%, transparent), transparent 72%);
}
.case.sortie::after {
  content: ''; position: absolute; inset: 4px; border-radius: 6px;
  border: 3px dashed var(--porte); pointer-events: none;
}
.case.jouable { cursor: pointer; }
.case.choisie { box-shadow: inset 0 0 0 4px var(--accent); }
.case.but::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 30%; height: 30%; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--accent); opacity: .5;
}
.case.conseil { box-shadow: inset 0 0 0 4px var(--bon); }
.case.dernier::after {
  content: ''; position: absolute; inset: 0;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  pointer-events: none;
}

.piece {
  position: relative; z-index: 1; user-select: none;
  color: var(--piece-blanche);
  -webkit-text-stroke: 0.028em var(--piece-noire);
  paint-order: stroke fill;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .35));
}
/* Le roi se voit de l'autre bout de la pièce : c'est lui qu'on sort. Même
   forme, même contour, un autre remplissage. */
.piece.p-K { color: var(--roi); }
.case:has(.p-K)::before {
  content: ''; position: absolute; inset: 7%; border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--roi) 55%, transparent);
}
.case.sortante { animation: sorti .7s ease-out 2; }
@keyframes sorti {
  0%, 100% { box-shadow: inset 0 0 0 0 var(--porte-clair); }
  50% { box-shadow: inset 0 0 0 6px var(--porte-clair); }
}

.coord {
  position: absolute; z-index: 2; pointer-events: none; user-select: none;
  font-size: calc(var(--c) * .19); line-height: 1; font-weight: 700;
  color: rgba(60, 35, 12, .5);
}
.coord.fichier { right: 4px; bottom: 2px; }
.coord.rangee { left: 4px; top: 2px; }

/* ── ce qu'on dit, et ce qu'on commande ───────────────────────────────── */

.dit { min-height: 1.5em; margin: 0; color: var(--encre-2); font-size: 15px; }
.dit.mauvais { color: var(--mauvais); }
.dit.bon { color: var(--bon); font-weight: 700; }

.barre { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; width: 100%; }
.compteurs { font-size: 14px; color: var(--encre-3); }
.compteurs b { color: var(--encre); font-variant-numeric: tabular-nums; font-size: 17px; }
.compteurs > span + span { margin-left: 14px; }

.fin { width: 100%; border-color: color-mix(in srgb, var(--bon) 45%, var(--ligne)); }
.fin h2 { margin: 0 0 4px; font-size: 20px; color: var(--bon); }
.fin p { margin: 0 0 6px; font-size: 15px; color: var(--encre-2); }
.fin .suite { color: var(--encre-3); font-size: 14px; margin: 0; }
/* L'AUTRE JEU, APRÈS LA RÉUSSITE. Discret — c'est une proposition, pas une
   réclame — mais pas gris sur gris : qui vient de gagner doit le voir. */
.fin .croise { margin: 10px 0 0; font-size: 14px; color: var(--encre-2); }
.fin .croise a { color: var(--accent); font-weight: 700; }
.attente { width: 100%; display: flex; gap: 12px; align-items: center;
  font-size: 15px; }

/* ── les deux tableaux d'honneur ──────────────────────────────────────── */

/* LE TABLEAU TIENT DANS PEU DE PLACE : un nom, un nombre. Lui donner une
   largeur minimale généreuse le faisait passer sous le plateau dès que la
   fenêtre se resserrait — alors qu'il se lit très bien en deux cent trente
   pixels, et que le lecteur préfère le voir à côté du jeu. */
.cote { flex: 1 1 240px; min-width: 230px; }
.cote h2 { font-size: 16px; margin: 0 0 8px; }
.cote h2 + div + h2 { margin-top: 18px; }
.note { margin: 6px 0 0; font-size: 13.5px; color: var(--encre-3); }

ol.tableau { list-style: none; margin: 0; padding: 0; counter-reset: rang; }
ol.tableau li {
  counter-increment: rang;
  display: grid; grid-template-columns: 26px 1fr auto; gap: 8px;
  align-items: baseline; padding: 6px 8px; border-radius: 10px;
  font-size: 14.5px;
}
ol.tableau li::before {
  content: counter(rang); color: var(--encre-3); font-size: 13px;
  font-variant-numeric: tabular-nums; text-align: right;
}
ol.tableau li:nth-child(odd) { background: var(--carte-2); }
/* L'or pour la première ligne : ce qui se gagne doit se voir. */
ol.tableau li:first-child::before { color: var(--or-2); font-weight: 800; }
ol.tableau li:first-child { background: linear-gradient(90deg,
  color-mix(in srgb, var(--or) 26%, transparent), transparent); }
ol.tableau li.moi { outline: 2px solid var(--accent); }
ol.tableau .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.tableau .score { color: var(--encre-2); white-space: nowrap; }
ol.tableau .score b { color: var(--encre); }
ol.tableau .temps { grid-column: 2 / 4; font-size: 12.5px; color: var(--encre-3); }

/* ── les règles ───────────────────────────────────────────────────────── */

dialog.regles {
  max-width: 580px; width: calc(100% - 28px); border: 1px solid var(--ligne);
  border-radius: 18px; background: var(--carte); color: var(--encre); padding: 20px;
}
dialog.regles::backdrop { background: rgba(40, 24, 10, .55); }
dialog.regles h2 { margin: 0 0 10px; font-size: 19px; }
dialog.regles p { font-size: 15px; color: var(--encre-2); }

/* LA SIGNATURE SUIT LE NOM : elle ne pèse pas comme lui, et ne doit pas
   peser. Elle était en pied de page, où personne ne la lisait. */
h1 .par { font-size: 13.5px; font-weight: 400; color: var(--encre-3); }

@media (max-width: 760px) { :root { --c: 70px; } .page { padding: 10px 10px 24px; } }
@media (max-width: 380px) { :root { --c: 54px; } }
