/* ============================================================
   Heat-Health Risk Index — Shared Stylesheet
   styles.css
   ============================================================ */

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

/* ── Design Tokens ── */
:root {
  --red:    #c0392b;
  --orange: #e67e22;
  --amber:  #f39c12;
  --cream:  #fdf6ec;
  --ink:    #1a1208;
  --mid:    #6b4f2a;
  --pale:   #f5ede0;
  --border: rgba(192,57,43,0.15);
  --nav-h:  64px;
}

/* ── Base ── */
body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Noise texture */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.032;
  mix-blend-mode: multiply;
}

/* Dark-background body variant (Data page) */
body.dark-bg {
  background: var(--ink);
  color: var(--cream);
}

body.dark-bg::before { opacity: 0.04; mix-blend-mode: overlay; }

/* ============================================================
   NAV
   ============================================================ */
nav {
  position: sticky; top: 0; z-index: 300;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2.5rem;
  background: rgba(253,246,236,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

/* Dark nav variant */
body.dark-bg nav {
  background: rgba(26,18,8,0.92);
  border-bottom-color: rgba(192,57,43,0.2);
}

/* Fixed nav variant (home page hero) */
nav.fixed-nav {
  position: fixed; top: 0; left: 0; right: 0;
  background: rgba(253,246,236,0.88);
}

.nav-logo {
  text-decoration: none;
  display: flex; align-items: center; gap: 0.6rem;
}

.nav-logo img {
  width: 34px; height: 34px;
  object-fit: contain;
}

.nav-logo span {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

body.dark-bg .nav-logo span { color: var(--cream); }

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

.nav-links a {
  font-size: 0.82rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  text-decoration: none; color: var(--mid);
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active { color: var(--red); }

body.dark-bg .nav-links a { color: rgba(253,246,236,0.45); }
body.dark-bg .nav-links a:hover,
body.dark-bg .nav-links a.active { color: var(--amber); }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  border-top: 1px solid var(--border);
  padding: 1.8rem 2.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--mid);
  letter-spacing: 0.03em;
  background: var(--cream);
}

footer strong { color: var(--ink); }

body.dark-bg footer {
  background: transparent;
  border-top-color: rgba(192,57,43,0.15);
  color: rgba(253,246,236,0.3);
}

body.dark-bg footer strong { color: rgba(253,246,236,0.6); }

/* ============================================================
   SHARED TYPOGRAPHY UTILITIES
   ============================================================ */
.eyebrow {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--red);
  margin-bottom: 1.2rem;
}

.eyebrow-amber { color: var(--amber); }
.eyebrow-orange { color: var(--orange); }

.section-divider {
  width: 48px; height: 2px;
  background: linear-gradient(90deg, var(--red), var(--amber));
  margin: 2rem 0;
  border-radius: 2px;
}

.section-rule {
  width: 40px; height: 2px;
  background: linear-gradient(90deg, var(--red), var(--amber));
  border-radius: 2px;
}

/* ============================================================
   PAGE HEADER (Resources + Data pages)
   ============================================================ */
.page-header {
  padding: 5rem 2.5rem 4rem;
  max-width: 860px;
  margin: 0 auto;
  position: relative; z-index: 1;
}

.page-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: normal;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 1.2rem;
}

.page-header p {
  font-size: 1.05rem;
  color: var(--mid);
  line-height: 1.65;
  font-weight: 300;
  max-width: 560px;
}

.page-header-rule {
  width: 100%; height: 1px;
  background: var(--border);
  margin-top: 3.5rem;
}

body.dark-bg .page-header h1 { color: var(--cream); }

/* ============================================================
   FADE-IN SECTIONS (scroll reveal)
   ============================================================ */
.reveal-section {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s ease, transform 0.9s ease;
  pointer-events: none;
}

.reveal-section.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ============================================================
   HERO SECTION
   ============================================================ */
#hhi-section-hero {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: calc(var(--nav-h) + 3rem) 2rem 5rem;
  position: relative;
}

#hhi-section-hero::after {
  content: '';
  position: absolute;
  top: 30%; left: 50%; transform: translate(-50%, -50%);
  width: 700px; height: 500px;
  background: radial-gradient(ellipse, rgba(230,126,34,0.12) 0%, rgba(192,57,43,0.06) 40%, transparent 70%);
  pointer-events: none; z-index: 0;
}

