:root {
  --bg: #1a1a1a;
  --bg-alt: #222;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #c9a84c;
  --accent-dim: #8a7332;
  --green: #4a7c59;
  --green-dim: #2d4a36;
  --border: #333;
  --font: 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Helvetica Neue', 'Arial', sans-serif;
  --font-mono: 'Courier New', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  font-size: 17px;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: #e0c060; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 2rem; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 2rem; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.site-logo { font-size: 1.4rem; letter-spacing: 0.05em; }
.site-logo a { color: var(--text); }
.site-logo a:hover { color: var(--accent); }

.site-nav {
  display: flex;
  gap: 2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color 0.2s;
}

.site-nav a:hover, .site-nav a.active { color: var(--accent); }

/* Hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 22px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 101;
}

.nav-toggle span {
  display: block; height: 2px; width: 100%;
  background: var(--text); transition: all 0.3s ease; border-radius: 1px;
}

.nav-toggle.active span:nth-child(1) { transform: translateY(10px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-10px) rotate(-45deg); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Typography */
h1, h2, h3, h4 { font-weight: normal; line-height: 1.3; }
h1 { font-size: 2.2rem; margin-bottom: 1rem; }
h2 { font-size: 1.6rem; margin: 2rem 0 1rem; }
h3 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
p { margin-bottom: 1.2rem; }

blockquote {
  border-left: 3px solid var(--accent-dim);
  padding-left: 1.5rem; margin: 1.5rem 0;
  color: var(--text-muted); font-style: italic;
}

/* Episode cards */
.episode-list { display: flex; flex-direction: column; gap: 2rem; margin: 2rem 0; }

.episode-card {
  border: 1px solid var(--border); border-radius: 4px;
  padding: 1.5rem 2rem;
  transition: border-color 0.2s, background 0.2s;
}

.episode-card:hover { border-color: var(--accent-dim); background: rgba(201, 168, 76, 0.03); }
.episode-card .ep-number { color: var(--text-muted); font-size: 0.85rem; font-family: var(--font-sans); letter-spacing: 0.1em; text-transform: uppercase; }
.episode-card h2 { margin: 0.3rem 0; font-size: 1.4rem; }
.episode-card h2 a { color: var(--text); }
.episode-card h2 a:hover { color: var(--accent); }
.episode-card .description { color: var(--text-muted); font-size: 0.95rem; }
.episode-card .meta { margin-top: 0.8rem; font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-sans); }

/* Story cards */
.story-card {
  border: 1px solid var(--border); border-radius: 4px;
  padding: 1.5rem 2rem; margin-bottom: 2rem;
  transition: border-color 0.2s, background 0.2s;
}

.story-card:hover { border-color: var(--green-dim); background: rgba(74, 124, 89, 0.03); }
.story-card .tag { display: inline-block; font-size: 0.75rem; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green); margin-bottom: 0.5rem; }
.story-card h2 a { color: var(--text); }
.story-card h2 a:hover { color: var(--accent); }

/* Map */
.map-container { width: 100%; height: 500px; border: 1px solid var(--border); border-radius: 4px; margin: 1.5rem 0; position: relative; }
#map { width: 100%; height: 100%; border-radius: 4px; }

.map-legend {
  position: absolute; bottom: 10px; left: 10px;
  background: rgba(26, 26, 26, 0.9); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.8rem 1rem; font-size: 0.8rem; font-family: var(--font-sans);
  color: var(--text); z-index: 10; max-width: 250px;
}

.map-legend h4 { font-size: 0.85rem; margin-bottom: 0.5rem; color: var(--accent); }
.map-legend .legend-item { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; }
.map-legend .legend-color { width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0; }

