:root {
  color-scheme: dark;

  --bg: #0A1020;
  --surface: #121A2E;
  --panel: #121A2E;
  --raised: #18223A;
  --border: #1F2A44;
  --strong: #5A6E96;
  --text: #EEF3FF;
  --soft: #B8C4DC;
  --mute: #8E9BB8;
  --hot: #FF7A3D;
  --gold: #FFD23F;
  --good: #52B153;
  --danger: #FF6B5E;
  --on-accent: #0E0B14;

  --gold-dim: rgba(255, 210, 63, 0.12);
  --hot-dim: rgba(255, 122, 61, 0.12);
  --good-dim: rgba(82, 177, 83, 0.12);
  --danger-dim: rgba(255, 107, 94, 0.12);

  --therm-0: #2B0B3F;
  --therm-1: #5A1A7A;
  --therm-2: #B0177A;
  --therm-3: #F26B1D;
  --therm-4: #FFD23F;
  --therm-5: #FFF4C2;
  --grad-primary: linear-gradient(90deg, #F26B1D, #FFD23F);
  --grad-therm: linear-gradient(90deg, #2B0B3F, #B0177A, #F26B1D, #FFD23F, #FFF4C2);

  --dpe-a: #009C6D;
  --dpe-b: #52B153;
  --dpe-c: #A5CC74;
  --dpe-d: #F4E70F;
  --dpe-e: #F0B50F;
  --dpe-f: #EB8235;
  --dpe-g: #D7221F;
  --dpe-ink: #0E0B14;
  --dpe-ink-g: #FFFFFF;

  /* Étiquette climat du DPE 2021 (arrêté du 31 mars 2021) : teintes échantillonnées sur le gabarit du dépôt open source rvaly/dpegenerator, à confirmer sur l'annexe officielle */
  --ges-a: #A4DBF8;
  --ges-b: #8CB4D3;
  --ges-c: #7792B1;
  --ges-d: #606F8F;
  --ges-e: #4D5271;
  --ges-f: #393551;
  --ges-g: #281B35;
  --ges-ink-light: #0E0B14;
  --ges-ink-dark: #FFFFFF;

  --paper: #FFFFFF;
  --paper-sunk: #F3F5F9;
  --paper-ink: #0E0B14;
  --paper-soft: #4A5468;
  --paper-line: #DDE2EB;
  --paper-good: #00704E;

  --font-ui: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;

  --header-h: 68px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* The app header is sticky: anchor targets and focused titles must land below it */
h1, h2, h3, [id] { scroll-margin-top: calc(var(--header-h) + 16px); }

/* Titles take focus between journey steps for screen readers; they are not controls */
h1[tabindex="-1"]:focus { outline: none; }

::selection {
  background: var(--gold);
  color: var(--on-accent);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--strong); border-radius: 4px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.25rem;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font: 700 0.95rem/1.2 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--grad-primary); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--gold); color: var(--gold); }
.btn-ghost:hover:not(:disabled) { background: var(--gold-dim); }
.btn-light { background: var(--text); color: var(--bg); font-family: var(--font-mono); font-weight: 600; font-size: 0.875rem; }
.btn-light:hover { background: var(--gold); }
.btn-quiet { background: transparent; border-color: var(--strong); color: var(--text); }
.btn-quiet:hover { border-color: var(--soft); }

.btn-close {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--mute);
  cursor: pointer;
}
.btn-close:hover { color: var(--text); }
.btn-close:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.dpe-a { background: var(--dpe-a); color: var(--dpe-ink); }
.dpe-b { background: var(--dpe-b); color: var(--dpe-ink); }
.dpe-c { background: var(--dpe-c); color: var(--dpe-ink); }
.dpe-d { background: var(--dpe-d); color: var(--dpe-ink); }
.dpe-e { background: var(--dpe-e); color: var(--dpe-ink); }
.dpe-f { background: var(--dpe-f); color: var(--dpe-ink); }
.dpe-g { background: var(--dpe-g); color: var(--dpe-ink-g); }

.ges-a { background: var(--ges-a); color: var(--ges-ink-light); }
.ges-b { background: var(--ges-b); color: var(--ges-ink-light); }
.ges-c { background: var(--ges-c); color: var(--ges-ink-light); }
.ges-d { background: var(--ges-d); color: var(--ges-ink-dark); }
.ges-e { background: var(--ges-e); color: var(--ges-ink-dark); }
.ges-f { background: var(--ges-f); color: var(--ges-ink-dark); }
.ges-g { background: var(--ges-g); color: var(--ges-ink-dark); }

.dpe-badge {
  display: inline-flex;
  align-items: center;
  min-width: 2em;
  height: 1.6em;
  padding: 0 0.6em 0 0.4em;
  border-radius: 0 6px 6px 0;
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1;
}

.therm-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--grad-therm);
}

