/* ==========================================================================
   Manual Barn — consolidated stylesheet (W2 quality-pass rebuild)
   One file, mobile-first, custom properties, responsive at 360/768/1200.
   Replaces the per-page inline <style> blocks that were duplicated across
   the whole site. No visual language change beyond formalizing the
   existing palette/type into tokens and adding the new chrome components
   named in the build plan (topbar, hub-hero, stat-chip, table scroll,
   noscript fallback, skip link). Body copy and data values are untouched
   by this file — CSS only ever targets layout, colour, spacing and type.
   ========================================================================== */

:root {
  /* palette — derived from the site's existing theme colour (#0d2a2e) */
  --ink: #0d2a2e;        /* deep */
  --ink-2: #1f3d42;      /* deep, lighter */
  --teal: #1f6f72;       /* mid */
  --teal-2: #2a8e91;     /* mid, lighter */
  --tint: #e6f0ef;       /* light tint of the theme colour, for bands/chips */
  --tint-2: #d7e9e7;     /* slightly deeper tint, for chip borders */
  --muted: #5a6f73;      /* neutral grey-teal for secondary text */
  --bg: #f6f1e7;         /* warm neutral background */
  --bg-2: #efe6d2;       /* warm neutral, deeper */
  --card: #ffffff;
  --accent: #c8533a;     /* existing secondary/accent hue, unchanged */
  --accent-2: #e08362;
  --line: #e2d8c3;
  --focus: #0b5fff;      /* visible focus ring, distinct from link colour */

  --radius: 10px;
  --radius-sm: 8px;
  --max: 1180px;

  --sp-1: 0.5rem;
  --sp-2: 1rem;
  --sp-3: 1.5rem;
  --sp-4: 2rem;
  --sp-5: 3rem;

  /* type scale */
  --fs-h1: 2.2rem;
  --fs-h1-hero: 2.4rem;
  --fs-h2: 1.5rem;
  --fs-h3: 1.15rem;
  --fs-body: 1.05rem;
  --fs-small: 0.85rem;
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}
.container { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* skip-to-content link: hidden until keyboard-focused */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  background: var(--ink); color: #fff; padding: 10px 16px;
  z-index: 100; border-radius: 0 0 6px 0; font-family: "Inter", sans-serif; font-size: 14px;
}
.skip-link:focus { left: 0; top: 0; }

h1, h2, h3, h4 {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700; line-height: 1.2; color: var(--ink);
}
h1 { font-size: var(--fs-h1); margin: 0 0 12px; letter-spacing: -0.5px; }
h2 { font-size: var(--fs-h2); margin: 2.25rem 0 14px; }
h3 { font-size: var(--fs-h3); margin: 24px 0 10px; }
small, .meta, .fs-small { font-size: var(--fs-small); }

/* ---------- topbar (source line) ---------- */
.topbar {
  background: var(--ink-2);
  color: #cfe6e4;
  font-family: "Inter", sans-serif;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 6px 12px;
}

/* ---------- header / nav ---------- */
.nav {
  background: var(--ink);
  color: #f6f1e7;
  border-bottom: 3px solid var(--accent);
}
.nav-inner {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 20px; max-width: var(--max); margin: 0 auto;
}
.brand {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 800; font-size: 22px; color: #f6f1e7; letter-spacing: -0.3px;
  display: flex; align-items: center; gap: 10px;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 4px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent);
}
.brand .mark svg { width: 20px; height: 20px; display: block; }
.nav a { color: #f6f1e7; opacity: 0.85; font-size: 15px; }
.nav a:hover { opacity: 1; }
.nav .spacer { flex: 1; }

.search-form { display: flex; gap: 0; flex: 1; max-width: 420px; }
.search-form input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); border-radius: 4px 0 0 4px; font-family: inherit; font-size: 15px;
}
.search-form button {
  padding: 9px 16px; border: 0; background: var(--accent); color: #fff;
  cursor: pointer; border-radius: 0 4px 4px 0; font-weight: 600;
}
.search-form button:hover { background: var(--accent-2); }

/* ---------- breadcrumbs ---------- */
.breadcrumbs { font-size: var(--fs-small); color: var(--muted); margin: 18px 0 6px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--ink); }

/* ---------- ad slot ---------- */
.ad-slot {
  background: #fffaf1; border: 1px dashed var(--line); color: var(--muted);
  text-align: center; padding: 14px; font-family: "Inter", sans-serif;
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; margin: 24px 0;
}

/* ---------- grid / card / pill ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line);
  padding: 16px; border-radius: var(--radius);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(13,42,46,0.08); }
.card:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.card .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.card .title {
  font-family: "Playfair Display", Georgia, serif; font-size: 17px;
  font-weight: 700; color: var(--ink); display: block; margin-bottom: 4px;
}
.pill {
  display: inline-block; padding: 3px 9px; font-size: 11px;
  font-family: "Inter", sans-serif; text-transform: uppercase;
  letter-spacing: 0.08em; background: var(--bg-2); color: var(--ink-2);
  border-radius: 3px; margin-right: 4px; margin-bottom: 4px;
  border: 1px solid transparent;
}
.pill.accent { background: var(--accent); color: #fff; }
.pill.teal { background: var(--teal); color: #fff; }

/* ---------- category / brand hero-band (hub pages) ---------- */
.hub-hero {
  background: linear-gradient(135deg, var(--tint) 0%, var(--bg) 70%);
  border-bottom: 1px solid var(--line);
  padding: 28px 0 22px;
  margin-bottom: 8px;
}
.hub-hero-inner {
  max-width: var(--max); margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: 1fr; gap: 20px; align-items: center;
}
.hub-hero.has-img .hub-hero-inner { grid-template-columns: 1.4fr 1fr; }
.hub-hero .breadcrumbs { margin-top: 0; }
.hub-hero h1 { margin-bottom: 6px; }
.hub-hero .hub-hero-media img {
  display: block; width: 100%; height: 180px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(13,42,46,0.10);
}
.hub-hero .hub-hero-media { max-width: 100%; }

