/* ============================================================
   EOIR Case Data Explorer — Institutional Gravitas Theme
   A prestigious legal data portal, not a tech dashboard.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */

:root {
  /* Deep institutional palette */
  --navy: #0D1B2A;
  --navy-mid: #1B2A4A;
  --navy-light: #243B63;
  --navy-muted: #3A506B;
  --brass: #B8860B;
  --brass-light: #D4A843;
  --brass-pale: #E8D5A3;
  --brass-glow: rgba(184, 134, 11, 0.12);

  /* Paper & ink */
  --parchment: #F5F1EB;
  --paper: #FDFCFA;
  --cream: #F0EBE1;
  --ink: #1A1A1A;
  --ink-light: #3D3D3D;
  --ink-muted: #757068;
  --ink-faint: #A9A49C;
  --rule: #D5CDBE;
  --rule-light: #E8E3DA;

  /* Status */
  --affirm: #2D6A4F;
  --deny: #9B2226;

  /* Typography */
  --serif: 'Cormorant Garamond', 'Georgia', serif;
  --sans: 'DM Sans', 'Helvetica Neue', sans-serif;
  --mono: 'IBM Plex Mono', 'Menlo', monospace;

  /* Spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --s9: 96px;

  /* Elevation */
  --lift-1: 0 1px 3px rgba(13, 27, 42, 0.06), 0 1px 2px rgba(13, 27, 42, 0.04);
  --lift-2: 0 4px 12px rgba(13, 27, 42, 0.08), 0 1px 3px rgba(13, 27, 42, 0.04);
  --lift-3: 0 8px 24px rgba(13, 27, 42, 0.1), 0 2px 6px rgba(13, 27, 42, 0.04);

  --radius: 3px;
}

/* ── Reset & Base ──────────────────────────────────────────── */

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--parchment);
  color: var(--ink);
  line-height: 1.65;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
}

/* Skip-to-content (accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--s4);
  background: var(--navy);
  color: #fff;
  padding: var(--s2) var(--s4);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  z-index: 200;
  border: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: var(--s2);
  color: #fff;
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* Focus-visible for keyboard navigation */
a:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* Selection color */
::selection {
  background: rgba(184, 134, 11, 0.18);
  color: var(--navy);
}

/* Page load fade-in */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ── Typography ────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  color: var(--navy);
  line-height: 1.25;
  margin: 0 0 var(--s4) 0;
  font-weight: 700;
}

h1 {
  font-size: 2.4rem;
  letter-spacing: -0.02em;
  border-left: 4px solid var(--brass);
  padding-left: var(--s4);
}

h2 {
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

p { margin: 0 0 var(--s4) 0; }

/* ── Links ─────────────────────────────────────────────────── */

a {
  color: var(--brass);
  text-decoration: none;
  transition: color 0.2s ease;
  border-bottom: 1px solid transparent;
}

a:hover {
  color: var(--brass-light);
  border-bottom-color: var(--brass);
  text-decoration: none;
}

/* ── Navigation ────────────────────────────────────────────── */

nav.navbar {
  background: var(--navy);
  padding: 0;
  position: relative;
  z-index: 100;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(59, 80, 107, 0.25) 0%, transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--s4) var(--s6);
}

.site-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  border: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.site-title:hover {
  color: var(--brass-light);
  border: none;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--s6);
}

.navbar-links a {
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: var(--s1) 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.25s;
}

.navbar-links a:hover,
.navbar-links a[aria-current="page"] {
  color: var(--brass-light);
  border-bottom-color: var(--brass);
}

/* Gold accent bar */
.accent-stripe {
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--brass) 0%,
    var(--brass-light) 35%,
    var(--brass-pale) 60%,
    var(--brass-light) 80%,
    var(--brass) 100%
  );
  opacity: 0.85;
}

/* Mobile nav toggle */
.navbar-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  padding: var(--s2);
  cursor: pointer;
}

.navbar-toggle-icon {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  position: relative;
}

