/* Layout : bandeau de saisie collant en haut, feuille d'article au centre, panneau de propositions à droite (dessous sur mobile). */
/* Thèmes : « archive » (clair, par défaut), « kraft » et « fluo » (clairs), « dark » (sombre).
   Sans choix du joueur, le jeu suit le système : archive en clair, dark en sombre. */
:root {
  --paper: #dbe5f2;       /* fond de page */
  --sheet: #ffffff;       /* feuille de l'article */
  --ink: #14243b;         /* texte */
  --muted: #5a6b82;
  --rule: #c9d6e6;
  --bar: #1d3150;         /* bloc de caviardage */
  --near-lo: #50627e;     /* mot proposé lointain, écrit dans un bloc */
  --near-hi: #e6eef8;     /* mot proposé très proche */
  --mark: #ffe45c;        /* surligneur : mots trouvés au dernier essai */
  --mark-ink: #14243b;
  --accent: #2c62c9;
  --danger: #b8322a;
  --ok: #23774a;          /* tampon DÉCLASSIFIÉ */
  --f-display: "Literata", Georgia, "Times New Roman", serif;
  --f-text: "Literata", Georgia, "Times New Roman", serif;
  --f-ui: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --paper: #15181a; --sheet: #1c2023; --ink: #e3e6e1; --muted: #8f968d; --rule: #30363a;
    --bar: #3a4247; --near-lo: #5d666b; --near-hi: #f2f5f1; --mark: #d9bf3a; --mark-ink: #15181a;
    --accent: #6fb8a6; --danger: #e07a64; --ok: #6fd39a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15181a; --sheet: #1c2023; --ink: #e3e6e1; --muted: #8f968d; --rule: #30363a;
  --bar: #3a4247; --near-lo: #5d666b; --near-hi: #f2f5f1; --mark: #d9bf3a; --mark-ink: #15181a;
  --accent: #6fb8a6; --danger: #e07a64; --ok: #6fd39a; color-scheme: dark;
}
:root[data-theme="archive"] {
  --paper: #dbe5f2; --sheet: #ffffff; --ink: #14243b; --muted: #5a6b82; --rule: #c9d6e6;
  --bar: #1d3150; --near-lo: #50627e; --near-hi: #e6eef8; --mark: #ffe45c; --mark-ink: #14243b;
  --accent: #2c62c9; --danger: #b8322a; --ok: #23774a; color-scheme: light;
}
:root[data-theme="kraft"] {
  --paper: #e9d9b0; --sheet: #faf1da; --ink: #2b2722; --muted: #6f6354; --rule: #dccaa0;
  --bar: #2e2a26; --near-lo: #6a6055; --near-hi: #f3ead8; --mark: #ffd84a; --mark-ink: #2b2722;
  --accent: #b3362b; --danger: #8f2a1d; --ok: #2f6b34; color-scheme: light;
}
:root[data-theme="fluo"] {
  --paper: #f3eefc; --sheet: #ffffff; --ink: #231c3a; --muted: #6b6385; --rule: #e0d8f2;
  --bar: #2a2342; --near-lo: #7a4a70; --near-hi: #ffb3d6; --mark: #c8ff5a; --mark-ink: #231c3a;
  --accent: #6a45e0; --danger: #c42f5b; --ok: #13865a; color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--f-ui); font-size: 15px; line-height: 1.45; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- bandeau ---------- */
.bar { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--rule);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.bar-inner { max-width: 1480px; margin: 0 auto; padding-block: 12px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { display: grid; gap: 3px; width: 22px; }
.logo span { height: 5px; background: var(--bar); border-radius: 1px; }
.logo span:nth-child(2) { width: 60%; background: var(--mark); }
.logo span:nth-child(3) { width: 80%; }
.name { font-family: var(--f-display); font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.guess { flex: 1 1 320px; display: flex; gap: 8px; min-width: 0; }
.guess input { flex: 1; min-width: 0; padding: 10px 14px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--sheet); font-family: var(--f-mono); font-size: 16px; }
.guess input:disabled { opacity: .5; }
button { cursor: pointer; padding: 9px 16px; border-radius: 3px; border: 1.5px solid var(--ink); background: var(--ink); color: var(--sheet); font-weight: 500; letter-spacing: .01em; }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
button.ghost:hover { border-color: var(--ink); }
button.danger { color: var(--danger); }
button.armed { background: var(--danger); color: var(--sheet); border-color: var(--danger); }
button.danger.armed { background: var(--danger); color: var(--sheet); border-color: var(--danger); }
.themes { display: flex; gap: 6px; align-items: center; }
.swatch { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--rule); background: var(--sw-a); position: relative; overflow: hidden; }
.swatch::after { content: ""; position: absolute; inset: 50% 0 0 0; background: var(--sw-b); }
.swatch:hover { border-color: var(--muted); }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--ink); }
.stats { display: flex; gap: 16px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.stats b { color: var(--ink); font-family: var(--f-mono); font-weight: 500; }
.feedback { max-width: 1480px; margin: 0 auto; min-height: 1.45em; padding-bottom: 8px; color: var(--muted); font-size: 14px; }
.feedback.bad { color: var(--danger); }
.feedback.good { color: var(--accent); }

/* ---------- mise en page ---------- */
/* Trois colonnes : pages trouvées | article | propositions et partie. */
.layout { max-width: 1480px; margin: 0 auto; padding-block: 24px 48px; display: grid; gap: 28px; align-items: start;
  grid-template-columns: 250px minmax(0, 1fr) 300px; grid-template-areas: "left sheet side";
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.left { grid-area: left; display: grid; gap: 18px; min-width: 0; position: sticky; top: 92px; }
.sheet { grid-area: sheet; }
.side { grid-area: side; }
.left .pages { max-height: calc(100vh - 200px); }
/* Historique replié : une fine barre à gauche, l'article prend la place. */
.head-actions { display: flex; align-items: center; gap: 10px; }
.fold-btn { padding: 0 7px; font-size: 18px; line-height: 1.3; background: transparent; color: var(--muted); border: 1px solid var(--rule); }
.fold-btn:hover { color: var(--ink); border-color: var(--ink); }
.pages-rail { display: none; }
.layout.folded { grid-template-columns: 40px minmax(0, 1fr) 300px; }
.layout.folded #pages-panel { display: none; }
.layout.folded .pages-rail { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 40px; padding: 10px 0;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); }
.layout.folded .pages-rail:hover { border-color: var(--ink); }
.pages-rail .chev { font-size: 18px; line-height: 1; color: var(--muted); }
.pages-rail .rail-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; color: var(--muted); }
.pages-rail b { font-family: var(--f-mono); color: var(--accent); font-weight: 500; letter-spacing: 0; }
/* Moins large : l'historique passe sous les propositions, à droite. */
@media (max-width: 1180px) {
  .layout, .layout.folded { grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "sheet side" "sheet left"; }
  .layout.folded .pages-rail { flex-direction: row; width: 100%; padding: 8px 12px; }
  .pages-rail .rail-label { writing-mode: horizontal-tb; transform: none; }
  .pages-rail .chev { transform: rotate(90deg); }
  .left, .side { position: static; }   /* l'historique est sous les propositions : rien ne doit rester fixé par-dessus */
  .left .pages { max-height: 32vh; }
}
@media (max-width: 860px) {
  .layout, .layout.folded { grid-template-columns: minmax(0, 1fr); grid-template-areas: "sheet" "side" "left"; }
}

