/* =====================================================================
   Calculo — feuille de style commune
   Thème clair, éditorial-outil. Palette restreinte, typo soignée.
   ===================================================================== */

:root {
  /* Couleurs */
  --bg: #FAF8F3;
  --surface: #FFFFFF;
  --surface-2: #F3EFE7;
  --ink: #1A1714;
  --muted: #6B645B;
  --border: #E7E1D6;
  --border-strong: #D8CFBF;
  --accent: #E8590C;       /* orange brûlé */
  --accent-ink: #B5450A;   /* orange foncé pour texte sur clair */
  --accent-soft: #FBE7D8;
  --pos: #15803D;          /* vert résultat positif */
  --pos-soft: #E3F2E7;
  --warn: #92400E;
  --warn-soft: #FBEFD9;

  /* Typo */
  --font-title: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* Échelle d'espacement 4/8 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --s9: 96px;

  --radius: 6px;
  --radius-lg: 10px;
  --maxw: 1080px;
  --shadow: 0 1px 2px rgba(26, 23, 20, 0.04), 0 4px 16px rgba(26, 23, 20, 0.05);
  --shadow-sm: 0 1px 2px rgba(26, 23, 20, 0.05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; display: block; }

a {
  color: var(--accent-ink);
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--accent); }

h1, h2, h3, h4 {
  font-family: var(--font-title);
  font-weight: 560;
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 var(--s4);
}
h1 { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); margin-top: var(--s7); }
h3 { font-size: 1.25rem; margin-top: var(--s5); }

p { margin: 0 0 var(--s4); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--s5);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: var(--s2) var(--s4);
  z-index: 200;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ===================== Header / Nav ===================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 248, 243, 0.92);
  backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  min-height: 66px;
}
.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.logo .logo__dot { color: var(--accent); }
.logo:hover { text-decoration: none; }

.nav-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  align-items: center;
  gap: var(--s2);
  color: var(--ink);
}
.nav-toggle:hover { background: var(--surface-2); }

.site-nav ul {
  list-style: none;
  display: flex;
  gap: var(--s2);
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: block;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 160ms, background 160ms;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: block; }
  .site-nav ul {
    flex-direction: column;
    gap: 0;
    padding: var(--s3) var(--s5);
  }
  .site-nav a { padding: var(--s3) var(--s2); border-radius: var(--radius); }
}

/* ===================== Layout helpers ===================== */
main { display: block; }
section { margin-block: var(--s7); }

.lead {
  font-size: 1.18rem;
  color: var(--muted);
  max-width: 60ch;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 var(--s3);
  font-weight: 500;
}

/* Page hero (asymétrique, pas centré) */
.page-hero {
  padding-top: var(--s7);
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--border);
}
.page-hero p { max-width: 62ch; }

.breadcrumb {
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: var(--s4);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent-ink); }

/* ===================== Calculator grid (tool + result) ===================== */
.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s6);
  align-items: start;
  margin-top: var(--s6);
}
@media (max-width: 820px) {
  .tool-grid { grid-template-columns: 1fr; gap: var(--s5); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s6);
  box-shadow: var(--shadow-sm);
}
.card h2 { margin-top: 0; }

.result-panel {
  position: sticky;
  top: 86px;
}
@media (max-width: 820px) {
  .result-panel { position: static; }
}

/* ===================== Forms ===================== */
.field { margin-bottom: var(--s5); }
.field:last-child { margin-bottom: 0; }
.field > label,
.fieldset-legend {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: var(--s2);
  color: var(--ink);
}
.field .hint {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: var(--s2);
  font-weight: 400;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color 150ms, box-shadow 150ms;
}
input:hover, select:hover { border-color: #c3b8a4; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="number"] { font-family: var(--font-mono); }

.input-suffix {
  position: relative;
}
.input-suffix input { padding-right: 44px; }
.input-suffix .unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  pointer-events: none;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
  margin: 0 0 var(--s5);
}
fieldset legend {
  padding: 0 var(--s2);
  font-weight: 600;
  font-size: 0.95rem;
}

