/* Métis Homeland Map V8 - Bottom Bar UI */

:root {
 /* Métis-inspired color palette (shared across modes) */
 --metis-red: #B8312F;
 --metis-green: #2D7D46;
 --metis-blue: #1E4D8C;
 --metis-yellow: #D4A520;
 --metis-burgundy: #722F37;
 
 /* Buffalo herd colors */
 --buffalo-original: #4CAF50;
 --buffalo-1870: #FF9800;
 --buffalo-1889: #F44336;

 /* Transitions */
 --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
 --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
 --transition-theme: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

 /* === LIGHT MODE (default) === */
 --bg-primary: #FDFCFA;
 --bg-secondary: #F5EFE6;
 --bg-tertiary: #E8DFD2;
 --bg-overlay: rgba(253, 252, 250, 0.95);

 --text-primary: #2C2416;
 --text-secondary: #4A3F2F;
 --text-muted: #6B5D4D;

 --border-color: rgba(44, 36, 22, 0.12);
 --shadow-color: rgba(0, 0, 0, 0.08);

 /* Shadows */
 --shadow-sm: 0 2px 8px var(--shadow-color);
 --shadow-md: 0 4px 16px var(--shadow-color);
 --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);

 /* Map tile filter */
 --map-filter: none;
}

/* === DARK MODE — Lamplight on Old Parchment === */
.dark-mode {
 --bg-primary: #1A1714;
 --bg-secondary: #252119;
 --bg-tertiary: #332D24;
 --bg-overlay: rgba(26, 23, 20, 0.95);

 --text-primary: #E8DFD2;
 --text-secondary: #B8A998;
 --text-muted: #8A7D6E;

 --border-color: rgba(184, 169, 152, 0.15);
 --shadow-color: rgba(0, 0, 0, 0.35);

 --shadow-sm: 0 2px 8px var(--shadow-color);
 --shadow-md: 0 4px 16px var(--shadow-color);
 --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

 /* Invert Voyager tiles into a dark, warm parchment look — keeps all detail */
 --map-filter: invert(1) hue-rotate(180deg) sepia(0.2) brightness(0.88) saturate(0.8);
}

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

body {
 font-family: 'Manrope', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
 background: var(--bg-primary);
 color: var(--text-primary);
 overflow: hidden;
 transition: background var(--transition-theme), color var(--transition-theme);
}

/* Theme crossfade for UI chrome */
.bottom-bar,
.stats-panel,
.legend-panel,
.layer-info-panel,
.layer-btn,
.stats-toggle,
.theme-toggle,
.control-btn,
.close-btn,
.stat-detail,
.legend-item,
.layer-info-toggle,
.expandable-header,
.feature-item,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
 transition: background var(--transition-theme), color var(--transition-theme), border-color var(--transition-theme), box-shadow var(--transition-theme);
}

#map {
 width: 100vw;
 height: 100vh;
 position: relative;
}

/* Apply aging filter to map tiles */
.leaflet-tile-pane {
 filter: var(--map-filter);
 transition: filter 0.5s ease;
}

/* Smooth hover transitions on map features */
.leaflet-overlay-pane path,
.leaflet-overlay-pane circle {
 transition: filter 0.2s ease, stroke-width 0.2s ease;
}

/* ============================================
BOTTOM CONTROL BAR
============================================ */
.bottom-bar {
 position: absolute;
 bottom: 20px;
 left: 50%;
 transform: translateX(-50%);
 width: calc(100% - 40px);
 max-width: 900px;
 background: var(--bg-overlay);
 backdrop-filter: blur(12px);
 -webkit-backdrop-filter: blur(12px);
 border: 1px solid var(--border-color);
 border-radius: 16px;
 box-shadow: var(--shadow-lg);
 z-index: 1000;
 padding: 12px 16px;
 display: flex;
 align-items: center;
 gap: 10px;
 transition: all var(--transition-smooth);
}

/* Layer Toggles — fill the bar, evenly distribute buttons */
.layer-toggles {
 display: flex;
 gap: 8px;
 flex: 0 1 auto;
 min-width: 0;
 justify-content: center;
}