.navbar-toggle-icon::before,
.navbar-toggle-icon::after {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  position: absolute;
  left: 0;
}

.navbar-toggle-icon::before { top: -6px; }
.navbar-toggle-icon::after { top: 6px; }

/* ── Loading Bar ──────────────────────────────────────────── */

@keyframes loadingSlide {
  0% { width: 0; }
  50% { width: 70%; }
  100% { width: 95%; }
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--brass);
  z-index: 9999;
  animation: loadingSlide 2s ease-out forwards;
  pointer-events: none;
}

/* ── Breadcrumbs ───────────────────────────────────────────── */

.breadcrumb {
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: var(--s5);
  font-family: var(--sans);
  letter-spacing: 0.01em;
  background: var(--cream);
  border-left: 4px solid var(--brass);
  padding: var(--s4) var(--s5);
  border-radius: var(--radius);
  font-weight: 500;
}

.breadcrumb a {
  color: var(--ink);
  border: none;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--brass);
}

.breadcrumb a:hover { color: var(--brass); }

.breadcrumb-sep {
  color: var(--brass);
  font-weight: 700;
  margin: 0 var(--s2);
}

.breadcrumb-current {
  color: var(--ink);
  font-weight: 700;
}

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

.hero {
  color: #fff;
  padding: var(--s9) 0 var(--s8);
  text-align: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(184, 134, 11, 0.08) 0%, transparent 60%),
    linear-gradient(175deg, var(--navy) 0%, #142238 40%, var(--navy-mid) 100%);
}

/* Decorative geometric lines */
.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 120px,
      rgba(255,255,255,0.015) 120px,
      rgba(255,255,255,0.015) 121px
    );
  pointer-events: none;
}

.hero-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 var(--s6);
  position: relative;
  z-index: 1;
  animation: fadeUp 0.6s ease-out;
}

.hero h1 {
  font-size: 2.8rem;
  color: #fff;
  border: none;
  padding: 0;
  margin-bottom: var(--s5);
  line-height: 1.15;
  text-wrap: balance;
}

.hero-subtitle {
  font-size: 1.1rem;
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: var(--s6);
  font-weight: 400;
}

.hero-actions {
  display: flex;
  gap: var(--s4);
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────── */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: var(--s3) var(--s5);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.5;
  background: var(--navy-mid);
  color: #fff;
}

button:hover, .btn:hover {
  background: var(--navy-light);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--lift-2);
}

/* Phase 2A: specificity fix — no !important needed */
a.btn-accent,
a.btn-accent:hover,
a.btn-accent:visited,
a.btn-accent:active,
a.btn-accent:focus,
.btn-accent {
  background: var(--brass);
  color: #fff;
  font-weight: 700;
}

a.btn-accent:hover,
.btn-accent:hover {
  background: var(--brass-light);
  color: #fff;
}

a.btn-outline,
a.btn-outline:hover,
a.btn-outline:visited,
a.btn-outline:active,
a.btn-outline:focus,
.btn-outline {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 2px solid #fff;
}

a.btn-outline:hover,
.btn-outline:hover {
  background: rgba(255,255,255,0.25);
  border-color: #fff;
  color: #fff;
}

/* ── Sections ──────────────────────────────────────────────── */

.section {
  padding: var(--s8) 0;
}

.section-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--s6);
}

.section-alt {
  background: var(--paper);
  border-top: 1px solid var(--rule-light);
  border-bottom: 1px solid var(--rule-light);
}

.section h2,
.about-section h2 {
  position: relative;
  display: inline-block;
  text-wrap: balance;
}

.section h2::after,
.about-section h2::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 48px;
  height: 3px;
  background: var(--brass);
  border-radius: 2px;
}

.section-description {
  font-size: 0.9375rem;
  color: var(--ink-muted);
  margin-bottom: var(--s6);
  max-width: 640px;
  line-height: 1.7;
}

/* ── Card Grid ─────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--s5);
}

.card-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s4);
}

/* ── Table Cards ───────────────────────────────────────────── */

