:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #23201c;
  --muted: #55504a;
  --accent: #7a4d2b;      /* warm brown, 5.7:1 on surface */
  --accent-ink: #ffffff;
  --border: #e2dbd0;
  --focus: #1a5b8a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(35, 32, 28, .08), 0 8px 24px rgba(35, 32, 28, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --surface: #262320;
    --ink: #f2ede6;
    --muted: #c3bbb0;
    --accent: #d9a066;    /* 6.1:1 on dark surface */
    --accent-ink: #201a12;
    --border: #38332d;
    --focus: #8ec7f0;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.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: 8px; top: -48px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .6rem 1rem;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 10;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; }

a { color: var(--accent); }
a:focus-visible,
summary:focus-visible,
details:focus-within > summary {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Header ---- */
.site-header {
  text-align: center;
  padding: clamp(2rem, 5vw, 4rem) 1.25rem 1.25rem;
  max-width: 48rem;
  margin: 0 auto;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .8rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  margin: 0 0 .5rem;
}
.home-link { color: var(--muted); text-decoration: none; }
.home-link:hover { color: var(--accent); }
h1 {
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  line-height: 1.1;
  margin: 0 0 .6rem;
}
.tagline { font-size: 1.1rem; color: var(--muted); margin: 0; }

/* ---- Section nav ---- */
.section-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.section-nav ul {
  list-style: none;
  margin: 0 auto;
  padding: .5rem 1rem;
  max-width: 60rem;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  justify-content: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .95rem;
}
.section-nav a {
  text-decoration: none;
  padding: .35rem .25rem;
  display: inline-block;
  min-height: 24px;
}
.section-nav a:hover { text-decoration: underline; }

/* ---- Main / sections ---- */
main { flex: 1; width: 100%; }
main > section {
  max-width: 52rem;
  margin: 0 auto;
  padding: clamp(1.75rem, 4vw, 3rem) 1.25rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 3.5rem;
}
main > section:last-of-type { border-bottom: 0; }

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  margin: 0 0 .5rem;
}
h3 { font-size: 1.2rem; margin: 1.75rem 0 .5rem; }
.section-intro {
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
  font-size: 1rem;
  margin: 0 0 1.25rem;
}

/* ---- Family tree (descendant fan chart, inline SVG) ---- */
.fanchart-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* A light card so the pastel wedges + dark labels read well in either theme. */
  background: #fbfaf7;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow);
}
.fanchart {
  display: block;
  width: 100%;
  height: auto;
  min-width: 34rem;              /* keep wedges legible; scroll on small screens */
  margin: 0 auto;
  font-family: ui-serif, Georgia, serif;
}
.fanchart text { font-family: ui-serif, Georgia, serif; }
/* Names in the A-Z index and elsewhere */
.person-name { font-weight: 600; }
.person-life { color: var(--muted); font-size: .85em; }

/* ---- Name index ---- */
.name-index-wrap { margin-top: 1.5rem; }
.name-index-wrap > summary {
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  color: var(--accent);
  padding: .4rem 0;
}
.name-index {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  columns: 2 14rem;
  column-gap: 2rem;
  font-size: .95rem;
}
.name-index li { break-inside: avoid; margin: 0 0 .3rem; }

/* ---- Timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.event {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}
.event:first-child { border-top: 0; }
.event-year {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  color: var(--accent);
}
.event-body h3 { margin: 0 0 .3rem; font-size: 1.1rem; }
.event-body p { margin: 0; }
@media (max-width: 32rem) {
  .event { grid-template-columns: 1fr; gap: .25rem; }
}

/* ---- Ken Records document ---- */
.doc-download { margin: 1rem 0 1.5rem; }
.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  text-decoration: none;
  padding: .7rem 1.2rem;
  border-radius: var(--radius);
  min-height: 44px;
}
.button:hover { filter: brightness(1.08); }
.doc-excerpt {
  margin: 0;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
  font-style: italic;
}
.doc-excerpt p { margin: 0 0 .75rem; }
.doc-attrib { font-style: normal; font-weight: 600; color: var(--muted); margin: 0; }
.doc-note {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .95rem;
  color: var(--muted);
}

/* ---- Gallery ---- */
.gallery {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}
.gallery figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.gallery img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
.gallery figcaption {
  padding: .75rem 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .9rem;
  color: var(--muted);
}
.ai-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .12rem .5rem;
  border-radius: 999px;
  margin-right: .5rem;
  vertical-align: middle;
}

/* ---- Graves ---- */
.graves {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
.graves li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.grave-name { font-weight: 700; }
.grave-place, .grave-detail {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .9rem;
  color: var(--muted);
}

/* ---- Obituary / in memoriam ---- */
.obituary {
  max-width: 40rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}
.obituary p { margin: 0 0 1rem; }
.obituary p:first-child { font-size: 1.05rem; }
.obituary p:last-child { margin-bottom: 0; }

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 1.75rem 1.25rem;
  color: var(--muted);
  font-size: .9rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  border-top: 1px solid var(--border);
}
.site-footer p { margin: .3rem 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
