/* ==========================================================================
   THE LAST ONES — Design System
   creaturesincrisis.org
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
  /* Colors */
  --color-bg: #0D0D0D;
  --color-bg-secondary: #141414;
  --color-bg-tertiary: #1a1a1a;
  --color-text: #f5f0e8;
  --color-text-muted: #9a9590;
  --color-accent: #8B0000;
  --color-accent-light: #a31515;
  --color-accent-glow: rgba(139, 0, 0, 0.4);
  --color-border: #2a2a2a;
  --color-border-light: #3a3a3a;
  
  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;
  
  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;
  
  /* Layout */
  --max-width: 1200px;
  --header-height: 72px;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background-color: var(--color-accent);
  color: var(--color-text);
}

a {
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-accent {
  color: var(--color-accent);
}

.font-mono {
  font-family: var(--font-mono);
}

.font-display {
  font-family: var(--font-display);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.section {
  padding: var(--space-20) 0;
}

.section-sm {
  padding: var(--space-12) 0;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(13, 13, 13, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.logo {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.logo-icon {
  color: var(--color-accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-accent);
  transition: width var(--transition-base);
}

.nav-link:hover {
  color: var(--color-text);
}

.nav-link:hover::after {
  width: 100%;
}

.nav-link.active {
  color: var(--color-text);
}

.nav-link.active::after {
  width: 100%;
}

/* Mobile Menu */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: var(--space-2);
}

@media (max-width: 768px) {
  .nav {
    display: none;
  }
  
  .mobile-menu-btn {
    display: block;
  }
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-secondary) 100%);
}

.hero-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
  padding: var(--space-8);
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  margin-bottom: var(--space-6);
  line-height: 1.1;
}

.hero-title span {
  color: var(--color-accent);
}

.hero-subtitle {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto var(--space-8);
  line-height: 1.6;
}

.hero-cta {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  border: 2px solid transparent;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-text);
  border-color: var(--color-accent);
}

.btn-primary:hover {
  background-color: var(--color-accent-light);
  border-color: var(--color-accent-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--color-accent-glow);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-border-light);
}

.btn-secondary:hover {
  border-color: var(--color-text);
  transform: translateY(-2px);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
  padding: var(--space-2) var(--space-4);
}

.btn-ghost:hover {
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--color-border-light);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.card-image {
  aspect-ratio: 21/9;
  overflow: hidden;
  background-color: var(--color-bg-tertiary);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.card:hover .card-image img {
  transform: scale(1.05);
}

.card-content {
  padding: var(--space-6);
}

.card-title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.card-meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

/* Species Card */
.species-card {
  position: relative;
}

.species-card .card-image {
  aspect-ratio: 21/9;
}

.species-count {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-accent);
}

.species-status {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  background-color: var(--color-accent);
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Grid Layouts
   -------------------------------------------------------------------------- */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Stats
   -------------------------------------------------------------------------- */
.stat {
  text-align: center;
  padding: var(--space-8);
}

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

.stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

/* --------------------------------------------------------------------------
   Species Detail
   -------------------------------------------------------------------------- */
.species-header {
  position: relative;
  min-height: 60vh;
  display: flex;
  align-items: flex-end;
  padding: var(--space-16) 0;
  background: linear-gradient(180deg, transparent 0%, var(--color-bg) 100%);
}

.species-hero-image {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
}

.species-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
}

.species-title {
  font-size: clamp(3rem, 10vw, 6rem);
  margin-bottom: var(--space-4);
}

