/* Le vertige des ancêtres : socle commun à toutes les pages
   (jetons de couleur et de typographie, remise à zéro, utilitaires, bandeau de consentement). */

:root {
  /* Neutres légèrement froids, un accent bleu vif, un orange en second. */
  --paper: #f3f4f4;
  --sheet: #fbfbfb;
  --ink: #1c1f22;
  --ink-soft: #4a4f55;
  --ink-faint: #656b72;
  --rule: #dcdfe0;
  --rule-strong: #b8bdc0;
  --accent: #0267c7;
  --distinct: #0b7a55; /* « ancêtre de tous » dans le village */
  --accent-strong: #044b94;
  --accent-wash: #e6effc;
  --gold: #e16c10;
  --gold-ink: #9b4805;
  --gold-wash: #feeadb;
  --gen-color: #1c1f22;

  --font-display: "Roboto", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ui: "Roboto", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 6px;
  --shadow-float: 0 14px 40px rgba(28, 31, 34, 0.18);
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
}

button, input, select { font: inherit; color: inherit; }
p { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }

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

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

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: .5rem .875rem; border-radius: var(--radius);
}
.skip-link:focus { top: 12px; }

/* ---------- Bandeau de consentement (créé par js/analytics.js) ----------
   Accepter et Refuser ont exactement le même poids visuel, comme le demande la CNIL. */

.consent {
  position: fixed; z-index: 1000;
  left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(25rem, calc(100vw - 32px));
  padding: 1.1rem 1.2rem 1rem;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 10px;
  box-shadow: var(--shadow-float);
  font-family: var(--font-ui); font-size: .9375rem; line-height: 1.45;
}
.consent-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; line-height: 1.2; margin: 0 0 .35rem; }
.consent-text { margin: 0; color: var(--ink-soft); }
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .9rem; }
.consent-btn {
  min-height: 44px; padding: .5rem 1rem;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer;
}
.consent-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.consent-more { display: inline-block; margin-top: .65rem; color: var(--accent); font-size: .875rem; }

@media print { .consent { display: none; } }

/* ---------- En-tête : le même sur toutes les pages ---------- */

