/* Oakmont Village Community Snapshot — "Sonoma Warm" editorial-civic design system.
   Data colors (validated for CVD + contrast): terracotta #c1652f (magnitude),
   teal #0e9384 + indigo #5a5b9f (categorical). Gold + sage are decorative only. */

:root {
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Public Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: 'Consolas', 'SF Mono', Menlo, monospace;

  --paper: #f4ecdd;
  --paper-tint: #eee3cf;
  --card: #fffdf8;
  --ink: #362a1c;
  --ink-2: #6a5842;
  --ink-3: #927f66;
  --line: #e6dbc6;
  --line-strong: #d8caae;

  --terracotta: #c1652f;
  --terracotta-dk: #a5501f;
  --teal: #0e9384;
  --indigo: #5a5b9f;
  --gold: #cf9a3a;
  --sage: #6b8f6b;

  --shadow-sm: 0 1px 2px rgba(74, 53, 32, 0.06), 0 2px 8px rgba(74, 53, 32, 0.05);
  --shadow-md: 0 2px 6px rgba(74, 53, 32, 0.08), 0 12px 30px rgba(74, 53, 32, 0.09);
  --radius: 14px;
  --maxw: 1120px;
}

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

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

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 78% -10%, rgba(207, 154, 58, 0.14), transparent 60%),
    radial-gradient(900px 500px at -5% 8%, rgba(193, 101, 47, 0.08), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

em { font-style: italic; }

/* ── Sample banner ─────────────────────────────────────────────── */
.sample-banner {
  background: var(--gold);
  color: #3a2a08;
  text-align: center;
  padding: 9px 20px;
  font-size: 0.86rem;
  letter-spacing: 0.01em;
}

/* ── Masthead ──────────────────────────────────────────────────── */
.masthead {
  padding: clamp(44px, 8vw, 92px) 24px clamp(30px, 5vw, 54px);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.masthead::after {
  content: '';
  position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  width: min(var(--maxw), calc(100% - 48px)); height: 3px;
  background: linear-gradient(90deg, var(--terracotta) 0%, var(--gold) 42%, transparent 78%);
}
.masthead-inner { max-width: var(--maxw); margin: 0 auto; }
.kicker {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--terracotta-dk);
}
.masthead h1 {
  font-family: var(--font-display); font-optical-sizing: auto;
  font-weight: 900; font-size: clamp(2.6rem, 8vw, 5.2rem);
  line-height: 0.98; letter-spacing: -0.02em; color: var(--ink);
  margin: 12px 0 0;
}
.masthead h1 em { color: var(--terracotta); font-weight: 900; }
.lead {
  font-family: var(--font-display); font-optical-sizing: auto;
  font-size: clamp(1.05rem, 2.2vw, 1.4rem); font-weight: 400;
  color: var(--ink-2); max-width: 44ch; margin: 18px 0 0; line-height: 1.45;
}
.masthead-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 22px; font-size: 0.86rem; color: var(--ink-3);
}
.badge {
  background: var(--ink); color: var(--paper); font-weight: 600;
  font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px;
}
.meta-dot { color: var(--line-strong); }

/* ── Layout shells ─────────────────────────────────────────────── */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.snapshot { padding: clamp(34px, 5vw, 56px) 0; }

/* ── KPI tiles ─────────────────────────────────────────────────── */
.kpi-grid {
  display: grid; gap: 14px; align-items: stretch;
  grid-template-columns: repeat(auto-fill, minmax(198px, 1fr));
}
.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 17px 18px 15px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.kpi-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); line-height: 1.3;
  min-height: 2.5em; /* reserve two lines so tiles align whether the label wraps or not */
}
.kpi-value {
  font-family: var(--font-display); font-optical-sizing: auto;
  font-weight: 900; font-size: clamp(1.6rem, 2.6vw, 2rem); line-height: 1.02;
  color: var(--terracotta); margin-top: 4px; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kpi-sub { font-size: 0.76rem; color: var(--ink-3); margin-top: auto; padding-top: 6px; }

/* ── Chart cards ───────────────────────────────────────────────── */
.chart-grid {
  display: grid; gap: 18px; margin-top: 28px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.chart-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
}
.chart-card h3 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.28rem; letter-spacing: -0.01em; color: var(--ink);
}
.chart-card .chart-kicker {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--terracotta-dk); margin-bottom: 4px;
}
.chart-svg { width: 100%; height: auto; margin: 16px 0 6px; overflow: visible; }
.chart-caption {
  font-size: 0.9rem; color: var(--ink-2); line-height: 1.5;
  margin-top: auto; padding-top: 12px;
}
.chart-caption strong { color: var(--ink); font-weight: 600; }

