/* AI Story Studio — feuille de style commune
   Direction visuelle reprise de la charte AST Toon V1 :
   contours sombres, aplats mats, ombres franches, rampe 2-3 niveaux. */

:root {
  /* Encre et papier */
  --ink:      #17120E;
  --ink-2:    #3A2E24;
  --canvas:   #E4E0D4;
  --canvas-2: #D2CDBC;
  --paper:    #F2EFE6;

  /* Aplats mats — chaque teinte a exactement deux niveaux (rampe toon) */
  --grass:    #4E7A3F;
  --grass-2:  #39592E;
  --sky:      #9FC2D4;
  --sky-2:    #7CA3B8;
  --sun:      #E8B73F;
  --sun-2:    #C9941F;
  --brick:    #B2432E;
  --brick-2:  #8C3121;
  --night:    #2C3A52;
  --night-2:  #1E2838;

  --line: 3px;
  --rail: 15.5rem;

  /* Échelle modulaire, quarte juste (1,333) */
  --t-xs: 0.78rem;
  --t-s:  0.882rem;
  --t-0:  1rem;
  --t-1:  1.333rem;
  --t-2:  1.777rem;
  --t-3:  clamp(1.85rem, 1.15rem + 2.8vw, 2.369rem);
  --t-4:  clamp(2.4rem, 1.6rem + 3.4vw, 3.157rem);
  --t-5:  clamp(2.9rem, 1.5rem + 5.6vw, 4.209rem);
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 17px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Archivo, "Helvetica Neue", Arial, sans-serif;
  font-variation-settings: "wdth" 100, "wght" 420;
  font-size: var(--t-0);
  line-height: 1.6;
  text-underline-offset: 0.18em;
}

/* ---------- Mise en page ---------- */
.rail {
  border-bottom: var(--line) solid var(--ink);
  background: var(--paper);
  padding: 0.9rem 1.1rem;
}

.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.brand {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  line-height: 1.05;
}
.brand b {
  display: block;
  font-size: var(--t-1);
  font-variation-settings: "wdth" 112, "wght" 850;
  letter-spacing: -0.015em;
}
.brand span {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--t-xs);
  font-variation-settings: "wdth" 92, "wght" 500;
  color: var(--ink-2);
}
.brand:hover b { color: var(--brick-2); }
.brand:hover { background: none; }

.menu-btn {
  font: inherit;
  font-variation-settings: "wdth" 100, "wght" 700;
  background: var(--sun);
  color: var(--ink);
  border: var(--line) solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.menu-btn:active { box-shadow: 1px 1px 0 var(--ink); transform: translate(3px, 3px); }

.rail nav { display: none; margin-top: 0.9rem; }
.rail nav.open { display: block; }

.rail nav a {
  display: block;
  padding: 0.46rem 0.6rem;
  color: var(--ink);
  text-decoration: none;
  border: var(--line) solid transparent;
  font-variation-settings: "wdth" 100, "wght" 600;
}
.rail nav a:hover { border-color: var(--ink); background: var(--canvas); }
.rail nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.rail-note {
  margin: 1rem 0 0;
  font-size: var(--t-xs);
  line-height: 1.45;
  color: var(--ink-2);
  max-width: 24ch;
  display: none;
}

main { padding: 2.2rem 1.15rem 5rem; }
.wrap { max-width: 56rem; margin: 0 auto; }
.prose { max-width: 66ch; }

@media (min-width: 62rem) {
  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--rail);
    border-bottom: 0;
    border-right: var(--line) solid var(--ink);
    padding: 1.6rem 1.2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .menu-btn { display: none; }
  .rail nav { display: block; margin-top: 1.8rem; }
  .rail-note { display: block; margin-top: auto; }
  main { padding: 3.4rem 2.6rem 6rem calc(var(--rail) + 2.6rem); }
  .wrap { margin: 0; }
}

