/* Hallmark · macrostructure: Long Document (archive familiale) · genre: editorial
 * tone: patrimonial chaleureux · anchor hue: terre cuite 28° + vert baobab 145°
 * paper: light · display: roman-serif (Lora) · pre-emit critique: P5 H5 E5 S5 R4 V5
 */
@import url("tokens.css");

/* ═══════════════════════════════ SOCLE ═══════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-feature-settings: "kern" 1, "liga" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
/* Grain de papier sur toute la page, à peine perceptible. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--grain); opacity: 0.5; mix-blend-mode: multiply;
}
body > * { position: relative; z-index: 1; }

h1, h2, h3, h4 {
  font-family: var(--font-display); font-style: normal; font-weight: 500;
  line-height: var(--leading-tight); letter-spacing: -0.015em;
  margin: 0; overflow-wrap: anywhere; min-width: 0; color: var(--ink);
}
h1 { font-weight: 500; }
p { margin: 0 0 var(--s-sm); max-width: var(--measure); }
a { color: var(--terra-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--terra); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-xs); }
::selection { background: var(--gold-soft); }
img, svg { max-width: 100%; }
/* Les porte-icônes fixent la taille ; le SVG s'y conforme au lieu de s'étirer.
   Ce sont des <span> : sans display, leur largeur serait ignorée. */
.wordmark__mark, .colophon__mark, .gate__seal, .village-card__mark,
.empty__art, .branch-card__art { display: block; }
.wordmark__mark > svg, .colophon__mark > svg, .gate__seal > svg,
.village-card__mark > svg, .empty__art > svg, .branch-card__art > svg,
.btn > svg, .bottomnav a > svg {
  width: 100%; height: 100%; display: block;
}
.btn > svg { width: 17px; height: 17px; flex: none; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s-lg) 0; }
button { font: inherit; }

.mono { font-family: var(--font-mono); font-size: 0.86em; letter-spacing: -0.02em; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: var(--s-sm); top: -4rem; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: var(--s-2xs) var(--s-sm); border-radius: var(--r-sm);
  transition: top var(--d-fast) var(--ease-out);
}
.skip-link:focus { top: var(--s-sm); }

/* Petit label en capitales, signature éditoriale du site. */
.eyebrow {
  display: inline-block; font-family: var(--font-body);
  font-size: var(--text-2xs); font-weight: 600;
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--ink-faint);
}
.eyebrow--terra { color: var(--terra); }
.eyebrow--gold  { color: var(--gold-deep); }

/* ═══════════════════════════ EN-TÊTE ═══════════════════════════ */
.masthead {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d-mid) var(--ease-out),
              background var(--d-mid) var(--ease-out);
}
.masthead.is-scrolled {
  border-bottom-color: var(--rule);
  background: color-mix(in oklab, var(--paper) 96%, transparent);
  box-shadow: 0 1px 0 rgba(40, 35, 31, 0.03), 0 8px 24px -18px rgba(40, 35, 31, 0.4);
}
.masthead__bar {
  display: flex; align-items: center; gap: var(--s-md);
  height: var(--header-h); padding: 0 var(--s-md);
  max-width: var(--shell-wide); margin: 0 auto;
}
.wordmark {
  display: flex; align-items: center; gap: var(--s-2xs);
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.wordmark__mark { width: 32px; height: 32px; flex: none; color: var(--forest); display: block; }
.wordmark__text { display: flex; flex-direction: column; line-height: 1.1; }
.wordmark__text b {
  font-family: var(--font-display); font-size: var(--text-md);
  font-weight: 600; letter-spacing: -0.015em;
}
.wordmark__text span {
  font-size: var(--text-2xs); letter-spacing: var(--tracking-wide);
  text-transform: uppercase; color: var(--ink-faint); font-weight: 500;
}
.masthead__nav { display: flex; gap: 1px; margin-left: auto; align-items: center; }
.navlink {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: var(--s-2xs) var(--s-xs); border-radius: var(--r-sm);
  color: var(--ink-soft); text-decoration: none;
  font-size: var(--text-sm); font-weight: 500; position: relative;
  transition: color var(--d-fast) var(--ease-out);
}
.navlink::after {
  content: ""; position: absolute; left: var(--s-xs); right: var(--s-xs); bottom: 6px;
  height: 1.5px; background: var(--terra); border-radius: 2px;
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--d-mid) var(--ease-out);
}
.navlink:hover, .navlink.is-hover { color: var(--ink); }
.navlink:hover::after { transform: scaleX(1); }
.navlink[aria-current="page"] { color: var(--terra-deep); font-weight: 600; }
.navlink[aria-current="page"]::after { transform: scaleX(1); }
.masthead__tools { display: flex; align-items: center; gap: var(--s-2xs); margin-left: var(--s-2xs); }