.hero-eyebrow {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--red);
  margin-bottom: 2rem;
  position: relative; z-index: 1;
}

/* Reveal button */
#hhi-reveal-btn {
  position: relative; z-index: 1;
  background: var(--ink);
  color: var(--cream);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; font-weight: 500;
  letter-spacing: 0.04em;
  padding: 1rem 2.2rem;
  cursor: pointer;
  border-radius: 2px;
  display: flex; align-items: center; gap: 0.6rem;
  transition: background 0.25s, transform 0.15s;
}

#hhi-reveal-btn:hover { background: var(--red); transform: translateY(-1px); }

#hhi-reveal-btn .btn-icon {
  width: 18px; height: 18px;
  background: linear-gradient(150deg, var(--amber), var(--red));
  clip-path: polygon(50% 0%, 80% 35%, 95% 65%, 65% 80%, 50% 100%, 35% 80%, 5% 65%, 20% 35%);
  flex-shrink: 0;
}

/* Hero title reveal */
#hhi-hero-title-wrap {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.8s cubic-bezier(0.16,1,0.3,1), opacity 0.6s ease;
  margin-top: 3rem;
  position: relative; z-index: 1;
}

#hhi-hero-title-wrap.visible { max-height: 700px; opacity: 1; }

#hhi-hero-title-wrap h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2.4rem, 6vw, 5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 1.5rem;
}

#hhi-hero-title-wrap h1 em { font-style: italic; color: var(--red); }

.hero-sub {
  font-size: clamp(0.95rem, 1.8vw, 1.15rem);
  color: var(--mid);
  max-width: 520px;
  margin: 0 auto 2.5rem;
  line-height: 1.65;
  font-weight: 300;
}

/* Scroll arrow */
.scroll-arrow {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--mid);
  font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-top: 1rem;
  animation: bob 2s ease-in-out infinite;
}

.scroll-arrow svg { width: 22px; height: 22px; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(6px); }
}

/* Page shake */
@keyframes shake {
  0%   { transform: translate(0,0) rotate(0); }
  15%  { transform: translate(-12px, 6px) rotate(-.8deg); }
  30%  { transform: translate(12px, -6px) rotate(.8deg); }
  45%  { transform: translate(-8px, 4px) rotate(-.5deg); }
  60%  { transform: translate(8px, -4px) rotate(.5deg); }
  75%  { transform: translate(-4px, 2px) rotate(-.2deg); }
  100% { transform: translate(0,0) rotate(0); }
}

.shaking { animation: shake .5s ease; }

/* ── Click hint arrow ── */
#hhi-click-hint {
  position: fixed;
  bottom: 2.5rem; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.35rem;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#hhi-click-hint svg {
  width: 28px; height: 28px;
  color: var(--red);
  filter: drop-shadow(0 0 8px rgba(192,57,43,0.6));
  animation: hintBounce 1.4s ease-in-out infinite;
}

#hhi-click-hint span {
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--red);
  text-shadow: 0 0 12px rgba(192,57,43,0.4);
  animation: hintFade 1.4s ease-in-out infinite;
}

#hhi-click-hint.hidden { opacity: 0; }

@keyframes hintBounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(8px); }
}

@keyframes hintFade {
  0%, 100% { opacity: 0.9; }
  50%       { opacity: 0.4; }
}

/* ============================================================
   STORY SECTION
   ============================================================ */
#hhi-section-story {
  padding: 7rem 2rem;
  background: var(--ink);
  position: relative; overflow: hidden;
}

#hhi-section-story::before {
  content: '';
  position: absolute; top: -60px; right: -40px;
  width: 320px; height: 320px;
  border: 1px solid rgba(192,57,43,0.2);
  border-radius: 50%; pointer-events: none;
}

.story-inner { max-width: 680px; margin: 0 auto; position: relative; z-index: 1; }

#hhi-section-story h2 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  color: var(--cream);
  line-height: 1.1; letter-spacing: -0.02em;
  margin-bottom: 1.8rem;
}

#hhi-section-story h2 em { color: var(--orange); font-style: italic; }

#hhi-section-story p {
  font-size: 1.05rem; line-height: 1.75;
  color: rgba(253,246,236,0.7);
  font-weight: 300; margin-bottom: 1.4rem;
}

#hhi-section-story p strong { color: var(--cream); font-weight: 500; }

/* Stat pills */
.stats-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 2.5rem; }