/* ---------- Titres et texte ---------- */
h1, h2, h3 { margin: 0; font-variation-settings: "wdth" 108, "wght" 830; letter-spacing: -0.02em; line-height: 1.04; overflow-wrap: break-word; }
h1 { font-size: var(--t-5); }
h2 { font-size: var(--t-3); margin-top: 3.2rem; }
h3 { font-size: var(--t-1); margin-top: 2rem; letter-spacing: -0.01em; font-variation-settings: "wdth" 104, "wght" 760; }
h1 + .lede { margin-top: 1.2rem; }
p, ul, ol, dl { margin: 1rem 0; }
.lede { font-size: var(--t-1); line-height: 1.42; max-width: 48ch; font-variation-settings: "wdth" 98, "wght" 480; }
.small { font-size: var(--t-s); color: var(--ink-2); }
strong { font-variation-settings: "wdth" 100, "wght" 720; }
a { color: var(--brick-2); text-decoration-thickness: 2px; }
a:hover { color: var(--ink); background: var(--sun); }

:where(a, button, summary, [tabindex]):focus-visible {
  outline: var(--line) solid var(--brick);
  outline-offset: 2px;
}

/* Rampe toon : séparateur à trois niveaux */
.ramp { display: flex; height: 10px; margin: 2.6rem 0 0; max-width: 56rem; }
.ramp span { flex: 1; border: var(--line) solid var(--ink); border-right-width: 0; }
.ramp span:last-child { border-right-width: var(--line); }
.ramp span:nth-child(1) { background: var(--sun); }
.ramp span:nth-child(2) { background: var(--brick); }
.ramp span:nth-child(3) { background: var(--night); }

/* ---------- Blocs encadrés ---------- */
.frame {
  border: var(--line) solid var(--ink);
  background: var(--paper);
  padding: 1.3rem 1.4rem;
}
.frame.lift { box-shadow: 8px 8px 0 var(--ink); }
.frame.dark { background: var(--night); color: var(--paper); }
.frame.dark a { color: var(--sun); }
.frame.warn { background: var(--sun); }
.frame > :first-child { margin-top: 0; }
.frame > :last-child { margin-bottom: 0; }
.frame h3 { margin-top: 0; }

.grid { display: grid; gap: 1.2rem; margin: 1.6rem 0; }
/* Une cellule de grille ne descend pas sous sa taille min-content par defaut :
   un bloc de code ou un tableau large elargit alors toute la page. */
.grid > *, .hero > *, .steps > li > * { min-width: 0; }
@media (min-width: 46rem) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Tableaux de contrats ---------- */
.sheet-scroll { overflow-x: auto; margin: 1.4rem 0; }
.sheet { width: 100%; border-collapse: collapse; font-size: var(--t-s); }
.sheet caption { text-align: left; font-size: var(--t-s); color: var(--ink-2); padding-bottom: 0.5rem; }
.sheet th, .sheet td { border: var(--line) solid var(--ink); padding: 0.55rem 0.7rem; text-align: left; vertical-align: top; }
.sheet thead th { background: var(--ink); color: var(--paper); font-variation-settings: "wdth" 100, "wght" 700; }
.sheet tbody th { background: var(--canvas-2); font-variation-settings: "wdth" 100, "wght" 700; }
.sheet tbody tr:nth-child(even) td { background: var(--paper); }

/* ---------- Listes de séquence (vraies séquences seulement) ---------- */
.steps { list-style: none; margin: 1.6rem 0; padding: 0; }
.steps > li {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0 1rem;
  border-top: var(--line) solid var(--ink);
  padding: 0.85rem 0;
}
.steps > li:last-child { border-bottom: var(--line) solid var(--ink); }
.steps .tag {
  font-variation-settings: "wdth" 84, "wght" 800;
  font-size: var(--t-s);
  align-self: start;
  background: var(--canvas-2);
  border: var(--line) solid var(--ink);
  text-align: center;
  padding: 0.1rem 0;
}
.steps b { display: block; font-variation-settings: "wdth" 102, "wght" 740; }
.steps p { margin: 0.2rem 0 0; font-size: var(--t-s); max-width: 60ch; }

/* ---------- Puces ---------- */
.bullets { list-style: none; padding: 0; }
.bullets li { position: relative; padding-left: 1.5rem; margin: 0.5rem 0; max-width: 64ch; }
.bullets li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.55em;
  width: 0.6rem; height: 0.6rem;
  background: var(--grass);
  border: 2px solid var(--ink);
}
.bullets.no li::before { background: var(--brick); }

/* ---------- Code / contrats JSON ---------- */
pre {
  margin: 1.2rem 0;
  padding: 1rem 1.1rem;
  background: var(--night);
  color: var(--paper);
  border: var(--line) solid var(--ink);
  overflow-x: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.55;
}
pre b { color: var(--sun); font-weight: 400; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 0.86em; }
p code, li code, td code { background: var(--canvas-2); border: 2px solid var(--ink); padding: 0 0.22em; }

