/* ============================================================
   DPO Romandie — Design system « éditorial suisse »
   Fraunces (display) + Hanken Grotesk (texte), auto-hébergés.
   Accessible (WCAG), AEO-friendly, mouvement à dégradation propre.
   ============================================================ */

:root {
  /* Couleurs */
  --paper:    #f6f2ea;   /* papier chaud */
  --paper-2:  #efe8da;
  --card:     #fffdf8;
  --ink:      #14302f;   /* texte principal (teal très sombre) */
  --muted:    #4c5b59;   /* texte secondaire (contraste AA) */
  --teal:     #0e4f52;
  --teal-deep:#0a3c3f;
  --night:    #07292b;   /* sections sombres */
  --line:     #ddd5c6;   /* filet chaud */
  --line-soft:#e8e1d3;
  --red:      #c10f2c;   /* croix suisse / accent */
  --red-deep: #9d0c24;
  --gold:     #b08948;   /* hairline rare */

  /* Typo */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Espace / rayons / ombres */
  --maxw: 1140px;
  --gut: clamp(20px, 5vw, 56px);
  --r: 4px;
  --shadow-s: 0 1px 2px rgba(10,40,42,.05), 0 2px 8px rgba(10,40,42,.05);
  --shadow-m: 0 4px 14px rgba(10,40,42,.07), 0 18px 40px rgba(10,40,42,.08);
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: clamp(16px, 1.05vw, 18px);
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
}
/* grain papier très subtil */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
img { max-width: 100%; height: auto; }
::selection { background: var(--teal); color: #fff; }

.container { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gut); }

/* ---------- Typographie ---------- */
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; color: var(--ink); line-height: 1.08; letter-spacing: -.012em; margin: 0; font-optical-sizing: auto; }
h1 { font-size: clamp(2.15rem, 5.4vw, 4.6rem); font-weight: 600; letter-spacing: -.022em; overflow-wrap: break-word; hyphens: auto; }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.5rem); margin: 0 0 .4em; }
h3 { font-size: clamp(1.15rem, 1.6vw, 1.4rem); font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--teal-deep); }
strong { font-weight: 600; color: var(--ink); }
em { font-style: italic; }

.eyebrow {
  font-family: var(--sans); font-weight: 600; font-size: .76rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--teal); margin: 0 0 1.1rem; display: inline-flex; align-items: center; gap: .7em;
}
.eyebrow::before { content: ""; width: 26px; height: 1px; background: var(--red); display: inline-block; }