.stat {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(192,57,43,0.25);
  border-radius: 6px;
  padding: 1rem 1.4rem;
  flex: 1; min-width: 140px;
}

.stat-num {
  font-family: 'DM Serif Display', serif;
  font-size: 2.2rem; color: var(--amber);
  line-height: 1; margin-bottom: 0.3rem;
}

.stat-label {
  font-size: 0.78rem;
  color: rgba(253,246,236,0.5);
  font-weight: 400; letter-spacing: 0.03em; line-height: 1.4;
}

/* ============================================================
   GUIDE / WHY IT MATTERS SECTION
   ============================================================ */
#hhi-section-guide {
  padding: 7rem 2rem;
  background: var(--cream);
  position: relative;
}

#hhi-section-guide::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 80% 50%, rgba(243,156,18,0.07) 0%, transparent 60%);
  pointer-events: none;
}

.guide-inner { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }

.guide-header { max-width: 580px; margin-bottom: 3.5rem; }

.guide-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  color: var(--ink); line-height: 1.1;
  letter-spacing: -0.02em; margin-bottom: 1rem;
}

.guide-header h2 em { color: var(--red); font-style: italic; }

.guide-header p { font-size: 1rem; color: var(--mid); line-height: 1.7; font-weight: 300; }

/* Why grid */
.why-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
  margin-bottom: 3rem;
}

.why-cell { background: #fff; padding: 2rem 1.8rem; }

.why-cell h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem; color: var(--ink);
  margin-bottom: 0.5rem; font-weight: normal;
}

.why-cell p { font-size: 0.875rem; color: var(--mid); line-height: 1.65; font-weight: 300; }

/* How to read steps */
.guide-subhead {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--red);
  margin-bottom: 1.4rem; margin-top: 3rem;
  display: flex; align-items: center; gap: 0.8rem;
}

.guide-subhead::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

.step {
  background: var(--pale);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 1.4rem;
  position: relative;
}

.step-num {
  font-family: 'DM Serif Display', serif;
  font-size: 2.5rem; color: rgba(192,57,43,0.12);
  line-height: 1; position: absolute; top: 0.8rem; right: 1rem;
}

.step h4 {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem; color: var(--ink);
  font-weight: normal; margin-bottom: 0.5rem;
}

.step p { font-size: 0.83rem; color: var(--mid); line-height: 1.6; font-weight: 300; }

/* Score legend */
.score-legend {
  margin-top: 3rem;
  background: var(--ink); border-radius: 8px;
  padding: 2rem 2.2rem;
  display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-start;
}

.score-legend-label {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--amber); margin-bottom: 0.9rem;
}

.score-legend-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem; color: var(--cream);
  margin-bottom: 0.4rem; font-weight: normal;
}

.score-legend-desc {
  font-size: 0.82rem; color: rgba(253,246,236,0.55);
  font-weight: 300; line-height: 1.55; max-width: 280px;
}

.score-bands { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-width: 200px; }

.score-band { display: flex; align-items: center; gap: 0.75rem; }

.score-band-swatch { width: 32px; height: 14px; border-radius: 3px; flex-shrink: 0; }

.score-band-text { font-size: 0.82rem; color: rgba(253,246,236,0.7); font-weight: 300; }

.score-band-text strong { color: var(--cream); font-weight: 500; }

/* ============================================================
   GRAPHS / DATA-AT-A-GLANCE SECTION
   ============================================================ */
#hhi-section-graphs {
  padding: 7rem 2rem;
  background: var(--ink);
  position: relative; overflow: hidden;
}

#hhi-section-graphs::before {
  content: '';
  position: absolute; bottom: -100px; left: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(ellipse, rgba(192,57,43,0.1) 0%, transparent 65%);
  pointer-events: none;
}

.graphs-inner { max-width: 980px; margin: 0 auto; position: relative; z-index: 1; }

.graphs-header {
  display: flex; align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap; gap: 1.5rem; margin-bottom: 3rem;
}

.graphs-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.02em; color: var(--cream); margin-bottom: 0.5rem;
}

.graphs-header p {
  font-size: 0.9rem; color: rgba(253,246,236,0.5);
  line-height: 1.6; font-weight: 300; max-width: 400px;
}

/* Glance stat counters */
.glance-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(192,57,43,0.2);
  border: 1px solid rgba(192,57,43,0.2);
  border-radius: 8px; overflow: hidden; margin-bottom: 2.5rem;
}

