:root {
  --ground: #f2f8fc;
  --pool: #e2f1fa;
  --card: #ffffff;
  --ink: #0f2233;
  --text: #3d5266;
  --soft: #58708a;
  --line: #d2e1ec;
  --line-soft: #e3edf4;
  --frame: #c3d6e4;
  --accent: #0a6fb8;
  --accent-ink: #07568f;
  --water-top: #7fd6fc;
  --water: #2ea6e6;
  --water-deep: #0b7fd1;
  --on-accent: #ffffff;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0b1722;
    --pool: #0f2231;
    --card: #132534;
    --ink: #eaf4fb;
    --text: #b6c9d8;
    --soft: #93aabc;
    --line: #213a4e;
    --line-soft: #1b3144;
    --frame: #2a465c;
    --accent: #6ccbf9;
    --accent-ink: #9bdcfb;
    --water-top: #8bdcfd;
    --water: #3fb1ee;
    --water-deep: #1a86d6;
    --on-accent: #06233a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* One language at a time; without JavaScript the page stays in French. */
[data-lang="fr"] [lang="en"],
[data-lang="en"] [lang="fr"] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--ground); }
.site-header .wrap { min-height: 72px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -0.01em; min-height: 44px; }
.brand:hover { color: var(--ink); }
.brand-mark { display: flex; align-items: center; justify-content: center; flex: none; }
.brand-mark svg { display: block; }
.site-nav { flex-grow: 1; display: flex; flex-wrap: wrap; gap: 0 24px; font-family: var(--mono); font-size: 13px; }
.site-nav a { color: var(--text); text-decoration: none; padding: 14px 0; }
.site-nav a:hover { color: var(--ink); }
.lang-switch { display: flex; gap: 2px; background: var(--pool); border-radius: 10px; padding: 3px; }
.lang-switch button { border: 0; background: transparent; color: var(--soft); font: 600 13px var(--mono); padding: 0 14px; min-height: 44px; border-radius: 8px; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--card); color: var(--ink); }

/* Buttons */
.btn { display: inline-flex; align-items: center; min-height: 50px; padding: 10px 26px; border-radius: 999px; font-weight: 700; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-ink); color: var(--on-accent); }
.btn-ghost { border: 1.5px solid var(--accent); color: var(--accent); }
.btn-ghost:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.btn-small { min-height: 44px; padding: 8px 20px; font-size: 15px; }
.text-link { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.text-link:hover { text-decoration: underline; }
.actions { margin-top: 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.note { margin: 18px 0 0; font-family: var(--mono); font-size: 13px; color: var(--soft); }

/* Hero */
.hero { position: relative; padding: 72px 0 0; background: linear-gradient(180deg, var(--ground), var(--pool)); overflow: hidden; }
.hero .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 48px 56px; padding-bottom: 120px; }
.hero-text { flex: 1 1 420px; min-width: 0; }
.status-chip { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-family: var(--mono); font-size: 13px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; }
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--water); display: inline-block; margin-right: 8px; }
h1 { margin: 24px 0 0; font-weight: 800; font-size: clamp(40px, 5.4vw, 72px); line-height: 1; letter-spacing: -0.04em; text-wrap: balance; }
.lead { max-width: 560px; margin: 24px 0 0; font-size: 20px; line-height: 1.45; color: var(--text); }