.layer-btn {
 display: flex;
 flex-direction: column;
 align-items: center;
 gap: 4px;
 padding: 8px 12px;
 background: var(--bg-secondary);
 border: 2px solid transparent;
 border-radius: 10px;
 cursor: pointer;
 color: var(--text-primary);
 transition: all var(--transition-fast);
 flex: 1;
 min-width: 0; /* Override <button> intrinsic min-width so flex:1 works */
}

.layer-btn:hover {
 background: var(--bg-tertiary);
 color: var(--text-primary);
 transform: translateY(-2px);
}

.layer-btn.active {
 background: linear-gradient(135deg, var(--metis-blue) 0%, var(--metis-green) 100%);
 color: white;
 box-shadow: var(--shadow-md);
 animation: layerPulse 0.35s ease-out;
}

@keyframes layerPulse {
 0% { transform: scale(1); }
 40% { transform: scale(1.08); }
 100% { transform: scale(1); }
}

/* Layer control wrapper - holds button + info icon */
.layer-control {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
 flex-direction: column;
}

/* Info button - small (i) icon for layer details */
.info-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.info-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Stats and theme wrapper - group together and center */
.stats-theme-group {
 display: flex;
 align-items: center;
 gap: 8px;
 flex-shrink: 0;
}

/* Make info-btn smaller and below the button */
.layer-control .info-btn {
 width: 16px;
 height: 16px;
 font-size: 10px;
 margin-top: -2px;
}

/* Adjust layer-btn inside layer-control */
.layer-control .layer-btn {
  flex: 1;
  min-width: 0;
}

/* Bottom bar - center all items */
.bottom-bar {
  justify-content: center;
}

/* Remove flex:1 from layer-toggles so it doesn't push stats/theme to right */
.layer-toggles {
  flex: 0 1 auto;
  justify-content: center;
}


/* Bottom bar entrance stagger */
.bottom-bar .layer-btn,
.bottom-bar .stats-toggle,
.bottom-bar .theme-toggle {
 opacity: 0;
 transform: translateY(10px);
 animation: btnStaggerIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.bottom-bar .layer-btn:nth-child(1) { animation-delay: 0.1s; }
.bottom-bar .layer-btn:nth-child(2) { animation-delay: 0.18s; }
.bottom-bar .layer-btn:nth-child(3) { animation-delay: 0.26s; }
.bottom-bar .layer-btn:nth-child(4) { animation-delay: 0.34s; }
.bottom-bar .layer-btn:nth-child(5) { animation-delay: 0.42s; }
.bottom-bar .stats-toggle { animation-delay: 0.5s; }
.bottom-bar .theme-toggle { animation-delay: 0.56s; }

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

.layer-btn .icon {
 font-size: 20px;
 line-height: 1;
 display: flex;
 align-items: center;
 justify-content: center;
 width: 24px;
 height: 24px;
}

.layer-btn .label {
 font-size: 10px;
 font-weight: 600;
 text-transform: uppercase;
 letter-spacing: 0.5px;
}

/* Stats Container (Center) */
.stats-container {
 display: flex;
 gap: 16px;
 flex: 1;
 justify-content: center;
 padding: 0 16px;
 border-left: 1px solid var(--border-color);
 border-right: 1px solid var(--border-color);
}

.stat {
 display: flex;
 flex-direction: column;
 align-items: center;
 gap: 4px;
 min-width: 50px;
}

.stat-icon {
 font-size: 16px;
 opacity: 0.8;
}

.stat-value {
 font-size: 18px;
 font-weight: 700;
 color: var(--text-primary);
 line-height: 1;
}

/* Stat colors */
.stat.waterways .stat-value { color: var(--metis-blue); }
.stat.trails .stat-value { color: var(--metis-red); }
.stat.locations .stat-value { color: var(--metis-green); }
.stat.buffalo .stat-value { color: var(--buffalo-1889); }

/* Stats Toggle — flex child inside the bar, aligned to right */
.stats-toggle {
 flex-shrink: 0;
 align-self: center;
}

.control-btn {
 width: 40px;
 height: 40px;
 border: none;
 background: var(--bg-secondary);
 color: var(--text-primary);
 border-radius: 10px;
 cursor: pointer;
 transition: all var(--transition-fast);
 display: flex;
 align-items: center;
 justify-content: center;
 font-size: 18px;
 line-height: 1;
}

.control-btn:hover {
 background: var(--bg-tertiary);
 transform: translateY(-2px);
}

/* ============================================
DARK MODE TOGGLE
============================================ */
.theme-toggle {
 width: 40px;
 height: 40px;
 border: none;
 background: var(--bg-secondary);
 color: var(--text-primary);
 border-radius: 10px;
 cursor: pointer;
 transition: all var(--transition-fast);
 display: flex;
 align-items: center;
 justify-content: center;
 font-size: 18px;
 line-height: 1;
 flex-shrink: 0;
}

.theme-toggle:hover {
 background: var(--bg-tertiary);
 transform: translateY(-2px);
}

.theme-toggle:focus-visible {
 outline: 3px solid var(--metis-yellow);
 outline-offset: 2px;
}

/* ============================================
SPLASH SCREEN
============================================ */
.splash {
 position: fixed;
 inset: 0;
 z-index: 2000;
 display: flex;
 align-items: center;
 justify-content: center;
 background: 
  linear-gradient(
  135deg,
  rgba(26, 23, 20, 0.82) 0%,
  rgba(26, 23, 20, 0.70) 60%,
  rgba(26, 23, 20, 0.55) 100%
  ),
  url('https://images.unsplash.com/photo-1569396116180-210c18754560?w=1920&q=60') center/cover no-repeat;
 backdrop-filter: blur(3px) brightness(0.6);
 -webkit-backdrop-filter: blur(3px) brightness(0.6);
 opacity: 1;
 transition: opacity 0.5s ease;
}

/* Film grain overlay */
.splash::after {
 content: '';
 position: absolute;
 inset: 0;
 z-index: 1;
 opacity: 0.04;
 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)'/%3E%3C/svg%3E");
 background-size: 256px 256px;
}

