/*
  Feuille de style unique, sans dépendance (polices Google chargées par le layout).
  Direction : l'univers textile — étiquette tissée, fil rouge, fiche technique.
  Tokens : fond « chambray » légèrement froid, encre bleu nuit, bleu indigo pour les actions,
  fil rouge pour les repères, moutarde pour les avertissements. Deux thèmes (clair / sombre).
*/

:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #e9ebef;
  --text: #141a2e;
  --muted: #566075;
  --border: #d5d9e1;
  --primary: #2b4a8b;
  --primary-strong: #1d3566;
  --on-primary: #ffffff;
  --thread: #c8361f;          /* le fil rouge : repères, kickers, accent */
  --thread-soft: #fbe9e4;
  --ok: #17663a;
  --ok-soft: #e3f3e8;
  --warn: #7a4a06;
  --warn-soft: #fff3d6;
  --warn-border: #eac46f;
  --info-soft: #e7eef9;
  --info-border: #b7c9e8;
  --danger: #b42318;
  --label: #f8f6f0;           /* fond « étiquette » légèrement chaud */
  --label-border: #cfc8b6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 26, 46, .06), 0 2px 8px rgba(20, 26, 46, .07);
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --maxw: 74rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #11151f;
    --surface: #1a2030;
    --surface-2: #232b3d;
    --text: #e7eaf1;
    --muted: #a6aebf;
    --border: #313a4f;
    --primary: #8fb3f3;
    --primary-strong: #b6cdf8;
    --on-primary: #0c1730;
    --thread: #f08a74;
    --thread-soft: #3a211c;
    --ok: #7fe0a6;
    --ok-soft: #16301f;
    --warn: #f3c86a;
    --warn-soft: #33270f;
    --warn-border: #6b5320;
    --info-soft: #182640;
    --info-border: #2f4b78;
    --danger: #f97066;
    --label: #242a36;
    --label-border: #4a5062;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11151f;
  --surface: #1a2030;
  --surface-2: #232b3d;
  --text: #e7eaf1;
  --muted: #a6aebf;
  --border: #313a4f;
  --primary: #8fb3f3;
  --primary-strong: #b6cdf8;
  --on-primary: #0c1730;
  --thread: #f08a74;
  --thread-soft: #3a211c;
  --ok: #7fe0a6;
  --ok-soft: #16301f;
  --warn: #f3c86a;
  --warn-soft: #33270f;
  --warn-border: #6b5320;
  --info-soft: #182640;
  --info-border: #2f4b78;
  --danger: #f97066;
  --label: #242a36;
  --label-border: #4a5062;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}
/* La visionneuse d'artefacts enveloppe l'accueil dans un body à 14px : on reprend la main. */
.is-preview.is-home { font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.6; color: var(--text); background: var(--bg); }

img, svg { max-width: 100%; }
a { color: var(--primary); text-underline-offset: .18em; }
a:hover { color: var(--primary-strong); }
:focus-visible { outline: 3px solid var(--thread); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 16px; }

.wrap {
  max-width: var(--maxw); margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Aperçu privé */
.preview-banner {
  background: var(--thread-soft); color: var(--text); font-size: .88rem; text-align: center;
  padding-block: 7px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px dashed var(--thread);
}
.preview-only { display: none; }
.is-preview .preview-only { display: block; }

/* En-tête : une bande « étiquette tissée » */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: relative; }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: repeating-linear-gradient(90deg, var(--thread) 0 10px, transparent 10px 16px); opacity: .9; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-block: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.main-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: .97rem; }
.main-nav a { color: var(--muted); text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; font-weight: 500; }
.main-nav a:hover { color: var(--text); }
.main-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--thread); }

main { padding-top: 28px; padding-bottom: 56px; min-height: 60vh; }

