/* SoundBirds Web UI - Clean Bioacoustic Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0d12;
  --surface: #12161d;
  --surface-raised: #171c25;
  --accent: #34d399;
  --accent-strong: #10b981;
  --text-main: #e7ebf0;
  --text-muted: #8b94a3;
  --text-dim: #5b6572;
  --border-color: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background-color: var(--bg-primary);
  background-image: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.25rem;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 680px;
}

.container-wide {
  max-width: 1080px;
}

/* Site Navigation */
.site-nav {
  display: flex;
  justify-content: center;
  width: fit-content;
  margin: 0 auto 2.5rem;
  padding: 0.2rem;
  gap: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 999px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  transition: background 0.2s ease, color 0.2s ease;
  cursor: pointer;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-link.active {
  background: var(--accent-strong);
  color: #04120c;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-strong), #0ea5a4);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.6;
  max-width: 520px;
  margin: 0 auto;
}

.experimental-notice {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.45rem;
  max-width: 620px;
  margin: 1rem auto 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.10);
  color: #fcd34d;
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: left;
}

/* Layout */
.single-column {
  display: flex;
  flex-direction: column;
  gap: 2.75rem;
}

.card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
  text-align: center;
}

/* Recorder */
.recorder-box {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  box-shadow: var(--shadow);
}

.action-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.mic-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-size: 1.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mic-btn:hover {
  background: rgba(16, 185, 129, 0.12);
  transform: scale(1.04);
}

.mic-btn.recording {
  background: #e11d48;
  border-color: #fb7185;
  color: #ffffff;
  animation: pulse-ring 1.4s infinite;
}

.clip-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.clip-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.06);
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.5); }
  100% { box-shadow: 0 0 0 18px rgba(225, 29, 72, 0); }
}

.recording-status {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

.timer {
  font-family: 'Outfit', monospace;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.05em;
}

/* Canvas */
.canvas-container {
  width: 100%;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #0b0e13;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
}

.visualizer-canvas {
  width: 100%;
  height: 72px;
  display: block;
}

.play-overlay-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: none;
  color: #04120c;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 10;
}

.play-overlay-btn:hover {
  transform: translate(-50%, -50%) scale(1.06);
  background: var(--accent);
}

.play-head {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: var(--accent-strong);
  display: none;
  pointer-events: none;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--accent), transparent);
  display: none;
  pointer-events: none;
}

.scan-line.scanning {
  display: block;
  animation: scan 1.2s ease-in-out infinite alternate;
}

@keyframes scan {
  0% { left: 0%; }
  100% { left: 99%; }
}