/* ═══════════════════════════ COMMANDES ═══════════════════════════ */
.btn {
  --bg: var(--paper-card); --fg: var(--ink); --bd: var(--rule-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2xs);
  min-height: 42px; padding: 0 var(--s-md);
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--bd); border-radius: var(--r-pill);
  font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
  text-decoration: none; cursor: pointer; box-shadow: var(--sh-inset);
  transition: background var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out),
              transform var(--d-fast) var(--ease-out),
              box-shadow var(--d-mid) var(--ease-out);
}
.btn:hover, .btn.is-hover { --bg: var(--paper-raised); --bd: var(--ink-ghost); box-shadow: var(--sh-paper); }
.btn:active, .btn.is-active { transform: translateY(1px); box-shadow: none; }
.btn:disabled, .btn.is-disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn[data-state="loading"] { color: var(--ink-faint); pointer-events: none; }
.btn[data-state="loading"]::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--ink-ghost); border-top-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn--primary { --bg: var(--terra); --fg: var(--on-terra); --bd: var(--terra-deep); }
.btn--primary:hover, .btn--primary.is-hover { --bg: var(--terra-deep); --bd: var(--terra-deep); }
.btn--forest { --bg: var(--forest); --fg: var(--on-forest); --bd: var(--forest-deep); }
.btn--forest:hover { --bg: var(--forest-deep); }
.btn--ghost { --bg: transparent; --bd: transparent; --fg: var(--ink-soft); box-shadow: none; }
.btn--ghost:hover { --bg: var(--paper-sand); }
.btn--sm { min-height: 34px; padding: 0 var(--s-sm); font-size: var(--text-xs); }
.btn--icon { min-width: 42px; padding: 0; }
.btn--sm.btn--icon { min-width: 34px; }
.btn.nav-toggle { display: none; }

.field { display: flex; flex-direction: column; gap: var(--s-3xs); }
.field > label, .field > span { font-size: var(--text-sm); color: var(--ink-soft); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: var(--s-2xs) var(--s-sm);
  background: var(--paper-raised); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: var(--r-md);
  font: inherit; font-size: var(--text-base);
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out);
}
.input:hover { border-color: var(--ink-ghost); }
.input:focus-visible { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(43, 74, 120, 0.12); outline: none; }
.input:disabled { background: var(--paper-sand); opacity: 0.7; }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 96px; resize: vertical; line-height: var(--leading-body); }

/* ═══════════════════════════ STATUTS ═══════════════════════════ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--s-2xs); border-radius: var(--r-pill);
  font-size: var(--text-2xs); font-weight: 500; line-height: 1.6;
  white-space: nowrap; border: 1px solid transparent;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.pill[data-s="CONFIRMED"]       { color: var(--st-confirmed); background: var(--st-confirmed-bg); border-color: color-mix(in oklab, var(--st-confirmed) 20%, transparent); }
.pill[data-s="HIGHLY_PROBABLE"] { color: var(--st-highly);    background: var(--st-highly-bg);    border-color: color-mix(in oklab, var(--st-highly) 18%, transparent); }
.pill[data-s="PROBABLE"]        { color: var(--st-probable);  background: var(--st-probable-bg);  border-color: color-mix(in oklab, var(--st-probable) 18%, transparent); }
.pill[data-s="UNCERTAIN"]       { color: var(--st-uncertain); background: var(--st-uncertain-bg); border-color: color-mix(in oklab, var(--st-uncertain) 24%, transparent); }
.pill[data-s="DISPUTED"]        { color: var(--st-disputed);  background: var(--st-disputed-bg);  border-color: color-mix(in oklab, var(--st-disputed) 24%, transparent); }
.pill[data-s="REJECTED"],
.pill[data-s="SUPERSEDED"]      { color: var(--st-rejected);  background: var(--st-rejected-bg); }

/* ═══════════════════════════ MISE EN PAGE ═══════════════════════════ */
.shell { max-width: var(--shell-max); margin: 0 auto; padding: var(--s-xl) var(--s-md) var(--s-3xl); }
.shell--wide { max-width: var(--shell-wide); }
.shell--narrow { max-width: 860px; }
.band { padding: var(--s-2xl) 0; }
.band--sand { background: var(--paper-sand); }
.band--warm { background: var(--paper-warm); }
.band--ink { background: var(--forest-deep); color: var(--on-dark); }
.band--ink h2, .band--ink h3 { color: var(--on-dark-strong); }
.band--ink .muted { color: var(--on-dark-muted); }

.section-head { margin-bottom: var(--s-lg); max-width: var(--measure); }
.section-head h2 { font-size: var(--text-3xl); margin-top: var(--s-2xs); }
.section-head p { color: var(--ink-muted); margin-top: var(--s-2xs); }

.page-head { margin-bottom: var(--s-lg); }
.page-head h1 { font-size: var(--text-3xl); margin-top: var(--s-2xs); }
.page-head p { color: var(--ink-muted); margin-top: var(--s-2xs); }

