/* ===== Banned in California — Redesign v2 ===== */

:root {
  --bg: #09090b;
  --bg-card: #111114;
  --bg-elevated: #18181b;
  --border: #1f1f23;
  --border-hover: #2a2a2e;

  --text: #e8e8ec;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent: #d4a843;
  --accent-dim: rgba(212, 168, 67, 0.12);

  --red: #dc2626;
  --orange: #ea580c;
  --yellow: #ca8a04;

  --red-bg: rgba(220, 38, 38, 0.10);
  --orange-bg: rgba(234, 88, 12, 0.10);
  --yellow-bg: rgba(202, 138, 4, 0.10);

  /* Fonts — Instrument Sans / Geist / Geist Mono */
  --font-heading: 'Instrument Sans', system-ui, sans-serif;
  --font-body: 'Geist', system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', monospace;

  --radius: 2px;
  --max-width: 1200px;

  /* Spacing scale (8px base) */
  --sp-1: 0.25rem;   /* 4px */
  --sp-2: 0.5rem;    /* 8px */
  --sp-3: 0.75rem;   /* 12px */
  --sp-4: 1rem;      /* 16px */
  --sp-5: 1.5rem;    /* 24px */
  --sp-6: 2rem;      /* 32px */
  --sp-7: 3rem;      /* 48px */
  --sp-8: 4rem;      /* 64px */
  --sp-9: 6rem;      /* 96px */
  --sp-10: 8rem;     /* 128px */

  /* Type scale (1.25 Major Third) */
  --text-xs: 0.65rem;
  --text-sm: 0.8rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.5rem;
  --text-display: clamp(3rem, 7vw, 5.5rem);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4rem;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===== Sticky Nav ===== */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0 var(--sp-6);
  transition: background 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}

.site-nav.scrolled {
  background: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-color: var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.nav-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.12em;
  color: var(--text);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-2);
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text-secondary);
  transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle.active span:first-child {
  transform: translateY(3.25px) rotate(45deg);
}

.nav-toggle.active span:last-child {
  transform: translateY(-3.25px) rotate(-45deg);
}

.nav-links {
  display: flex;
  gap: var(--sp-6);
}

.nav-links a {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
  position: relative;
}

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

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
}

/* ===== Hero ===== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: var(--sp-10) var(--sp-6);
}

.hero-grid-bg {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(255,255,255,0.025) 59px, rgba(255,255,255,0.025) 60px),
    repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(255,255,255,0.025) 59px, rgba(255,255,255,0.025) 60px);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 20%, transparent 70%);
  animation: gridPulse 8s ease-in-out infinite alternate;
}

@keyframes gridPulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: var(--text-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: var(--sp-6);
}

.hero-title-accent {
  position: relative;
  display: inline-block;
}

.hero-title-accent::after {
  content: '';
  position: absolute;
  bottom: 0.06em;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

.hero-subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: var(--sp-6);
  max-width: 600px;
}

.hero-tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: var(--sp-7);
}

/* Severity Legend */
.severity-legend {
  display: flex;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.severity-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.severity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.severity-dot--red { background: var(--red); }
.severity-dot--orange { background: var(--orange); }
.severity-dot--yellow { background: var(--yellow); }

/* ===== Stats Banner ===== */
.stats-banner {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.stats-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: var(--sp-7) var(--sp-6);
}

.stat-item {
  text-align: center;
  border-top: 2px solid var(--accent);
  padding-top: var(--sp-5);
  position: relative;
}

.stat-item + .stat-item {
  border-left: 1px solid var(--border);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: var(--sp-2);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 200px;
  margin: 0 auto;
  line-height: 1.45;
}

/* ===== Product Sections ===== */
.product-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--sp-10) var(--sp-6);
  overflow: hidden;
}

.section-header {
  margin-bottom: var(--sp-7);
}

.section-header h2 {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-1);
}

.section-header-sub {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.section-rule {
  width: 48px;
  height: 2px;
  background: var(--accent);
  margin-top: var(--sp-3);
}

/* Section text + diagram layout */
.section-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-7);
  align-items: start;
  margin-bottom: var(--sp-7);
}

.section-layout > * {
  min-width: 0; /* prevent grid blowout */
}

.section-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--sp-5);
}

.callout {
  background: var(--bg-card);
  border-left: 2px solid var(--accent);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.callout strong {
  color: var(--text);
}

/* Diagram container */
.section-diagram {
  grid-column: 1 / -1;
  position: relative;
  margin-top: var(--sp-4);
  min-width: 0; /* prevent grid blowout */
}

.diagram-scroll-hint {
  display: none; /* shown only on mobile */
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: var(--sp-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.diagram-scroll-wrap object,
.diagram-scroll-wrap img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ===== Process List ===== */
.process-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.process-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-card);
  transition: background 0.2s;
}

.process-item:hover {
  background: var(--bg-elevated);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.badge--red {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.badge--orange {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid rgba(234, 88, 12, 0.2);
}

.badge--yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid rgba(202, 138, 4, 0.2);
}

.process-item-body h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.process-item-body p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.55;
}

/* ===== Map Section ===== */
#map-section {
  padding: var(--sp-10) 0;
}

.map-section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.map-wrapper {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--sp-5);
  min-height: 550px;
}