.splash.fade-out {
 opacity: 0;
 pointer-events: none;
}

/* Staggered reveal for splash children */
@keyframes staggerIn {
 from {
 opacity: 0;
 transform: translateY(16px);
 }
 to {
 opacity: 1;
 transform: translateY(0);
 }
}

/* Splash entrance animation */
@keyframes splashEnter {
 from {
 opacity: 0;
 transform: scale(0.92) translateY(12px);
 }
 to {
 opacity: 1;
 transform: scale(1) translateY(0);
 }
}

.splash-card {
 background: rgba(253, 252, 250, 0.92);
 backdrop-filter: blur(16px);
 -webkit-backdrop-filter: blur(16px);
 border-radius: 20px;
 border: 1px solid rgba(212, 165, 32, 0.2);
 padding: 52px 48px 44px;
 max-width: 520px;
 width: calc(100% - 32px);
 box-shadow: 0 32px 96px rgba(0,0,0,0.55), 0 8px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
 text-align: center;
 position: relative;
 overflow: hidden;
 animation: splashEnter 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
 z-index: 2;
}

/* Top color bar - Métis sash stripe */
.splash-card::before {
 content: '';
 position: absolute;
 top: 0; left: 0; right: 0;
 height: 6px;
 background: linear-gradient(90deg,
 #B8312F 0%, #B8312F 20%,
 #D4A520 20%, #D4A520 40%,
 #2D7D46 40%, #2D7D46 60%,
 #1E4D8C 60%, #1E4D8C 80%,
 #722F37 80%, #722F37 100%
 );
}