.card {
  background: var(--paper-card); border: 1px solid var(--rule);
  border-radius: var(--r-lg); padding: var(--s-md); box-shadow: var(--sh-inset);
}
.card + .card { margin-top: var(--s-md); }
.card__title {
  font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600;
  margin-bottom: var(--s-xs); display: flex; align-items: baseline;
  gap: var(--s-2xs); flex-wrap: wrap;
}
.card__title small { font-family: var(--font-body); font-size: var(--text-xs); color: var(--ink-faint); font-weight: 400; }
.panel { composes: card; }

.stack { display: flex; flex-direction: column; gap: var(--s-md); }
.row { display: flex; gap: var(--s-2xs); align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: var(--s-sm); align-items: baseline; justify-content: space-between; flex-wrap: wrap; }

/* ═══════════════════════════ HERO D'ACCUEIL ═══════════════════════════ */
.hero {
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--rule);
  background:
    radial-gradient(120% 90% at 78% 8%, rgba(178, 145, 85, 0.13), transparent 55%),
    radial-gradient(90% 70% at 8% 100%, rgba(52, 75, 60, 0.10), transparent 60%),
    linear-gradient(178deg, var(--paper-warm), var(--paper) 62%);
}
.hero__inner {
  max-width: var(--shell-wide); margin: 0 auto;
  padding: var(--s-2xl) var(--s-md) var(--s-xl);
  display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: var(--s-2xl); align-items: center; min-height: min(78vh, 700px);
}
.hero__title {
  font-size: var(--text-hero); line-height: 0.98; letter-spacing: -0.035em;
  margin-top: var(--s-sm); font-weight: 500;
}
.hero__title em {
  font-style: normal; color: var(--terra-deep);
  position: relative; white-space: nowrap;
}
.hero__title em::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0.06em; height: 0.055em;
  background: var(--gold); opacity: 0.5; border-radius: 2px;
  transform: scaleX(0); transform-origin: left;
  animation: underline-in var(--d-vslow) var(--ease-out) 600ms forwards;
}
@keyframes underline-in { to { transform: scaleX(1); } }
.hero__lede {
  font-size: var(--text-md); color: var(--ink-soft);
  max-width: var(--measure-narrow); margin-top: var(--s-md);
  line-height: 1.62;
}
.hero__actions { display: flex; gap: var(--s-2xs); flex-wrap: wrap; margin-top: var(--s-lg); }
.hero__meta {
  margin-top: var(--s-lg); padding-top: var(--s-md);
  border-top: 1px solid var(--rule); display: flex; gap: var(--s-lg); flex-wrap: wrap;
}
.hero__meta div { display: flex; flex-direction: column; gap: 2px; }
.hero__meta b {
  font-family: var(--font-display); font-size: var(--text-xl);
  font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.hero__meta span { font-size: var(--text-2xs); letter-spacing: var(--tracking-wide);
                   text-transform: uppercase; color: var(--ink-faint); font-weight: 500; }

.hero__art { position: relative; display: grid; place-items: center; min-height: 380px; }
.hero__art svg { width: 100%; height: auto; max-height: 560px; overflow: visible; }

/* Le tracé de l'arbre se révèle lentement, une seule fois. */
.grow-line {
  stroke-dasharray: var(--len, 400); stroke-dashoffset: var(--len, 400);
  animation: grow var(--d-vslow) var(--ease-out) forwards;
}
@keyframes grow { to { stroke-dashoffset: 0; } }
.fade-in { opacity: 0; animation: fade var(--d-slow) var(--ease-out) forwards; }
@keyframes fade { to { opacity: 1; } }

/* ═══════════════════════════ LIGNÉE ═══════════════════════════ */
.lineage { display: grid; gap: var(--s-md); }
.lineage__track {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-md); align-items: stretch; position: relative;
}
.lineage__step {
  position: relative; background: var(--paper-card); border: 1px solid var(--rule);
  border-radius: var(--r-lg); padding: var(--s-md); text-decoration: none; color: inherit;
  box-shadow: var(--sh-inset);
  transition: transform var(--d-mid) var(--ease-out), box-shadow var(--d-mid) var(--ease-out),
              border-color var(--d-fast) var(--ease-out);
}
.lineage__step:hover { transform: translateY(-3px); box-shadow: var(--sh-raise); border-color: var(--gold); }
.lineage__step::after {
  content: ""; position: absolute; right: calc(var(--s-md) / -2 - 7px); top: 50%;
  width: 14px; height: 14px; transform: translateY(-50%) rotate(45deg);
  border-top: 1.5px solid var(--rule-strong); border-right: 1.5px solid var(--rule-strong);
}
.lineage__step:last-child::after { display: none; }
.lineage__gen {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--gold-deep); letter-spacing: 0.1em;
}
.lineage__name { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; margin: var(--s-3xs) 0; }
.lineage__note { font-size: var(--text-sm); color: var(--ink-muted); margin: 0; }