.ai-status-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.ai-status-banner.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Primary button */
.btn-primary {
  width: 100%;
  padding: 0.8rem 1.25rem;
  background: var(--accent-strong);
  color: #04120c;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.98rem;
  transition: background 0.2s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Results Section */
.results-card {
  display: none;
}

.results-card.active {
  display: block;
  animation: fadeIn 0.35s ease;
  border-top: 1px solid var(--border-color);
  padding-top: 2.5rem;
}

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

/* Species Showcase */
.top-species-banner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.bird-photo-wrapper {
  width: 100%;
  height: 240px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b0e13;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bird-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail-photo-wrapper {
  height: 320px;
}

.media-attribution {
  margin: 0.35rem 0 0;
  color: var(--text-dim);
  font-size: 0.68rem;
  line-height: 1.4;
}

.media-attribution a {
  color: var(--text-muted);
  text-decoration: underline;
}

.bird-info-box {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.species-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.species-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.scientific-name {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.15rem;
}

.confidence-badge {
  background: var(--accent-strong);
  color: #04120c;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.3rem 0.9rem;
  border-radius: 8px;
}

.tag-group {
  display: flex;
  gap: 0.5rem;
}

.habitat-tag {
  background: var(--surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
}

.description-text {
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text-main);
}

.canto-box {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.canto-icon {
  font-size: 0.95rem;
  line-height: 1.4;
}

/* Reference audio section */
.canto-sample-box {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-top: 0.25rem;
}

.sample-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.detail-player-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.detail-player {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.detail-player:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  min-width: 0;
}

.player-badge {
  background: rgba(16, 185, 129, 0.14);
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.player-filename {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-player .custom-audio-player {
  background: transparent;
  border: none;
  padding: 0;
}

/* Audio player bar */
.custom-audio-player {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.custom-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: none;
  color: #04120c;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.custom-play-btn:hover {
  background: var(--accent);
}

.player-track-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.track-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-bar-container {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.time-display {
  font-family: 'Outfit', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Links / buttons */
.wiki-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.25rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 8px;
  transition: background 0.2s ease, border-color 0.2s ease;
  width: fit-content;
}

.wiki-link-btn:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.wiki-external {
  background: transparent;
  color: var(--text-muted);
}

.wiki-external:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-strong);
  color: var(--text-main);
}

.back-link {
  margin-top: 0.15rem;
  width: fit-content;
}

.back-top-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
  width: fit-content;
}

.back-top-link:hover {
  color: var(--accent);
}

/* Predictions */
.predictions-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pred-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pred-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
}

.bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent-strong);
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* Catalog Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.catalog-grid .spinner {
  margin: 2.5rem auto;
  width: 26px;
  height: 26px;
}

.empty-message {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
}

.catalog-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.catalog-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.catalog-card-main {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  text-decoration: none;
  color: inherit;
}

.catalog-sounds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.7rem 1.15rem 1rem;
  border-top: 1px solid var(--border-color);
}

.catalog-sound-credit {
  flex-basis: 100%;
  margin: 0;
  color: var(--text-dim);
  font-size: 0.62rem;
  line-height: 1.4;
}

.sound-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sound-btn:hover {
  background: rgba(52, 211, 153, 0.12);
  border-color: var(--accent);
}

.catalog-photo-wrapper {
  width: 100%;
  height: 200px;
  background: #0b0e13;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.catalog-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.catalog-photo-link {
  display: block;
  line-height: 0;
}

.catalog-name-link {
  text-decoration: none;
  color: inherit;
}

.catalog-name-link:hover .catalog-name {
  color: var(--accent);
}

.catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.2rem;
}

.catalog-actions .wiki-link-btn {
  margin-top: 0;
}

.catalog-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.1rem 1.15rem;
  flex-grow: 1;
  align-items: center;
  text-align: center;
}

.catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.catalog-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.catalog-scientific {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.catalog-photo-credit {
  color: var(--text-dim);
  font-size: 0.62rem;
  line-height: 1.4;
}

.experimental-badge {
  align-self: flex-start;
  padding: 0.18rem 0.5rem;
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.1);
  color: #fcd34d;
  font-size: 0.64rem;
  font-weight: 700;
}

.experimental-note {
  color: #fcd34d;
  font-size: 0.8rem;
  line-height: 1.45;
}

.catalog-audio {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.catalog-audio .custom-audio-player {
  padding: 0.45rem 0.75rem;
}

/* Footer */
footer {
  margin-top: 3.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

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

/* Mobile */
@media (max-width: 640px) {
  body {
    padding: 1.75rem 1rem;
  }

  header {
    margin-bottom: 2rem;
  }

  .site-nav {
    margin-bottom: 2rem;
  }

  .nav-link {
    padding: 0.3rem 0.75rem;
    font-size: 0.76rem;
    white-space: nowrap;
  }

  h1 {
    font-size: 1.8rem;
  }

  .brand-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .subtitle {
    font-size: 0.92rem;
  }

  .single-column {
    gap: 2.25rem;
  }

  .recorder-box {
    padding: 1.5rem 1.1rem;
  }

  .mic-btn {
    width: 68px;
    height: 68px;
    font-size: 1.6rem;
  }

  .clip-btn {
    width: 42px;
    height: 42px;
  }

  .bird-photo-wrapper {
    height: 200px;
  }

  .detail-photo-wrapper {
    height: 260px;
  }

  .species-name {
    font-size: 1.45rem;
  }

  .custom-audio-player {
    gap: 0.6rem;
  }

  .time-display {
    font-size: 0.7rem;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .catalog-photo-wrapper {
    height: 150px;
  }

  .catalog-body {
    padding: 0.9rem 0.85rem;
  }

  .catalog-name {
    font-size: 1rem;
  }
}

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

  .catalog-photo-wrapper {
    height: 180px;
  }

  .action-controls {
    gap: 0.8rem;
  }
}