/* Typographie */
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; letter-spacing: -0.015em; text-wrap: balance; font-weight: 700; }
h1 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.75rem); margin: .2em 0 .5em; }
h2 { font-size: clamp(1.3rem, 1.1rem + .9vw, 1.7rem); margin: 1.8em 0 .6em; }
h3 { font-size: 1.15rem; margin: 1.4em 0 .4em; }
h4 { font-size: 1.02rem; margin: 1.2em 0 .3em; }
p, ul, ol { margin: 0 0 1em; }
li { margin-bottom: .35em; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 44rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.num, .tabular { font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }

.prose { max-width: 46rem; }
.prose.prose-wide { max-width: 64rem; }
.prose h2 { border-top: 1px solid var(--border); padding-top: 1.2em; }
.prose h2:first-of-type { border-top: 0; padding-top: 0; }
.prose img { border-radius: var(--radius); }
.prose figure { margin: 1.4em 0; }
.prose figcaption { font-size: .88rem; color: var(--muted); margin-top: .4em; }

/* Kicker « étiquette » : un petit cartouche en monospace, bord cousu */
.kicker, .card-kicker {
  display: inline-block; font-family: var(--font-mono); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--thread); background: var(--label); border: 1px dashed var(--label-border); border-radius: 3px; padding: 2px 8px;
}

.breadcrumb { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }
.updated { margin-top: 40px; font-size: .9rem; color: var(--muted); }

/* Accueil */
.hero { padding: 20px 0 10px; display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: center; }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 36px; } }
.hero h1 { max-width: 46rem; margin-top: .3em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0 8px; }
.hero-figure { min-width: 0; }
.hero-figure svg { width: 100%; height: auto; display: block; }

.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); margin: 26px 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.card h2, .card h3 { margin: 0; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); }
.card .card-link { margin-top: auto; font-weight: 600; }
.card-kicker { align-self: flex-start; }

.trust-list { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.trust-list li { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; margin: 0; }

.stat-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin: 18px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--thread); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.stat strong { display: block; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .88rem; color: var(--muted); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); color: var(--on-primary); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--text); }
.btn-link { background: none; border: 0; color: var(--primary); padding: 6px 0; min-height: 0; text-decoration: underline; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Encadrés */
.callout { border-radius: var(--radius); padding: 14px 18px; margin: 1.2em 0; border: 1px solid; }
.callout > :last-child { margin-bottom: 0; }
.callout.info { background: var(--info-soft); border-color: var(--info-border); }
.callout.warn { background: var(--warn-soft); border-color: var(--warn-border); }
.callout.ok { background: var(--ok-soft); border-color: var(--ok); }
.callout-title { font-weight: 700; display: block; margin-bottom: 4px; font-family: var(--font-display); }

.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--thread-soft); color: var(--danger); }
.pub { display: inline-block; font-family: var(--font-mono); font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border); color: var(--muted); vertical-align: middle; margin-left: 2px; }

/* Tableaux */
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; white-space: nowrap; font-family: var(--font-display); font-size: .92rem; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.highlight td { background: var(--ok-soft); }

/* Listes de contrôle */
.check { list-style: none; padding-left: 0; }
.check li { position: relative; padding-left: 30px; }
.check li::before { content: ""; position: absolute; left: 2px; top: .3em; width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--primary); }
.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 44px; margin-bottom: 14px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-family: var(--font-display); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; }

/* Sommaire */
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin: 1.2em 0 1.6em; }
.toc ol { margin: 6px 0 0; padding-left: 1.2em; }
.toc li { margin: 2px 0; }

/* Encart partenaires / passage à l'action */
.partner-box { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--thread); border-radius: var(--radius); padding: 16px 18px; margin: 1.6em 0; }
.partner-box h2, .partner-box h3 { margin-top: 0; font-size: 1.1rem; border: 0; padding: 0; }
.partner-box > :last-child { margin-bottom: 0; }

/* FAQ */
details.faq { border-top: 1px solid var(--border); padding: 10px 0; }
details.faq:last-of-type { border-bottom: 1px solid var(--border); }
details.faq summary { cursor: pointer; font-weight: 600; font-family: var(--font-display); font-size: 1.02rem; padding: 4px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; color: var(--thread); font-weight: 700; flex: none; }
details.faq[open] summary::after { content: "–"; }
details.faq > :not(summary) { margin-top: 6px; }

/* Lettre d'information (formulaire Netlify) */
.newsletter { background: var(--label); border: 1px dashed var(--label-border); border-radius: var(--radius); padding: 18px 20px; margin: 2em 0; }
.newsletter h2, .newsletter h3 { margin-top: 0; font-size: 1.15rem; border: 0; padding: 0; }
.newsletter form { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-top: 10px; }
.newsletter input[type="email"] { flex: 1 1 220px; min-width: 0; }
.newsletter .small { margin: 8px 0 0; }