.glance-stat {
  background: rgba(255,255,255,0.03);
  padding: 1.6rem 1.4rem; text-align: center;
  transition: background 0.2s;
}

.glance-stat:hover { background: rgba(255,255,255,0.07); }

.glance-stat-num {
  font-family: 'DM Serif Display', serif;
  font-size: 2.6rem; line-height: 1; margin-bottom: 0.3rem;
  background: linear-gradient(135deg, var(--amber), var(--orange));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.glance-stat-label {
  font-size: 0.75rem; color: rgba(253,246,236,0.45);
  font-weight: 400; letter-spacing: 0.04em; line-height: 1.4;
}

/* Chart tabs */
.chart-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.tab-btn {
  background: transparent;
  border: 1px solid rgba(253,246,236,0.12);
  color: rgba(253,246,236,0.45);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.55rem 1.2rem; border-radius: 3px;
  cursor: pointer; transition: all 0.2s;
}

.tab-btn:hover { border-color: rgba(243,156,18,0.4); color: rgba(253,246,236,0.8); }
.tab-btn.active { background: var(--red); border-color: var(--red); color: #fff; }

/* Chart panels */
.chart-panel {
  display: none;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(192,57,43,0.18);
  border-radius: 10px; padding: 2rem;
  animation: fadeIn 0.35s ease;
}

.chart-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chart-panel-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}

.chart-panel-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem; color: var(--cream); margin-bottom: 0.25rem;
}

.chart-panel-sub { font-size: 0.78rem; color: rgba(253,246,236,0.4); font-weight: 300; }

.chart-insight {
  background: rgba(192,57,43,0.15);
  border-left: 3px solid var(--red);
  border-radius: 4px; padding: 0.75rem 1rem;
  font-size: 0.8rem; color: rgba(253,246,236,0.7);
  line-height: 1.55; max-width: 280px; flex-shrink: 0;
}

.chart-insight strong { color: var(--amber); font-weight: 500; }

/* Risk meter */
.risk-meter-wrap { margin-top: 2rem; }

.risk-meter-label {
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(253,246,236,0.4); margin-bottom: 0.8rem;
}

.risk-select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(253,246,236,0.12);
  color: var(--cream);
  font-family: 'DM Sans', sans-serif; font-size: 0.82rem;
  padding: 0.5rem 2.2rem 0.5rem 0.9rem;
  border-radius: 4px; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(253,246,236,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-color: rgba(255,255,255,0.06);
  margin-bottom: 1rem;
}

.risk-select option { background: #2a1a0a; }

.risk-bars { display: flex; flex-direction: column; gap: 0.7rem; }

.risk-bar-row {
  display: grid; grid-template-columns: 110px 1fr 42px;
  align-items: center; gap: 0.9rem;
}

.risk-bar-name {
  font-size: 0.78rem; color: rgba(253,246,236,0.6);
  font-weight: 400; text-align: right;
}

.risk-bar-track {
  height: 10px; background: rgba(255,255,255,0.06);
  border-radius: 99px; overflow: hidden;
}

.risk-bar-fill {
  height: 100%; border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.16,1,0.3,1);
}

.risk-bar-val {
  font-family: 'DM Serif Display', serif;
  font-size: 0.9rem; color: var(--amber); text-align: right;
}

/* ============================================================
   CTA SECTION
   ============================================================ */
#hhi-section-cta {
  padding: 8rem 2rem; text-align: center;
  background: var(--cream); position: relative;
}

#hhi-section-cta::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(230,126,34,0.08) 0%, transparent 65%);
  pointer-events: none;
}

.cta-inner { position: relative; z-index: 1; }

.cta-inner p {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  color: var(--ink); margin-bottom: 2rem; letter-spacing: -0.01em;
}

.map-btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  background: var(--red); color: #fff;
  text-decoration: none; font-size: 0.9rem; font-weight: 500;
  letter-spacing: 0.04em; padding: 1.1rem 2.4rem;
  border-radius: 2px;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(192,57,43,0.3);
}

.map-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.map-btn:hover {
  background: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(26,18,8,0.25);
}

/* ============================================================
   LIVE DATA FEED SECTION
   ============================================================ */
#hhi-section-live {
  padding: 7rem 2rem;
  background: var(--cream);
  position: relative;
}

#hhi-section-live::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(192,57,43,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.live-inner { max-width: 980px; margin: 0 auto; position: relative; z-index: 1; }