.table-card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s5);
  box-shadow: var(--lift-1);
  transition: all 0.25s ease;
  text-decoration: none;
  color: var(--ink);
  position: relative;
}

.table-card:hover {
  border-left-color: var(--brass);
  box-shadow: var(--lift-3);
  transform: translateY(-3px);
  text-decoration: none;
  color: var(--ink);
}

.table-card-icon {
  font-size: 1.5rem;
  margin-bottom: var(--s3);
  line-height: 1;
  opacity: 0.7;
  filter: grayscale(20%);
}

.table-card:hover .table-card-icon {
  opacity: 1;
  filter: none;
}

a.table-card,
a.table-card:hover,
a.table-card:visited,
a.table-card:active {
  text-decoration: none;
  border-bottom: none;
}

.table-card h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--ink);
  margin-bottom: var(--s2);
  transition: color 0.2s;
}

.table-card:hover h3 {
  color: var(--brass);
}

.table-card p {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  margin-bottom: 0;
  line-height: 1.6;
}

/* Code key cards — compact */
.table-card-sm {
  padding: var(--s4);
  border-left-width: 3px;
}

.table-card-sm h3 {
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
}

.table-card-sm p {
  font-size: 0.75rem;
}

/* ── About Grid ────────────────────────────────────────────── */

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s6);
}

.about-item {
  padding-top: var(--s4);
  border-top: 2px solid var(--rule);
  transition: border-color 0.25s ease;
}

.about-item:hover {
  border-top-color: var(--brass);
}

.about-item h3 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.6875rem;
  color: var(--ink-muted);
  margin-bottom: var(--s3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.about-item p {
  font-size: 0.875rem;
  color: var(--ink-light);
  line-height: 1.7;
}

/* ── Data Tables ───────────────────────────────────────────── */

table.rows-and-columns {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--lift-1);
  width: 100%;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

table.rows-and-columns th {
  background: var(--navy);
  color: rgba(255,255,255,0.92);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--s3) var(--s4);
  position: sticky;
  top: 0;
  z-index: 10;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--brass);
}

table.rows-and-columns th a {
  color: rgba(255,255,255,0.92);
  border: none;
}

table.rows-and-columns th a:hover {
  color: var(--brass-light);
}

table.rows-and-columns td {
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--rule-light);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

table.rows-and-columns tr:nth-child(even) {
  background: rgba(13, 27, 42, 0.018);
}

table.rows-and-columns tr:hover {
  background: var(--brass-glow);
}

table.rows-and-columns tr:last-child td {
  border-bottom: none;
}

/* Link column cells */
table.rows-and-columns td a {
  color: var(--brass);
  font-weight: 500;
  border: none;
}

table.rows-and-columns td a:hover {
  color: var(--brass-light);
}

/* ── Table-Specific Column Styling (Section 9.18) ─────────── */

/* Decision columns: bold */
body.table-proceedings-readable td.col-ij_decision,
body.table-bonds-readable td.col-bond_decision,
body.table-appeals-readable td.col-bia_decision {
  font-weight: 600;
}

/* Date columns: monospace, no-wrap */
body.table-cases-readable td.col-latest_hearing_date,
body.table-proceedings-readable td.col-decision_date,
body.table-schedule-readable td.col-hearing_date {
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Court columns: slightly bolder */
body.table-cases-readable td.col-current_court,
body.table-proceedings-readable td.col-base_court {
  font-weight: 500;
}

/* ── Facets ────────────────────────────────────────────────── */

.facet-info {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s4);
  margin-bottom: var(--s4);
  box-shadow: var(--lift-1);
  break-inside: avoid;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.facet-info h3 {
  font-family: var(--sans);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-bottom: var(--s3);
  font-weight: 700;
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--rule-light);
}

.facet-info ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.facet-info li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--s1) var(--s2);
  font-size: 0.8125rem;
  border-bottom: none;
  border-radius: var(--radius);
  transition: background 0.15s ease;
  color: var(--ink-muted);
}