.map-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; font-family: var(--font-sans); }
.map-controls button {
  background: var(--bg-alt); border: 1px solid var(--border); color: var(--text);
  padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.map-controls button:hover, .map-controls button.active { border-color: var(--accent); color: var(--accent); }

/* Species explorer */
.species-explorer { border: 1px solid var(--border); border-radius: 4px; padding: 1.5rem; margin: 2rem 0; }
.species-explorer input {
  width: 100%; padding: 0.8rem 1rem; background: var(--bg-alt);
  border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 1rem; font-family: var(--font);
}
.species-explorer input:focus { outline: none; border-color: var(--accent); }
.species-results { margin-top: 1rem; max-height: 400px; overflow-y: auto; }
.species-result { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.2s; }
.species-result:hover { background: var(--bg-alt); }
.species-result .scientific-name { font-style: italic; color: var(--text-muted); font-size: 0.9rem; }
.species-result .common-name { font-size: 1rem; margin-bottom: 0.2rem; }
.species-result .rank-badge { display: inline-block; font-size: 0.75rem; font-family: var(--font-sans); padding: 0.1rem 0.5rem; border-radius: 3px; margin-left: 0.5rem; }

.rank-G1, .rank-G2 { background: #8b0000; color: #fff; }
.rank-G3 { background: #cc6600; color: #fff; }
.rank-G4 { background: #cccc00; color: #000; }
.rank-G5 { background: #2d7a3e; color: #fff; }

/* Data viz */
.chart-container { border: 1px solid var(--border); border-radius: 4px; padding: 1.5rem; margin: 2rem 0; background: var(--bg-alt); }
.chart-container h3 { color: var(--accent); margin-top: 0; }
.bar-chart { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.bar-row { display: flex; align-items: center; gap: 1rem; }
.bar-label { width: 180px; font-size: 0.85rem; font-family: var(--font-sans); text-align: right; flex-shrink: 0; }
.bar-track { flex-grow: 1; height: 24px; background: rgba(255,255,255,0.05); border-radius: 3px; position: relative; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 0.8s ease; }
.bar-value { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 0.8rem; font-family: var(--font-sans); color: var(--text); }

/* Article */
.article-body { font-size: 1.05rem; line-height: 1.8; }
.article-body p { margin-bottom: 1.5rem; }
.article-body .lead { font-size: 1.2rem; color: var(--text-muted); font-style: italic; margin-bottom: 2rem; }
.article-body .data-callout { background: var(--bg-alt); border-left: 3px solid var(--green); padding: 1rem 1.5rem; margin: 2rem 0; border-radius: 0 4px 4px 0; }
.article-body .data-callout .label { font-size: 0.75rem; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green); margin-bottom: 0.5rem; }

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

@media (max-width: 768px) {
  body { font-size: 16px; }

  .container, .container-narrow { padding: 0 1rem; }

  /* Header */
  .site-header { padding: 0.75rem 0; }
  .site-logo { font-size: 1.15rem; }

  /* Hamburger nav */
  .nav-toggle { display: flex; }
  .site-nav {
    position: fixed; top: 0; right: -100%;
    width: 240px; height: 100vh;
    background: var(--bg); border-left: 1px solid var(--border);
    flex-direction: column; gap: 0;
    padding: 4.5rem 1.5rem 2rem;
    transition: right 0.3s ease; z-index: 99;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  }
  .site-nav.open { right: 0; }
  .site-nav a {
    padding: 1rem 0; border-bottom: 1px solid var(--border);
    font-size: 1rem; text-align: left;
  }

  /* Typography */
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; margin: 1.5rem 0 0.8rem; }
  h3 { font-size: 1.1rem; }

  /* Episode cards */
  .episode-card { padding: 1rem 1.2rem; }
  .episode-card h2 { font-size: 1.2rem; }

  /* Story cards */
  .story-card { padding: 1rem 1.2rem; }
  .story-card h2 { font-size: 1.15rem; }

  /* Map */
  .map-container { height: 300px; }
  .map-controls { gap: 0.4rem; }
  .map-controls button { font-size: 0.75rem; padding: 0.4rem 0.7rem; }
  .map-legend { max-width: 180px; padding: 0.6rem 0.8rem; font-size: 0.7rem; bottom: 5px; left: 5px; }

  /* Species explorer */
  .species-explorer { padding: 1rem; margin: 1.5rem 0; }
  .species-explorer input { padding: 0.7rem 0.8rem; font-size: 0.95rem; }
  .species-result { padding: 0.7rem 0.8rem; }
  .species-result .common-name { font-size: 0.95rem; }

  /* Data viz */
  .chart-container { padding: 1rem; margin: 1.5rem 0; }
  .bar-row { gap: 0.5rem; }
  .bar-label { width: 90px; font-size: 0.7rem; }
  .bar-track { height: 20px; }
  .bar-value { font-size: 0.7rem; }

  /* Article */
  .article-body { font-size: 1rem; line-height: 1.7; }
  .article-body .lead { font-size: 1.05rem; }
  .article-body .data-callout { padding: 0.8rem 1rem; margin: 1.5rem 0; }

  /* Footer */
  .site-footer { padding: 1.5rem 0; margin-top: 2.5rem; font-size: 0.8rem; }
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  .container, .container-narrow { padding: 0 0.8rem; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  .site-logo { font-size: 1.05rem; }
  .episode-card { padding: 0.8rem 1rem; }
  .story-card { padding: 0.8rem 1rem; }
  .map-container { height: 250px; }
  .map-legend { max-width: 150px; font-size: 0.65rem; padding: 0.5rem 0.6rem; }
  .bar-label { width: 70px; font-size: 0.65rem; }
  .species-explorer input { font-size: 0.9rem; }
}