.radio-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.radio-pill {
  position: relative;
}
.radio-pill input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.radio-pill label {
  display: inline-block;
  padding: var(--s2) var(--s4);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  background: var(--surface);
  transition: all 150ms;
}
.radio-pill input:checked + label {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.radio-pill input:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
}
@media (max-width: 460px) {
  .two-col { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font: inherit;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms, transform 80ms;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: #cf4e08; }
.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}
.btn--ghost:hover { background: var(--surface-2); }

.error-msg {
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid #ecd3a3;
  border-radius: var(--radius);
  padding: var(--s3) var(--s4);
  font-size: 0.92rem;
  margin-top: var(--s4);
}

/* ===================== Result display ===================== */
.result-headline {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}
.result-headline.is-pos { color: var(--pos); }
.result-headline.is-accent { color: var(--accent-ink); }
.result-sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: var(--s2);
}
.result-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s5);
  margin-bottom: var(--s5);
}
.result-block.is-pos {
  background: var(--pos-soft);
  border-color: #c4e2cb;
}

.kv-list { margin: 0; }
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px dashed var(--border);
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .kv-label { color: var(--muted); font-size: 0.94rem; }
.kv-row .kv-val {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
}
.kv-row.is-total {
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
  margin-top: var(--s2);
  padding-top: var(--s4);
}
.kv-row.is-total .kv-label { color: var(--ink); font-weight: 600; }
.kv-row.is-total .kv-val { font-size: 1.15rem; font-weight: 600; }
.kv-row .kv-val.neg { color: var(--accent-ink); }
.kv-row .kv-val.pos { color: var(--pos); }

/* Step-by-step detail */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li {
  position: relative;
  padding-left: 42px;
  margin-bottom: var(--s4);
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}
.steps li b { font-family: var(--font-mono); }

/* ===================== Disclaimer ===================== */
.disclaimer {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  background: var(--warn-soft);
  border: 1px solid #ecd3a3;
  border-radius: var(--radius);
  padding: var(--s4);
  font-size: 0.9rem;
  color: #6b4a16;
  margin-top: var(--s5);
}
.disclaimer svg { flex: 0 0 auto; color: var(--warn); margin-top: 2px; }

/* ===================== Article ===================== */
.article {
  max-width: 72ch;
  margin-top: var(--s8);
}
.article h2 { margin-top: var(--s7); }
.article ul, .article ol { padding-left: 1.3em; }
.article li { margin-bottom: var(--s2); }
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--s4) 0 var(--s5);
  font-size: 0.94rem;
}
.article th, .article td {
  text-align: left;
  padding: var(--s3);
  border-bottom: 1px solid var(--border);
}
.article th {
  background: var(--surface-2);
  font-weight: 600;
}
.article td.num, .article th.num { text-align: right; font-family: var(--font-mono); }
.article tbody tr:hover { background: var(--surface); }

/* ===================== Internal linking ===================== */
.related {
  border-top: 1px solid var(--border);
  padding-top: var(--s6);
  margin-top: var(--s8);
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s4);
  margin-top: var(--s4);
}
.related-grid a {
  display: block;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 150ms, transform 120ms;
}
.related-grid a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.related-grid a .num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-ink);
}
.related-grid a strong { display: block; margin-top: 2px; }

/* ===================== Ad slots (publicité / CPM) =====================
   Placeholder discret, dans le thème. Hauteur réservée = anti layout-shift.
   Variantes : --leaderboard (~90px), --rectangle (~250-300px),
   --inarticle (fluide), --sidebar (rectangle latéral desktop).
   Quand le vrai code AdSense/Ezoic est collé, l'annonce remplit la zone. */
.ad-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(
      135deg,
      transparent,
      transparent 10px,
      rgba(232, 89, 12, 0.03) 10px,
      rgba(232, 89, 12, 0.03) 20px
    );
  overflow: hidden;
}
/* étiquette « Publicité » discrète, en haut à gauche de la zone réservée */
.ad-slot .ad-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}
/* l'annonce réelle (ins AdSense, iframe Ezoic…) prend toute la place */
.ad-slot ins,
.ad-slot iframe,
.ad-slot > div:not(.ad-label) { width: 100%; }