.site-header {
  position: sticky; top: 0; z-index: 800;
  display: flex; align-items: center; gap: .5rem 1.25rem; min-height: 60px;
  padding: max(8px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 8px max(20px, env(safe-area-inset-left));
  background: var(--paper); border-bottom: 1px solid var(--rule); font-size: 1rem; line-height: 1.4;
}
.site-header .site-brand {
  display: inline-flex; align-items: center; gap: .6rem; white-space: nowrap;
  color: var(--ink); text-decoration: none; font-family: var(--font-display); font-size: 1.25rem; font-weight: 600;
}
.site-mark { width: 30px; height: 30px; flex: none; }
.site-tools { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.site-tools .present-link, .site .site-tools .present-link:hover {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: 0 .8rem; border-radius: var(--radius);
  border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--ink); text-decoration: none; font-size: .875rem; font-weight: 600;
}
.site .site-tools .present-link, .site .site-tools .present-link:hover { color: var(--ink); }
.site .site-tools .present-link:hover, .site-tools .present-link:hover { background: var(--accent-wash); border-color: var(--accent); }
.present-link .icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.site-header .display-toggle-label { display: none; }
nav.views-nav { display: flex; gap: .25rem; }
nav.views-nav a {
  position: relative; white-space: nowrap; text-decoration: none; font-size: .9375rem;
  padding: .55rem .7rem; border-radius: var(--radius); color: var(--ink-soft);
}
nav.views-nav a:hover { color: var(--ink); background: var(--accent-wash); }
nav.views-nav a[aria-current="page"] { color: var(--accent-strong); text-shadow: .3px 0 0 currentColor, -.3px 0 0 currentColor; } /* gras simulé : rien ne bouge d’une page à l’autre */
nav.views-nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: .7rem; right: .7rem; bottom: .2rem;
  height: 2px; background: var(--accent); border-radius: 1px;
}
.nav-short { display: none; }
@media (max-width: 1379px) {
  .nav-long { display: none; }
  .nav-short { display: inline; }
}
@media (max-width: 959px) {
  .site-header { flex-wrap: wrap; }
  nav.views-nav { order: 3; width: 100%; }
}
@media (max-width: 559px) {
  .site-header { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .site-header .site-brand { font-size: 1rem; gap: .45rem; }
  .site-mark { width: 26px; height: 26px; }
  .site-menu-label { display: none; }
  .present-link span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .site-tools .present-link { padding: 0 .55rem; }
  .site-header .display-toggle { padding: 0 .45rem; }
  .site-menu-toggle { padding: 0 .5rem; }
}
/* Hors du parcours (accueil, crédits…), la première étape devient le départ, en bleu.
   Sur le parcours, c'est l'étape en cours qui porte cette pastille. */
.nav-start { display: none; }
nav.views-nav:not(:has([aria-current])) a:first-child,
nav.views-nav a[aria-current="page"] {
  background: var(--accent); color: #fff; border-radius: 999px; padding-inline: 1rem; text-shadow: none;
}
nav.views-nav:not(:has([aria-current])) a:first-child { font-weight: 700; }
nav.views-nav:not(:has([aria-current])) a:first-child:hover, nav.views-nav a[aria-current="page"]:hover { background: var(--accent-strong); color: #fff; }
nav.views-nav a[aria-current="page"]::after { display: none; }
nav.views-nav:not(:has([aria-current])) a:first-child .nav-start { display: inline; }
nav.views-nav:not(:has([aria-current])) a:first-child :is(.nav-long, .nav-short) { display: none; }
@media (max-width: 1199px) { .nav-start-more { display: none; } }

/* Téléphone : les quatre étapes tiennent sur une ligne. */
@media (max-width: 479px) {
  nav.views-nav { gap: 0; justify-content: space-between; overflow-x: auto; scrollbar-width: none; }
  nav.views-nav a { padding-inline: .3rem; font-size: .8125rem; }
  nav.views-nav:not(:has([aria-current])) a:first-child, nav.views-nav a[aria-current="page"] { padding-inline: .65rem; }
  nav.views-nav a[aria-current="page"]::after { left: .3rem; right: .3rem; }
}

/* ---------- Barre « revenir, continuer », en bas des quatre étapes ---------- */

.step-bar {
  position: sticky; bottom: 0; z-index: 700;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem;
  padding: 8px max(20px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: var(--sheet); border-top: 1px solid var(--rule-strong); font-size: .9375rem; line-height: 1.25;
}
.step-bar .step-prev, .step-bar .step-next {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; padding: .4rem 1.1rem; min-width: 0;
  border: 1px solid var(--rule-strong); border-radius: 999px; color: var(--ink); text-decoration: none;
}
.step-bar .step-prev { justify-self: start; }
.step-bar .step-next { justify-self: end; background: var(--accent); border-color: var(--accent); color: #fff; }
.step-bar .step-prev:hover { background: var(--accent-wash); }
.step-bar .step-next:hover { background: var(--accent-strong); color: #fff; }
.step-verb { font-weight: 700; }
.step-count { color: var(--ink-soft); white-space: nowrap; }
@media (max-width: 899px) { .step-name { display: none; } }
@media (max-width: 479px) { .step-bar { gap: .4rem; padding-inline: 12px; } .step-bar .step-prev, .step-bar .step-next { padding-inline: .8rem; } .step-count { font-size: .8125rem; } }
@media print { nav.views-nav, .step-bar { display: none; } }

/* ---------- Menu du site (créé par js/site-menu.js) ---------- */

.site-menu { position: relative; display: inline-flex; flex: none; }
.site-menu-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
  min-width: 36px; min-height: 36px; padding: 0 .7rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); cursor: pointer;
  font: inherit; font-size: .875rem; font-weight: 600;
}
.site-menu-toggle .icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.site-menu-toggle:hover, .site-menu-toggle[aria-expanded="true"] { background: var(--accent-wash); border-color: var(--accent); }
.site-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 900;
  width: min(19rem, calc(100vw - 32px)); max-height: min(80vh, 36rem); overflow: auto;
  padding: .4rem; background: var(--sheet); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 10px; box-shadow: var(--shadow-float);
  font-family: var(--font-ui); font-size: .9375rem; line-height: 1.3; text-align: left;
}
.site-menu-panel ul { list-style: none; margin: 0; padding: 0; }
.site-menu-panel a, .site-menu-panel button {
  display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 40px; padding: .35rem .6rem;
  border: 0; border-radius: var(--radius); background: none; color: var(--ink); text-decoration: none;
  font: inherit; text-align: left; cursor: pointer;
}
/* Les pages de lecture colorent leurs liens en bleu : le menu garde l'encre du texte. */
.site-menu-panel a, .site .site-menu-panel a, .site .site-menu-panel a:hover { color: var(--ink); }
.site-menu-panel a:hover, .site-menu-panel button:hover, .site-menu-panel a:focus-visible, .site-menu-panel button:focus-visible { background: var(--accent-wash); }
.site-menu-panel a[aria-current="page"] { font-weight: 700; color: var(--accent-strong); }
.site-menu-panel .icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-soft); }
.site-menu-panel a[aria-current="page"] .icon { color: var(--accent); }
.site-menu-sep { margin-top: .3rem; padding-top: .3rem; border-top: 1px solid var(--rule); }
.site-menu-head { padding: .5rem .6rem .2rem; font-size: .75rem; font-weight: 700; letter-spacing: .04em; color: var(--ink-soft); }
.site-menu-panel a.site-menu-start, .site .site-menu-panel a.site-menu-start, .site .site-menu-panel a.site-menu-start:hover {
  min-height: 48px; margin-bottom: .2rem; background: var(--accent); color: #fff; font-weight: 700; font-size: 1rem;
}
.site-menu-panel a.site-menu-start:hover, .site-menu-panel a.site-menu-start:focus-visible { background: var(--accent-strong); }
.site-menu-panel a.site-menu-start .icon { color: #fff; }
@media print { .site-menu { display: none; } }

/* ---------- Panneau « Affichage » (créé par js/display.js) et réglages d'accessibilité ----------
   Les réglages sont des attributs data-* sur <html>, posés par js/display-boot.js avant le rendu. */

.display-menu { position: relative; display: inline-flex; }
.display-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
  min-width: 36px; min-height: 32px; padding: 0 .6rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); cursor: pointer;
  font-weight: 700; font-size: .875rem; line-height: 1;
}
.display-toggle-label { font-weight: 600; }
.display-toggle:hover, .display-toggle[aria-expanded="true"] { background: var(--accent-wash); border-color: var(--accent); }
.display-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 900;
  width: min(21rem, calc(100vw - 32px)); max-height: min(80vh, 40rem); overflow: auto;
  padding: .9rem 1rem 1rem;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 10px; box-shadow: var(--shadow-float);
  font-family: var(--font-ui); font-size: .9375rem; line-height: 1.4; text-align: left;
}
.display-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.display-panel .display-head h2 { margin: 0; font-family: var(--font-ui); font-size: 1.0625rem; font-weight: 700; line-height: 1.3; letter-spacing: 0; }
.display-close {
  width: 32px; height: 32px; border: 0; border-radius: var(--radius); background: none;
  font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--ink-soft);
}
.display-close:hover { background: var(--accent-wash); color: var(--ink); }
/* Une ligne par réglage : le nom à gauche (légende flottante), les choix en boutons à droite. */
.display-row { display: flow-root; margin: 0; padding: .35rem 0; border: 0; border-top: 1px solid var(--rule); }
.display-row legend { float: left; width: 6.75rem; padding: 0; margin: 0; line-height: 36px; font-weight: 600; font-size: .8125rem; color: var(--ink-soft); }
.display-options { display: flex; margin-left: 6.75rem; }
.display-opt {
  position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 36px;
  border: 1px solid var(--rule-strong); margin-left: -1px; background: var(--sheet); color: var(--ink); cursor: pointer;
}
.display-opt:first-child { margin-left: 0; border-radius: var(--radius) 0 0 var(--radius); }
.display-opt:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.display-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.display-opt:hover { background: var(--accent-wash); }
.display-opt:has(input:checked) { z-index: 1; background: var(--accent); border-color: var(--accent); color: #fff; }
.display-opt:has(input:focus-visible) { z-index: 2; outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.display-glyph { display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-weight: 600; }
.display-glyph svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.display-glyph .fill { fill: currentColor; stroke: none; }
.display-glyph .fill.is-soft { opacity: .35; }
.is-size-100 { font-size: .75rem; } .is-size-115 { font-size: .875rem; } .is-size-130 { font-size: 1rem; } .is-size-150 { font-size: 1.1875rem; }
.is-font-roboto { font-family: "Roboto", system-ui, sans-serif; }
.is-font-hyperlegible { font-family: "Atkinson Hyperlegible", system-ui, sans-serif; }
.is-font-system { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.is-links-underline u { text-underline-offset: 2px; }
.display-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--rule); }
.display-foot p { font-size: .8125rem; color: var(--ink-faint); }
.display-reset {
  min-height: 36px; padding: .3rem .8rem; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--sheet); cursor: pointer; white-space: nowrap;
}
.display-reset:hover { border-color: var(--ink-soft); }

