/* Guide du MultiMonde : feuille de style commune aux pages du guide.
   Polices incluses (licence SIL OFL, voir fonts/) : le guide marche hors ligne. */
@font-face { font-family: "VT323"; src: url("fonts/vt323-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Alegreya"; src: url("fonts/alegreya-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Alegreya"; src: url("fonts/alegreya-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Alegreya"; src: url("fonts/alegreya-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
:root {
  --ink: #1d1a2e;          /* encre de nuit, le fond */
  --ink-2: #26223b;        /* pages du grimoire */
  --ink-3: #322d4b;        /* reliefs */
  --line: #443d63;
  --parchment: #ecdfc4;    /* texte */
  --faded: #a99f8a;        /* texte secondaire */
  --gold: #f0c05a;
  --blood: #e8615e;
  --sea: #4ec5b5;
  --forest: #94c973;
  --arcane: #b997f5;
  --sky: #7fb2f0;
  --bone: #d8d2c4;
  --term: #15131f;         /* fond des encadres de terminal */
  --display: "VT323", ui-monospace, monospace;
  --body: "Alegreya", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--ink);
  background-image: radial-gradient(ellipse at 50% -10%, #2c2648 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--parchment);
  font: 1.0625rem/1.68 var(--body);
}
a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #ffd98a; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 2px; }

/* ---------- Charpente : menu + page ---------- */
.shell { display: grid; grid-template-columns: 17rem minmax(0, 1fr); min-height: 100vh; }
.spine {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--ink-2); border-right: 1px solid var(--line);
  padding: 1.4rem 1rem 2rem;
}
.spine .brand {
  display: block; font: 2rem/1 var(--display); color: var(--gold);
  text-decoration: none; margin: 0 .4rem 1.2rem;
}
.spine .brand small { display: block; font-size: 1.05rem; color: var(--faded); margin-top: .2rem; }
.spine ol { list-style: none; margin: 0; padding: 0; }
.spine li a {
  display: flex; align-items: center; gap: .65rem;
  padding: .42rem .5rem; border-radius: 6px;
  color: var(--parchment); text-decoration: none; font-size: 1rem; line-height: 1.3;
}
.spine li a:hover { background: var(--ink-3); }
.spine li a[aria-current="page"] { background: var(--ink-3); color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.spine .play {
  display: block; margin: 1.4rem .4rem 0; padding: .6rem .8rem; text-align: center;
  border: 1px solid var(--gold); border-radius: 6px; color: var(--gold); text-decoration: none;
  font: 1.35rem/1 var(--display);
}
.spine .play:hover { background: var(--gold); color: var(--ink); }

.topbar { display: none; }
main { padding: 2.2rem clamp(1rem, 4vw, 3.5rem) 4rem; max-width: 52rem; }

@media (max-width: 860px) {
  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; gap: .8rem; position: sticky; top: 0; z-index: 5;
    padding: .55rem 1rem; background: rgba(38, 34, 59, .96); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { font: 1.6rem/1 var(--display); color: var(--gold); text-decoration: none; flex: 1; }
  .topbar button {
    font: 1.25rem/1 var(--display); color: var(--parchment); background: var(--ink-3);
    border: 1px solid var(--line); border-radius: 6px; padding: .45rem .75rem; cursor: pointer;
  }
  .spine {
    position: fixed; inset: 0 25% 0 0; max-width: 20rem; z-index: 10; height: 100%;
    transform: translateX(-102%); transition: transform .2s ease-out; box-shadow: 0 0 40px #000a;
  }
  body.nav-open .spine { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: #0008; z-index: 9; }
  main { padding: 1.4rem 1rem 3rem; }
}

/* ---------- Typographie ---------- */
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.05; color: var(--gold); }
h1 { font-size: clamp(2.6rem, 7vw, 3.8rem); margin: .4rem 0 .6rem; }
h2 {
  font-size: clamp(1.9rem, 4.5vw, 2.4rem); margin: 2.8rem 0 .8rem;
  display: flex; align-items: center; gap: .6rem;
  padding-bottom: .35rem; border-bottom: 1px dashed var(--line);
}
h3 { font-size: 1.55rem; margin: 1.8rem 0 .4rem; color: var(--bone); }
p, ul, ol, dl { margin: 0 0 1rem; }
.lead { font-size: 1.2rem; color: var(--bone); }
strong { color: #fff3da; }
em { color: var(--bone); }
ul { padding-left: 1.3rem; }
li { margin-bottom: .3rem; }
li::marker { color: var(--gold); }

/* Commandes en ligne */
code, kbd {
  font-family: var(--mono); font-size: .88em; color: var(--forest);
  background: var(--term); border: 1px solid var(--ink-3); border-radius: 4px; padding: .05em .35em;
  white-space: nowrap;
}

/* ---------- Illustrations ASCII ---------- */
.art {
  margin: .5rem 0 1.4rem; padding: 0; overflow-x: auto;
  font: clamp(.6rem, 2.3vw, 1.08rem)/1.2 var(--mono); color: var(--faded);
}
.art.banner { font-size: clamp(.7rem, 3.2vw, 1.3rem); line-height: 1.12; }
.art.banner .g { text-shadow: 0 0 18px rgba(240, 192, 90, .35); }
.art.center { text-align: center; }
.art .g { color: var(--gold); } .art .r { color: var(--blood); } .art .s { color: var(--sea); }
.art .f { color: var(--forest); } .art .a { color: var(--arcane); } .art .k { color: var(--sky); }
.art .w { color: #fff; } .art .d { color: #6d6488; }

/* ---------- Encadres ---------- */
.term {
  background: var(--term); border: 1px solid var(--ink-3); border-radius: 8px;
  padding: .8rem 1rem; margin: 0 0 1.2rem; overflow-x: auto;
  font: .9rem/1.5 var(--mono); color: var(--bone); white-space: pre-wrap; overflow-wrap: anywhere;
}
.term.grid { white-space: pre; overflow-wrap: normal; }
.term .in { color: var(--forest); }
.term .in::before { content: "> "; color: var(--gold); }
.term .c { color: var(--faded); }
.term .hl { color: var(--gold); }
.term .red { color: var(--blood); }
.term .sea { color: var(--sea); }

.tip, .secret {
  border-left: 3px solid var(--sea); background: var(--ink-2);
  padding: .8rem 1rem; margin: 0 0 1.2rem; border-radius: 0 8px 8px 0;
}
.tip > :last-child, .secret > :last-child { margin-bottom: 0; }
.tip b:first-child { color: var(--sea); font-weight: 700; }
.secret { border-left-color: var(--arcane); background: linear-gradient(90deg, #2d2548, var(--ink-2)); }
.secret b:first-child { color: var(--arcane); }
.veil { color: transparent; background: repeating-linear-gradient(90deg, #4a4170 0 6px, #3b3459 6px 12px); border-radius: 3px; user-select: none; }

/* Listes de type "fiche" : terme + explication */
.ledger { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .35rem 1.1rem; margin: 0 0 1.4rem; }
.ledger dt { font-family: var(--mono); font-size: .92rem; color: var(--forest); padding-top: .18rem; }
.ledger dd { margin: 0; }
@media (max-width: 560px) {
  .ledger { grid-template-columns: 1fr; gap: .1rem; }
  .ledger dd { margin-bottom: .6rem; }
}

/* Grilles de fiches (races, ecoles...) */
.sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .9rem; margin: 0 0 1.4rem; }
.sheet { background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; }
.sheet h3 { margin: 0 0 .3rem; font-size: 1.45rem; display: flex; align-items: center; gap: .5rem; }
.sheet p { margin: 0 0 .4rem; font-size: .98rem; }
.sheet .meta { font-size: .9rem; color: var(--faded); }

/* Etiquettes de sorts / talents */
.runes { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 1.2rem; padding: 0; list-style: none; }
.runes li {
  margin: 0; font: .86rem/1.2 var(--mono); padding: .3rem .55rem; border-radius: 5px;
  background: var(--term); border: 1px solid var(--ink-3); color: var(--bone);
}
.runes li[role="button"] { cursor: pointer; }
.runes li[role="button"]:hover { border-color: var(--gold); }
.runes li[aria-pressed="true"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.rune-info { margin: -.6rem 0 1.4rem; padding: .6rem .8rem; min-height: 2.6rem; font-size: .97rem; color: var(--bone); background: var(--ink-2); border-radius: 6px; }
.rune-info b { font-family: var(--mono); color: var(--gold); font-weight: 400; }
.runes li.r1 { border-color: #6b5aa0; color: var(--arcane); }
.runes li.r2, .runes li.r3, .runes li.r4, .runes li.r5 { border-color: #8a6a2a; color: var(--gold); }
.runes li.hidden { color: #6d6488; letter-spacing: .1em; }

/* Etapes numerotees (vraie sequence) */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 1.6rem; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 .9rem 3rem; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -.15rem;
  width: 2.1rem; height: 2.1rem; display: grid; place-items: center;
  font: 1.5rem/1 var(--display); color: var(--ink); background: var(--gold); border-radius: 50%;
}

/* Sommaire facon "inventory" */
.inventory { font-family: var(--mono); background: var(--term); border: 1px solid var(--ink-3); border-radius: 10px; padding: 1rem 1.1rem; margin: 0 0 1.6rem; }
.inventory .head { color: var(--bone); margin: 0 0 .5rem; }
.inventory .group { color: var(--blood); margin: .7rem 0 .2rem; }
.inventory ul { list-style: none; padding: 0; margin: 0; }
.inventory li { margin: 0; padding: .15rem 0; display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.inventory li::before { content: "-"; color: var(--blood); }
.inventory a { color: var(--parchment); font-weight: 600; text-decoration: none; }
.inventory a:hover { color: var(--gold); text-decoration: underline; }
.inventory .note { color: var(--faded); font-size: .86rem; font-family: var(--body); }

/* Icones pixel */
.px { display: inline-block; width: 1.5em; height: 1.5em; flex: none; vertical-align: -.3em; }
.px svg { width: 100%; height: 100%; display: block; image-rendering: pixelated; shape-rendering: crispEdges; }
h2 .px { width: 1.15em; height: 1.15em; }

/* Tableau des commandes */
.cmd-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 1rem; position: sticky; top: 0; padding: .6rem 0; background: var(--ink); z-index: 2; }
@media (max-width: 860px) { .cmd-tools { position: static; } }
.cmd-tools input {
  flex: 1 1 14rem; font: 1rem var(--mono); color: var(--parchment); background: var(--term);
  border: 1px solid var(--line); border-radius: 6px; padding: .55rem .7rem;
}
.cmd-tools button {
  font: .95rem var(--body); color: var(--bone); background: var(--ink-2); cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem;
}
.cmd-tools button[aria-pressed="true"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.cmd-list { list-style: none; padding: 0; margin: 0; }
.cmd-list li { display: grid; grid-template-columns: 9.5rem 1fr; gap: .2rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--ink-3); margin: 0; }
.cmd-list .name { font: 1rem var(--mono); color: var(--forest); }
.cmd-list .syn { grid-column: 2; font: .85rem var(--mono); color: var(--faded); overflow-wrap: anywhere; }
.cmd-list .desc { grid-column: 2; grid-row: 1; }
.cmd-list .cat { font-size: .8rem; color: var(--faded); }
@media (max-width: 560px) {
  .cmd-list li { grid-template-columns: 1fr; }
  .cmd-list .syn, .cmd-list .desc { grid-column: 1; grid-row: auto; }
}
.empty { color: var(--faded); font-style: italic; }

/* Pied de page / navigation entre chapitres */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1rem; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.pager a { font: 1.35rem/1.2 var(--display); text-decoration: none; }
.pager .next { margin-left: auto; text-align: right; }

/* Une seule animation : l'ouverture de la banniere de l'accueil */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: unroll 1.1s steps(18, end) both; }
  @keyframes unroll { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#cats { display: flex; flex-wrap: wrap; gap: .35rem; }
