/*
  style.css
  Direction: warm natural history atlas. Paper ground, ink type.
  
  Fonts:
    Cormorant Garamond -- headings. Old-style, genuinely distinguished, used in 
                          serious academic publishing. Not a web default anywhere.
    Work Sans          -- body. Geometric but warm, much less used than Inter.
    Fira Code          -- data labels, mono values. Warm and readable at small sizes.
*/

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

:root {
  --bg:       #f5f1e8;
  --surface:  #ede9de;
  --surface2: #e5e0d3;
  --border:   #c8c2b0;
  --rule:     #b0a894;

  --ink:      #1a1814;
  --text:     #2c2820;
  --muted:    #6e6758;
  --faint:    #9e9788;

  /* severity: deep rust to pale straw */
  --terra:    #a83318;
  --amber:    #c07818;
  --clay:     #7a2210;

  /* data colors -- muted, map-like */
  --blue:     #2e6080;
  --green:    #3d6e4a;
  --sand:     #b89840;

  --mono:  'Fira Code', 'Courier New', monospace;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'Work Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.72;
  font-size: 16px;
}

/* ========== NAV ========== */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--ink);
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  border-bottom: 1px solid #333028;
}

.nav-brand {
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: #e8e2d4;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 0;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 0 14px;
  height: 44px;
  line-height: 44px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7a7468;
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.nav-links a:hover { color: #e8e2d4; }

/* ========== LAYOUT ========== */

.page-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 36px;
}

/* ========== HEADER ========== */

.site-header {
  padding: 80px 0 64px;
  border-bottom: 2px solid var(--ink);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 0 60px;
  align-items: start;
}

.header-text {
  grid-column: 1;
  grid-row: 1 / 3;
}

.header-stats {
  grid-column: 2;
  grid-row: 1 / 4;
  padding-top: 8px;
}

.header-byline {
  grid-column: 1;
  grid-row: 3;
  padding-top: 24px;
}

.kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}

.project-title {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 5vw, 4.2rem);
  font-weight: 700;
  line-height: 1.04;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.project-subtitle {
  margin-top: 16px;
  font-size: 1.08rem;
  color: var(--muted);
  font-weight: 300;
  line-height: 1.65;
  max-width: 420px;
}

.byline {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--faint);
  text-transform: uppercase;
  line-height: 1.8;
}

/* ---- stat cards stacked vertically in right column ---- */

.stat-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.stat-card {
  background: var(--surface);
  padding: 16px 20px 14px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.stat-num {
  font-family: var(--serif);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--terra);
  line-height: 1.0;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 100px;
}

.stat-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.6;
}

/* ========== VIZ SECTIONS -- two-column layout ========== */

.viz-section {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto auto auto;
  gap: 0 48px;
  align-items: start;
}

.section-sidebar {
  grid-column: 1;
  grid-row: 1 / 4;
  padding-top: 4px;
  position: sticky;
  top: 60px;
}

.section-main {
  grid-column: 2;
  grid-row: 1 / 4;
}

.section-num {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}

.section-title {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-style: italic;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  line-height: 1.18;
}

.section-body {
  font-size: 0.94rem;
  color: var(--text);
  margin-bottom: 14px;
  font-weight: 400;
  line-height: 1.72;
}

.note {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.02em;
  color: var(--muted);
  line-height: 1.7;
  margin-top: 14px;
}

/* ========== VIZ FRAME ========== */

.viz-frame {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px 20px 16px;
}

.viz-caption {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ========== SLIDER (Viz 1) ========== */

.slider-row {
  display: grid;
  grid-template-columns: max-content minmax(140px, 1fr) max-content;
  align-items: center;
  column-gap: 16px;
  row-gap: 6px;
  margin-bottom: 14px;
}

.slider-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

.slider-value {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--terra);
  min-width: 42px;
}

#poverty-slider {
  -webkit-appearance: none;
  appearance: none;
  min-width: 120px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#poverty-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--terra);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

#poverty-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--terra);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.slider-count {
  grid-column: 2 / 4;
  justify-self: end;
  text-align: right;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* ========== MAP LEGEND ========== */

