/* FlyBi Education — SoniTrace Style */
:root {
  --bg: #0e1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #3fb950;
  --accent-soft: #1a3828;
  --blue: #58a6ff;
  --blue-soft: #1a3a5c;
  --yellow: #d29922;
  --yellow-soft: #3d2e00;
  --red: #f85149;
  --red-soft: #3d1418;
  --orange: #db6d28;
  --orange-soft: #3d2200;
  --purple: #bc8cff;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, rgba(14,17,23,.97), rgba(14,17,23,.85));
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
}
.nav-brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent) !important;
  text-decoration: none !important;
  letter-spacing: -0.02em;
}
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--text); }

/* ── Main Content ── */
.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  flex: 1;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-inner a { color: var(--text-muted); }
.footer-inner a:hover { color: var(--accent); }
.footer-sep { margin: 0 0.5rem; }

/* ── Hero (Index) ── */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--accent);
}
.hero .subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ── Stat Cards (Index) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2.5rem 0;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}
.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
}
.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Search & Filters ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.filters input,
.filters select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.filters input:focus,
.filters select:focus {
  border-color: var(--accent);
}
.filters input { flex: 1; min-width: 200px; }
.filters select { min-width: 150px; }
.filters button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.filters button:hover { opacity: 0.85; }

/* ── Species Grid (Wiki) ── */
.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.species-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  text-decoration: none !important;
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.species-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(63, 185, 80, 0.1);
}
.species-card .card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--border);
}
.species-card .card-img-placeholder {
  width: 100%;
  height: 180px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2rem;
}
.species-card .card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.species-card .card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}
.species-card .card-latin {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}
.species-card .card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 0.75rem;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  white-space: nowrap;
}
.rl-safe { background: var(--accent-soft); color: var(--accent); }
.rl-warning { background: var(--yellow-soft); color: var(--yellow); }
.rl-vulnerable { background: var(--orange-soft); color: var(--orange); }
.rl-endangered { background: var(--red-soft); color: var(--red); }
.rl-critical { background: var(--red-soft); color: var(--red); }
.rl-extinct { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.rl-restricted { background: var(--blue-soft); color: var(--blue); }

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.pagination a {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.15s;
}
.pagination a:hover { border-color: var(--accent); }
.pagination .active {
  background: var(--accent);
  color: var(--bg);
  border: none;
}

/* ── Detail Page ── */
.detail-header {
  margin-bottom: 2rem;
}
.detail-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.detail-header .latin {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-style: italic;
}
.detail-header .badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
}
@media (max-width: 768px) {
  .detail-layout { grid-template-columns: 1fr; }
}

/* Steckbrief Sidebar */
.steckbrief {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  align-self: start;
  position: sticky;
  top: 5rem;
}
.steckbrief h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.steckbrief dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.88rem;
}
.steckbrief dt {
  color: var(--text-muted);
  font-weight: 400;
}
.steckbrief dd {
  font-weight: 600;
}

/* Image Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.gallery-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.gallery-img:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

/* Audio Player */
.audio-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.audio-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.audio-item .audio-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.audio-item .audio-type {
  font-weight: 600;
  color: var(--accent);
}
.audio-item .audio-info {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.audio-item audio {
  width: 100%;
  height: 36px;
}
.audio-item .audio-credit {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.audio-item .audio-credit a { color: var(--text-muted); }

/* ── Section titles ── */
.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Results info ── */
.results-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.9);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
}
.lightbox-credit {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  background: rgba(0,0,0,0.7);
  padding: 0.4rem 1rem;
  border-radius: 999px;
}