/* ═══════════════════════════ CHIFFRES ═══════════════════════════ */
.figures {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px; background: var(--rule);
  border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden;
}
@media (min-width: 720px)  { .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .figures { grid-template-columns: repeat(9, minmax(0, 1fr)); } }
.figure { background: var(--paper-card); padding: var(--s-md) var(--s-sm); text-align: left; }
.figure b {
  display: block; font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.4vw, 2.25rem); font-weight: 500; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.figure span {
  display: block; margin-top: var(--s-2xs); font-size: 0.625rem;
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--ink-faint); font-weight: 500;
}

/* ═══════════════════════════ CARTES BRANCHES ═══════════════════════════ */
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: var(--s-md); }
.branch-card {
  position: relative; display: flex; flex-direction: column; gap: var(--s-2xs);
  padding: var(--s-md); background: var(--paper-card);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  text-decoration: none; color: inherit; overflow: hidden; box-shadow: var(--sh-inset);
  transition: transform var(--d-mid) var(--ease-out), box-shadow var(--d-mid) var(--ease-out),
              border-color var(--d-fast) var(--ease-out);
}
.branch-card:hover { transform: translateY(-3px); box-shadow: var(--sh-raise); border-color: var(--rule-strong); }
.branch-card__art { position: absolute; right: -12px; top: -8px; width: 132px; height: 112px; opacity: 0.14; pointer-events: none; color: var(--forest); }
.branch-card:hover .branch-card__art { opacity: 0.22; }
.branch-card__gen { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--gold-deep); }
.branch-card h3 { font-size: var(--text-xl); font-weight: 600; }
.branch-card__meta { display: flex; gap: var(--s-sm); flex-wrap: wrap; font-size: var(--text-xs); color: var(--ink-muted); margin-top: auto; padding-top: var(--s-2xs); }
.branch-card__meta b { font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ═══════════════════════════ VILLAGES ═══════════════════════════ */
.village-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: var(--s-md); }
.village-card {
  position: relative; padding: var(--s-md); background: var(--paper-card);
  border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--sh-inset);
  display: flex; flex-direction: column; gap: var(--s-2xs);
  transition: transform var(--d-mid) var(--ease-out), box-shadow var(--d-mid) var(--ease-out);
}
.village-card:hover { transform: translateY(-2px); box-shadow: var(--sh-raise); }
.village-card__mark { width: 26px; height: 26px; color: var(--forest); opacity: 0.75; }
.village-card h3 { font-size: var(--text-lg); font-weight: 600; }
.village-card__variants { font-size: var(--text-xs); color: var(--ink-faint); font-style: italic; }
.village-card__count { margin-top: auto; padding-top: var(--s-2xs); font-size: var(--text-xs); color: var(--ink-muted); }

/* ═══════════════════════════ MÉMOIRE & SOURCES ═══════════════════════════ */
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-md); margin-top: var(--s-lg); }
.flow__step { position: relative; padding-top: var(--s-md); border-top: 2px solid currentColor; }
.flow__step:nth-child(1) { color: var(--wood); }
.flow__step:nth-child(2) { color: var(--gold-deep); }
.flow__step:nth-child(3) { color: var(--terra); }
.flow__step:nth-child(4) { color: var(--forest); }
.flow__n { font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: 0.1em; }
.flow__step h3 { font-size: var(--text-lg); margin: var(--s-3xs) 0 var(--s-2xs); color: var(--ink); }
.flow__step p { font-size: var(--text-sm); color: var(--ink-muted); margin: 0; }
.band--ink .flow__step h3 { color: var(--on-dark-strong); }
.band--ink .flow__step p { color: var(--on-dark-muted); }
.band--ink .flow__step:nth-child(1) { color: var(--on-dark-1); }
.band--ink .flow__step:nth-child(2) { color: var(--on-dark-2); }
.band--ink .flow__step:nth-child(3) { color: var(--on-dark-3); }
.band--ink .flow__step:nth-child(4) { color: var(--on-dark-4); }

/* ═══════════════════════════ LISTES ═══════════════════════════ */
.list { border-top: 1px solid var(--rule); }
.list__item {
  display: grid; grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: var(--s-sm); align-items: center;
  padding: var(--s-xs) var(--s-2xs);
  border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit;
  transition: background var(--d-fast) var(--ease-out), padding-left var(--d-fast) var(--ease-out);
}
.list__item:hover { background: var(--paper-warm); padding-left: var(--s-sm); }
.list__item strong { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.list__meta { font-size: var(--text-xs); color: var(--ink-muted); }

/* Cartes de personnes, quatre densités. */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(232px, 100%), 1fr)); gap: var(--s-sm); }
.pcard {
  display: flex; gap: var(--s-xs); align-items: flex-start;
  padding: var(--s-sm); background: var(--paper-card);
  border: 1px solid var(--rule); border-radius: var(--r-md);
  text-decoration: none; color: inherit; box-shadow: var(--sh-inset);
  transition: transform var(--d-fast) var(--ease-out), box-shadow var(--d-mid) var(--ease-out),
              border-color var(--d-fast) var(--ease-out);
}
.pcard:hover { transform: translateY(-2px); box-shadow: var(--sh-paper); border-color: var(--rule-strong); }
.pcard__mono {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper-sand); color: var(--wood);
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 600;
  border: 1px solid var(--rule-strong);
}
.pcard__body { min-width: 0; flex: 1; }
.pcard__name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); line-height: 1.25; }
.pcard__sub { font-size: var(--text-xs); color: var(--ink-muted); margin-top: 2px; }

