:root {
  --navy: #1a365d;
  --navy-dark: #0f2744;
  --indigo: #2c5282;
  --gold: #c9a227;
  --gold-soft: #f6e7b2;
  --cream: #faf7f2;
  --paper: #ffffff;
  --ink: #1a202c;
  --muted: #4a5568;
  --border: #e2e8f0;
  --success: #276749;
  --danger: #c53030;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(15, 39, 68, 0.08);
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --focus: #dd6b20;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(201, 162, 39, 0.12), transparent 60%),
    radial-gradient(900px 380px at 100% 0%, rgba(44, 82, 130, 0.10), transparent 55%),
    var(--cream);
  line-height: 1.65;
}
a { color: var(--indigo); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--navy); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
img { max-width: 100%; height: auto; }
.container { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }
.visually-hidden,
.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: 0.75rem;
  top: -3rem;
  z-index: 1000;
  background: var(--gold);
  color: var(--navy-dark);
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
}
.page-title {
  font-family: var(--serif);
  color: var(--navy);
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy) 55%, var(--indigo));
  color: #fff;
  border-bottom: 4px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 0;
}
.brand {
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: min(100%, 16rem);
}
.brand-mark {
  color: var(--gold);
  font-size: 1.25rem;
  line-height: 1;
}
.brand-title {
  display: block;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-tagline {
  display: block;
  margin-top: 0.1rem;
  opacity: 0.85;
  font-size: 0.86rem;
}
.nav-toggle {
  display: none;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
}
.nav a {
  color: #edf2f7;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.nav a:hover { color: var(--gold-soft); }
.footer-heading {
  color: #fff;
  font-family: var(--serif);
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  font-weight: 700;
}
.search-form {
  display: flex;
  gap: 0.35rem;
}
.search-form input {
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  min-width: 12rem;
  font: inherit;
}
.search-form button {
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy-dark);
  font-weight: 700;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

/* Hero */
.hero {
  padding: 2.5rem 0 1.5rem;
}
.hero-card {
  background: var(--paper);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2.25rem);
  border: 1px solid var(--border);
  display: grid;
  gap: 1.5rem;
}
@media (min-width: 860px) {
  .hero-card { grid-template-columns: 1.4fr 1fr; align-items: center; }
}
.hero h2 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.2;
  margin: 0 0 0.75rem;
  color: var(--navy);
}
.hero p { margin: 0 0 1rem; color: var(--muted); font-size: 1.05rem; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.stat {
  background: linear-gradient(180deg, #f7fafc, #edf2f7);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border);
}
.stat strong {
  display: block;
  font-size: 1.6rem;
  color: var(--navy);
  font-family: var(--serif);
}
.stat span { color: var(--muted); font-size: 0.85rem; }

/* Buttons */
.btn {
  display: inline-block;
  background: var(--navy);
  color: #fff !important;
  text-decoration: none !important;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  font-weight: 700;
  border: 0;
  cursor: pointer;
}
.btn:hover { background: var(--indigo); }
.btn-secondary {
  background: transparent;
  color: var(--navy) !important;
  border: 2px solid var(--navy);
}
.btn-secondary:hover { background: var(--navy); color: #fff !important; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Layout sections */
.section { padding: 1.5rem 0 2rem; }
.section h2 {
  font-family: var(--serif);
  color: var(--navy);
  margin: 0 0 1rem;
  font-size: 1.55rem;
}
.grid-2 {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 860px) {
  .grid-2 { grid-template-columns: 2fr 1fr; }
}
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card h3 { margin-top: 0; font-family: var(--serif); color: var(--navy); }

/* County grid */
.county-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}
.county-chip {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  text-decoration: none;
  color: var(--navy);
  font-weight: 600;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.county-chip strong { display: block; }
.chip-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.county-chip:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: var(--shadow);
  color: var(--navy-dark);
}

/* Schematic SC map */
.sc-map {
  position: relative;
  background: linear-gradient(180deg, #0f2744, #1a365d 55%, #2c5282);
  color: #fff;
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.08);
}
.sc-map-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
}
.sc-map-header .meta { color: rgba(255,255,255,0.78); }
.sc-map-outline {
  position: absolute;
  right: -1rem;
  bottom: -1rem;
  width: min(280px, 45%);
  opacity: 0.9;
  pointer-events: none;
  color: var(--gold-soft);
}
.sc-map-grid {
  display: grid;
  gap: 0.45rem;
  position: relative;
  z-index: 1;
}
.sc-map-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}
.sc-map-cell {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(246, 231, 178, 0.35);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  min-width: 4.6rem;
  text-align: center;
  backdrop-filter: blur(2px);
}
.sc-map-cell:hover {
  background: var(--gold);
  color: var(--navy-dark);
  border-color: var(--gold);
}