.live-header {
  display: flex; align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap; gap: 1.5rem; margin-bottom: 2.5rem;
}

.live-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.02em; color: var(--ink); margin-bottom: 0.4rem;
}

.live-header p {
  font-size: 0.9rem; color: var(--mid);
  line-height: 1.6; font-weight: 300; max-width: 400px;
}

.live-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--red);
  border: 1px solid rgba(192,57,43,0.25);
  border-radius: 99px; padding: 0.3rem 0.8rem;
  align-self: flex-start;
}

.live-badge::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--red); border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

.live-controls {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 1.5rem; align-items: center;
}

.live-search {
  flex: 1; min-width: 200px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 4px; color: var(--ink);
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem;
  padding: 0.6rem 1rem; outline: none; transition: border-color 0.2s;
}

.live-search::placeholder { color: rgba(26,18,8,0.3); }
.live-search:focus { border-color: rgba(192,57,43,0.4); }

.live-sort {
  background: #fff; border: 1px solid var(--border);
  border-radius: 4px; color: var(--ink);
  font-family: 'DM Sans', sans-serif; font-size: 0.82rem;
  padding: 0.6rem 2rem 0.6rem 0.9rem;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(26,18,8,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-color: #fff;
}

.live-count { font-size: 0.78rem; color: var(--mid); margin-left: auto; font-weight: 400; }

.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.live-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 1.2rem 1.4rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.live-card:hover {
  border-color: rgba(192,57,43,0.35);
  box-shadow: 0 4px 20px rgba(192,57,43,0.08);
  transform: translateY(-2px);
}

.live-card-id {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--orange); margin-bottom: 0.5rem;
}

.live-card-score {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem; color: var(--ink); line-height: 1; margin-bottom: 0.3rem;
}

.live-card-label {
  font-size: 0.72rem; color: var(--mid);
  font-weight: 300; margin-bottom: 0.9rem; letter-spacing: 0.04em;
}

.live-card-bar {
  height: 4px; background: var(--pale);
  border-radius: 99px; overflow: hidden; margin-bottom: 0.9rem;
}

.live-card-bar-fill { height: 100%; border-radius: 99px; transition: width 0.6s cubic-bezier(0.16,1,0.3,1); }

.live-card-metrics {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.4rem;
}

.live-metric {
  text-align: center; background: var(--pale);
  border-radius: 4px; padding: 0.4rem 0.3rem;
}

.live-metric-val { font-family: 'DM Serif Display', serif; font-size: 0.9rem; color: var(--ink); line-height: 1; }
.live-metric-lbl { font-size: 0.6rem; color: var(--mid); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.live-risk {
  display: inline-block; font-size: 0.62rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.15rem 0.5rem; border-radius: 3px; margin-bottom: 0.7rem;
}

.live-risk.high     { background: rgba(192,57,43,0.12); color: var(--red); }
.live-risk.elevated { background: rgba(230,126,34,0.12); color: var(--orange); }
.live-risk.moderate { background: rgba(243,156,18,0.12); color: #b37a00; }
.live-risk.low      { background: rgba(76,175,80,0.12);  color: #2e7d32; }

.live-loading {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--mid); font-size: 0.85rem; font-weight: 300; padding: 2rem 0;
}

.live-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.live-error { color: var(--red); font-size: 0.85rem; padding: 1.5rem 0; font-weight: 300; }

.live-more-wrap { text-align: center; margin-top: 2rem; }

.live-more-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--mid); font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.75rem 2rem; border-radius: 2px;
  cursor: pointer; transition: all 0.2s;
}

.live-more-btn:hover { background: var(--ink); border-color: var(--ink); color: var(--cream); }

/* ============================================================
   RESOURCES PAGE
   ============================================================ */
.resource-category { padding-top: 3.5rem; margin-bottom: 1.6rem; }

.category-eyebrow {
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--red); margin-bottom: 0.75rem;
}

.category-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem; font-weight: normal;
  letter-spacing: -0.01em; color: var(--ink); margin-bottom: 0.4rem;
}

.category-desc {
  font-size: 0.88rem; color: var(--mid);
  font-weight: 300; line-height: 1.55; margin-bottom: 1.4rem;
}