/* ═══════════════════════════ FICHE PERSONNE ═══════════════════════════ */
.person-hero {
  background:
    radial-gradient(90% 120% at 92% 0%, rgba(178, 145, 85, 0.14), transparent 58%),
    linear-gradient(180deg, var(--paper-warm), var(--paper));
  border-bottom: 1px solid var(--rule);
}
.person-hero__inner {
  max-width: var(--shell-max); margin: 0 auto;
  padding: var(--s-xl) var(--s-md) var(--s-lg);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--s-md); align-items: center;
}
.person-hero__mono {
  width: 92px; height: 92px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--paper-card); border: 1.5px solid var(--gold);
  font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 500;
  color: var(--wood); box-shadow: var(--sh-paper);
}
.person-hero h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); letter-spacing: -0.03em; }
.person-hero__alias { color: var(--ink-muted); font-size: var(--text-md); font-style: italic; margin-top: 2px; }
.person-hero__facts { display: flex; gap: var(--s-md); flex-wrap: wrap; margin-top: var(--s-xs); font-size: var(--text-sm); color: var(--ink-muted); }
.person-hero__facts b { color: var(--ink-soft); font-weight: 600; }

.person-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--s-md); }

.bio {
  font-family: var(--font-display); font-size: var(--text-lg);
  line-height: 1.62; color: var(--ink-soft); max-width: var(--measure);
  border-left: 2px solid var(--gold); padding-left: var(--s-md);
}

/* Mini-arbre familial de la fiche. */
.kin { display: grid; gap: var(--s-sm); }
.kin__row { display: flex; gap: var(--s-2xs); flex-wrap: wrap; align-items: center; }
.kin__label {
  font-size: var(--text-2xs); letter-spacing: var(--tracking-wide);
  text-transform: uppercase; color: var(--ink-faint); font-weight: 600;
  width: 100%; margin-bottom: 2px;
}
.chip {
  display: inline-flex; align-items: center; gap: var(--s-2xs);
  padding: var(--s-3xs) var(--s-xs) var(--s-3xs) var(--s-3xs);
  background: var(--paper-card); border: 1px solid var(--rule);
  border-radius: var(--r-pill); text-decoration: none; color: inherit;
  font-size: var(--text-sm); transition: border-color var(--d-fast) var(--ease-out),
    background var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out);
}
.chip:hover { border-color: var(--terra); background: var(--paper-raised); transform: translateY(-1px); }
.chip__mono {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper-sand); color: var(--wood);
  font-family: var(--font-display); font-size: var(--text-2xs); font-weight: 600; flex: none;
}
.chip--self { background: var(--gold-soft); border-color: var(--gold); font-weight: 600; }
.chip--rejected { opacity: 0.6; }
.chip--rejected .chip__name { text-decoration: line-through; }

.relation { display: flex; align-items: center; gap: var(--s-2xs); padding: var(--s-3xs) 0; flex-wrap: wrap; }
.relation__role {
  font-size: var(--text-2xs); letter-spacing: var(--tracking-wide);
  text-transform: uppercase; color: var(--ink-faint); min-width: 58px; font-weight: 600;
}
.why {
  margin-left: auto; font-size: var(--text-2xs); background: transparent;
  border: 1px solid var(--rule-strong); border-radius: var(--r-pill);
  padding: 2px var(--s-2xs); color: var(--ink-muted); cursor: pointer;
  transition: border-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out);
}
.why:hover { border-color: var(--terra); color: var(--terra-deep); background: var(--terra-soft); }