.facet-info li:hover {
  background: var(--brass-glow);
}

.facet-info li a {
  color: var(--ink-light);
  text-decoration: none;
  border: none;
  font-size: 0.8125rem;
}

.facet-info li a:hover {
  color: var(--brass);
}

/* Facet count values (right-aligned numbers) */
.facet-info li .facet-count {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  margin-left: var(--s2);
  white-space: nowrap;
}

/* Facet results container — grid layout for compact display */
.facet-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  column-gap: var(--s4);
  margin-bottom: var(--s4);
}

/* ── Search / Inputs ───────────────────────────────────────── */

input[type="search"],
input[type="text"],
input[type="number"],
select,
textarea {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
  font-family: var(--sans);
  font-size: 0.8125rem;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

textarea[name="sql"] {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  min-height: 100px;
  width: 100%;
  border-radius: var(--radius);
  padding: var(--s4);
}

/* Slightly stronger focus glow than the default input:focus (0.15 vs 0.1) */
textarea[name="sql"]:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

/* ── Code / Monospace ──────────────────────────────────────── */

.code, pre {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

code {
  font-family: var(--mono);
  background: rgba(13, 27, 42, 0.05);
  padding: 2px 6px;
  border-radius: 2px;
  color: var(--navy-mid);
  font-size: 0.75rem;
}

pre {
  background: var(--cream);
  color: var(--ink-light);
  padding: var(--s4);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.6;
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: var(--ink-light);
  font-size: 0.8125rem;
}

/* ── Datasette Content Area ────────────────────────────────── */

header {
  background: transparent;
  border: none;
  padding: 0;
}

.content {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--s6);
}

/* Database listing */
.database-tables ul {
  list-style: none;
  padding: 0;
}

.database-tables li {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--rule-light);
}

.database-tables li:last-child {
  border-bottom: none;
}

/* Row counts and metadata */
.table-row-count,
.query-description {
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin-bottom: var(--s4);
}

/* Pagination — style as button */
p > a[href*="_next"] {
  display: inline-flex;
  align-items: center;
  padding: var(--s2) var(--s4);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--brass);
  font-weight: 600;
  font-size: 0.8125rem;
  transition: all 0.2s;
}

p > a[href*="_next"]:hover {
  border-color: var(--brass);
  box-shadow: var(--lift-1);
  color: var(--brass-light);
}

/* "View and edit SQL" link styling */
p > a[href*="sql="] {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  border-bottom: 1px dotted var(--rule);
}

/* ── Query Page Styling ───────────────────────────────────── */

body.query .content form {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s5);
  box-shadow: var(--lift-1);
}

/* ── Row Detail View ───────────────────────────────────────── */

dl {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  margin: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--lift-1);
}

dt {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  padding: var(--s3) var(--s4);
  background: rgba(13, 27, 42, 0.025);
  border-bottom: 1px solid var(--rule-light);
  display: flex;
  align-items: center;
  border-right: 1px solid var(--rule-light);
}

dd {
  padding: var(--s3) var(--s4);
  margin: 0;
  border-bottom: 1px solid var(--rule-light);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
}

dt:last-of-type,
dd:last-of-type {
  border-bottom: none;
}

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

footer {
  background: var(--navy);
  color: rgba(255, 255, 255, 0.6);
  padding: var(--s8) var(--s6) var(--s7);
  font-size: 0.8125rem;
  margin-top: var(--s8);
  position: relative;
  border-top: 3px solid var(--brass);
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at 30% 0%, rgba(184, 134, 11, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: var(--s7);
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: var(--s6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  position: relative;
}

.footer-column h4 {
  font-family: var(--serif);
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
  margin-bottom: var(--s3);
}

.footer-column p {
  line-height: 1.7;
  margin-bottom: 0;
}

footer a {
  color: var(--brass-light);
  border-bottom: 1px solid transparent;
}

footer a:hover {
  color: var(--brass-pale);
  border-bottom-color: var(--brass-light);
}

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: var(--s5);
  text-align: center;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  position: relative;
}

.footer-bottom p { margin: 0; }

/* ── Datasette Overrides ───────────────────────────────────── */

/* Remove Datasette's default crumb separator styling */
.crumbs { margin-bottom: var(--s5); }

/* h3 row count heading */
h3:not(.table-card h3):not(.about-item h3):not(.facet-info h3) {
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink-muted);
}