/* SVG chart primitives */
.bar-fill { transition: opacity 0.12s ease; }
.chart-svg .bar-group:hover .bar-fill { opacity: 0.82; }
.bar-track { fill: var(--paper-tint); }
.bar-value { font-family: var(--font-body); font-weight: 600; font-variant-numeric: tabular-nums; fill: var(--ink); }
.bar-label { font-family: var(--font-body); fill: var(--ink-2); }
.axis-label { font-family: var(--font-body); fill: var(--ink-3); }
.legend-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; font-size: 0.82rem; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* ── Callouts ──────────────────────────────────────────────────── */
.callouts {
  display: grid; gap: 14px; margin-top: 22px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.callout {
  border-left: 3px solid var(--terracotta); padding: 4px 0 4px 16px;
}
.callout-value {
  font-family: var(--font-display); font-weight: 600; font-size: 1.5rem;
  color: var(--ink); line-height: 1.1;
}
.callout-label { font-size: 0.88rem; color: var(--ink-2); margin-top: 3px; }

.method-note {
  font-size: 0.82rem; color: var(--ink-3); line-height: 1.55;
  margin-top: 30px; padding: 14px 18px; background: var(--paper-tint);
  border-radius: 10px; max-width: 76ch;
}

/* ── Explorer ──────────────────────────────────────────────────── */
.explorer-section { max-width: var(--maxw); margin: 0 auto clamp(40px, 6vw, 72px); padding: 0 24px; }
.explorer-toggle {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 20px 24px;
  display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: 3px;
  box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, transform 0.05s ease;
}
.explorer-toggle:hover { box-shadow: var(--shadow-md); }
.explorer-toggle:active { transform: translateY(1px); }
.explorer-toggle-label {
  font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; color: var(--ink);
}
.explorer-toggle-sub { grid-column: 1; font-size: 0.86rem; color: var(--ink-3); }
.chevron {
  grid-row: 1 / span 2; grid-column: 2; width: 13px; height: 13px;
  border-right: 2.5px solid var(--terracotta); border-bottom: 2.5px solid var(--terracotta);
  transform: rotate(45deg); transition: transform 0.2s ease; margin-right: 6px;
}
.explorer-toggle[aria-expanded="true"] .chevron { transform: rotate(-135deg); }

.explorer {
  margin-top: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.tab-bar {
  display: flex; gap: 2px; overflow-x: auto; padding: 6px 10px 0;
  border-bottom: 1px solid var(--line); background: var(--paper-tint);
}
.tab {
  border: none; background: none; cursor: pointer; white-space: nowrap;
  padding: 12px 15px; font-family: var(--font-body); font-size: 0.9rem; font-weight: 500;
  color: var(--ink-3); border-bottom: 3px solid transparent; margin-bottom: -1px;
  transition: color 0.12s ease;
}
.tab:hover { color: var(--terracotta-dk); }
.tab.active { color: var(--terracotta-dk); border-bottom-color: var(--terracotta); font-weight: 700; }

.explorer-controls {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 20px 12px;
}
.explorer-controls input[type="search"] {
  flex: 1; min-width: 200px; padding: 9px 13px; font-size: 0.9rem; font-family: inherit;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink);
}
.explorer-controls input[type="search"]:focus {
  outline: none; border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(193, 101, 47, 0.15);
}
.explorer-controls select {
  padding: 9px 11px; font-size: 0.9rem; font-family: inherit; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink);
}
.row-count { font-size: 0.82rem; color: var(--ink-3); margin-left: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  position: sticky; top: 0; background: var(--card); text-align: left; cursor: pointer;
  user-select: none; padding: 11px 16px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
thead th:hover { color: var(--terracotta-dk); }
thead th.sorted-asc::after { content: ' ↑'; color: var(--terracotta); }
thead th.sorted-desc::after { content: ' ↓'; color: var(--terracotta); }
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--paper-tint); }
td.code { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-3); white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.pct { text-align: right; color: var(--ink-2); font-size: 0.84rem; font-variant-numeric: tabular-nums; }
td.na { color: var(--line-strong); font-style: italic; }
.dist-bar { min-width: 90px; height: 7px; background: var(--paper-tint); border-radius: 4px; overflow: hidden; }
.dist-bar > i { display: block; height: 100%; background: var(--terracotta); border-radius: 4px; }

.explorer-downloads {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--paper-tint);
}
.explorer-downloads span { font-size: 0.85rem; color: var(--ink-2); font-weight: 600; }
.btn {
  cursor: pointer; font-family: inherit; font-size: 0.84rem; font-weight: 600;
  padding: 8px 15px; border-radius: 8px; border: 1.5px solid var(--terracotta);
  background: var(--terracotta); color: #fff; transition: opacity 0.12s ease;
}
.btn:hover { opacity: 0.88; }
.btn-outline { background: transparent; color: var(--terracotta-dk); }

/* ── Tooltip ───────────────────────────────────────────────────── */
.tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 7px 11px;
  border-radius: 8px; font-size: 0.82rem; line-height: 1.4; box-shadow: var(--shadow-md);
  transform: translate(-50%, -115%); white-space: nowrap; max-width: 260px;
}
.tooltip b { color: #fff; }
.tooltip .tt-val { color: var(--gold); font-variant-numeric: tabular-nums; }

/* ── Footer ────────────────────────────────────────────────────── */
.site-footer {
  max-width: var(--maxw); margin: 0 auto; padding: 30px 24px 60px;
  border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--ink-3);
}
.site-footer p + p { margin-top: 8px; }
.footer-fine { max-width: 80ch; line-height: 1.55; }

/* ── Motion ────────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(14px); animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
.kpi:nth-child(1) { animation-delay: 0.02s } .kpi:nth-child(2) { animation-delay: 0.06s }
.kpi:nth-child(3) { animation-delay: 0.10s } .kpi:nth-child(4) { animation-delay: 0.14s }
.kpi:nth-child(5) { animation-delay: 0.18s } .kpi:nth-child(6) { animation-delay: 0.22s }
.kpi:nth-child(7) { animation-delay: 0.26s } .kpi:nth-child(8) { animation-delay: 0.30s }
.kpi:nth-child(n+9) { animation-delay: 0.34s }
.chart-card:nth-child(1) { animation-delay: 0.10s } .chart-card:nth-child(2) { animation-delay: 0.18s }
.chart-card:nth-child(3) { animation-delay: 0.26s } .chart-card:nth-child(4) { animation-delay: 0.34s }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  .chevron, .bar-fill, .explorer-toggle { transition: none; }
  body { background-attachment: scroll; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
  .kpi { padding: 14px 14px 13px; }
  .kpi-value { font-size: 1.55rem; }
  .kpi-label { min-height: 2.4em; }
  .chart-grid { grid-template-columns: 1fr; }
  main, .explorer-section { padding-left: 16px; padding-right: 16px; }
}