.lead { font-size: clamp(1.18rem, 1.7vw, 1.42rem); line-height: 1.5; color: #283f3e; font-weight: 400; }
.prose { max-width: 70ch; }

/* ---------- En-tête ---------- */
.site-header { position: sticky; top: 0; z-index: 60; transition: background .4s var(--ease), box-shadow .4s var(--ease), border-color .4s; border-bottom: 1px solid transparent; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; }
.site-header.scrolled { background: rgba(246,242,234,.86); backdrop-filter: saturate(1.4) blur(12px); border-bottom-color: var(--line); box-shadow: 0 1px 0 rgba(10,40,42,.02); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand .mark { width: 33px; height: 36px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--teal); transition: transform .5s var(--ease); }
.brand:hover .mark { transform: rotate(-5deg); }
.brand .mark svg { width: 100%; height: 100%; display: block; }
.site-footer .brand .mark { color: #fff; }
.brand b { font-family: var(--display); font-weight: 600; font-size: 1.2rem; letter-spacing: -.01em; }
.brand small { display: block; font-family: var(--sans); font-weight: 500; font-size: .6rem; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; margin-top: -2px; }
.nav { display: flex; align-items: center; gap: 28px; }
.nav a:not(.btn) { color: var(--ink); text-decoration: none; font-size: .96rem; font-weight: 500; position: relative; padding: 4px 0; }
.nav a:not(.btn)::after { content: ""; position: absolute; left: 0; bottom: 0; width: 0; height: 1.5px; background: var(--teal); transition: width .3s var(--ease); }
.nav a:not(.btn):hover::after { width: 100%; }

/* ---------- Boutons ---------- */
.btn, .cta {
  --bg: var(--teal); --fg: #fff;
  display: inline-flex; align-items: center; gap: .6em; background: var(--bg); color: var(--fg) !important;
  padding: 13px 24px; border-radius: var(--r); text-decoration: none; font-weight: 600; font-size: .98rem;
  border: 1px solid var(--bg); letter-spacing: .005em; transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s; box-shadow: var(--shadow-s);
}
.btn::after, .cta::after { content: "→"; font-size: 1.05em; transition: transform .3s var(--ease); }
.btn:hover, .cta:hover { background: var(--teal-deep); transform: translateY(-2px); box-shadow: var(--shadow-m); }
.btn:hover::after, .cta:hover::after { transform: translateX(4px); }
.btn:active, .cta:active { transform: translateY(0); }
.btn.lg { padding: 16px 30px; font-size: 1.05rem; }
.btn.ghost { background: transparent; color: var(--ink) !important; border-color: var(--line); box-shadow: none; }
.btn.ghost::after { content: "→"; }
.btn.ghost:hover { background: transparent; border-color: var(--teal); color: var(--teal-deep) !important; }

/* ---------- Sceau (élément signature) ---------- */
.seal { position: absolute; width: clamp(168px, 20vw, 272px); height: auto; right: 0; top: 4px; color: var(--teal); opacity: .92; }
.seal .ring { animation: sealspin 48s linear infinite; transform-origin: 100px 100px; }
@keyframes sealspin { to { transform: rotate(360deg); } }
.seal-text { font-family: var(--sans); font-weight: 600; font-size: 9.2px; letter-spacing: .24em; fill: var(--teal); text-transform: uppercase; }
@media (prefers-reduced-motion: reduce) { .seal .ring { animation: none; } }

/* ---------- Hero ---------- */
.hero { position: relative; padding: clamp(54px, 9vw, 116px) 0 clamp(40px, 6vw, 76px); overflow: hidden; }
.hero::after { content: ""; position: absolute; left: 50%; right: 0; top: -30%; width: 70vw; height: 120%; transform: translateX(-10%);
  background: radial-gradient(45% 50% at 70% 30%, rgba(14,79,82,.07), transparent 70%); pointer-events: none; z-index: -1; }
.hero .container { position: relative; }
.hero h1 { max-width: 16ch; margin: 0 0 .5em; }
.hero .lead { max-width: 46ch; margin: 0 0 2rem; }
.hero .cta, .hero .btn { margin-right: 12px; }
.hero .callout { margin-top: 2.6rem; max-width: 60ch; }
.hero .seal { right: var(--gut); top: clamp(40px, 7vw, 96px); }
@media (max-width: 900px) { .hero .seal { position: static; display: block; margin: 0 0 26px; width: 130px; } }

/* ---------- Médaille 3D (sceau) ---------- */
.hero .coin { position: absolute; right: var(--gut); top: clamp(40px, 7vw, 96px); width: clamp(168px, 20vw, 272px); aspect-ratio: 1 / 1; }
.hero .coin .seal { position: static; right: auto; top: auto; width: 100%; height: auto; }
.hero .coin canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; opacity: 0; transition: opacity .9s var(--ease); cursor: grab; }
.hero .coin.coin-ready canvas { opacity: 1; }
.hero .coin.coin-ready .seal { opacity: 0; transition: opacity .6s var(--ease); }
@media (max-width: 900px) { .hero .coin { position: static; margin: 0 0 26px; width: 132px; } }

/* Apparition au chargement (hero) */
.hero .eyebrow, .hero h1, .hero .lead, .hero p, .hero .callout, .hero .seal { opacity: 0; transform: translateY(18px); animation: rise .9s var(--ease) forwards; }
.hero .eyebrow { animation-delay: .05s; }
.hero h1 { animation-delay: .14s; }
.hero .lead { animation-delay: .26s; }
.hero p { animation-delay: .36s; }
.hero .callout { animation-delay: .46s; }
.hero .seal { animation: stamp 1.05s var(--ease) .35s both; }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes stamp { 0% { opacity: 0; transform: scale(1.24) rotate(-8deg); } 55% { opacity: 1; transform: scale(.965) rotate(1.5deg); } 100% { opacity: .95; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hero .eyebrow, .hero h1, .hero .lead, .hero p, .hero .callout, .hero .seal { opacity: 1; transform: none; animation: none; } }

/* ---------- Rythme des sections ---------- */
main { display: block; }
main > section { padding: clamp(34px, 5vw, 64px) 0; position: relative; }
main > section + section { border-top: 1px solid var(--line-soft); }
.page-head { padding: clamp(48px, 7vw, 92px) 0 clamp(20px, 3vw, 34px); }
.page-head .eyebrow { margin-bottom: .9rem; }
.page-head h1 { font-size: clamp(2.1rem, 4.4vw, 3.4rem); max-width: 20ch; }
.page-head .sub { color: var(--muted); font-size: 1.12rem; margin: .8rem 0 0; max-width: 60ch; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: 1.4rem; letter-spacing: .01em; }
.breadcrumb a { text-decoration: none; color: var(--teal); }

/* ---------- Définition ---------- */
.definition { font-family: var(--display); font-size: clamp(1.25rem, 2vw, 1.6rem); line-height: 1.4; font-weight: 400; color: var(--ink); padding: 4px 0 4px 26px; border-left: 2px solid var(--red); margin: 1.2rem 0; }

/* ---------- Étapes (cartes éditoriales numérotées) ---------- */
ol.steps { counter-reset: s; list-style: none; padding: 0; margin: 1.6rem 0; display: grid; gap: 0; }
ol.steps > li { counter-increment: s; position: relative; padding: 26px 0 26px 86px; border-top: 1px solid var(--line); }
ol.steps > li:last-child { border-bottom: 1px solid var(--line); }
ol.steps > li::before { content: counter(s, decimal-leading-zero); position: absolute; left: 0; top: 22px; font-family: var(--display); font-size: 2.4rem; font-weight: 600; color: var(--teal); line-height: 1; font-feature-settings: "tnum"; }
ol.steps > li strong { display: block; font-size: 1.12rem; margin-bottom: .2em; }

/* ---------- Statistique éditoriale ---------- */
p.stat { font-family: var(--display); font-size: clamp(1.3rem, 2.4vw, 1.9rem); line-height: 1.35; color: var(--ink); border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); padding: 1rem 0; margin: 1.8rem 0; font-weight: 400; }

/* ---------- Citation expert ---------- */
blockquote.expert { margin: 2rem 0; padding: 0 0 0 30px; border-left: 2px solid var(--teal); font-family: var(--display); font-style: italic; font-size: clamp(1.2rem, 1.9vw, 1.5rem); line-height: 1.45; color: var(--ink); }
blockquote.expert cite { display: block; margin-top: .8rem; font-family: var(--sans); font-style: normal; font-weight: 600; font-size: .85rem; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }

/* ---------- Encadré honnête ---------- */
.callout { position: relative; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--r); padding: 18px 22px; margin: 1.6rem 0; font-size: .98rem; color: #2c3d3c; box-shadow: var(--shadow-s); }
.callout strong { color: var(--ink); }
.callout.info { border-left-color: var(--teal); }

/* ---------- Listes ---------- */
main ul { padding-left: 0; list-style: none; margin: 1rem 0; }
main ul > li { position: relative; padding-left: 26px; margin: .55em 0; }
main ul > li::before { content: ""; position: absolute; left: 4px; top: .62em; width: 7px; height: 7px; background: var(--teal); transform: rotate(45deg); }

/* ---------- Cartes / grilles ---------- */
.grid { display: grid; gap: 22px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 780px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 26px; box-shadow: var(--shadow-s); transition: transform .35s var(--ease), box-shadow .35s var(--ease); }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-m); }
.card h2, .card h3 { margin-top: 0; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 1.6rem 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 14px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
thead th { background: var(--teal); color: #fff; font-weight: 600; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; border-bottom: none; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(14,79,82,.03); }
td:first-child { font-weight: 600; color: var(--ink); }

/* ---------- FAQ ---------- */
.faq { margin: 1.4rem 0; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 20px 44px 20px 0; font-weight: 600; font-size: 1.08rem; list-style: none; position: relative; color: var(--ink); transition: color .2s; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; position: absolute; right: 8px; top: 24px; width: 12px; height: 12px;
  background: linear-gradient(var(--teal),var(--teal)) center/12px 2px no-repeat, linear-gradient(var(--teal),var(--teal)) center/2px 12px no-repeat; transition: transform .3s var(--ease); }
.faq details[open] summary::after { transform: rotate(135deg); }
.faq summary:hover { color: var(--teal); }
.faq details > div { padding: 0 44px 22px 0; color: #2c3d3c; }

/* ---------- Sur le même sujet ---------- */
.related { margin: 3rem 0 0; padding: 28px 0 0; border-top: 2px solid var(--ink); }
.related h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.related ul { display: grid; gap: 0; }
.related li { padding: 0; }
.related li::before { display: none; }
.related a { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 4px; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); font-family: var(--display); font-size: 1.15rem; transition: padding .3s var(--ease), color .3s; }
.related a::after { content: "→"; color: var(--teal); transition: transform .3s var(--ease); }
.related a:hover { color: var(--teal); padding-left: 14px; }
.related a:hover::after { transform: translateX(5px); }

/* ---------- Bande CTA (sombre) ---------- */
.cta-band { position: relative; margin: clamp(48px,7vw,90px) 0 0; padding: clamp(48px,7vw,86px) var(--gut); background: var(--night); color: #eef4f3; border-radius: 8px; text-align: center; overflow: hidden; }
.cta-band::before { content: ""; position: absolute; inset: 0; opacity: .5; background: radial-gradient(50% 70% at 50% -10%, rgba(255,255,255,.06), transparent 60%); }
.cta-band h2 { color: #fff; font-size: clamp(1.8rem,3.4vw,2.7rem); margin: 0 auto .6rem; max-width: 18ch; position: relative; }
.cta-band p { color: #b9cecc; max-width: 48ch; margin: 0 auto 2rem; position: relative; }
.cta-band .btn { background: #fff; color: var(--teal-deep) !important; border-color: #fff; position: relative; }
.cta-band .btn:hover { background: var(--paper); transform: translateY(-2px); }

/* ---------- Pied de page ---------- */
.site-footer { background: var(--night); color: #aebfbd; margin-top: clamp(50px,8vw,96px); padding: clamp(46px,6vw,72px) 0 32px; font-size: .92rem; }
.site-footer .cols { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 30px; }
@media (max-width: 760px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } }
.site-footer .brand { color: #fff; margin-bottom: 12px; }
.site-footer .brand b { color: #fff; }
.site-footer h3 { color: #fff; font-family: var(--sans); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 12px; font-weight: 600; }
.site-footer a { color: #aebfbd; text-decoration: none; display: block; margin: 7px 0; transition: color .2s, padding .2s; }
.site-footer a:hover { color: #fff; padding-left: 3px; }
.site-footer p { color: #92a5a3; }
.site-footer .legal { grid-column: 1 / -1; border-top: 1px solid rgba(255,255,255,.12); margin-top: 30px; padding-top: 20px; font-size: .82rem; color: #8a9d9b; }
.site-footer .legal a { display: inline; color: #b9cecc; }
.lang { display: flex; gap: 6px; margin-top: 14px; }
.lang a, .lang span { padding: 5px 11px; border-radius: 4px; font-size: .8rem; text-decoration: none; }
.lang a.active { background: var(--teal); color: #fff; }
.lang span { color: #a8bbb9; }

/* ---------- Formulaires ---------- */
.field { margin: 0 0 16px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; color: var(--ink); }
.field input, .field textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); font: inherit; color: var(--ink); background: var(--card); transition: border-color .2s, box-shadow .2s; }
.field input:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,79,82,.12); outline: none; }
::placeholder { color: #7a8a88; opacity: 1; }

/* ---------- Accessibilité ---------- */
.skip { position: absolute; left: -9999px; top: 0; background: var(--teal); color: #fff !important; padding: 12px 18px; border-radius: 0 0 6px 0; z-index: 200; text-decoration: none; }
.skip:focus { left: 0; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2.5px solid var(--teal); outline-offset: 3px; border-radius: 2px; }

/* Liens en plein texte : distinguables autrement que par la couleur (WCAG 1.4.1) */
main p a, main li a, .lead a, .callout a, .definition a, .field a, .site-footer .legal a {
  text-decoration: underline; text-underline-offset: .15em; text-decoration-thickness: 1px; text-decoration-color: rgba(14,79,82,.5);
}
.site-footer .legal a { text-decoration-color: rgba(185,206,204,.6); }
main p a:hover, main li a:hover, .callout a:hover, .definition a:hover, .field a:hover, .site-footer .legal a:hover { text-decoration-color: currentColor; }

/* ---------- Révélation au scroll (progressive : seulement si JS) ---------- */
.js [data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js [data-reveal].is-revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js [data-reveal] { opacity: 1 !important; transform: none !important; transition: none; } }
/* Filet de sécurité : si app.js ne s'exécute pas, tout réapparaît après 3 s */
.no-reveal [data-reveal] { opacity: 1 !important; transform: none !important; }

/* ---------- Nav mobile (liens visibles, repli en ligne) ---------- */
@media (max-width: 860px) {
  .site-header .container { flex-wrap: wrap; min-height: 0; padding-block: 12px; }
  .nav { width: 100%; flex-wrap: wrap; gap: 14px 20px; margin-top: 6px; }
  .nav a:not(.btn) { font-size: .9rem; }
}

/* ---------- Transitions de page natives (cross-document) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: .32s; }
::view-transition-new(root) { animation-duration: .32s; }
/* le header reste fixe pendant la transition */
.site-header { view-transition-name: site-header; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