.species-scientific {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.species-count-hero {
  font-family: var(--font-mono);
  font-size: var(--text-6xl);
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.species-count-label {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* --------------------------------------------------------------------------
   Map
   -------------------------------------------------------------------------- */
.map-container {
  height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

#map {
  height: 100%;
  width: 100%;
  background-color: var(--color-bg-secondary);
}

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */
.section-header {
  margin-bottom: var(--space-12);
  text-align: center;
}

.section-title {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto;
}

.section-divider {
  width: 60px;
  height: 4px;
  background-color: var(--color-accent);
  margin: var(--space-6) auto 0;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer {
  background-color: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  padding: var(--space-16) 0 var(--space-8);
  margin-top: var(--space-24);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-12);
  margin-bottom: var(--space-12);
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

.footer-brand {
  max-width: 300px;
}

.footer-brand .logo {
  margin-bottom: var(--space-4);
}

.footer-brand p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.footer-heading {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: var(--space-2);
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.footer-links a:hover {
  color: var(--color-text);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Memorial Page
   -------------------------------------------------------------------------- */
.memorial-card {
  background-color: var(--color-bg-secondary);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.memorial-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background-color: var(--color-accent);
}

.memorial-name {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-2);
  text-decoration: line-through;
  text-decoration-color: var(--color-accent);
}

.memorial-year {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}

.memorial-count {
  font-family: var(--font-mono);
  font-size: var(--text-5xl);
  font-weight: 700;
  color: var(--color-text-muted);
  opacity: 0.3;
}

/* --------------------------------------------------------------------------
   Dispatches
   -------------------------------------------------------------------------- */
.dispatch-card {
  border-left: 4px solid var(--color-accent);
  padding-left: var(--space-6);
}

.dispatch-meta {
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.dispatch-title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.dispatch-excerpt {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   404 Page
   -------------------------------------------------------------------------- */
.error-page {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.error-code {
  font-family: var(--font-mono);
  font-size: clamp(6rem, 20vw, 12rem);
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  opacity: 0.3;
}

.error-message {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-8);
}

/* --------------------------------------------------------------------------
   About Page
   -------------------------------------------------------------------------- */
.about-hero {
  text-align: center;
  padding: var(--space-24) 0;
}

.about-content {
  max-width: 700px;
  margin: 0 auto;
}

.about-content p {
  font-size: var(--text-lg);
  line-height: 1.8;
  margin-bottom: var(--space-6);
}

/* --------------------------------------------------------------------------
   Filters / Search
   -------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-8);
  padding: var(--space-6);
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-select {
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.search-input {
  flex: 1;
  min-width: 200px;
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-12);
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
}

.page-link:hover {
  color: var(--color-text);
  border-color: var(--color-border-light);
}

.page-link.active {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Loading / Skeleton
   -------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-secondary) 0%,
    var(--color-bg-tertiary) 50%,
    var(--color-bg-secondary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fadeIn {
  animation: fadeIn var(--transition-base) forwards;
}

.animate-slideUp {
  animation: slideUp var(--transition-base) forwards;
}

/* Staggered animations */
.stagger > * {
  opacity: 0;
  animation: slideUp var(--transition-base) forwards;
}

.stagger > *:nth-child(1) { animation-delay: 0.1s; }
.stagger > *:nth-child(2) { animation-delay: 0.2s; }
.stagger > *:nth-child(3) { animation-delay: 0.3s; }
.stagger > *:nth-child(4) { animation-delay: 0.4s; }
.stagger > *:nth-child(5) { animation-delay: 0.5s; }
.stagger > *:nth-child(6) { animation-delay: 0.6s; }
.stagger > *:nth-child(7) { animation-delay: 0.7s; }
.stagger > *:nth-child(8) { animation-delay: 0.8s; }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.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;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }

.mt-0 { margin-top: 0; }
.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   FEATURE 1: Interactive World Map
   ========================================================================== */
.world-map-container {
  height: 500px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  z-index: 1;
}

.map-wrapper {
  position: relative;
}

.map-legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  z-index: 1000;
  min-width: 180px;
}

.legend-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-3);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  padding: var(--space-1) 0;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.critical { background: #dc2626; box-shadow: 0 0 6px #dc262680; }
.legend-dot.endangered { background: #f97316; box-shadow: 0 0 6px #f9731680; }
.legend-dot.vulnerable { background: #eab308; box-shadow: 0 0 6px #eab30880; }
.legend-dot.other { background: #6b7280; }

.custom-popup .leaflet-popup-content-wrapper {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-md);
  color: #f5f0e8;
}

.custom-popup .leaflet-popup-tip {
  background: #1a1a1a;
}

.custom-popup .leaflet-popup-close-button {
  color: #9a9590 !important;
}

.custom-cluster-icon {
  background: transparent;
}

.map-section {
  padding-bottom: var(--space-8);
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
  background: #1a1a1a;
  color: #f5f0e8;
  border-radius: var(--radius-md);
}

.leaflet-popup-tip {
  background: #1a1a1a;
}

/* ==========================================================================
   FEATURE 4: Extinction Clock & Live Stats Bar
   ========================================================================== */
.extinction-clock-banner {
  background: linear-gradient(90deg, #1a0000 0%, #2a0a00 50%, #1a0000 100%);
  border-bottom: 1px solid #3a0000;
  padding: var(--space-3) 0;
}

.clock-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.clock-icon {
  color: var(--color-accent);
  display: flex;
  align-items: center;
  animation: pulse 2s ease-in-out infinite;
}

.clock-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.clock-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.clock-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 600;
}

.clock-source {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-left: auto;
}

.live-stats-bar {
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) 0;
}

.stats-bar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
}

.stat-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-2) var(--space-6);
}

.stat-bar-number {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-bar-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-1);
}

.stat-bar-sep {
  width: 1px;
  height: 40px;
  background: var(--color-border);
}

@media (max-width: 768px) {
  .stats-bar-inner {
    gap: var(--space-2);
  }
  .stat-bar-item {
    padding: var(--space-2) var(--space-3);
    min-width: 80px;
  }
  .stat-bar-sep {
    display: none;
  }
  .clock-source {
    display: none;
  }
}

/* ==========================================================================
   FEATURE 3: Threat Filter Pills
   ========================================================================== */
.threat-filter-bar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.threat-filter-pill {
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.threat-filter-pill:hover {
  border-color: var(--color-border-light);
  color: var(--color-text);
}

.threat-filter-pill.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text);
}

.threat-filter-pill .pill-count {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 0 var(--space-2);
  margin-left: var(--space-2);
  font-size: var(--text-xs);
}

.species-card {
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.species-card.filtering-out {
  opacity: 0;
  transform: scale(0.95);
}

.species-card.filtering-in {
  opacity: 1;
  transform: scale(1);
}

/* ==========================================================================
   FEATURE 2: Species Comparison Tool
   ========================================================================== */
.compare-section {
  padding: var(--space-8) 0;
}

.compare-selector {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  margin-bottom: var(--space-8);
}

.compare-selector-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-4);
}