/* Bottom decorative border - brass accent line */
.splash-card::after {
 content: '';
 position: absolute;
 bottom: 0; left: 50%;
 transform: translateX(-50%);
 width: 60%;
 height: 3px;
 background: linear-gradient(90deg, transparent, #D4A520, transparent);
 border-radius: 2px;
}

/* Métis infinity symbol */
.splash-motif {
 font-size: 64px;
 line-height: 1;
 margin: 0 auto 24px;
 color: #B8312F;
 text-shadow: 0 4px 16px rgba(184, 49, 47, 0.3), 0 0 48px rgba(184, 49, 47, 0.08);
 /* Staggered entrance - first element */
 opacity: 0;
 animation: motifPulse 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes motifPulse {
 0% {
 opacity: 0;
 transform: scale(0.8);
 filter: blur(4px);
 }
 60% {
 transform: scale(1.03);
 }
 100% {
 opacity: 1;
 transform: scale(1);
 filter: blur(0);
 }
}

.splash-card h1 {
 font-family: 'Fraunces', Georgia, serif;
 font-size: 42px;
 font-weight: 700;
 color: #1A1714;
 line-height: 1.12;
 margin-bottom: 12px;
 letter-spacing: -0.5px;
 /* Staggered entrance */
 opacity: 0;
 transform: translateY(16px);
 animation: staggerIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}

.splash-card .subtitle {
 font-family: 'Fraunces', Georgia, serif;
 font-size: 19px;
 font-weight: 600;
 color: #B8312F;
 margin-bottom: 24px;
 letter-spacing: 0.3px;
 /* Staggered entrance */
 opacity: 0;
 transform: translateY(12px);
 animation: staggerIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.25s forwards;
}

.splash-card p {
 font-size: 15px;
 line-height: 1.7;
 color: #4A3F2F;
 margin-bottom: 32px;
 /* Staggered entrance */
 opacity: 0;
 transform: translateY(10px);
 animation: staggerIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.30s forwards;
}

/* Layer preview pills */
.layer-pills {
 display: flex;
 flex-wrap: wrap;
 gap: 8px;
 justify-content: center;
 margin-bottom: 40px;
}

.pill {
 display: inline-flex;
 align-items: center;
 gap: 6px;
 padding: 8px 16px;
 border-radius: 999px;
 background: rgba(245, 239, 230, 0.7);
 border: 1.5px solid #E8DFD2;
 font-size: 13px;
 font-weight: 600;
 color: #4A3F2F;
 cursor: pointer;
 transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
 /* Staggered entrance */
 opacity: 0;
 transform: scale(0.9);
 animation: pillPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.pill:nth-child(1) { animation-delay: 0.35s; }
.pill:nth-child(2) { animation-delay: 0.41s; }
.pill:nth-child(3) { animation-delay: 0.47s; }
.pill:nth-child(4) { animation-delay: 0.53s; }
.pill:nth-child(5) { animation-delay: 0.59s; }

.pill:hover {
 background: #B8312F;
 border-color: #B8312F;
 color: #FDFCFA;
 transform: translateY(-2px);
 box-shadow: 0 4px 12px rgba(184, 49, 47, 0.25);
}

.pill .pill-icon {
 font-size: 15px;
 line-height: 1;
}

@keyframes pillPop {
 0% {
 opacity: 0;
 transform: scale(0.85);
 }
 100% {
 opacity: 1;
 transform: scale(1);
 }
}

/* CTA button */
.enter-btn {
 display: inline-flex;
 align-items: center;
 gap: 10px;
 padding: 16px 40px;
 background: #B8312F;
 color: #FDFCFA;
 font-family: 'Manrope', sans-serif;
 font-size: 14px;
 font-weight: 700;
 letter-spacing: 0.6px;
 text-transform: uppercase;
 border: 2px solid #D4A520;
 border-radius: 10px;
 cursor: pointer;
 transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
 box-shadow: 0 6px 20px rgba(184, 49, 47, 0.35), 0 2px 6px rgba(0,0,0,0.15);
 opacity: 0;
 transform: translateY(12px);
 animation: staggerIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.45s forwards;
}

.enter-btn:hover {
 background: #D4A520;
 border-color: #B8312F;
 color: #1A1714;
 transform: translateY(-3px) scale(1.02);
 box-shadow: 0 12px 32px rgba(212, 165, 32, 0.4), 0 4px 12px rgba(0,0,0,0.2);
}

.enter-btn:hover .arrow {
 transform: translateX(5px);
}

.splash-card .tagline {
 margin-top: 24px;
 font-size: 11px;
 color: #8A7D6E;
 letter-spacing: 0.5px;
 text-transform: uppercase;
 font-weight: 600;
 opacity: 0;
 animation: staggerIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.55s forwards;
}

/* Splash dark mode */
.dark-mode .splash-card {
 background: rgba(37, 33, 25, 0.94);
 backdrop-filter: blur(16px);
 -webkit-backdrop-filter: blur(16px);
 border-color: rgba(212, 165, 32, 0.15);
}

.dark-mode .splash-card h1 { color: #E8DFD2; }
.dark-mode .splash-card .subtitle { color: #D4A520; }
.dark-mode .splash-card p { color: #B8A998; }
.dark-mode .pill { background: #332D24; border-color: #4A3F2F; color: #B8A998; }
.dark-mode .enter-btn { background: #D4A520; color: #1A1714; border-color: #B8312F; }
.dark-mode .enter-btn:hover { background: #1A1714; color: #D4A520; border-color: #D4A520; }
.dark-mode .splash-card .tagline { color: #6B5D4D; }
.dark-mode .splash-motif { color: #D4A520; text-shadow: 0 2px 12px rgba(212, 165, 32, 0.3); }

/* Splash responsive */
@media (max-width: 500px) {
 .splash-card {
 padding: 40px 28px 36px;
 }
 .splash-card h1 {
 font-size: 28px;
 }
 .splash-card .subtitle {
 font-size: 15px;
 }
 .splash-card p {
 font-size: 13.5px;
 }
}

/* ============================================
COLLAPSIBLE PANELS
============================================ */
.stats-panel,
.legend-panel,
.layer-info-panel {
 position: absolute;
 bottom: 100px;
 left: 50%;
 transform: translateX(-50%) translateY(20px) scale(0.97);
 width: calc(100% - 40px);
 max-width: 600px;
 background: var(--bg-overlay);
 backdrop-filter: blur(12px);
 -webkit-backdrop-filter: blur(12px);
 border: 1px solid var(--border-color);
 border-radius: 16px;
 box-shadow: var(--shadow-lg);
 z-index: 999;
 opacity: 0;
 pointer-events: none;
 transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
 overflow: hidden;
}

.stats-panel.visible,
.legend-panel.visible,
.layer-info-panel.visible {
 opacity: 1;
 pointer-events: auto;
 transform: translateX(-50%) translateY(0) scale(1);
}

.stats-panel-header,
.legend-panel-header {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 16px 20px;
 background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
 color: var(--bg-primary);
}

.stats-panel-header h3,
.legend-panel-header h3 {
 font-size: 16px;
 font-weight: 600;
 margin: 0;
}

.close-btn {
 width: 32px;
 height: 32px;
 border: none;
 background: rgba(255, 255, 255, 0.1);
 border-radius: 8px;
 color: white;
 font-size: 24px;
 cursor: pointer;
 display: flex;
 align-items: center;
 justify-content: center;
 transition: background var(--transition-fast);
}

.close-btn:hover {
 background: rgba(255, 255, 255, 0.2);
}

/* Stats Detail Panel */
.stats-detail {
 display: grid;
 grid-template-columns: repeat(2, 1fr);
 gap: 16px;
 padding: 20px;
}

.stat-detail {
 padding: 16px;
 background: var(--bg-secondary);
 border-radius: 12px;
}

.stat-detail .stat-label {
 font-size: 11px;
 text-transform: uppercase;
 letter-spacing: 0.5px;
 color: var(--text-muted);
 font-weight: 600;
 margin-bottom: 8px;
}


.stats-detail {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.stat-detail .stat-value {
 font-size: 28px;
 font-weight: 700;
 color: var(--text-primary);
 line-height: 1;
 margin-bottom: 6px;
}

.stat-detail .stat-desc {
 font-size: 11px;
 color: var(--text-secondary);
 line-height: 1.4;
}

.stats-source {
 padding: 16px 20px;
 background: var(--bg-secondary);
 border-top: 1px solid var(--border-color);
}

.stats-source p {
 font-size: 11px;
 color: var(--text-muted);
 margin: 0;
 font-style: italic;
}

/* Legend Panel */
.legend-content {
 padding: 20px;
}

.legend-category {
 margin-bottom: 20px;
}

.legend-category:last-child {
 margin-bottom: 0;
}

.legend-category h4 {
 font-size: 12px;
 font-weight: 600;
 text-transform: uppercase;
 letter-spacing: 1px;
 color: var(--text-muted);
 margin-bottom: 12px;
}

.legend-item {
 display: flex;
 align-items: center;
 gap: 10px;
 padding: 8px;
 margin-bottom: 8px;
 background: var(--bg-secondary);
 border-radius: 8px;
 font-size: 13px;
 color: var(--text-primary);
 transition: background var(--transition-fast);
}

.legend-item:hover {
 background: var(--bg-tertiary);
}

.legend-icon {
 width: 20px;
 height: 20px;
 border-radius: 4px;
 flex-shrink: 0;
}

.legend-icon.waterway {
 background: var(--metis-blue);
 border-radius: 2px;
 box-shadow: 0 0 6px rgba(30, 77, 140, 0.4);
}

.legend-icon.trail {
 background: var(--metis-red);
 border-radius: 2px;
 background-image: repeating-linear-gradient(
 90deg,
 var(--metis-red) 0px,
 var(--metis-red) 4px,
 transparent 4px,
 transparent 8px
 );
}

.legend-icon.location {
 background: var(--metis-green);
 border-radius: 50%;
 border: 3px solid var(--bg-primary);
 box-shadow: 0 2px 6px rgba(45, 125, 70, 0.4);
}

.legend-icon.buffalo-original {
 background: var(--buffalo-original);
 border: 2px solid rgba(0, 0, 0, 0.2);
}

.legend-icon.buffalo-1870 {
 background: var(--buffalo-1870);
 border: 2px solid rgba(0, 0, 0, 0.2);
}

.legend-icon.buffalo-1889 {
 background: var(--buffalo-1889);
 border: 2px solid rgba(0, 0, 0, 0.2);
}

/* Layer Info Panel */
.layer-info-header {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 16px 20px;
 background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
 color: var(--bg-primary);
}

.layer-info-header h3 {
 font-size: 16px;
 font-weight: 600;
 margin: 0;
}

.layer-info-content {
 padding: 20px;
 max-height: 60vh;
 overflow-y: auto;
}

.layer-info-section {
 margin-bottom: 20px;
}

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

.layer-info-toggle {
 display: flex;
 align-items: center;
 gap: 12px;
 margin-bottom: 16px;
 padding: 12px;
 background: var(--bg-secondary);
 border-radius: 10px;
}

.layer-info-toggle input[type="checkbox"] {
 width: 20px;
 height: 20px;
 cursor: pointer;
}

.layer-info-toggle label {
 font-size: 14px;
 font-weight: 600;
 color: var(--text-primary);
 cursor: pointer;
 flex: 1;
}

.layer-info-about h4,
.layer-info-sources h4,
.layer-info-features h4 {
 font-size: 12px;
 font-weight: 600;
 text-transform: uppercase;
 letter-spacing: 1px;
 color: var(--text-muted);
 margin-bottom: 10px;
}

.layer-info-about p,
.layer-info-sources p {
 font-size: 13px;
 color: var(--text-secondary);
 line-height: 1.6;
 margin-bottom: 10px;
}

.layer-info-sources p {
 font-size: 12px;
 font-style: italic;
 color: var(--text-muted);
}

/* Expandable sections for buffalo eras */
.expandable-section {
 margin-bottom: 12px;
}

.expandable-header {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 12px;
 background: var(--bg-secondary);
 border-radius: 8px;
 cursor: pointer;
 color: var(--text-primary);
 transition: background var(--transition-fast);
}

.expandable-header:hover {
 background: var(--bg-tertiary);
}

.expandable-header h5 {
 font-size: 13px;
 font-weight: 600;
 margin: 0;
}

.expandable-icon {
 font-size: 16px;
 transition: transform var(--transition-fast);
}

.expandable-header.active .expandable-icon {
 transform: rotate(180deg);
}

.expandable-content {
 padding: 12px;
 background: var(--bg-primary);
 border-left: 3px solid var(--text-muted);
 margin-left: 12px;
 font-size: 13px;
 color: var(--text-secondary);
 line-height: 1.6;
}

/* Feature list items */
.feature-item {
 padding: 10px;
 margin-bottom: 8px;
 background: var(--bg-secondary);
 border-radius: 8px;
 font-size: 13px;
 color: var(--text-primary);
}

.feature-item strong {
 display: block;
 margin-bottom: 4px;
 color: var(--text-primary);
}

.feature-item p {
 margin: 0;
 color: var(--text-secondary);
 font-size: 12px;
 line-height: 1.5;
}

/* ============================================
RESPONSIVE
============================================ */
@media (max-width: 768px) {
 .bottom-bar {
 flex-direction: row;
 flex-wrap: wrap;
 gap: 10px;
 padding: 12px 16px;
 justify-content: center;
 align-items: center;
 }
 
 .layer-toggles {
 width: 100%;
 justify-content: center;
 flex-wrap: wrap;
 flex: 0 0 100% !important;
 gap: 8px;
 }
 
 /* Utility buttons centered on second row */
 .stats-toggle,
 .theme-toggle {
 flex: none !important;
 }
 
 .stats-toggle {
 order: 10;
 }
 
 .theme-toggle {
 order: 11;
 margin-left: 8px;
 }
 
 .stats-detail {
 grid-template-columns: 1fr;
 }
 
 .stats-panel,
 .legend-panel,
 .layer-info-panel {
 width: calc(100% - 20px);
 bottom: auto;
 top: 20px;
 }
}

/* ============================================
MAP CONTROLS POLISH
============================================ */
.leaflet-control-zoom {
 border: none !important;
 box-shadow: var(--shadow-md) !important;
 border-radius: 8px !important;
 overflow: hidden;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
 background: var(--bg-primary) !important;
 color: var(--text-primary) !important;
 border: none !important;
 width: 36px !important;
 height: 36px !important;
 line-height: 36px !important;
 font-size: 18px !important;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
 background: var(--bg-secondary) !important;
}

/* Popup styling */
.leaflet-popup-content-wrapper {
 border-radius: 12px;
 box-shadow: var(--shadow-lg);
 padding: 0;
 overflow: hidden;
 background: var(--bg-overlay) !important;
 backdrop-filter: blur(12px);
 -webkit-backdrop-filter: blur(12px);
 color: var(--text-primary);
}

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

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

.popup-header {
 background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
 padding: 14px 18px;
}

.popup-title {
 font-weight: 600;
 font-size: 16px;
 color: var(--bg-primary);
 margin: 0;
}

.popup-body {
 padding: 16px;
}

.popup-description {
 font-size: 13px;
 color: var(--text-secondary);
 line-height: 1.6;
 margin-bottom: 12px;
}

.popup-meta {
 display: flex;
 flex-wrap: wrap;
 gap: 8px;
}

.popup-tag {
 background: var(--bg-secondary);
 padding: 4px 10px;
 border-radius: 20px;
 font-size: 11px;
 color: var(--text-primary);
 font-weight: 500;
}

.popup-tag.founded {
 color: var(--metis-blue);
 background: rgba(30, 77, 140, 0.12);
}

.popup-tag.type {
 color: var(--metis-green);
 background: rgba(45, 125, 70, 0.12);
}

/* ============================================
ACCESSIBILITY
============================================ */
/* Screen-reader only utility class */
.sr-only {
 position: absolute;
 width: 1px;
 height: 1px;
 padding: 0;
 margin: -1px;
 overflow: hidden;
 clip: rect(0, 0, 0, 0);
 white-space: nowrap;
 border: 0;
}

/* Keyboard focus styles */
.layer-btn:focus-visible,
.control-btn:focus-visible,
.close-btn:focus-visible,
.theme-toggle:focus-visible {
 outline: 3px solid var(--metis-yellow);
 outline-offset: 2px;
}

/* Ensure focus ring is visible on dark backgrounds */
.close-btn:focus-visible {
 outline-color: var(--metis-yellow);
}

/* Error banner for data loading failures */
.error-banner {
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 z-index: 2000;
 padding: 14px 20px;
 background: linear-gradient(135deg, var(--metis-red), #8B1A1A);
 color: #FAF6F0;
 font-size: 14px;
 font-weight: 500;
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: 12px;
 opacity: 0;
 pointer-events: none;
 transform: translateY(-100%);
 transition: all var(--transition-smooth);
 box-shadow: 0 4px 12px rgba(184, 49, 47, 0.3);
}

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

.error-banner .error-message {
 flex: 1;
 line-height: 1.4;
}

.error-banner .error-dismiss {
 background: rgba(255, 255, 255, 0.15);
 border: 1px solid rgba(255, 255, 255, 0.25);
 color: white;
 padding: 6px 14px;
 border-radius: 6px;
 cursor: pointer;
 font-size: 13px;
 font-weight: 600;
 transition: background var(--transition-fast);
 flex-shrink: 0;
}

.error-banner .error-dismiss:hover {
 background: rgba(255, 255, 255, 0.25);
}

/* Warning variant (non-critical layer failures) */
.error-banner.warning {
 background: linear-gradient(135deg, #E65100, #BF360C);
}

/* ============================================
MAP OVERLAY
============================================ */
/* ============================================
RESPONSIVE — PHONES & TABLETS
============================================ */
/* Small phones (320-480px) */
@media (max-width: 480px) {
 .bottom-bar {
 bottom: 8px;
 left: 8px;
 right: 8px;
 width: auto;
 transform: none;
 padding: 10px 12px;
 gap: 8px;
 justify-content: center;
 /* Safe area for notched phones */
 padding-bottom: max(10px, env(safe-area-inset-bottom));
 }

 .layer-toggles {
 gap: 6px;
 }

 .layer-btn {
 padding: 6px 8px;
 gap: 2px;
 }

 .layer-btn .icon {
 font-size: 16px;
 width: 20px;
 height: 20px;
 }

 .layer-btn .label {
 font-size: 9px;
 }

 .control-btn,
 .theme-toggle {
 width: 36px;
 height: 36px;
 font-size: 16px;
 }

 /* Bottom-sheet style for phones — slides up from bottom, ~65% viewport */
 .stats-panel,
 .legend-panel,
 .layer-info-panel {
  width: calc(100% - 16px);
  left: 8px;
  right: 8px;
  transform: translateY(20px);
  bottom: 60px;
  top: auto;
  max-height: 65vh;
  border-radius: 16px 16px 8px 8px;
 }

 .layer-info-content {
  max-height: calc(65vh - 60px);
  overflow-y: auto;
 }

 .stats-panel.visible,
 .legend-panel.visible,
 .layer-info-panel.visible {
  transform: translateY(0);
 }



.stats-detail {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

 .stat-detail .stat-value {
 font-size: 22px;
 }

 /* Map overlay title */
 .overlay-header h1 {
 font-size: 18px;
 }

 .overlay-header p {
 font-size: 12px;
 }

 /* Error banner */
 .error-banner {
 font-size: 13px;
 padding: 10px 14px;
 }

 /* Larger touch targets */
 .layer-btn,
 .control-btn,
 .theme-toggle,
 .close-btn {
 min-height: 44px;
 }

 /* Compact bottom bar on mobile */
 .bottom-bar {
   padding: 8px 12px;
   gap: 8px;
 }

 /* Larger touch targets for info buttons */
 .info-btn {
   width: 28px;
   height: 28px;
   font-size: 16px;
 }

 /* Adjust layer-control gap */
 .layer-control {
   gap: 4px;
 }

 /* Vertical layer-control: reduce gap for mobile */
 .layer-control {
   gap: 1px;
 }

 /* Info button even smaller on mobile */
 .layer-control .info-btn {
   width: 14px;
   height: 14px;
   font-size: 9px;
   margin-top: 0;
 }

 /* Stats-theme-group: center on mobile */
 .stats-theme-group {
   justify-content: center;
 }
}

/* Tablets & medium screens (481-768px) */
@media (min-width: 481px) and (max-width: 768px) {
 .bottom-bar {
 bottom: 12px;
 width: calc(100% - 32px);
 padding: 10px 14px;
 }

 .stats-panel,
 .legend-panel,
 .layer-info-panel {
 width: calc(100% - 32px);
 max-width: 500px;
 }
}

/* Landscape phone */
@media (max-width: 768px) and (orientation: landscape) {
 .bottom-bar {
 flex-direction: row;
 bottom: 8px;
 padding: 8px 12px;
 }

 .layer-toggles {
 width: 100%;
 flex-wrap: nowrap;
 flex: 1;
 }

 .layer-btn .label {
 display: none;
 }

 .layer-btn {
 padding: 8px 10px;
 }

 .stats-panel,
 .legend-panel,
 .layer-info-panel {
 top: 10px;
 max-height: calc(100vh - 70px);
 width: 400px;
 left: 50%;
 transform: translateX(-50%) translateY(20px);
 }

 .stats-panel.visible,
 .legend-panel.visible,
 .layer-info-panel.visible {
 transform: translateX(-50%) translateY(0);
 }
}

/* Existing desktop breakpoint — keep but refine */
@media (max-width: 768px) {
 .bottom-bar {
 flex-direction: column;
 gap: 12px;
 padding: 16px;
 }

 .layer-toggles {
 width: 100%;
 justify-content: center;
 flex-wrap: wrap;
 flex: none;
 }

 .stats-toggle {
 align-self: flex-end;
 }

 .stats-detail {
 grid-template-columns: 1fr;
 }

 .stats-panel,
 .legend-panel,
 .layer-info-panel {
 width: calc(100% - 20px);
 bottom: auto;
 top: 20px;
 }
}