/* ═══════════════════════════ PREUVES ═══════════════════════════ */
.evidence {
  border-left: 2px solid var(--gold); padding-left: var(--s-sm);
  margin: var(--s-2xs) 0 var(--s-md);
}
.evidence__head { display: flex; align-items: baseline; gap: var(--s-2xs); flex-wrap: wrap; }
.evidence__src { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.evidence__line { font-size: var(--text-sm); color: var(--ink-muted); }
.confidence { display: inline-flex; align-items: center; gap: var(--s-2xs); font-size: var(--text-2xs); color: var(--ink-faint); }
.confidence__bar { width: 54px; height: 3px; border-radius: 2px; background: var(--paper-deep); overflow: hidden; }
.confidence__bar i { display: block; height: 100%; background: var(--gold-deep); }
.diplomatic {
  font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.75;
  white-space: pre-wrap; background: var(--paper-warm);
  border: 1px solid var(--rule); border-left: 3px solid var(--wood);
  border-radius: var(--r-sm); padding: var(--s-sm); overflow-x: auto;
}
.interpretation { font-size: var(--text-base); color: var(--ink-soft); margin-top: var(--s-2xs); }

/* ═══════════════════════════ ARCHIVES ═══════════════════════════ */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: var(--s-md); }
.thumb {
  display: block; background: var(--paper-card); border: 1px solid var(--rule);
  border-radius: var(--r-sm); overflow: hidden; text-decoration: none; color: inherit;
  box-shadow: var(--sh-paper); transform: rotate(-0.5deg);
  transition: transform var(--d-mid) var(--ease-out), box-shadow var(--d-mid) var(--ease-out);
}
.thumb:nth-child(even) { transform: rotate(0.6deg); }
.thumb:hover { transform: rotate(0deg) translateY(-3px) scale(1.015); box-shadow: var(--sh-lift); }
.thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-deep); }
.thumb figcaption { padding: var(--s-2xs) var(--s-xs) var(--s-xs); font-size: var(--text-xs); color: var(--ink-muted); }
.viewer { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s-md); }
.viewer__image {
  position: relative; background: var(--paper-deep); border: 1px solid var(--rule-strong);
  border-radius: var(--r-md); overflow: hidden; min-height: 320px; box-shadow: var(--sh-paper);
}
.viewer__image img { display: block; width: 100%; height: auto; }

/* ═══════════════════════════ ARBRE ═══════════════════════════ */
.tree-page { display: flex; flex-direction: column; height: calc(100dvh - var(--header-h)); }
.tree-bar {
  display: flex; align-items: center; gap: var(--s-2xs); flex-wrap: wrap;
  padding: var(--s-2xs) var(--s-md);
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper-warm) 92%, transparent);
  backdrop-filter: blur(8px);
}
.tree-bar__group { display: flex; align-items: center; gap: 2px; padding: 2px;
  background: var(--paper-sand); border-radius: var(--r-pill); border: 1px solid var(--rule); }
.tree-bar__group .btn { border-color: transparent; background: transparent; box-shadow: none; min-height: 30px; }
.tree-bar__group .btn[aria-pressed="true"] {
  background: var(--paper-raised); border-color: var(--rule-strong);
  color: var(--terra-deep); font-weight: 600; box-shadow: var(--sh-paper);
}
.tree-bar__sep { width: 1px; height: 22px; background: var(--rule-strong); margin: 0 var(--s-3xs); }
/* En desktop, tous les réglages tiennent sur une ligne ; sur petit écran ils
   se replient derrière un bouton. */
.tree-bar__opts { display: contents; }
.tree-bar label { white-space: nowrap; align-items: center; }
.tree-bar label input[type="checkbox"] { margin: 0; flex: none; }
.tree-bar select.input { max-width: 130px; }
.btn.tree-more { display: none; }
.tree-bar { flex-wrap: nowrap; overflow: visible; }
.tree-bar > * { flex: none; }
.tree-stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: grab;
  background:
    radial-gradient(110% 80% at 15% -10%, rgba(178, 145, 85, 0.10), transparent 55%),
    radial-gradient(90% 70% at 92% 108%, rgba(52, 75, 60, 0.09), transparent 60%),
    var(--paper);
}
.tree-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: var(--grain); opacity: 0.42; mix-blend-mode: multiply;
}
.tree-stage.is-panning { cursor: grabbing; }
.tree-stage svg { display: block; position: relative; z-index: 1; }
.tree-legend {
  position: absolute; left: var(--s-sm); bottom: var(--s-sm); z-index: 5;
  background: color-mix(in oklab, var(--paper-card) 94%, transparent);
  border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: var(--s-2xs) var(--s-xs); font-size: var(--text-2xs);
  display: flex; gap: var(--s-2xs); flex-wrap: wrap;
  max-width: min(600px, calc(100vw - 2rem)); backdrop-filter: blur(8px); box-shadow: var(--sh-paper);
}
.tree-zoom {
  position: absolute; right: var(--s-sm); bottom: var(--s-sm); z-index: 5;
  display: flex; flex-direction: column; gap: 2px;
  background: color-mix(in oklab, var(--paper-card) 94%, transparent);
  border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: 3px; backdrop-filter: blur(8px); box-shadow: var(--sh-paper);
}
.node-card { cursor: pointer; }
.node-card .node-bg { transition: fill var(--d-fast) var(--ease-out); }
.node-card:hover .node-bg { fill: var(--paper-raised); }
.node-card:focus { outline: none; }
.node-card:focus-visible .node-frame { stroke: var(--focus); stroke-width: 2.6; }
.tree-stage[data-focus] .node-card { transition: opacity var(--d-mid) var(--ease-out); }
.tree-stage[data-focus] .node-card:not(.is-kin) { opacity: 0.22; }
.tree-stage[data-focus] .link-path:not(.is-kin) { opacity: 0.14; }
.link-path { transition: opacity var(--d-mid) var(--ease-out); }