/* stat chips (home hero) — numbers already printed elsewhere on the page */
.stat-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
.stat-chip {
  background: rgba(246,241,231,0.12);
  border: 1px solid rgba(246,241,231,0.35);
  color: #f6f1e7;
  border-radius: 999px;
  padding: 6px 14px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.hub-hero .stat-chip {
  background: #fff; border-color: var(--tint-2); color: var(--ink-2);
}

/* ---------- layout (content + sidebar) ---------- */
.layout { display: grid; grid-template-columns: 1fr 280px; gap: 32px; margin-top: 24px; }
.sidebar { font-size: 14px; }
.sidebar h4 {
  font-family: "Inter", sans-serif; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--muted); margin: 0 0 8px;
}
.sidebar ul { list-style: none; padding: 0; margin: 0 0 24px; }
.sidebar li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.sidebar li a { display: flex; justify-content: space-between; gap: 8px; }
.sidebar li .count { color: var(--muted); font-size: 12px; flex: none; }

/* ---------- home hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--ink) 0%, var(--teal) 100%);
  color: #f6f1e7; padding: 40px 20px;
}
.hero-inner {
  max-width: var(--max); margin: 0 auto;
  display: grid; grid-template-columns: 1fr; gap: 24px; align-items: center;
}
.hero h1 { color: #f6f1e7; font-size: var(--fs-h1-hero); }
.hero p { font-size: 1.05rem; opacity: 0.92; max-width: 520px; }
.hero img { border-radius: var(--radius); }
.hero .search-form { max-width: none; margin-top: 18px; }
.hero .search-form input { font-size: 16px; padding: 13px 16px; }
.hero .search-form button { padding: 13px 20px; font-size: 15px; }

/* ---------- footer ---------- */
.footer { background: var(--ink); color: #c5beaf; padding: 36px 20px; margin-top: 48px; font-size: 14px; }
.footer-inner {
  max-width: var(--max); margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px;
}
.footer h4 {
  color: #f6f1e7; margin: 0 0 10px; font-family: "Inter", sans-serif;
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em;
}
.footer a { color: #c5beaf; display: block; padding: 3px 0; }
.footer a:hover, .footer a:focus-visible { color: #f6f1e7; }
.footer-bar {
  text-align: center; color: #8a8270; padding-top: 20px; margin-top: 20px;
  border-top: 1px solid #2a3d40; font-size: 13px;
}

/* ---------- pdf viewer ---------- */
.pdf-frame { width: 100%; height: 480px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); }

/* ---------- prose ---------- */
.prose p { margin: 0 0 14px; }
.prose { max-width: 70ch; }

/* ---------- data tables ---------- */
.table-scroll { overflow-x: auto; margin: 16px 0; -webkit-overflow-scrolling: touch; }
table.kv { border-collapse: collapse; width: 100%; max-width: 540px; }
table.kv th, table.kv td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.kv th { background: var(--bg-2); font-family: "Inter", sans-serif; font-weight: 600; width: 40%; }
table.kv tr:nth-child(even) td { background: rgba(31,111,114,0.05); }
table.kv th:first-child, table.kv td:first-child { position: sticky; left: 0; }

/* ---------- alpha nav / empty state ---------- */
.alpha-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 24px; }
.alpha-nav a { padding: 4px 9px; background: #fff; border: 1px solid var(--line); border-radius: 3px; font-family: "Inter", sans-serif; font-size: 13px; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- noscript fallback ---------- */
.noscript-box {
  background: #fffaf1; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin: 16px 0; color: var(--ink-2); font-size: 14px;
}

/* ==========================================================================
   Responsive breakpoints — mobile-first. Base rules above target 360px+,
   which is treated as the design floor (no horizontal scroll, no clipped
   nav, tap targets stay usable) all the way up through this file.
   ========================================================================== */

@media (max-width: 480px) {
  .nav-inner { gap: 12px; }
  .search-form { order: 3; max-width: none; flex-basis: 100%; }
  .hero { padding: 28px 16px; }
  .hero h1 { font-size: 1.8rem; }
  .pdf-frame { height: 360px; }
  .footer-inner { grid-template-columns: 1fr; }
}

/* tablet, 768px+ */
@media (min-width: 768px) {
  .layout { grid-template-columns: 1fr 280px; }
  .hero-inner { grid-template-columns: 1.2fr 1fr; }
  .hub-hero.has-img .hub-hero-inner { grid-template-columns: 1.4fr 1fr; }
  .pdf-frame { height: 640px; }
}

/* below tablet: stack layout and hero */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hub-hero .hub-hero-inner { grid-template-columns: 1fr !important; }
}

/* desktop, 1200px+ */
@media (min-width: 1200px) {
  .pdf-frame { height: 760px; }
  .grid.cols-3 { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .card:hover { transition: none; transform: none; }
}

/* ---------- print ---------- */
@media print {
  .nav, .topbar, .footer, .hero, .hub-hero, .ad-slot, .search-form, .sidebar,
  .pdf-frame, #save-btn, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a { color: #000; text-decoration: underline; }
  a[href^="/"]::after, a[href^="http"]::after { content: ""; }
  .container { max-width: 100%; padding: 0; }
  .layout { display: block; }
  table.kv { max-width: 100%; }
  table.kv th:first-child, table.kv td:first-child { position: static; }
}