.compare-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.compare-slot {
  position: relative;
}

.compare-slot-select {
  width: 100%;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9590' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

.compare-slot-select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.compare-vs-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-2);
}

.compare-results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.compare-results.visible {
  opacity: 1;
}

.compare-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.compare-card-header {
  position: relative;
  height: 180px;
  overflow: hidden;
}

.compare-card-header img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare-card-header-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-4);
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.compare-card-name {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.compare-card-status {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.compare-card-body {
  padding: var(--space-5);
}

.compare-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.compare-stat-row:last-child {
  border-bottom: none;
}

.compare-stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.compare-stat-value {
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: right;
}

.compare-population-bar {
  margin-top: var(--space-4);
}

.compare-population-bar-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  display: flex;
  justify-content: space-between;
}

.compare-population-bar-track {
  height: 8px;
  background: var(--color-bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.compare-population-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width var(--transition-slow);
}

.compare-card-link {
  display: block;
  text-align: center;
  padding: var(--space-3);
  margin: var(--space-4);
  background: var(--color-accent);
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  transition: background var(--transition-fast);
  text-decoration: none;
}

.compare-card-link:hover {
  background: var(--color-accent-light);
}

.compare-placeholder {
  background: var(--color-bg-secondary);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

@media (max-width: 900px) {
  .compare-slots {
    grid-template-columns: 1fr;
  }
  .compare-results {
    grid-template-columns: 1fr;
  }
  .compare-vs-badge {
    display: none;
  }
}

@media (max-width: 768px) {
  .world-map-container {
    height: 350px;
  }
  .map-legend {
    bottom: 10px;
    left: 10px;
    padding: var(--space-3);
  }
}