/* ═══════════════════════════ ÉTATS ═══════════════════════════ */
.empty {
  padding: var(--s-2xl) var(--s-md); text-align: center;
  display: grid; place-items: center; gap: var(--s-sm);
}
.empty__art { width: 72px; height: 72px; color: var(--rule-strong); }
.empty h3 { font-size: var(--text-xl); }
.empty p { color: var(--ink-muted); max-width: 46ch; margin: 0 auto; }

.skeleton { display: grid; gap: var(--s-sm); }
.sk {
  border-radius: var(--r-md);
  background: linear-gradient(100deg, var(--paper-sand) 28%, var(--paper-warm) 46%, var(--paper-sand) 64%);
  background-size: 220% 100%; animation: sk 1.4s ease-in-out infinite;
}
@keyframes sk { 0% { background-position: 120% 0; } 100% { background-position: -20% 0; } }
.sk--line { height: 13px; }
.sk--title { height: 30px; width: 46%; }
.sk--card { height: 96px; }

/* ═══════════════════════════ DIVERS ═══════════════════════════ */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 520px; }
table.data th, table.data td { text-align: left; padding: var(--s-2xs) var(--s-xs); border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th {
  font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-faint); font-weight: 600;
}
table.data tbody tr:hover { background: var(--paper-warm); }

.toast {
  position: fixed; left: 50%; bottom: var(--s-md); transform: translateX(-50%);
  z-index: 90; background: var(--ink); color: var(--paper);
  padding: var(--s-2xs) var(--s-md); border-radius: var(--r-pill);
  font-size: var(--text-sm); box-shadow: var(--sh-lift); max-width: min(560px, calc(100vw - 2rem));
  animation: toast-in var(--d-mid) var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

dialog.sheet {
  width: min(760px, calc(100vw - 2rem)); max-height: 86dvh; padding: 0;
  border: 1px solid var(--rule-strong); border-radius: var(--r-xl);
  background: var(--paper); color: var(--ink); box-shadow: var(--sh-lift);
}
dialog.sheet::backdrop { background: rgba(40, 35, 31, 0.44); backdrop-filter: blur(3px); }
.sheet__head { display: flex; align-items: baseline; gap: var(--s-sm); padding: var(--s-md) var(--s-md) var(--s-2xs); border-bottom: 1px solid var(--rule); }
.sheet__body { padding: var(--s-md); overflow-y: auto; max-height: 68dvh; }

.gate { min-height: calc(100dvh - var(--header-h)); display: grid; place-items: center; padding: var(--s-lg) var(--s-md); }
.gate__card { width: min(440px, 100%); }
.gate__seal { width: 54px; height: 54px; color: var(--forest); margin-bottom: var(--s-sm); }
.form-error { margin-top: var(--s-2xs); font-size: var(--text-sm); color: var(--danger); display: flex; gap: var(--s-3xs); }

/* ═══════════════════════════ PIED DE PAGE ═══════════════════════════ */
.colophon {
  background: var(--forest-deep); color: var(--on-dark-link);
  padding: var(--s-2xl) var(--s-md) var(--s-xl); margin-top: var(--s-3xl);
}
.colophon__inner { max-width: var(--shell-max); margin: 0 auto; display: grid; gap: var(--s-lg); }
.colophon__top { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s-xl); align-items: start; }
.colophon__mark { width: 40px; height: 40px; color: var(--gold); }
.colophon h2 { font-family: var(--font-display); font-size: var(--text-xl); color: var(--on-dark-strong); font-weight: 500; margin-top: var(--s-2xs); }
.colophon__motto {
  font-family: var(--font-display); font-size: var(--text-md); color: var(--gold);
  letter-spacing: 0.06em; margin-top: var(--s-2xs);
}
.colophon p { color: var(--on-dark-muted); font-size: var(--text-sm); max-width: 54ch; }
.colophon__links { display: flex; gap: var(--s-md); flex-wrap: wrap; }
.colophon__links a { color: var(--on-dark-link); text-decoration: none; font-size: var(--text-sm); border-bottom: 1px solid rgba(216, 222, 213, 0.3); }
.colophon__links a:hover { color: var(--pure-white); border-bottom-color: var(--gold); }
.colophon__base { border-top: 1px solid rgba(216, 222, 213, 0.16); padding-top: var(--s-md); font-size: var(--text-xs); color: var(--on-dark-faint); }

/* ═══════════════════════════ NAVIGATION BASSE (mobile) ═══════════════════════════ */
.bottomnav { display: none; }