/* Outils */
.tool-intro { max-width: 52rem; }
.tool { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 16px; }
.tool > * { min-width: 0; }
@media (min-width: 1060px) {
  .tool { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tool-output { position: sticky; top: 16px; }
}
.tool-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px 6px; margin: 0 0 16px; min-width: 0; }
.tool-form legend { font-weight: 700; padding: 0 6px; font-family: var(--font-display); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: .95rem; }
.field .hint { font-size: .85rem; color: var(--muted); }
.row { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.row-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], input[type="url"], select, textarea {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; min-height: 44px; width: 100%;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid transparent; box-shadow: 0 0 0 3px var(--info-border); }
input[type="range"] { width: 100%; accent-color: var(--primary); }
.choice { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.choice input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--primary); }
.input-unit { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.input-unit span { color: var(--muted); font-size: .9rem; white-space: nowrap; }

.lines { display: grid; gap: 12px; margin-bottom: 12px; }
.line { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 2px; background: var(--bg); }
.line-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-weight: 600; font-size: .9rem; color: var(--muted); }

.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }

/* Résultats de calcul : la « fiche » */
.result-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.result-sheet h2 { margin: 0 0 10px; font-size: 1.15rem; border: 0; padding: 0; }
.result-main { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); margin-bottom: 14px; }
.result-main div { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.result-main strong { display: block; font-family: var(--font-display); font-size: 1.45rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.result-main span { font-size: .85rem; color: var(--muted); }
.result-main .good strong { color: var(--ok); }
.result-main .bad strong { color: var(--danger); }
.result-sheet table { font-size: .93rem; }
.result-sheet .table-wrap { margin: .6em 0; }
.verdict { padding: 12px 14px; border-radius: 8px; margin-top: 12px; font-weight: 500; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.bad { background: var(--thread-soft); color: var(--danger); }
.bar { height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* Étiquette de composition générée (aperçu imprimable) */
.label-paper { background: #fff; color: #111; border: 1px solid #ccc; border-radius: 6px; padding: 16px; font-size: .9rem; line-height: 1.4; font-family: var(--font-body); box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 8px 24px rgba(0, 0, 0, .08); }
.label-paper .label-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 6px 0; }
.label-paper .symbols { display: flex; gap: 10px; flex-wrap: wrap; }
.label-paper .symbols svg { width: 30px; height: 30px; }
.label-paper .ribbon { border: 1px dashed #999; padding: 10px 12px; width: max-content; max-width: 100%; }
.label-paper .empty { color: #777; font-style: italic; }

/* Comparatif : fiches côte à côte */
.compare-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); margin: 1.2em 0; }
.compare-cards .card h3 { font-size: 1.05rem; }
.compare-cards .price { font-family: var(--font-display); font-size: 1.35rem; font-variant-numeric: tabular-nums; margin: 0; }
.compare-cards .price small { font-size: .8rem; color: var(--muted); font-family: var(--font-body); }
.compare-cards ul { margin: 0; padding-left: 1.1em; font-size: .93rem; color: var(--muted); }

/* Pied de page */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); font-size: .92rem; color: var(--muted); }
.footer-inner { padding-block: 24px 28px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 12px 0; }
.footer-nav a { color: var(--muted); }
.disclaimer { max-width: 54rem; }
.copyright { margin: 0; }
.contact-mail { font-family: var(--font-mono); font-size: .92em; }
.contact-mail[data-copied]::after { content: " ✓ copiée"; color: var(--ok); font-family: var(--font-body); }

/* Page d'erreur */
.error-page { text-align: center; padding: 48px 0; }
.error-page h1 { font-size: clamp(2.4rem, 2rem + 3vw, 4rem); }

/* Impression : outils */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; color: #000; font-size: 11pt; }
  .site-header, .site-footer, .skip, .no-print, .tool-form, .breadcrumb, .updated, .partner-box, .tool-intro, .after-tool, .preview-banner, .newsletter, .main-nav { display: none !important; }
  main { padding: 0; min-height: 0; }
  .tool { display: block; margin: 0; }
  .tool-output { position: static; }
  .result-sheet, .label-paper { box-shadow: none; border-radius: 0; }
  a { color: inherit; text-decoration: none; }
}