/* Bandeau horizontal — header de hub, inter-sections */
.ad-slot--leaderboard {
  min-height: 90px;
  max-width: 728px;
  margin-inline: auto;
}
/* Pavé carré — sous le résultat (zone la plus regardée) */
.ad-slot--rectangle {
  min-height: 280px;
  max-width: 336px;
  margin-inline: auto;
}
/* In-article fluide — au fil de l'article explicatif */
.ad-slot--inarticle {
  min-height: 250px;
  margin-block: var(--s6);
}
/* Rectangle latéral sticky (desktop, dans les articles) */
.ad-slot--sidebar {
  min-height: 600px;
  max-width: 300px;
}

@media (max-width: 480px) {
  .ad-slot--rectangle { min-height: 250px; max-width: 300px; }
  .ad-slot--leaderboard { min-height: 100px; max-width: 320px; }
}

/* Disposition article + colonne pub latérale (desktop ≥ 1000px) */
.article-with-aside {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--s7);
  align-items: start;
}
.article-with-aside .article { margin-top: 0; }
.article-aside { position: sticky; top: 86px; }
@media (max-width: 1000px) {
  .article-with-aside { grid-template-columns: 1fr; }
  .article-aside { display: none; }
}

/* ===================== Footer ===================== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: var(--s9);
  padding-block: var(--s7);
}
.site-footer__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: var(--s6);
}
@media (max-width: 720px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; gap: var(--s5); }
}
@media (max-width: 460px) {
  .site-footer__grid { grid-template-columns: 1fr; }
}
.site-footer h4 {
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 var(--s3);
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: var(--s2); }
.site-footer a { color: var(--ink); text-decoration: none; font-size: 0.94rem; }
.site-footer a:hover { color: var(--accent-ink); text-decoration: underline; }
.site-footer .footer-brand p { color: var(--muted); font-size: 0.92rem; max-width: 38ch; }
.site-footer .copyright {
  margin-top: var(--s6);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===================== Hub specific ===================== */
.hub-hero {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: var(--s6);
  align-items: center;
  padding-top: var(--s8);
  padding-bottom: var(--s6);
}
@media (max-width: 820px) {
  .hub-hero { grid-template-columns: 1fr; }
}
.hub-hero__aside {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  box-shadow: var(--shadow-sm);
}
.hub-hero__aside dl { margin: 0; }
.hub-hero__aside dt {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--accent-ink);
  font-weight: 600;
}
.hub-hero__aside dd { margin: 0 0 var(--s4); color: var(--muted); font-size: 0.92rem; }
.hub-hero__aside dd:last-child { margin-bottom: 0; }

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 4px 4px 4px 12px;
  max-width: 520px;
  margin-top: var(--s5);
}
.search-bar svg { color: var(--muted); flex: 0 0 auto; }
.search-bar input {
  border: none;
  background: transparent;
  flex: 1;
  padding: 8px 4px;
  font-family: var(--font-body);
}
.search-bar input:focus { outline: none; box-shadow: none; }

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--s5);
  margin-top: var(--s5);
}
.calc-card {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms, transform 130ms, box-shadow 160ms;
}
.calc-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.calc-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.calc-card__num {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-ink);
  letter-spacing: 0.05em;
}
.calc-card__icon { color: var(--accent); }
.calc-card h3 { margin: 0; font-size: 1.22rem; }
.calc-card p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.calc-card__tags {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding-top: var(--s2);
}
.calc-card__tags span {
  font-size: 0.74rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.no-results {
  color: var(--muted);
  font-style: italic;
  padding: var(--s5) 0;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s5);
  margin-top: var(--s5);
}
.method-item {
  border-left: 2px solid var(--accent);
  padding-left: var(--s4);
}
.method-item h3 { margin-top: 0; font-size: 1.1rem; }
.method-item p { color: var(--muted); font-size: 0.94rem; margin: 0; }

.band {
  background: var(--surface);
  border-block: 1px solid var(--border);
  padding-block: var(--s7);
  margin-block: var(--s8);
}
.band .container > h2 { margin-top: 0; }

/* small print row */
.sources-list {
  font-size: 0.88rem;
  color: var(--muted);
  columns: 2;
  column-gap: var(--s6);
}
@media (max-width: 540px) { .sources-list { columns: 1; } }
.sources-list li { margin-bottom: var(--s2); break-inside: avoid; }