/* Taille du texte : tout le site est en rem. */
:root[data-size="115"] { font-size: 115%; }
:root[data-size="130"] { font-size: 130%; }
:root[data-size="150"] { font-size: 150%; }

/* Police */
:root[data-font="hyperlegible"] {
  --font-display: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-ui: "Atkinson Hyperlegible", system-ui, sans-serif;
}
:root[data-font="system"] {
  --font-display: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Contraste renforcé : encre noire, filets marqués, accent plus sombre, liens soulignés. */
:root[data-contrast="high"] {
  --paper: #ffffff;
  --sheet: #ffffff;
  --ink: #000000;
  --ink-soft: #1c1f22;
  --ink-faint: #2f3439;
  --rule: #6b7178;
  --rule-strong: #2f3439;
  --accent: #003f80;
  --distinct: #05583c;
  --accent-strong: #002a57;
  --accent-wash: #dce9fb;
  --gold-ink: #6b3000;
}
:root[data-contrast="high"] a { text-decoration-thickness: 2px; }
:root[data-contrast="high"] :focus-visible { outline: 3px solid #000; box-shadow: 0 0 0 6px #ffd400; }

/* Espacement élargi (valeurs du critère WCAG 1.4.12). */
:root[data-spacing="wide"] body { line-height: 1.8; letter-spacing: .06em; word-spacing: .16em; }
:root[data-spacing="wide"] p { margin-bottom: .4em; }

/* Liens toujours soulignés */
:root[data-links="underline"] a,
:root[data-contrast="high"] main a,
:root[data-contrast="high"] footer a { text-decoration: underline !important; text-underline-offset: .18em; }

/* Animations réduites, à la demande du visiteur (le réglage du système est traité dans css/style.css). */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important;
}


@media print { .lang-switch { display: none; } }

/* ---------- Liens externes ----------
   Ils ouvrent un nouvel onglet (target="_blank") : une flèche le montre, une mention le dit aux lecteurs d'écran. */

a[target="_blank"]::after {
  content: "\2197"; display: inline-block; margin-left: .15em; font-size: .85em; line-height: 1; text-decoration: none;
}
:lang(en) a[target="_blank"]::after { content: "\2197" / " (opens in a new tab)"; }
:lang(fr) a[target="_blank"]::after { content: "\2197" / " (nouvel onglet)"; }
:lang(es) a[target="_blank"]::after { content: "\2197" / " (se abre en una pestaña nueva)"; }

/* ---------- « Connu par » des événements (frise, page des dates) ----------
   Distinct de la précision de la date : l'archéologie reconstitue, la tradition raconte après coup. */

.basis-tag {
  display: inline-block; padding: 0 .35rem; border: 1px solid var(--rule-strong); border-radius: 3px;
  font-family: var(--font-ui); font-size: .6875rem; font-weight: 600; letter-spacing: .03em; line-height: 1.45;
  text-transform: uppercase; vertical-align: .1em; color: var(--ink-soft); white-space: nowrap;
}
.basis-tag.is-ecrits { border-color: var(--accent); color: var(--accent); }
.basis-tag.is-archeologie { border-color: var(--gold); background: var(--gold-wash); color: var(--gold-ink); }
.basis-tag.is-tradition { border-style: dashed; font-style: italic; }

/* Téléphone : les panneaux « Affichage » et « Menu » s'ouvrent sur toute la largeur, sous l'en-tête. */
@media (max-width: 559px) {
  .display-panel, .site-menu-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; max-height: calc(100dvh - 80px); }
}
