/* Stoddard County Genealogy Archive — design system v2
   Warm archival identity, modernized. 100% static, zero external dependencies.
   System font stack only. Layout version switchable via html[data-view]. */

:root {
  --parchment: #f5eeda;
  --parchment-deep: #efe5cc;
  --ink: #2b2118;
  --gold: #b08d3e;
  --gold-deep: #7a5f22;
  --muted: #6b5d4f;
  --card: #fffdf7;
  --gold-soft: #e9dcc0;
  --rule: #d9cba6;
  --shadow-sm: 0 2px 8px rgba(43, 33, 24, 0.06);
  --shadow-md: 0 10px 28px rgba(43, 33, 24, 0.10);
  --radius: 12px;
  --font: "Noto Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--parchment);
  background-image: radial-gradient(ellipse at 50% -10%, #faf5e6 0%, var(--parchment) 55%);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.65;
  font-size: 17px;
}

::selection { background: var(--gold-soft); }

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

/* ---------- Layout ---------- */
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

main { padding-bottom: 3.5rem; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 238, 218, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 3px double var(--gold);
  padding: 1.1rem 0 0.9rem;
  margin-bottom: 2.25rem;
  transition: padding 0.2s ease;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.site-header .masthead {
  font-size: 1.55rem;
  font-weight: bold;
  letter-spacing: 0.03em;
  margin: 0 0 0.15rem;
  color: var(--ink);
  line-height: 1.2;
}
.site-header .masthead-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
  font-style: italic;
}

/* Compact header once scrolled */
body.scrolled .site-header { padding: 0.55rem 0 0.5rem; }
body.scrolled .site-header .masthead { font-size: 1.05rem; }
body.scrolled .site-header .masthead-sub { display: none; }
body.scrolled .view-toggle-label { display: none; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin-top: 0.85rem;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--gold-soft); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--gold);
  font-weight: bold;
}

/* ---------- View toggle (Desktop | Mobile) ---------- */
.view-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  margin-top: 0.15rem;
}
.view-toggle-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.view-toggle .seg {
  display: flex;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.view-toggle button {
  font-family: var(--font);
  font-size: 0.83rem;
  padding: 0.42rem 0.95rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.view-toggle button:hover { color: var(--ink); }
.view-toggle button[aria-pressed="true"] {
  background: var(--gold);
  color: #fff;
  font-weight: bold;
  box-shadow: 0 1px 4px rgba(43, 33, 24, 0.25);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 3px double var(--gold);
  margin-top: 3.5rem;
  padding: 1.75rem 0 3rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fffdf7 0%, #faf3df 100%);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 2.75rem 2.25rem;
  margin-bottom: 2.25rem;
  box-shadow: var(--shadow-md);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft), var(--gold));
  opacity: 0.55;
  pointer-events: none;
}
.hero h1 {
  margin: 0 0 1rem;
  font-size: 2.35rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.hero p:last-child { margin-bottom: 0; }
.hero .lead { font-size: 1.12rem; }

/* ---------- Stat grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2.25rem 0;
}
.stat {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.4rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat .num {
  font-size: 1.7rem;
  font-weight: bold;
  color: var(--ink);
  display: block;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat .lbl {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* ---------- Cards ---------- */
.card-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem;
  margin: 2.25rem 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.6rem;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.card h2, .card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.18rem;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.card .card-cta {
  display: inline-block;
  margin-top: 0.85rem;
  color: var(--gold-deep);
  font-weight: bold;
  font-size: 0.95rem;
}
.card .card-cta::after { content: " →"; }
.card--soon {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}
.card--soon:hover { transform: none; box-shadow: none; }
.card--soon h3 { color: var(--muted); }

/* ---------- Tables ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
caption {
  text-align: left;
  font-style: italic;
  color: var(--muted);
  padding-bottom: 0.5rem;
  background: transparent;
  box-shadow: none;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
thead th {
  border-bottom: 2px solid var(--gold);
  background: rgba(176, 141, 62, 0.08);
  color: var(--ink);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: rgba(176, 141, 62, 0.05); }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: rgba(176, 141, 62, 0.13); }
tbody tr:last-child td { border-bottom: none; }

/* Sortable table hooks */
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th:hover { color: var(--gold-deep); }
table.sortable thead th .sort-ind { color: var(--gold); font-size: 0.8em; }
table.sortable thead th.sorted-asc .sort-ind::after { content: " ▲"; }
table.sortable thead th.sorted-desc .sort-ind::after { content: " ▼"; }

/* ---------- Search input ---------- */
.search-bar { margin: 1.75rem 0; }
.search-bar input[type="search"],
.search-bar input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}
.search-bar input[type="search"]:focus,
.search-bar input[type="text"]:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  box-shadow: var(--shadow-md);
}
.search-hint { color: var(--muted); font-size: 0.88rem; margin-top: 0.45rem; }