.sheet { background: var(--sheet); border: 1px solid var(--rule); padding: clamp(18px, 4vw, 44px) clamp(18px, 5vw, 56px); min-width: 0; }
.sheet-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--rule); padding-bottom: 10px; margin-bottom: 22px; }
.sheet-meta b { font-family: var(--f-mono); letter-spacing: .04em; color: var(--ink); text-transform: none; font-weight: 500; }
/* Tampon : CLASSIFIÉ pendant la partie, DÉCLASSIFIÉ une fois le titre trouvé. */
.title-row { margin-bottom: 18px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 24px; flex-wrap: wrap; }
.title-row .title { flex: 1 1 260px; min-width: 0; }
.stamp { flex: none; margin-top: 4px; padding: 4px 12px 3px; transform: rotate(-7deg);
  font-family: var(--f-ui); font-weight: 600; font-size: 17px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--danger); border: 3px solid currentColor; border-radius: 4px; opacity: .85;
  box-shadow: inset 0 0 0 2px var(--sheet), inset 0 0 0 3px currentColor; user-select: none; }
.stamp.declass { color: var(--ok); opacity: .95; }
.stamp.slam { animation: slam .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes slam {
  0% { transform: rotate(-16deg) scale(2.2); opacity: 0; }
  60% { transform: rotate(-6deg) scale(.94); opacity: 1; }
  100% { transform: rotate(-7deg) scale(1); opacity: .95; }
}
@media (prefers-reduced-motion: reduce) { .stamp.slam { animation: none; } }
.title { font-family: var(--f-display); font-weight: 600; font-size: clamp(28px, 4.5vw, 40px); line-height: 1.35; margin: 0; text-wrap: balance; }
.body { font-family: var(--f-text); font-size: 17.5px; line-height: 1.9; max-width: 68ch; }
.body p { margin: 0 0 1.1em; }
.loading { color: var(--muted); font-style: italic; }

/* ---------- mots ---------- */
.w { border-radius: 2px; }
.hidden-w { display: inline-block; background: var(--bar); color: transparent; min-width: calc(var(--n, 3) * .62em); height: 1.25em; line-height: 1.25em; vertical-align: -0.2em;
  cursor: pointer; text-align: center; font-family: var(--f-mono); font-size: .8em; padding: 0 .15em; user-select: none; transition: outline-color .3s; }
.title .hidden-w { height: 1.15em; line-height: 1.15em; }
.hidden-w.near { color: color-mix(in oklab, var(--near-hi) calc(var(--s) * 100%), var(--near-lo)); font-family: var(--f-text); font-size: .9em; font-style: italic; }
.hidden-w.show-len::after { content: attr(data-n); color: var(--mark); font-family: var(--f-mono); font-style: normal; font-size: .85em; margin-left: .3em; }
.hidden-w { position: relative; }
.hidden-w.show-len:not(.near)::after { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; }
.hidden-w.fresh { outline: 2px solid var(--mark); outline-offset: 1px; }
.found { transition: background-color 1.2s; }
.found.fresh { background: var(--mark); color: var(--mark-ink); }
.found.given { color: var(--muted); }
.peeked { color: var(--muted); font-style: italic; text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.demo { cursor: default; font-size: .85em; }

/* ---------- fin de partie ---------- */
.won-bar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between;
  background: color-mix(in oklab, var(--mark) 45%, var(--sheet)); color: var(--ink); border: 1.5px solid var(--mark);
  border-radius: 3px; padding: 12px 16px; margin-bottom: 22px; }
.won-bar > div:first-child { display: grid; gap: 2px; min-width: 0; }
.won-bar strong { font-family: var(--f-display); font-size: 19px; font-weight: 600; }
.won-bar span { color: var(--ink); font-size: 14px; }
.won-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.won-actions .ghost { border-color: var(--ink); }
.win { margin-top: 28px; border-top: 2px solid var(--ink); padding-top: 18px; display: grid; gap: 10px; }
.win h2 { font-family: var(--f-display); font-size: 24px; margin: 0; }
.win p { margin: 0; }

/* ---------- panneau ---------- */
.side { display: grid; gap: 18px; min-width: 0; position: sticky; top: 92px; }
@media (max-width: 860px) { .side { position: static; } }
.panel { display: grid; gap: 10px; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0; font-weight: 600; border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.hint, .legend p { margin: 0; color: var(--muted); font-size: 13.5px; }
.legend p { line-height: 1.9; }
.credit { font-size: 12.5px !important; line-height: 1.5 !important; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 46vh; overflow-y: auto; font-variant-numeric: tabular-nums; }
.history li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 3px; }
.history li { cursor: pointer; }
.history li:hover { background: color-mix(in oklab, var(--rule) 60%, transparent); }
.history li.latest, .history li.latest:hover { background: color-mix(in oklab, var(--mark) 35%, transparent); }
.history .n { color: var(--muted); font-family: var(--f-mono); font-size: 12px; }
.history .word { font-family: var(--f-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .res { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.history .res.hit { color: var(--accent); font-weight: 600; }
.meter { width: 42px; height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--muted); }
.pages-summary { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pages { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-height: 32vh; overflow-y: auto; font-variant-numeric: tabular-nums; }
.pages li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "pt pt share" "pn pd pd";
  gap: 2px 8px; align-items: center; padding: 6px 6px; border-radius: 3px; border-bottom: 1px solid var(--rule); }
.pages .pt { grid-area: pt; }
.pages .pn { grid-area: pn; }
.pages .pd { grid-area: pd; }
.pages .share { grid-area: share; }
.pages li.current { background: color-mix(in oklab, var(--mark) 30%, transparent); }
.pages .pt { color: var(--ink); text-decoration: none; font-family: var(--f-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pages .pt:hover { text-decoration: underline; }
.pages .pt.masked { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.pages .share { padding: 1px 7px; font-size: 11.5px; background: transparent; color: var(--muted); border: 1px solid var(--rule); }
.pages .share:hover { color: var(--ink); border-color: var(--ink); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.panel-head h2 { border: 0; padding: 0; }
.link-btn { padding: 0; background: none; border: 0; color: var(--accent); font-size: 12.5px; text-decoration: underline; text-underline-offset: 2px; }
.pages .pn { font-family: var(--f-mono); font-size: 12.5px; color: var(--accent); }
.pages .pn.lost { color: var(--danger); }
.pages .pd { font-size: 12px; color: var(--muted); text-align: right; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.seed-form { display: grid; gap: 6px; font-size: 13.5px; color: var(--muted); }
.seed-form .row { display: flex; gap: 8px; }
.seed-form input { flex: 1; min-width: 0; padding: 8px 10px; border: 1.5px solid var(--rule); border-radius: 3px; background: var(--sheet); font-family: var(--f-mono); }

/* ---------- publicité et pied de page ---------- */
.ad-slot { display: grid; gap: 6px; justify-items: center; min-height: 250px; padding: 10px; border: 1px dashed var(--rule); border-radius: 3px; }
.ad-label { justify-self: start; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.site-footer { max-width: 1480px; margin: 0 auto; padding-block: 8px 32px; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }
/* ---------- pages légales ---------- */
.legal { max-width: 72ch; margin: 0 auto; padding-block: 32px 64px; font-family: var(--f-text); font-size: 16.5px; line-height: 1.7;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.legal h1 { font-family: var(--f-display); font-size: 32px; margin: 0 0 8px; }
.legal h2 { font-family: var(--f-ui); font-size: 14px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 32px 0 8px; }
.legal .todo { background: var(--mark); color: var(--mark-ink); padding: 0 4px; border-radius: 2px; font-family: var(--f-mono); font-size: .85em; }
.legal .back { font-family: var(--f-ui); font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
