@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('/fonts/archivo-latin-var.woff2') format('woff2');
}

:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #232328;
  --line: #2e2e34;
  --text: #f5f5f2;
  --muted: #a1a1aa;
  --accent: #ffd400;
  --accent-ink: #141414;
  --seg-accise: #ffd400;
  --seg-tva: #ffe97a;
  --seg-produit: #a1a1aa;
  --seg-distribution: #5b5b63;
  --seg-produit-distribution: #7c7c85;
  --danger: #ff6b6b;
  --radius: 14px;
  --gutter: 16px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-stretch: 78%; font-weight: 850; line-height: 1.02; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: clamp(1.7rem, 6vw, 2.3rem); }
p { margin: 0; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.wrap { width: 100%; max-width: 680px; margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.accent { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.9em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- Barre du haut ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 800; font-stretch: 85%; font-size: 1.05rem; }
.brand__icon { color: var(--accent); width: 1.4em; height: 1.4em; }
.topbar__nav { display: flex; gap: 16px; font-size: 0.95rem; }
.topbar__nav a { color: var(--muted); text-decoration: none; }
.topbar__nav a:hover { color: var(--text); }

/* ---- Hero ---- */
.hero { padding-block: 12px 20px; }
.hero h1 { font-size: clamp(2.6rem, 12vw, 4.4rem); font-stretch: 70%; font-weight: 900; text-transform: uppercase; }
.hero__sub { color: var(--muted); margin-top: 10px; font-size: 1.05rem; }

/* ---- Contrôles ---- */
.label, legend { display: block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; padding: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-snap-type: x proximity; }
.chips--scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start;
  min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; font-size: 0.98rem; cursor: pointer;
}
.chip[aria-checked="true"], .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip--small { min-height: 38px; padding: 0 14px; font-size: 0.92rem; font-weight: 600; }

.toggle { display: inline-flex; background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; }
.toggle__btn { min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; }
.toggle__btn[aria-checked="true"] { background: var(--text); color: var(--bg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 750; font-size: 1rem; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn--accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--accent:hover { border-color: var(--text); }
.btn--small { min-height: 40px; padding: 0 12px; font-size: 0.9rem; border-radius: 10px; }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 0.92rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; }

input[type="text"], input[type="search"] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 12px;
  min-height: 48px; padding: 0 14px; width: 100%;
}
input:focus { border-color: var(--accent); outline: none; }

/* ---- Calculateur ---- */
.calc { display: grid; gap: 22px; }
.amount { display: grid; gap: 12px; justify-items: start; }
.amount__field { display: flex; align-items: baseline; gap: 8px; width: 100%; border-bottom: 3px solid var(--line); padding-bottom: 4px; }
.amount__field:focus-within { border-color: var(--accent); }
.amount__field input {
  flex: 0 1 auto; width: 3ch; max-width: 80%; min-width: 0; border: 0; background: none; padding: 0; min-height: 0;
  font-size: clamp(3.6rem, 18vw, 5.5rem); font-weight: 900; font-stretch: 72%; line-height: 1; color: var(--text);
}
.amount__unit { font-size: clamp(2rem, 9vw, 3rem); font-weight: 800; font-stretch: 72%; color: var(--muted); }

.price-line { display: grid; gap: 8px; justify-items: start; font-size: 0.95rem; color: var(--muted); }
.price-edit { width: 100%; }
.price-line__text strong { color: var(--text); }
.price-edit { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.price-edit label { grid-column: 1 / -1; font-size: 0.85rem; }

/* ---- Résultat (la carte à capturer) ---- */
.result { margin-top: 28px; display: grid; gap: 14px; }
.result__card {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 22px;
  padding: 22px 18px 18px; display: grid; gap: 4px; overflow: hidden;
}
.result__intro { font-size: 1.15rem; font-weight: 700; color: var(--muted); }
.result__big {
  font-size: clamp(4.2rem, 22vw, 7rem); font-weight: 900; font-stretch: 68%;
  line-height: 0.92; color: var(--accent); letter-spacing: -0.02em; margin-top: 6px;
}
.result__label { font-size: clamp(1.4rem, 6vw, 1.9rem); font-weight: 850; font-stretch: 78%; }
.result__label .muted { font-weight: 600; }

.bar { display: flex; height: 64px; margin: 18px 0 6px; border-radius: 12px; overflow: hidden; gap: 3px; background: var(--bg); }
.bar__seg { position: relative; display: flex; align-items: center; justify-content: center; min-width: 4px; color: var(--accent-ink); font-weight: 850; font-size: 0.95rem; transition: flex-basis 0.35s ease; }
.bar__seg span { white-space: nowrap; overflow: hidden; padding-inline: 4px; }
.bar__seg--distribution span, .bar__seg--produit_distribution span { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .bar__seg { transition: none; } }

.seg--accise { background: var(--seg-accise); }
.seg--tva { background: var(--seg-tva); }
.seg--produit { background: var(--seg-produit); }
.seg--distribution { background: var(--seg-distribution); }
.seg--produit_distribution { background: var(--seg-produit-distribution); }

.legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.legend__item { display: grid; grid-template-columns: 14px 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.legend__item:last-child { border-bottom: 0; }
.legend__swatch { width: 14px; height: 14px; border-radius: 4px; }
.legend__name { font-weight: 700; }
.legend__name small { display: block; font-weight: 500; color: var(--muted); font-size: 0.82rem; }
.legend__amount { text-align: right; font-weight: 850; font-size: 1.25rem; font-stretch: 85%; }
.legend__amount small { display: block; color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.legend__group { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-top: 12px; }

.result__meta { margin-top: 10px; color: var(--muted); font-size: 0.85rem; }
.result__url { margin-top: 6px; font-weight: 800; font-size: 0.9rem; color: var(--accent); letter-spacing: 0.02em; }
.result__error { color: var(--danger); font-weight: 600; }
.result__actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 480px) { .result__actions { grid-template-columns: 2fr 1fr; } }
.sources-line { font-size: 0.82rem; color: var(--muted); }
.sources-line a { color: var(--muted); }

/* ---- Stations ---- */
.stations { margin-top: 56px; display: grid; gap: 14px; }
.stations__fuel { color: var(--muted); }
.stations__fuel strong { color: var(--text); }
.stations__controls { display: grid; gap: 10px; }
.search { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.toggle--radius { justify-self: start; }
.stations__status { color: var(--muted); font-size: 0.95rem; min-height: 1.4em; }
.stations__status strong { color: var(--text); }
.stations__status .warn { color: var(--accent); }
.place-choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 0.9rem; color: var(--muted); }

.station-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.station {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: start;
}
.station:first-child { border-color: var(--accent); }
.station__price { display: grid; justify-items: start; gap: 2px; min-width: 92px; }
.station__rank { font-weight: 800; color: var(--muted); font-size: 0.8rem; }
.station__value { font-size: 1.75rem; font-weight: 900; font-stretch: 72%; line-height: 1; }
.station:first-child .station__value { color: var(--accent); }
.station__delta { font-size: 0.76rem; font-weight: 700; color: var(--muted); line-height: 1.2; }
.station__info { min-width: 0; }
.station__address { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.station__meta { color: var(--muted); font-size: 0.85rem; line-height: 1.35; margin-top: 2px; }
.station__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.station__actions .btn--small { min-height: 38px; }
.station__use { margin-left: auto; }
.more-btn { justify-self: center; }

/* ---- Dialogue de partage ---- */
.share {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  border: 1.5px solid var(--line); border-radius: 20px; padding: 16px;
  background: var(--surface); color: var(--text);
}
.share[open] { display: grid; gap: 14px; }
.share::backdrop { background: rgb(0 0 0 / 0.75); }
.share__head { display: flex; justify-content: space-between; align-items: center; }
.share__head h2 { font-size: 1.6rem; }
.share__preview { display: grid; place-items: center; background: var(--bg); border-radius: 12px; padding: 10px; min-height: 0; }
.share__preview canvas { display: block; max-width: 100%; max-height: 52dvh; width: auto; height: auto; border-radius: 8px; }
.share__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share__actions .btn[hidden] { display: none; }
.share__actions:has(.btn[hidden]) { grid-template-columns: 1fr; }

/* ---- Pied de page ---- */
.footer { margin-top: 64px; padding-block: 28px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; display: grid; gap: 10px; }
.footer strong { color: var(--text); }
.footer__nav { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---- Pages de texte (méthodologie, mentions) ---- */
.page-simple main { padding-block: 24px 40px; }
.prose { display: grid; gap: 16px; }
.prose h1 { font-size: clamp(2.2rem, 9vw, 3.4rem); font-stretch: 72%; text-transform: uppercase; }
.prose h2 { margin-top: 18px; font-size: clamp(1.5rem, 5vw, 2rem); }
.prose h3 { font-size: 1.2rem; font-stretch: 90%; margin-top: 8px; }
.prose p, .prose li { color: #d6d6d3; }
.prose ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.prose code, .formula { font-family: ui-monospace, 'Cascadia Mono', Menlo, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.formula { display: block; padding: 12px 14px; overflow-x: auto; line-height: 1.7; }
.table-scroll { overflow-x: auto; border: 1.5px solid var(--line); border-radius: var(--radius); }
.table-scroll table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 0.9rem; }
.table-scroll th, .table-scroll td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-scroll th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface); }
.status { display: inline-block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.status--OFFICIEL { background: #1f3b22; color: #8ee59a; }
.status--DEDUIT { background: #3b3317; color: var(--accent); }
.status--A_COMPLETER { background: #3d1e1e; color: #ff9b9b; }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 8px; }
.todo { color: #ff9b9b; font-weight: 700; }