.resource-card {
  display: block; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--border);
  border-radius: 6px; padding: 1.4rem 1.6rem;
  margin-top: 0.75rem; position: relative;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.resource-card::after {
  content: '↗'; position: absolute; top: 1.3rem; right: 1.4rem;
  font-size: 0.85rem; color: rgba(192,57,43,0.2); transition: color 0.2s, transform 0.2s;
}

.resource-card:hover {
  border-color: rgba(192,57,43,0.4);
  box-shadow: 0 4px 24px rgba(192,57,43,0.08);
  transform: translateY(-1px);
}

.resource-card:hover::after { color: var(--red); transform: translate(2px, -2px); }

.resource-publisher {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--orange); margin-bottom: 0.35rem;
}

.resource-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem; color: var(--ink);
  line-height: 1.35; margin-bottom: 0.5rem; padding-right: 1.5rem;
}

.resource-desc { font-size: 0.85rem; color: var(--mid); line-height: 1.6; font-weight: 300; }

/* ============================================================
   DATA PAGE — MAP SECTION
   ============================================================ */
#map-section {
  position: relative; width: 100%; height: 680px;
  overflow: hidden; border-bottom: 1px solid rgba(192,57,43,0.2);
}

#map { position: absolute; inset: 0; width: 100%; height: 100%; }

#map-section::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(to bottom, transparent, var(--ink));
  pointer-events: none; z-index: 2;
}

/* View toggle */
#view-toggle {
  position: absolute; top: 20px; right: 20px;
  z-index: 10; display: flex; gap: 4px;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px; padding: 4px; backdrop-filter: blur(6px);
}

.view-btn {
  font-family: 'Space Mono', monospace; font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase;
  color: rgba(255,255,255,0.45); background: transparent;
  border: none; cursor: pointer; padding: 5px 10px;
  border-radius: 2px; transition: all 0.2s;
}