/* ---------- Statuts ---------- */
.chip {
  display: inline-block;
  font-size: var(--t-xs);
  font-variation-settings: "wdth" 92, "wght" 760;
  border: 2px solid var(--ink);
  padding: 0.05rem 0.42rem;
  background: var(--canvas-2);
  white-space: nowrap;
}
.chip.ok { background: var(--grass); color: var(--paper); }
.chip.aim { background: var(--sun); }
.chip.todo { background: var(--brick); color: var(--paper); }

/* ---------- Pied de page ---------- */
footer {
  margin-top: 4rem;
  border-top: var(--line) solid var(--ink);
  padding-top: 1.2rem;
  font-size: var(--t-s);
  color: var(--ink-2);
  max-width: 56rem;
}
footer p { margin: 0.4rem 0; max-width: 70ch; }

/* ---------- Figures ---------- */
figure { margin: 1.6rem 0; }
figure svg { display: block; width: 100%; height: auto; }
figcaption { font-size: var(--t-s); color: var(--ink-2); margin-top: 0.6rem; max-width: 60ch; }

/* ---------- Ouverture de la page d'accueil ---------- */
.hero { display: grid; gap: 1.8rem; align-items: start; }
@media (min-width: 58rem) {
  .hero { grid-template-columns: minmax(0, 1fr) 17.5rem; gap: 2.6rem; }
}
.shot {
  border: var(--line) solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
  background: var(--sky);
  overflow: hidden;
}
.shot svg { display: block; width: 100%; height: auto; }
.shot-note { font-size: var(--t-xs); line-height: 1.45; color: var(--ink-2); margin: 1rem 0 0; }

.compile { opacity: 0; animation: appear 300ms steps(2, end) forwards; }
.compile.d1 { animation-delay: 240ms; }
.compile.d2 { animation-delay: 480ms; }
.compile.d3 { animation-delay: 720ms; }
.compile.d4 { animation-delay: 960ms; }
@keyframes appear { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .compile { animation: none; opacity: 1; }
}

/* --- Formulaire de contact ------------------------------------------- */

.form { max-width: 40rem; margin: 1.8rem 0 0; }
.field { margin-bottom: 1.2rem; }
.field label {
  display: block;
  font-size: var(--t-s);
  font-variation-settings: "wdth" 100, "wght" 700;
  margin-bottom: 0.35rem;
}
.field .hint { font-size: var(--t-xs); color: var(--ink-2); font-variation-settings: "wdth" 100, "wght" 400; }
.field input,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: var(--t-0);
  color: var(--ink);
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 0;
  padding: 0.6rem 0.7rem;
  box-shadow: 4px 4px 0 var(--ink);
}
.field textarea { min-height: 9rem; resize: vertical; }
.field input:focus-visible,
.field textarea:focus-visible {
  outline: var(--line) solid var(--brick);
  outline-offset: 3px;
}
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.send {
  font: inherit;
  font-size: var(--t-0);
  font-variation-settings: "wdth" 104, "wght" 760;
  color: var(--ink);
  background: var(--sun);
  border: var(--line) solid var(--ink);
  border-radius: 0;
  padding: 0.65rem 1.3rem;
  box-shadow: 6px 6px 0 var(--ink);
  cursor: pointer;
}
.send:hover { background: var(--sun-2); }
.send:active { box-shadow: 2px 2px 0 var(--ink); transform: translate(4px, 4px); }

.note { border: var(--line) solid var(--ink); padding: 0.9rem 1.1rem; margin: 1.6rem 0; }
.note.ok { background: var(--grass); color: var(--paper); }
.note.bad { background: var(--brick); color: var(--paper); }
.note p { margin: 0; }

.ways { list-style: none; padding: 0; margin: 1.6rem 0; }
.ways li {
  border-bottom: var(--line) solid var(--ink);
  padding: 0.8rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  align-items: baseline;
}
.ways li:first-child { border-top: var(--line) solid var(--ink); }
.ways b { font-variation-settings: "wdth" 100, "wght" 740; min-width: 7rem; }
.ways span { font-size: var(--t-s); color: var(--ink-2); flex: 1 1 14rem; }
