/* ==========================================================================
   Pedeaux Family Archive
   Archival warm palette. Mobile-first. No framework.
   ========================================================================== */

:root {
  /* Paper & ink */
  --paper:        #f7f3ea;
  --paper-2:      #f1ebde;
  --paper-3:      #e8e0cf;
  --card:         #fffdf8;
  --ink:          #1c1815;
  --ink-2:        #4a423a;
  --ink-3:        #7d7266;
  --rule:         #d8cdb8;
  --rule-soft:    #e6dcc9;

  /* Accents */
  --oxblood:      #7a2e2e;
  --oxblood-lite: #a24545;
  --gold:         #a8873f;
  --sea:          #3d5a6c;

  /* Evidence */
  --ev-verified:  #4a6b45;
  --ev-confirm:   --gold;
  --ev-inferred:  #8a6a3a;

  /* Branch hues */
  --b-pedeaux:    #7a2e2e;
  --b-aucoin:     #3d5a6c;
  --b-gaiennie:   #6b5a8a;
  --b-brunetti:   #8a5a2b;
  --b-franovich:  #2f6b63;
  --b-moizant:    #7d6a3f;
  --b-larmann:    #55603f;
  --b-wellmeyer:  #6b4a52;

  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --maxw: 1180px;
  --radius: 3px;
  --shadow: 0 1px 2px rgba(28,24,21,.06), 0 6px 20px rgba(28,24,21,.05);
  --shadow-lg: 0 2px 6px rgba(28,24,21,.08), 0 18px 50px rgba(28,24,21,.12);
  --panel-w: 460px;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 12% 8%,  rgba(168,135,63,.05), transparent 42%),
    radial-gradient(circle at 88% 72%, rgba(122,46,46,.045), transparent 46%);
  background-attachment: fixed;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; letter-spacing: .002em; }
p { margin: 0 0 1em; }
a { color: var(--oxblood); text-underline-offset: .18em; text-decoration-thickness: .06em; }
a:hover { color: var(--oxblood-lite); }
img { max-width: 100%; height: auto; display: block; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sr-only {
  position: absolute; 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: -999px; top: 0; z-index: 200;
  background: var(--ink); color: var(--paper); padding: 10px 16px;
}
.skip-link:focus { left: 8px; top: 8px; }

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

/* ── Masthead ─────────────────────────────────────────────────────────── */

.masthead {
  position: sticky; top: 0; z-index: 60;
  background: rgba(247,243,234,.92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule-soft);
}
.masthead__inner {
  display: flex; align-items: center; gap: 16px;
  min-height: 58px;
}
.masthead__mark {
  font-family: var(--serif); font-size: 1.15rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.masthead__mark span { color: var(--oxblood); }
.masthead__nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.masthead__nav a {
  font-size: .8rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none; padding: 8px 10px; border-radius: var(--radius);
}
.masthead__nav a:hover { background: var(--paper-3); color: var(--ink); }
@media (max-width: 720px) { .masthead__nav a { display: none; } .masthead__nav a.always { display: inline-block; } }

/* ── Hero ─────────────────────────────────────────────────────────────── */

.hero { padding: 68px 0 46px; border-bottom: 1px solid var(--rule-soft); }
.hero__eyebrow {
  font-size: .74rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 1.02; margin-bottom: .28em; font-weight: 500;
}
.hero h1 em { font-style: italic; color: var(--oxblood); }
.hero__lede {
  font-family: var(--serif); font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  line-height: 1.5; color: var(--ink-2); max-width: 62ch;
}
.hero__stats {
  display: flex; flex-wrap: wrap; gap: 14px 40px; margin-top: 34px;
  padding-top: 26px; border-top: 1px solid var(--rule-soft);
}
.stat__n { font-family: var(--serif); font-size: 2rem; line-height: 1; color: var(--oxblood); display: block; }
.stat__l { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-top: 6px; display: block; }

/* ── Section furniture ────────────────────────────────────────────────── */

.section { padding: 62px 0; border-bottom: 1px solid var(--rule-soft); }
.section:last-of-type { border-bottom: 0; }
.section__label {
  font-size: .74rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 12px;
}
.section h2 { font-size: clamp(1.8rem, 4.4vw, 2.6rem); font-weight: 500; margin-bottom: .35em; }
.section__intro { font-family: var(--serif); font-size: 1.16rem; color: var(--ink-2); max-width: 68ch; }

/* ── Controls ─────────────────────────────────────────────────────────── */

.controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 26px 0 8px; padding: 14px; background: var(--paper-2);
  border: 1px solid var(--rule-soft); border-radius: var(--radius);
}
.controls__search {
  flex: 1 1 220px; min-width: 0;
  font: inherit; font-size: .92rem; padding: 9px 12px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
}
.controls__search::placeholder { color: var(--ink-3); }
.btn {
  font: inherit; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 14px; border: 1px solid var(--rule); background: var(--card);
  color: var(--ink-2); border-radius: var(--radius); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--paper-3); color: var(--ink); }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ── Tree ─────────────────────────────────────────────────────────────── */