/* ═══════════════════════════ RESPONSIVE ═══════════════════════════ */
@media (max-width: 1080px) {
  .hero__inner { grid-template-columns: minmax(0, 1fr); gap: var(--s-lg); min-height: 0; padding-bottom: var(--s-lg); }
  .hero__art { min-height: 300px; order: 2; }
  .person-grid, .viewer { grid-template-columns: minmax(0, 1fr); }
  .colophon__top { grid-template-columns: minmax(0, 1fr); gap: var(--s-md); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
  .tree-bar { flex-wrap: wrap; }
}
@media (max-width: 760px) {
  /* L'en-tête doit tenir sans jamais déborder : le texte du bouton s'efface
     avant le reste, l'icône suffit. */
  .masthead__bar { gap: var(--s-2xs); padding: 0 var(--s-sm); }
  .wordmark__text b { font-size: var(--text-base); }
  .btn.nav-toggle { display: inline-flex; margin-left: auto; }
  .btn.tree-more { display: inline-flex; margin-left: auto; }
  .tree-bar { flex-wrap: nowrap; }
  .tree-bar__opts { display: none; }
  .tree-bar__opts.is-open {
    display: flex; flex-wrap: wrap; gap: var(--s-3xs);
    width: 100%; padding-top: var(--s-2xs); margin-top: var(--s-2xs);
    border-top: 1px solid var(--rule);
  }
  .tree-bar__opts.is-open .tree-bar__sep { display: none; }
  .tree-bar > div:first-child { flex: 1 1 auto !important; }
  .masthead__nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    padding: var(--s-2xs) var(--s-sm) var(--s-sm); margin: 0;
    box-shadow: var(--sh-raise); max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
  }
  .navlink { padding: var(--s-xs) var(--s-2xs); font-size: var(--text-md); border-radius: var(--r-md); }
  .navlink::after { display: none; }
  .navlink[aria-current="page"] { background: var(--paper-sand); }
  .lineage__track { grid-template-columns: minmax(0, 1fr); }
  .lineage__step::after { right: 50%; top: auto; bottom: calc(var(--s-md) / -2 - 7px); transform: translateX(50%) rotate(135deg); }
  .person-hero__inner { grid-template-columns: auto minmax(0, 1fr); }
  .person-hero__inner > .row:last-child { grid-column: 1 / -1; }
  .flow { grid-template-columns: minmax(0, 1fr); }
  .list__item { grid-template-columns: minmax(0, 1fr) auto; }
  .list__item .list__id { display: none; }
  .tree-legend { display: none; }
  .shell { padding: var(--s-lg) var(--s-sm) var(--s-2xl); }
  .hero__inner { padding: var(--s-lg) var(--s-sm) var(--s-md); }
  .colophon { padding: var(--s-xl) var(--s-sm) 5.5rem; }

  /* Navigation basse : les quatre destinations principales, toujours à portée. */
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: color-mix(in oklab, var(--paper) 96%, transparent);
    backdrop-filter: blur(14px); border-top: 1px solid var(--rule);
    padding: 6px var(--s-2xs) calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; min-height: 46px; text-decoration: none;
    color: var(--ink-faint); font-size: var(--text-2xs); font-weight: 500;
    border-radius: var(--r-sm); transition: color var(--d-fast) var(--ease-out);
  }
  .bottomnav a svg { width: 21px; height: 21px; }
  .bottomnav a[aria-current="page"] { color: var(--terra-deep); }
  body { padding-bottom: 0; }
  .tree-page { height: calc(100dvh - var(--header-h) - 58px); }
}
@media (max-width: 520px) {
  .wordmark__text span { display: none; }
  #logoutBtn { min-width: 40px; padding: 0 var(--s-2xs); font-size: 0; gap: 0; }
  #logoutBtn::after {
    content: ""; width: 18px; height: 18px; display: block;
    background: currentColor;
    -webkit-mask: var(--icon-key) center / contain no-repeat;
    mask: var(--icon-key) center / contain no-repeat;
  }
}
@media (max-width: 400px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .hero__meta { gap: var(--s-md); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.1s !important; scroll-behavior: auto !important;
  }
  .grow-line { stroke-dashoffset: 0; }
  .fade-in { opacity: 1; }
  .hero__title em::after { transform: scaleX(1); }
  .branch-card:hover, .thumb:hover, .lineage__step:hover, .pcard:hover, .village-card:hover { transform: none; }
}

@media print {
  .masthead, .tree-bar, .tree-zoom, .why, .btn, .bottomnav, .colophon { display: none !important; }
  body { background: var(--pure-white); }
  body::before { display: none; }
  .card, .branch-card { break-inside: avoid; }
}

/* Le trait de couple et sa marque restent visibles en mode focus. */
.tree-stage[data-focus] .couple-mark { opacity: 0.3; transition: opacity var(--d-mid) var(--ease-out); }
.tree-stage[data-focus] .couple-link.is-kin ~ .couple-mark { opacity: 1; }
.couple-mark { pointer-events: none; }