/* ---------- Person pages ---------- */
.person-head { margin-bottom: 1.5rem; }
.person-head h1 {
  margin: 0 0 0.3rem;
  font-size: 2.1rem;
  letter-spacing: -0.01em;
}
.person-dates { color: var(--muted); font-style: italic; margin: 0 0 1rem; font-size: 1.05rem; }

dl.record {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.5rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin: 1.75rem 0;
  box-shadow: var(--shadow-sm);
}
dl.record dt {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 0.15rem;
}
dl.record dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Cemetery pages ---------- */
.cemetery-head h1 { margin: 0 0 0.3rem; letter-spacing: -0.01em; }
.cemetery-meta { color: var(--muted); font-style: italic; font-size: 1.02rem; }

/* ---------- Generic ---------- */
h2.section {
  font-size: 1.4rem;
  border-bottom: 2px solid var(--gold-soft);
  padding-bottom: 0.45rem;
  margin-top: 2.75rem;
  letter-spacing: 0.01em;
}
.lead { font-size: 1.1rem; }
.small { font-size: 0.88rem; color: var(--muted); }
.rule { border: none; border-top: 1px solid var(--rule); margin: 2.25rem 0; }

a { color: var(--gold-deep); text-decoration-thickness: 1px; }
a:visited { color: var(--muted); }
a:hover { color: var(--ink); }

/* ---------- Mobile layout version (user-selected, any screen width) ---------- */
html[data-view="mobile"] body { font-size: 19px; }
html[data-view="mobile"] .wrap { max-width: 100%; }
html[data-view="mobile"] .stat-grid,
html[data-view="mobile"] .card-row { grid-template-columns: 1fr; }
html[data-view="mobile"] dl.record { grid-template-columns: 1fr; }
html[data-view="mobile"] dl.record dt { margin-top: 0.8rem; }
html[data-view="mobile"] dl.record dt:first-child { margin-top: 0; }
html[data-view="mobile"] table { display: block; overflow-x: auto; }
html[data-view="mobile"] .hero { padding: 1.75rem 1.4rem; }
html[data-view="mobile"] .hero h1 { font-size: 1.7rem; }
html[data-view="mobile"] .person-head h1 { font-size: 1.65rem; }
html[data-view="mobile"] .site-nav a { padding: 0.7rem 0; font-size: 1.05rem; }
html[data-view="mobile"] .view-toggle button { min-height: 44px; padding: 0.6rem 1.05rem; }
html[data-view="mobile"] th,
html[data-view="mobile"] td { padding: 0.7rem 0.6rem; font-size: 0.95rem; }
html[data-view="mobile"] .search-bar input[type="search"],
html[data-view="mobile"] .search-bar input[type="text"] { font-size: 1.15rem; padding: 1rem 1.1rem; }

/* ---------- Narrow screens: the desktop version is responsive and collapses
   gracefully; only an explicit mobile choice forces the roomy layout. ---------- */
@media (max-width: 700px) {
  body { font-size: 16px; }
  .hero { padding: 1.6rem 1.35rem; }
  .hero h1 { font-size: 1.55rem; }
  .stat-grid,
  .card-row { grid-template-columns: 1fr; }
  dl.record { grid-template-columns: 1fr; }
  dl.record dt { margin-top: 0.75rem; }
  dl.record dt:first-child { margin-top: 0; }
  th,
  td { padding: 0.55rem 0.45rem; font-size: 0.88rem; }
  .site-header .masthead { font-size: 1.3rem; }
  table { display: block; overflow-x: auto; }
}

/* Small screens: stack header-top when a preference IS set too */
@media (max-width: 560px) {
  .header-top { flex-direction: column; }
  .view-toggle { margin-top: 0.6rem; }
}

/* ---------- A–Z browse list ---------- */
.browse-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1.5rem;
}
.browse-letters a {
  padding: 0.3rem 0.7rem;
  border: 1px solid #d8cdb2;
  border-radius: 999px;
  background: var(--card);
  text-decoration: none;
  font-size: 0.9rem;
}
.browse-letters a:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.browse-list {
  columns: 2;
  column-gap: 2.5rem;
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
}
.browse-list li {
  break-inside: avoid;
  margin: 0 0 0.4rem;
}
.browse-list a { text-decoration: none; }
.browse-list a:hover { text-decoration: underline; }
.browse-list .dates {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.timeline {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
}
.timeline li {
  border-left: 2px solid var(--gold);
  margin: 0 0 0.9rem;
  padding: 0 0 0 1rem;
}
.timeline .tl-date {
  display: block;
  font-weight: bold;
  font-size: 0.9rem;
}
.timeline .tl-detail {
  display: block;
  margin: 0.15rem 0;
}
.timeline .tl-meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}
@media (max-width: 700px) {
  .browse-list { columns: 1; }
}

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