.map-legend {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.legend-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.double-swatch-item {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: 18px;
}

.double-swatch {
  width: 20px;
  height: 13px;
  border: 1.5px solid #6F7D5C;
  background: rgba(160,50,20,0.1);
  flex-shrink: 0;
}

/* ========== CONTROLS ========== */

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.control-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.control-select {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 5px 28px 5px 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239e9788'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.control-select:focus { outline: 1px solid var(--terra); }

.control-input {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  width: 190px;
  outline: none;
}

.control-input:focus {
  border-color: var(--terra);
}

.control-clear {
  margin-left: auto;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--rule);
  padding: 5px 11px;
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
}

.control-clear:hover {
  color: var(--ink);
  border-color: var(--terra);
}

/* ========== TOOLTIP ========== */

#tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  padding: 13px 17px;
  font-family: var(--mono);
  font-size: 11px;
  color: #ede8dc;
  line-height: 1.9;
  max-width: 280px;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 9999;
  box-shadow: 0 6px 24px rgba(26,24,20,0.28);
}

#tooltip.visible { opacity: 1; }

.tt-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  font-weight: 600;
  color: #ede8dc;
  margin-bottom: 7px;
  line-height: 1.25;
}

.tt-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.tt-key { color: #7a7468; }
.tt-val { color: #ede8dc; }

.tt-badge {
  display: none;
  margin-top: 8px;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid var(--amber);
  padding: 1px 6px;
}

/* ========== LOADING ========== */

.viz-loading {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  padding: 56px 0;
  text-align: center;
  letter-spacing: 0.06em;
}

/* ========== STRIP PLOTS ========== */

.strip-wrap {
  display: flex;
  gap: 2px;
  width: 100%;
  overflow-x: auto;
  align-items: flex-start;
  background: var(--surface2);
  padding: 2px;
}

.strip-panel {
  flex: 1;
  min-width: 132px;
  background: var(--surface);
}

/* ========== LINKED BANNER ========== */

.linked-state-banner {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--terra);
  min-height: 14px;
}

/* ========== STRIP LEGEND ========== */

#strip-legend {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ========== WRITEUP ========== */

.writeup-section {
  margin-top: 72px;
  padding-top: 56px;
  border-top: 2px solid var(--ink);
  padding-bottom: 96px;
}

.writeup-inner {
  max-width: 680px;
}

.writeup-q {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--clay);
  margin: 40px 0 12px;
}

.writeup-section p {
  font-size: 0.97rem;
  color: var(--text);
  margin-bottom: 0.9em;
  line-height: 1.72;
}

/* ========== FOOTER ========== */

.site-footer {
  background: var(--ink);
  padding: 28px 36px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.07em;
  color: #4a4840;
  line-height: 2;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 780px) {
  .site-header {
    grid-template-columns: 1fr;
  }
  .header-text  { grid-column: 1; grid-row: 1; }
  .header-stats { grid-column: 1; grid-row: 2; padding-top: 32px; }
  .header-byline{ grid-column: 1; grid-row: 3; }

  .viz-section {
    grid-template-columns: 1fr;
  }
  .section-sidebar { grid-column: 1; grid-row: 1; position: static; }
  .section-main    { grid-column: 1; grid-row: 2; }

  .nav-links { display: none; }
  .page-wrap { padding: 0 18px; }
  .project-title { font-size: 2.2rem; }

  .slider-row {
    grid-template-columns: minmax(0, 1fr) max-content;
  }

  .slider-label {
    grid-column: 1 / -1;
  }

  #poverty-slider {
    grid-column: 1 / 2;
    min-width: 0;
  }

  .slider-count {
    grid-column: 1 / 2;
  }
}

/* ========== NAV SEARCH ========== */

.nav-search {
  position: relative;
  margin-left: auto;
}

#county-search {
  background: #2a2820;
  border: 1px solid #3a3830;
  color: #e8e2d4;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 10px;
  width: 200px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}

#county-search:focus {
  border-color: var(--amber);
  width: 240px;
}

#county-search::placeholder { color: #5a5848; }

#search-results {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--ink);
  border: 1px solid #3a3830;
  list-style: none;
  width: 280px;
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
}

#search-results li {
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: #c8c2b0;
  cursor: pointer;
  border-bottom: 1px solid #2a2820;
  transition: background 0.1s;
}

#search-results li:hover {
  background: #2a2820;
  color: #e8e2d4;
}

/* ========== ACTIVE NAV LINK ========== */

.nav-links a.active {
  color: var(--amber) !important;
}