.scene { flex: 1 1 380px; min-width: 0; max-width: 480px; margin: 0 auto; position: relative; padding-top: 56px; }
.mascot { position: absolute; top: 0; right: 18px; width: 104px; height: auto; z-index: 1; animation: bob 4.5s ease-in-out infinite; filter: drop-shadow(0 10px 14px rgba(11, 127, 209, 0.25)); }
.mascot-eyes { transform-origin: 60px 79px; animation: blink 5.5s infinite; }
.scene-card { position: relative; background: var(--card); border: 1px solid var(--frame); border-radius: 24px; padding: 24px 24px 20px; box-shadow: 0 24px 60px rgba(15, 34, 51, 0.12); }
.scene-head { display: flex; align-items: center; gap: 12px; font-size: 17px; }
.tag { font-family: var(--mono); font-size: 12px; color: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.chart { list-style: none; margin: 22px 0 0; padding: 0; height: 190px; display: flex; align-items: stretch; gap: 10px; }
.chart li { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.chart b { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--soft); }
.chart i { display: block; width: 100%; height: calc(var(--h) * 0.72); border-radius: 10px 10px 6px 6px; background: linear-gradient(180deg, var(--water-top), var(--water)); transform-origin: bottom; animation: rise 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.chart li:nth-child(2) i { animation-delay: 0.06s; }
.chart li:nth-child(3) i { animation-delay: 0.12s; }
.chart li:nth-child(4) i { animation-delay: 0.18s; }
.chart li:nth-child(5) i { animation-delay: 0.24s; }
.chart li:nth-child(6) i { animation-delay: 0.3s; }
.chart li:nth-child(7) i { animation-delay: 0.36s; }
.chart .is-top i { background: linear-gradient(180deg, var(--water), var(--water-deep)); }
.chart .is-top b { color: var(--ink); }
.chart span { font-family: var(--mono); font-size: 12px; color: var(--soft); }
.tiles { margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.tiles > div { flex: 1 1 110px; background: var(--ground); border-radius: 14px; padding: 12px 14px; }
.tiles dt { font-size: 12px; color: var(--soft); }
.tiles dd { margin: 2px 0 0; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; }

.wave { position: absolute; left: 0; bottom: -1px; width: 200%; height: 60px; display: block; fill: var(--ground); animation: drift 14s linear infinite; }

@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-9px) rotate(3deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
@keyframes rise { from { transform: scaleY(0); } }
@keyframes drift { to { transform: translateX(-50%); } }

/* Chapters */
.chapter { padding: 80px 0; }
.chapter + .chapter { border-top: 1px solid var(--line); }
.chapter .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 32px 64px; }
.chapter-text { flex: 1 1 320px; min-width: 0; }
.chapter-visual { flex: 1 1 420px; min-width: 0; }
.eyebrow { font-family: var(--mono); font-size: 13px; color: var(--accent); }
h2 { margin: 12px 0 0; font-weight: 800; font-size: clamp(28px, 3vw, 40px); line-height: 1.08; letter-spacing: -0.03em; text-wrap: balance; }
.chapter-text p { margin: 14px 0 0; color: var(--text); max-width: 520px; }
.chapter-text h2 + p { margin-top: 20px; }
code { font-family: var(--mono); font-size: 0.9em; }

.panel { background: var(--card); border: 1px solid var(--frame); border-radius: 20px; }
.step { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--pool); color: var(--accent); font: 700 15px var(--mono); display: flex; align-items: center; justify-content: center; }

.journey { list-style: none; margin: 0; padding: 10px 26px; }
.journey li { display: flex; gap: 16px; align-items: flex-start; padding: 18px 0; border-bottom: 1px dashed var(--line); }
.journey li:last-child { border-bottom: 0; }
.journey b { display: block; font-size: 18px; }
.journey div span { color: var(--text); }
.journey .is-done .step { background: var(--accent); color: var(--on-accent); }

.deeds { margin: 0; }
.deeds > div { padding: 20px 26px; border-bottom: 1px solid var(--line-soft); }
.deeds > div:last-child { border-bottom: 0; }
.deeds dt { font-weight: 800; font-size: 18px; }
.deeds dd { margin: 4px 0 0; color: var(--text); }

.cost { padding: 24px 26px; }
.cost-head { display: flex; justify-content: space-between; gap: 16px; font-family: var(--mono); font-size: 12px; color: var(--soft); letter-spacing: 0.02em; }
.cost-rows { margin: 18px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 16px; }
.cost-row { display: flex; justify-content: space-between; gap: 16px; }
.cost-row .mono { font-size: 14px; white-space: nowrap; }
.bar { margin-top: 6px; height: 10px; border-radius: 5px; background: var(--pool); }
.bar i { display: block; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--water-top), var(--water)); }
.cost-foot { margin: 20px 0 0; font-size: 14px; color: var(--soft); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; gap: 16px; align-items: flex-start; padding: 20px 22px; }
.steps b { display: block; font-size: 18px; }
.steps p { margin: 4px 0 0; color: var(--text); }
.steps .btn { margin-top: 14px; }

.repo { margin-top: 28px; max-width: 520px; }
.repo-label { display: block; font-family: var(--mono); font-size: 13px; color: var(--soft); }
.repo-line { margin-top: 8px; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--frame); border-radius: 14px; padding: 6px 6px 6px 16px; }
.repo-line code { flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 14px; padding: 8px 0; }
.copy { flex: none; border: 0; background: var(--pool); color: var(--accent); font: 600 13px var(--mono); min-height: 44px; padding: 0 16px; border-radius: 10px; cursor: pointer; }
.copy:hover { color: var(--accent-ink); }
.copy .copy-done, .copy.is-done .copy-idle { display: none; }
.copy.is-done .copy-done { display: inline; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 36px 0 48px; font-size: 14px; color: var(--soft); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: center; }
.site-footer p { flex: 1 1 100%; margin: 0 0 8px; max-width: 760px; }
.site-footer a { color: var(--text); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }

/* 404 */
.lost { min-height: 70vh; display: flex; align-items: center; text-align: center; }
.lost .wrap { width: 100%; }
.lost .mascot { position: static; width: 120px; animation: bob 4.5s ease-in-out infinite; }
.lost .lead { margin-left: auto; margin-right: auto; }
.lost .actions { justify-content: center; }

@media (max-width: 720px) {
  .site-nav { order: 3; flex-basis: 100%; gap: 0 18px; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
  .site-nav a { padding: 10px 0 14px; }
  .lang-switch { margin-left: auto; }
  .hero { padding-top: 48px; }
  .hero .wrap { padding-bottom: 96px; }
  .chapter { padding: 56px 0; }
  .chart { height: 160px; gap: 6px; }
  .mascot { width: 88px; right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .mascot, .mascot-eyes, .chart i, .wave { animation: none; }
}