/* Filter form — tighter spacing, closer to data */
form.filters {
  margin-bottom: var(--s3);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s4);
  box-shadow: var(--lift-1);
}

/* "View and edit SQL" link */
p:has(> a[href*="sql="]) {
  margin-bottom: var(--s3);
  font-size: 0.8125rem;
}

/* The data table — full width */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  width: 100%;
  min-width: 0;
}

/* Advanced export section */
.advanced-export {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s4);
  box-shadow: var(--lift-1);
}

/* Row count heading */
.content > h3 {
  margin-bottom: var(--s2);
}

/* Advanced export heading — subtle label within merged panel */
h3#export {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: var(--s2);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--rule-light);
}

/* Datasette plugin: copyable, etc. */
.copyable { cursor: pointer; }

/* ── About Page ───────────────────────────────────────────── */

.about-page {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--s7) var(--s6);
}

.about-section {
  margin-bottom: var(--s7);
}

.about-section:last-child {
  margin-bottom: 0;
}

.about-page ul {
  padding-left: var(--s5);
  margin: 0 0 var(--s4) 0;
}

.about-page li {
  padding: var(--s2) 0;
  line-height: 1.7;
  color: var(--ink-light);
}

.about-page li + li {
  border-top: 1px solid var(--rule-light);
}

/* ── Keyboard Shortcut Hints ──────────────────────────────── */

kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1;
  padding: 3px 7px;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(13, 27, 42, 0.06);
  vertical-align: baseline;
}

/* ── Facet Custom Scrollbar ───────────────────────────────── */

.facet-info::-webkit-scrollbar {
  width: 5px;
}

.facet-info::-webkit-scrollbar-track {
  background: transparent;
}

.facet-info::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 3px;
}

.facet-info::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint);
}

/* ── Filter Form Polish ───────────────────────────────────── */

form.filters .filter-row {
  display: flex;
  gap: var(--s2);
  align-items: center;
  margin-bottom: var(--s2);
  flex-wrap: wrap;
}

form.filters select,
form.filters input[type="text"] {
  flex: 1;
  min-width: 120px;
}

form.filters input[type="submit"] {
  background: var(--navy-mid);
  color: #fff;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: var(--s2) var(--s4);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

form.filters input[type="submit"]:hover {
  background: var(--brass);
}

/* ── Search Bar ────────────────────────────────────────────── */

.search-form {
  margin-bottom: var(--s6);
}

.hero .search-form {
  max-width: 560px;
  margin: 0 auto var(--s6);
}

.search-wrapper {
  display: flex;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrapper:focus-within {
  border-color: var(--brass-light);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.2);
  background: rgba(255, 255, 255, 0.15);
}

/* Phase 2A: specificity fix — parent qualifier instead of !important */
.search-wrapper .search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1rem;
  padding: var(--s3) var(--s4);
  box-shadow: none;
}

.search-wrapper .search-input:focus {
  border: none;
  box-shadow: none;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-wrapper .search-btn {
  background: var(--brass);
  border: none;
  color: #fff;
  padding: var(--s3) var(--s4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  border-radius: 0;
  text-transform: none;
  letter-spacing: normal;
}

.search-wrapper .search-btn:hover {
  background: var(--brass-light);
  transform: none;
  box-shadow: none;
}

.search-hint {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  margin: var(--s2) 0 0;
  text-align: center;
}

.search-hint kbd {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
}

/* Non-hero search (table pages, etc.) */
.section .search-form .search-wrapper {
  background: var(--paper);
  border-color: var(--rule);
}

.section .search-form .search-input {
  color: var(--ink);
}

.section .search-form .search-input::placeholder {
  color: var(--ink-faint);
}

.section .search-form .search-hint {
  color: var(--ink-faint);
}

/* ── Stats Bar ─────────────────────────────────────────────── */

.stats-bar {
  display: flex;
  justify-content: center;
  gap: var(--s7);
  margin-bottom: var(--s7);
  padding: var(--s6) var(--s5);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--lift-1);
}

.stat {
  text-align: center;
}

.stat-number {
  display: block;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-top: var(--s1);
}

/* ── Table Card Count Badge ───────────────────────────────── */

.table-card-count {
  display: block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-faint);
  margin-top: var(--s2);
  font-variant-numeric: tabular-nums;
}