#map {
  width: 100%;
  height: 550px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.facility-list {
  max-height: 550px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.facility-list::-webkit-scrollbar {
  width: 4px;
}

.facility-list::-webkit-scrollbar-track {
  background: var(--bg);
}

.facility-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.facility-card {
  background: var(--bg-card);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  transition: background 0.15s;
}

.facility-card:hover,
.facility-card.active {
  background: var(--bg-elevated);
}

.facility-card.active {
  border-left: 2px solid var(--accent);
  padding-left: calc(var(--sp-4) - 2px);
}

.facility-card h4 {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.facility-card .facility-city {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.facility-card .facility-type {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 1px 8px;
  border-radius: var(--radius);
  margin-top: var(--sp-1);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Facility Detail Panel (below map) */
.facility-detail {
  display: none;
  margin-top: var(--sp-5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--sp-5) var(--sp-5) var(--sp-5) calc(var(--sp-5) - 2px);
  animation: detailSlideIn 0.25s ease;
}

.facility-detail.visible {
  display: block;
}

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

.facility-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-4);
}

.facility-detail-name {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.facility-detail-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.facility-detail-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.facility-detail-close:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.facility-detail-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: var(--sp-4);
}

.facility-detail-processes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.facility-detail-processes .process-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius);
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.filter-btn {
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
}

.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ===== Footer ===== */
.site-footer {
  padding: 0 var(--sp-6) var(--sp-8);
}

.footer-rule {
  max-width: var(--max-width);
  margin: 0 auto var(--sp-6);
  height: 1px;
  background: var(--border);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-attribution {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.footer-attribution a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

.footer-attribution a:hover {
  opacity: 0.8;
}

.footer-note {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 600px;
  line-height: 1.55;
}

/* ===== Animations ===== */
.reveal-section {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

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

/* Staggered children */
.process-item {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease, background 0.2s;
}

.reveal-section.visible .process-item {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Leaflet dark overrides ===== */
.leaflet-container {
  background: var(--bg-card) !important;
  font-family: var(--font-body) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-elevated) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-tip {
  background: var(--bg-elevated) !important;
}

.leaflet-popup-content {
  margin: 10px 14px !important;
  font-family: var(--font-body) !important;
  line-height: 1.4 !important;
}

.leaflet-popup-content h3 {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.leaflet-popup-content p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 1px 0;
}

.leaflet-popup-content .popup-type {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 1px 8px;
  border-radius: var(--radius);
  margin-top: 4px;
  background: var(--accent-dim);
  color: var(--accent);
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 900px) {
  .stats-inner {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-5);
  }

  .stat-item + .stat-item {
    border-left: none;
  }

  /* Two-col stats: add left border to right column items */
  .stat-item:nth-child(even) {
    border-left: 1px solid var(--border);
  }

  .section-layout {
    grid-template-columns: 1fr;
    gap: var(--sp-6);
  }

  .map-wrapper {
    grid-template-columns: 1fr;
  }

  #map {
    height: 400px;
  }

  .facility-list {
    max-height: 280px;
  }

  /* Show mobile nav toggle */
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 3.5rem;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(9, 9, 11, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: var(--sp-4) var(--sp-6);
    gap: var(--sp-3);
  }

  .nav-links.open {
    display: flex;
  }

  .product-section {
    padding: var(--sp-9) var(--sp-6);
  }

  #map-section {
    padding: var(--sp-9) 0;
  }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 600px) {
  .stats-inner {
    grid-template-columns: 1fr 1fr;
    padding: var(--sp-6) var(--sp-4);
  }

  .product-section {
    padding: var(--sp-8) var(--sp-4);
  }

  #map-section {
    padding: var(--sp-8) 0;
  }

  .map-section-inner {
    padding: 0 var(--sp-4);
  }

  .hero {
    padding: var(--sp-9) var(--sp-4);
    min-height: 85vh;
  }

  .hero-title {
    font-size: clamp(2.2rem, 10vw, 3.5rem);
  }

  .hero-subtitle {
    font-size: var(--text-base);
  }

  .hero-tagline {
    font-size: var(--text-sm);
  }

  .severity-legend {
    gap: var(--sp-4);
  }

  .stat-number {
    font-size: var(--text-2xl);
  }

  .stat-label {
    font-size: var(--text-xs);
  }

  .section-header h2 {
    font-size: var(--text-2xl);
  }

  .section-header {
    margin-bottom: var(--sp-6);
  }

  /* Diagrams: horizontal scroll on mobile */
  .diagram-scroll-hint {
    display: block;
  }

  .diagram-scroll-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-bottom: var(--sp-2);
  }

  .diagram-scroll-wrap::-webkit-scrollbar {
    height: 3px;
  }

  .diagram-scroll-wrap::-webkit-scrollbar-track {
    background: transparent;
  }

  .diagram-scroll-wrap::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }

  .diagram-scroll-wrap object {
    min-width: 700px;
    width: 700px;
    height: auto;
    display: block;
  }

  /* Process list tighter on mobile */
  .process-item {
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
  }

  .process-item-body h4 {
    font-size: var(--text-sm);
  }

  .process-item-body p {
    font-size: var(--text-xs);
    line-height: 1.5;
  }

  .callout {
    font-size: var(--text-sm);
    padding: var(--sp-3) var(--sp-4);
  }

  .section-subtitle {
    font-size: var(--text-base);
  }

  /* Map */
  #map {
    height: 300px;
  }

  .facility-list {
    max-height: 220px;
  }

  .facility-detail {
    padding: var(--sp-4);
  }

  .facility-detail-name {
    font-size: var(--text-base);
  }

  /* Footer */
  .site-footer {
    padding: 0 var(--sp-4) var(--sp-8);
  }

  .footer-note {
    font-size: var(--text-xs);
  }

  /* Filter bar scroll on mobile */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--sp-2);
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex-shrink: 0;
  }
}

/* ===== Responsive: Small mobile ===== */
@media (max-width: 380px) {
  .stats-inner {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
  }

  .stat-item:nth-child(even) {
    border-left: none;
  }

  .hero-title {
    font-size: 2rem;
  }

  .severity-legend {
    flex-direction: column;
    gap: var(--sp-2);
  }
}