.tree { margin-top: 26px; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.tree > ul { padding-left: 0; }

/* connector spine */
.tree ul ul::before {
  content: ''; position: absolute; left: 0; top: -14px; bottom: 18px;
  border-left: 1px solid var(--rule);
}
.tree li { position: relative; margin: 10px 0 0; }
.tree ul ul > li::before {
  content: ''; position: absolute; left: -22px; top: 26px; width: 18px;
  border-top: 1px solid var(--rule);
}

.node {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--card);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--branch, var(--rule));
  border-radius: var(--radius);
  padding: 11px 13px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.node:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.node[aria-current="true"] { border-color: var(--oxblood); box-shadow: 0 0 0 2px rgba(122,46,46,.14), var(--shadow-lg); }
.node.is-dim { opacity: .34; }

.node__toggle {
  width: 22px; height: 22px; flex: none; margin-top: 2px;
  border: 1px solid var(--rule); border-radius: 50%; background: var(--paper-2);
  color: var(--ink-2); font-size: .82rem; line-height: 1;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.node__toggle:hover { background: var(--paper-3); }
.node__toggle.is-leaf { visibility: hidden; }

.node__body { min-width: 0; }
.node__name { font-family: var(--serif); font-size: 1.12rem; font-weight: 600; line-height: 1.25; }
.node__name .sur { text-transform: uppercase; letter-spacing: .03em; font-size: .92em; }
.node__meta { font-size: .82rem; color: var(--ink-3); margin-top: 2px; }
.node__rel {
  font-size: .68rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 3px; display: block;
}
.node__tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }

.pill {
  font-size: .64rem; letter-spacing: .09em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; border: 1px solid currentColor;
  white-space: nowrap;
}
.pill--verified { color: var(--ev-verified); }
.pill--confirm  { color: var(--gold); }
.pill--inferred { color: #8a6a3a; }
.pill--origin   { color: var(--sea); border-style: dashed; }
.pill--branch   { color: var(--branch, var(--ink-3)); }

.node__chev { color: var(--ink-3); font-size: 1rem; margin-top: 3px; }

.tree li.is-collapsed > ul { display: none; }

/* Eight generations of nesting would strangle the deep cards on a phone.
   Tighten the indent and the connector geometry together so they stay aligned. */
@media (max-width: 720px) {
  .tree ul { padding-left: 13px; }
  .tree ul ul > li::before { left: -13px; width: 10px; }
  .node { padding: 10px 11px; gap: 8px; }
  .node__name { font-size: 1.04rem; }
}
@media (max-width: 420px) {
  .tree ul { padding-left: 9px; }
  .tree ul ul > li::before { left: -9px; width: 7px; }
}

/* ── Detail panel ─────────────────────────────────────────────────────── */

.panel {
  position: fixed; inset: 0 0 0 auto; width: min(var(--panel-w), 100%);
  background: var(--card); border-left: 1px solid var(--rule);
  box-shadow: -12px 0 44px rgba(28,24,21,.14);
  transform: translateX(101%); transition: transform .26s cubic-bezier(.4,0,.2,1);
  z-index: 90; display: flex; flex-direction: column;
}
.panel.is-open { transform: none; }
.panel__head {
  padding: 20px 22px 16px; border-bottom: 1px solid var(--rule-soft);
  display: flex; gap: 12px; align-items: flex-start;
  border-top: 4px solid var(--branch, var(--oxblood));
}
.panel__title { flex: 1; min-width: 0; }
.panel__title h3 { font-size: 1.6rem; margin: 0 0 4px; font-weight: 500; }
.panel__dates { font-size: .9rem; color: var(--ink-3); }
.panel__close {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--paper-2); color: var(--ink-2);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.panel__close:hover { background: var(--paper-3); }
.panel__body { padding: 20px 22px 40px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.panel__portrait { margin: 0 0 18px; }
.panel__portrait img {
  width: 100%; border: 1px solid var(--rule); border-radius: var(--radius);
  filter: sepia(.12) contrast(1.02);
}
.panel__portrait figcaption { font-size: .78rem; color: var(--ink-3); margin-top: 7px; font-style: italic; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 5px 14px; margin: 0 0 18px; font-size: .92rem; }
.kv dt { color: var(--ink-3); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; padding-top: 3px; }
.kv dd { margin: 0; }

.panel h4 {
  font-family: var(--sans); font-size: .74rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--gold); margin: 26px 0 10px; font-weight: 600;
}

.record {
  border: 1px solid var(--rule-soft); border-left: 2px solid var(--gold);
  background: var(--paper-2); border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 12px;
}
.record__title { font-weight: 600; font-size: .92rem; margin-bottom: 2px; }
.record__cite { font-size: .76rem; color: var(--ink-3); margin-bottom: 9px; font-family: var(--mono); }
.record__text {
  font-family: var(--serif); font-size: 1.02rem; line-height: 1.55;
  color: var(--ink); margin: 0;
}
.record__hl {
  margin: 10px 0 0; padding-top: 9px; border-top: 1px dashed var(--rule);
  font-size: .88rem; color: var(--oxblood);
}

.note {
  font-size: .9rem; color: var(--ink-2); background: var(--paper-2);
  border: 1px dashed var(--rule); border-radius: var(--radius); padding: 12px 14px;
}

.srclist { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.srclist li { margin-bottom: 6px; }

.scrim {
  position: fixed; inset: 0; background: rgba(28,24,21,.32);
  opacity: 0; pointer-events: none; transition: opacity .26s; z-index: 80;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

@media (max-width: 620px) {
  .panel { inset: auto 0 0 0; width: 100%; height: 88vh; border-left: 0; border-top: 1px solid var(--rule); border-radius: 12px 12px 0 0; transform: translateY(101%); }
  .panel.is-open { transform: none; }
  .panel__head { border-radius: 12px 12px 0 0; }
}

/* ── Streams ──────────────────────────────────────────────────────────── */

.streams { display: grid; gap: 14px; margin-top: 30px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stream {
  background: var(--card); border: 1px solid var(--rule-soft);
  border-top: 3px solid var(--branch, var(--rule)); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stream h3 { font-size: 1.3rem; margin-bottom: 2px; }
.stream__origin { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.stream p { font-size: .93rem; color: var(--ink-2); margin: 0; }

/* ── Prose ────────────────────────────────────────────────────────────── */

.prose { max-width: 68ch; }
.prose p { font-family: var(--serif); font-size: 1.12rem; line-height: 1.72; }
.prose h3 { font-size: 1.5rem; margin-top: 1.9em; }
.pull {
  font-family: var(--serif); font-style: italic; font-size: 1.2rem;
  border-left: 2px solid var(--oxblood); padding: 4px 0 4px 20px;
  margin: 26px 0; color: var(--ink-2);
}

.corrections { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.corrections li {
  background: var(--card); border: 1px solid var(--rule-soft); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.corrections .was { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.corrections .now { font-family: var(--serif); font-size: 1.1rem; margin-top: 3px; }
.corrections .why { font-size: .9rem; color: var(--ink-2); margin-top: 6px; }

/* ── Footer ───────────────────────────────────────────────────────────── */

.foot { padding: 44px 0 60px; font-size: .88rem; color: var(--ink-3); }
.foot a { color: var(--ink-2); }
.foot__rule { height: 1px; background: var(--rule-soft); margin-bottom: 28px; }

/* ── Print ────────────────────────────────────────────────────────────── */

@media print {
  .masthead, .controls, .panel, .scrim, .node__toggle, .node__chev { display: none !important; }
  body { background: #fff; }
  .node { break-inside: avoid; box-shadow: none; }
  .tree li.is-collapsed > ul { display: block !important; }
}