/* ── 404 / Error Page ─────────────────────────────────────── */

.error-page {
  max-width: 600px;
  margin: var(--s9) auto;
  text-align: center;
  padding: 0 var(--s6);
}

.error-page h1 {
  font-size: 2.4rem;
  border: none;
  padding: 0;
  margin-bottom: var(--s4);
}

.error-message {
  font-size: 1.05rem;
  color: var(--ink-muted);
  line-height: 1.7;
  margin-bottom: var(--s6);
}

.error-actions {
  display: flex;
  gap: var(--s4);
  justify-content: center;
}

/* ── Footer Updated Badge ─────────────────────────────────── */

.footer-updated {
  display: inline-block;
  margin-left: var(--s2);
  opacity: 0.7;
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .navbar-inner {
    flex-wrap: wrap;
    padding: var(--s3) var(--s4);
  }

  .navbar-toggle { display: block; }

  /* Phase 4A: animated mobile nav instead of display:none toggle */
  .navbar-links {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    width: 100%;
    flex-direction: column;
    gap: 0;
    padding-top: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: var(--s3);
  }

  .navbar-links.open {
    max-height: 300px;
    opacity: 1;
    padding-top: var(--s3);
  }

  .navbar-links a {
    padding: var(--s3) 0;
    border-bottom: none;
    font-size: 0.8125rem;
  }

  /* Hero */
  .hero { padding: var(--s7) 0 var(--s6); }

  .hero h1 { font-size: 1.75rem; }

  .hero-subtitle { font-size: 0.9375rem; }

  .hero-inner { padding: 0 var(--s4); }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }

  /* Sections */
  .section { padding: var(--s6) 0; }
  .section-inner { padding: 0 var(--s4); }

  /* Cards */
  .card-grid { grid-template-columns: 1fr; }

  .card-grid-compact {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Tables */
  table.rows-and-columns th,
  table.rows-and-columns td {
    padding: var(--s2) var(--s3);
  }

  /* Row detail */
  dl { grid-template-columns: 1fr; }

  dt {
    border-right: none;
    border-bottom: none;
    padding-bottom: var(--s1);
  }

  dd { padding-top: 0; }

  /* Content */
  .content { padding: var(--s4); }

  /* Footer */
  footer { padding: var(--s6) var(--s4); }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: var(--s5);
  }

  /* About */
  .about-grid { grid-template-columns: 1fr; }

  .about-page { padding: var(--s5) var(--s4); }

  /* Stats & search */
  .stats-bar {
    flex-wrap: wrap;
    gap: var(--s4) var(--s6);
    padding: var(--s4);
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .search-wrapper {
    border-width: 1px;
  }

  /* Error page */
  .error-page { margin: var(--s7) auto; }

  .error-actions {
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.5rem; }
  h2 { font-size: 1.35rem; }

  .table-card { padding: var(--s4); }

  .card-grid-compact { grid-template-columns: 1fr; }

  .stats-bar {
    gap: var(--s3) var(--s5);
  }

  .stat-number {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.5625rem;
  }
}

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

@media print {
  nav.navbar, .accent-stripe, .hero, footer,
  .search-form, .stats-bar, .loading-bar { display: none; }
  body { background: #fff; font-size: 10pt; }
  .content { max-width: 100%; padding: 0; }
  table.rows-and-columns th { background: #eee; color: #000; }
}