/* Content / prose */
.prose {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
}
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--serif);
  color: var(--navy);
  line-height: 1.25;
  font-weight: 700;
}
.prose h2 { font-size: 1.45rem; margin: 1.75rem 0 0.75rem; }
.prose h3,
.prose .content-section-title {
  font-size: 1.2rem;
  margin: 1.75rem 0 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--gold-soft);
}
.prose p {
  margin: 0 0 1.1rem;
}
.prose p + p {
  margin-top: 0;
}
.prose a {
  font-weight: 600;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.prose a.link-dead {
  color: #9b2c2c;
  text-decoration-style: dashed;
}
.prose a.wayback-fallback {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-left: 0.25rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  white-space: nowrap;
}
.prose a.wayback-fallback:hover {
  background: var(--gold-soft);
  color: var(--navy-dark);
  border-color: var(--gold);
}
.prose strong { color: var(--navy-dark); }
.prose .address-block {
  background: #f7fafc;
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 0 0 1.25rem;
  line-height: 1.55;
  color: var(--muted);
}
.prose .address-block a {
  display: inline-block;
  margin-bottom: 0.25rem;
}
.prose .resource-list,
.prose .town-list {
  list-style: none;
  margin: 0 0 1.35rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.prose .resource-list li {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  line-height: 1.45;
}
.prose .resource-list li:hover {
  border-color: #cbd5e0;
  box-shadow: 0 4px 14px rgba(15, 39, 68, 0.06);
}
.prose .resource-list a {
  text-decoration: none;
}
.prose .resource-list a:hover {
  text-decoration: underline;
}
.prose .town-list {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.4rem;
}
.prose .town-list li {
  background: linear-gradient(180deg, #fff, #f7fafc);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.95rem;
  color: var(--navy);
  font-weight: 600;
}
.prose br {
  content: "";
}

/* County page */
.county-article { padding: 1.5rem 1.5rem 1.75rem; }
.county-header h1 {
  font-family: var(--serif);
  color: var(--navy);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 0.35rem;
  line-height: 1.2;
}
.fact-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}
.fact-list li {
  background: #f7fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.fact-label {
  display: inline-block;
  min-width: 7.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-right: 0.35rem;
}
.topic-callout {
  margin: 1.25rem 0 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid #f0e0a0;
  background: linear-gradient(180deg, #fffdf5, #faf7f2);
}
.topic-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}
.topic-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(201, 162, 39, 0.25);
}
.topic-list li:last-child { border-bottom: 0; }
.topic-list a {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--navy);
}
.topic-list a:hover { text-decoration: underline; color: var(--indigo); }
.lead {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}
.research-panel {
  margin-top: 1.5rem;
  padding-top: 0.25rem;
}
.county-enriched-intro {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.link-note {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
a.link-archived {
  color: #744210;
}
.county-body { margin-top: 1rem; }
.county-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.breadcrumb a { text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }
.aside-title {
  font-family: var(--serif);
  color: var(--navy);
  font-size: 1.15rem;
  margin: 0 0 0.85rem;
}
.county-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.45rem;
}
.county-chip.is-active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.sticky-card {
  position: sticky;
  top: 1rem;
}
.meta { color: var(--muted); font-size: 0.92rem; margin-bottom: 1rem; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.list-plain li:last-child { border-bottom: 0; }
.list-plain a { font-weight: 600; text-decoration: none; }
.list-plain a:hover { text-decoration: underline; }
.badge {
  display: inline-block;
  background: var(--gold-soft);
  color: var(--navy-dark);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Footer */
.site-footer {
  margin-top: 2rem;
  background: var(--navy-dark);
  color: #cbd5e0;
  padding: 2rem 0;
}
.site-footer a { color: var(--gold-soft); }
.footer-grid {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 760px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr; }
}
.site-footer h3 {
  color: #fff;
  font-family: var(--serif);
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 0.35rem 0; }

/* Admin */
.admin-body { background: #edf2f7; min-height: 100vh; }
.admin-header {
  background: var(--navy-dark);
  color: #fff;
  padding: 0.9rem 0;
}
.admin-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; }
.admin-nav a { color: #e2e8f0; text-decoration: none; font-weight: 600; }
.admin-nav a:hover { color: var(--gold-soft); }
.admin-main { padding: 1.5rem 0 3rem; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.95rem;
}
.table th { background: #f7fafc; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: linear-gradient(145deg, var(--navy-dark), var(--indigo));
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 0.25rem;
  font-family: var(--serif);
  color: var(--navy);
  font-size: 1.5rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}
.form-group textarea { min-height: 320px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.alert-error { background: #fff5f5; color: var(--danger); border: 1px solid #feb2b2; }
.alert-success { background: #f0fff4; color: var(--success); border: 1px solid #9ae6b4; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Mobile */
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .header-inner { align-items: flex-start; }
  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.35rem 0 0.5rem;
  }
  .nav.is-open { display: flex; }
  .nav a {
    width: 100%;
    padding: 0.45rem 0.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .search-form {
    width: 100%;
  }
  .search-form input { flex: 1; min-width: 0; }
  .brand-tagline { display: none; }
  .sc-map-cell { min-width: 4.1rem; font-size: 0.75rem; }
  .fact-label { min-width: 6rem; display: block; margin-bottom: 0.1rem; }
}

@media (max-width: 520px) {
  .hero .stats { grid-template-columns: 1fr; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn, .btn-secondary { text-align: center; }
}

/* Contact form */
.contact-form .hp-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.contact-form-wrap {
  margin: 1.25rem 0;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f7fafc;
}

/* Glossary */
.glossary dt {
  font-weight: 700;
  color: var(--navy);
  margin-top: 0.85rem;
}
.glossary dd {
  margin: 0.2rem 0 0.55rem;
  color: var(--muted);
}