.packs { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; }
.pack { flex: 1 1 150px; max-width: 240px; padding: 1.1rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; text-align: center; }
.pack.best { border-color: var(--gold); }
.pack .price, .pack .credits, .pack .unit { display: block; }
.pack .price { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.pack .credits { font-family: var(--font-mono); font-size: 0.8rem; color: var(--gold); margin: 0.3rem 0 0.1rem; }
.pack .unit { font-family: var(--font-mono); font-size: 0.75rem; color: var(--soft); }
.doc .packs { margin: 1.2rem 0 0.4rem; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  min-height: var(--header-h);
  padding: 0.25rem clamp(16px, 5vw, 64px);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
}
.site-brand svg { flex: none; }
.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}
.site-nav a:not(.btn) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}
.site-nav a:not(.btn):hover { color: var(--gold); }

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem 16px 2.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--soft);
  text-align: center;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 1.25rem;
}
.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--soft);
  text-decoration: none;
}
.site-footer a:hover { color: var(--gold); }

@media (max-width: 640px) {
  .site-nav { gap: 0 1rem; font-size: 0.8rem; }
}

/* No room beside the brand: the nav takes its own row instead of disappearing */
@media (max-width: 480px) {
  .site-nav { flex-basis: 100%; }
}

@media print {
  html, body { background: #fff; }
}

.doc { line-height: 1.7; }
.doc main { max-width: 720px; margin: 0 auto; padding: 3rem 16px 4rem; }
.doc h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.03em; margin-bottom: 1.5rem; }
.doc h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; margin: 2.4rem 0 0.8rem; color: var(--text); }
.doc h2::before { content: ''; display: inline-block; width: 0.45em; height: 0.45em; margin: 0 0.5em 0.12em 0; border-radius: 2px; background: var(--hot); }
.doc h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 1.2rem 0 0.4rem; }
.doc p, .doc li { color: var(--soft); margin-bottom: 1rem; }
.doc .fine { font-size: 0.8rem; }
.doc li { margin-bottom: 0.4rem; }
.doc ul, .doc ol { padding-left: 1.3rem; margin-bottom: 1rem; }
.doc strong { color: var(--text); font-weight: 700; }
.doc main a { color: var(--gold); text-underline-offset: 3px; }
.doc main a:hover { color: var(--text); }
.doc code { font-family: var(--font-mono); font-size: 0.85em; color: var(--text); }

.doc table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: 0.9rem; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); color: var(--soft); }
.doc th { color: var(--text); font-weight: 700; border-bottom-color: var(--strong); }
.doc .table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.doc main > table { display: block; overflow-x: auto; }
.doc .table-wrap table { margin-bottom: 0; }

.doc .crumbs { font-family: var(--font-mono); font-size: 0.8rem; color: var(--soft); margin-bottom: 1.2rem; }
.doc .crumbs a { color: var(--soft); }
.doc .updated { font-family: var(--font-mono); font-size: 0.8rem; color: var(--soft); }
.doc .source { margin-top: 2.5rem; font-size: 0.8rem; font-family: var(--font-mono); color: var(--soft); }
.doc .note { font-family: var(--font-mono); font-size: 0.8rem; color: var(--soft); }
.doc .alert { margin: 1.5rem 0; padding: 1rem 1.25rem 0.1rem; border-left: 3px solid var(--gold); background: var(--gold-dim); border-radius: var(--radius-sm); }

.doc .cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  margin: 2.5rem 0;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  background: var(--grad-primary);
  color: var(--on-accent);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.doc .cta:hover { color: var(--on-accent); filter: brightness(1.08); }

.doc .related { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.doc .related h2 { font-size: 1rem; }

.doc .chart { margin: 1.5rem 0 2rem; padding: 1.3rem 1.4rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.doc .bar-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.55rem; }
.doc .bar-label { flex: none; width: 2.2rem; height: 1.75rem; padding-left: 0.5rem; border-radius: 0 6px 6px 0; font-weight: 700; font-size: 0.9rem; display: flex; align-items: center; }
.doc .bar-track { flex: 1; min-width: 0; height: 0.85rem; background: var(--raised); border-radius: 0 5px 5px 0; overflow: hidden; }
.doc .bar-fill { display: block; height: 100%; border-radius: 0 5px 5px 0; }
.doc .bar-val { flex: none; width: 9.5rem; text-align: right; font-family: var(--font-mono); font-size: 0.8rem; color: var(--soft); }
.doc .bar-val strong { color: var(--text); }
.doc .chart-note { margin: 0.6rem 0 0; font-size: 0.8rem; font-family: var(--font-mono); color: var(--soft); }
.doc .hub-dept { font-size: 1rem; margin: 1.2rem 0 0.4rem; }

.doc .notice { padding: 1.1rem 1.3rem; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 12px; margin-bottom: 1rem; }
.doc .notice p { color: var(--text); }
.doc .notice p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
  .doc .bar-val { width: 5.5rem; font-size: 0.72rem; line-height: 1.3; }
  .doc .bar-n { display: block; }
}