.view-btn.active { background: #ff5014; color: #fff; }

/* HUD */
#hud { position: absolute; top: 20px; left: 20px; z-index: 10; width: 210px; pointer-events: none; }

.hud-title {
  font-family: 'Bebas Neue', sans-serif; font-size: 26px;
  letter-spacing: 3px; color: #fff; line-height: 1; margin-bottom: 2px;
  text-shadow: 0 0 20px rgba(255,80,20,0.9);
}

.hud-sub {
  font-size: 9px; color: #bbb; letter-spacing: 2px;
  text-transform: uppercase; margin-bottom: 14px;
  font-family: 'Space Mono', monospace;
}

.legend-label {
  font-size: 9px; color: #999; letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 5px;
  font-family: 'Space Mono', monospace;
}

.gradient-bar {
  height: 8px; border-radius: 2px; margin-bottom: 4px;
  background: linear-gradient(to right, #0d0221, #3d0066, #cc00ff, #ff3300, #ffaa00, #ffff00);
}

.legend-ticks { display: flex; justify-content: space-between; margin-bottom: 14px; }
.legend-ticks span { font-size: 8px; color: #888; font-family: 'Space Mono', monospace; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }

.stat-box {
  background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px; padding: 8px; backdrop-filter: blur(6px);
}

.stat-box .val { font-family: 'Bebas Neue', sans-serif; font-size: 18px; color: #ff5014; line-height: 1; }
.stat-box .lbl {
  font-size: 8px; color: #666; letter-spacing: 1px;
  text-transform: uppercase; margin-top: 2px; font-family: 'Space Mono', monospace;
}

/* Mapbox popup */
.mapboxgl-popup-content {
  background: rgba(8,8,8,0.97) !important;
  border: 1px solid rgba(255,80,20,0.6) !important;
  border-radius: 4px !important; padding: 0 !important;
  box-shadow: 0 4px 24px rgba(255,80,20,0.25) !important;
  font-family: 'Space Mono', monospace !important; min-width: 200px;
}

.mapboxgl-popup-tip { display: none !important; }

.mapboxgl-popup-close-button {
  color: #ff5014 !important; font-size: 16px !important;
  padding: 6px 8px !important; line-height: 1 !important;
}

.p-inner { padding: 14px 16px; }
.p-tract { font-size: 9px; color: #666; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.p-score { font-family: 'Bebas Neue', sans-serif; font-size: 32px; color: #ff5014; line-height: 1; margin-bottom: 4px; }
.p-bar-bg { height: 3px; background: #222; border-radius: 2px; margin-bottom: 12px; }
.p-bar { height: 3px; border-radius: 2px; background: linear-gradient(to right, #cc00ff, #ff3300, #ffaa00); }
.p-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #1a1a1a; }
.p-row:last-child { border-bottom: none; }
.p-lbl { color: #666; font-size: 10px; }
.p-val { font-weight: bold; color: #ddd; font-size: 10px; }

/* DATA TABLE */
.data-controls {
  max-width: 1100px; margin: 0 auto 2rem;
  padding: 0 2.5rem; display: flex;
  gap: 1rem; flex-wrap: wrap; align-items: center;
  position: relative; z-index: 1;
}

.data-search {
  flex: 1; min-width: 220px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(253,246,236,0.1);
  border-radius: 4px; color: var(--cream);
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem;
  padding: 0.65rem 1rem; outline: none; transition: border-color 0.2s;
}

.data-search::placeholder { color: rgba(253,246,236,0.25); }
.data-search:focus { border-color: rgba(243,156,18,0.4); }

.data-filter {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(253,246,236,0.1);
  border-radius: 4px; color: var(--cream);
  font-family: 'DM Sans', sans-serif; font-size: 0.82rem;
  padding: 0.65rem 2rem 0.65rem 0.9rem;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(253,246,236,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center;
  background-color: rgba(255,255,255,0.05);
}

.data-filter option { background: #2a1a0a; }

.data-count {
  font-size: 0.78rem; color: rgba(253,246,236,0.3);
  font-weight: 400; letter-spacing: 0.04em; margin-left: auto;
}

.table-wrap { max-width: 1100px; margin: 0 auto; padding: 0 2.5rem 6rem; position: relative; z-index: 1; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }

.data-table thead th {
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.15em;
  text-transform: uppercase; color: rgba(253,246,236,0.35);
  padding: 0.7rem 1rem; text-align: left;
  border-bottom: 1px solid rgba(192,57,43,0.2);
  cursor: pointer; user-select: none; white-space: nowrap; transition: color 0.2s;
}

.data-table thead th:hover { color: var(--amber); }
.data-table thead th.sorted { color: var(--amber); }

.data-table thead th .sort-icon { display: inline-block; margin-left: 0.35rem; opacity: 0.4; font-size: 0.6rem; }
.data-table thead th.sorted .sort-icon { opacity: 1; }

.data-table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background 0.15s; cursor: pointer; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.05); }

.data-table tbody td { padding: 0.85rem 1rem; color: rgba(253,246,236,0.7); font-weight: 300; vertical-align: middle; }
.data-table tbody td:first-child { color: var(--cream); font-weight: 400; font-size: 0.78rem; font-family: 'Space Mono', monospace; }

.risk-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.2rem 0.55rem; border-radius: 3px;
}

.risk-badge.low      { background: rgba(76,175,80,0.15);  color: #4caf50; }
.risk-badge.moderate { background: rgba(243,156,18,0.15); color: #f39c12; }
.risk-badge.elevated { background: rgba(230,126,34,0.15); color: #e67e22; }
.risk-badge.high     { background: rgba(192,57,43,0.2);   color: #e84040; }

.mini-bar-wrap { display: flex; align-items: center; gap: 0.55rem; }
.mini-bar-track { width: 64px; height: 5px; background: rgba(255,255,255,0.07); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.mini-bar-fill { height: 100%; border-radius: 99px; }
.mini-bar-val { font-family: 'DM Serif Display', serif; font-size: 0.88rem; color: var(--amber); min-width: 34px; }

.no-results { text-align: center; padding: 4rem 2rem; color: rgba(253,246,236,0.3); font-size: 0.9rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .table-wrap { overflow-x: auto; }
  .data-table { min-width: 700px; }
  #map-section { height: 480px; }
  .glance-stats { grid-template-columns: 1fr; }
  .chart-panel-header { flex-direction: column; }
  .chart-insight { max-width: 100%; }
  .risk-bar-row { grid-template-columns: 80px 1fr 36px; }
  .score-legend { flex-direction: column; }
  .why-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  nav { padding: 0 1.2rem; }
  .nav-links { gap: 1.2rem; }
  .stats-row { flex-direction: column; }
  .page-header, .data-controls, .table-wrap { padding-left: 1.2rem; padding-right: 1.2rem; }
  #map-section { height: 400px; }
  .live-grid { grid-template-columns: 1fr; }
  .live-header { flex-direction: column; align-items: flex-start; }
}
