/*
 * fuglelyde.dk — Fuglekort (cards.css)
 * Modern Nordic Minimalist Collection & Baseball Trading Cards
 */

@import url('styles.css');

body {
  overflow-y: auto !important;
  min-height: 100vh;
  padding-bottom: 60px;
}

/* =========================================================
   TOOLBAR (Search, Sort & Category Filter Pills)
   ========================================================= */
.toolbar-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 280px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 12px 38px 12px 42px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--r-btn);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s ease;
}
.search-box input:focus {
  border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-tint), var(--shadow-sm);
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.14s ease;
}
.search-clear-btn:hover {
  background: var(--border-medium);
  color: var(--text-main);
}

.sort-select {
  padding: 12px 18px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--r-btn);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s ease;
}
.sort-select:hover {
  border-color: var(--border-medium);
}
.sort-select:focus {
  border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-tint);
}

/* Category Filter Pills */
.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pill-btn {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  padding: 7px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all 0.16s ease;
  white-space: nowrap;
  user-select: none;
}
.pill-btn:hover {
  border-color: var(--pine-border);
  color: var(--text-main);
  transform: translateY(-1px);
}
.pill-btn.active {
  background: var(--pine);
  border-color: var(--pine);
  color: #FFFFFF;
  box-shadow: var(--shadow-pine);
}

/* Status row below filters */
.toolbar-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  flex-wrap: wrap;
}

.counter-text {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.deck-hint-pill {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--pine);
  background: var(--pine-tint);
  border: 1px solid var(--pine-border);
  padding: 3px 10px;
  border-radius: var(--r-pill);
}

/* =========================================================
   CARDS GRID CONTAINER (Uniform, Clean Layout)
   ========================================================= */
.cards-grid-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 60px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
  align-items: stretch;
}

/* =========================================================
   BASEBALL TRADING CARD — Nordic Tactile Edition
   ========================================================= */
.baseball-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  cursor: pointer;
  transition:
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.22s ease,
    border-color 0.22s ease;
}

/* ROYGBIV variant colour — Mit Dæk cards only, one colour per distinct
   photo+audio combo owned for a species, assigned in discovery order so
   several cards of the same bird read as a set rather than duplicates. */
.baseball-card.has-variant-color {
  border-top: 4px solid var(--variant-color);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.baseball-card:hover {
  transform: translateY(-5px);
  border-color: var(--pine-border);
  box-shadow: var(--shadow-lg);
}

/* Card Top Header Strip */
.card-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-series-tag {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pine);
  background: var(--pine-tint);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--pine-border);
}

/* Card Framed Photo with Foil Stamp & Ambient Bokeh (Uncropped) */
.card-photo-wrapper {
  position: relative;
  width: 100%;
  height: 195px;
  border-radius: 12px;
  overflow: hidden;
  background: #15241C;
  margin-bottom: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-photo-bg {
  position: absolute;
  inset: -15px;
  width: calc(100% + 30px);
  height: calc(100% + 30px);
  object-fit: cover;
  object-position: center;
  filter: blur(16px) brightness(0.82) saturate(1.3);
  opacity: 0.52;
  pointer-events: none;
  transform: scale(1.08);
  transition: opacity 0.3s ease;
}

.card-photo {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.28));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.baseball-card:hover .card-photo {
  transform: scale(1.05);
}

.card-photo-sheen {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 55%),
              radial-gradient(ellipse at center, transparent 65%, rgba(0,0,0,0.2) 100%);
  pointer-events: none;
}

/* Photo credit — small, unobtrusive, bottom-right so it never collides with
   the point-stamp badge (top-left) or the blind-cover badge (centered). */
.card-photo-credit {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 5;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* Collectible Point Stamp Badges */
.card-stamp-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.stamp-tier-3 {
  background: linear-gradient(135deg, #FDE047 0%, #D97706 100%);
  color: #451A03;
  border: 1px solid rgba(255, 255, 255, 0.75);
}
.stamp-tier-2 {
  background: linear-gradient(135deg, #F1F5F9 0%, #94A3B8 100%);
  color: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.75);
}
.stamp-tier-1 {
  background: linear-gradient(135deg, #FED7AA 0%, #C2410C 100%);
  color: #431407;
  border: 1px solid rgba(255, 255, 255, 0.75);
}

/* Card Nameplate Banner */
.card-nameplate {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 60px;
}

.card-danish-name {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 400;
  color: var(--pine);
  line-height: 1.22;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sci-name {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.card-en-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* Difficulty badge (header strip) */
.card-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  text-decoration: none;
}

.tier-badge.tier-1 { color: #1e7d4a; background: #e8f6ee; border-color: rgba(30, 125, 74, 0.25); }
.tier-badge.tier-2 { color: #9a6a00; background: #fdf3dd; border-color: rgba(154, 106, 0, 0.25); }
.tier-badge.tier-3 { color: #b93845; background: #fdf0f1; border-color: rgba(185, 56, 69, 0.25); }

/* Nameplate row: names left, observation count right */
.card-nameplate-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.card-nameplate-row .card-nameplate {
  flex: 1;
  min-width: 0;
}

.card-obs-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  padding-top: 1px;
}

.card-obs-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease;
}
.card-obs-count:hover {
  color: var(--pine, #245C42);
}

/* On-card sound strip: decorative trimmed-clip waveform + inline play */
.card-sound-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.card-sound-play-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--pine, #245C42);
  color: #fff;
  font-size: 0.62rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 0 0 2px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.card-sound-play-btn:hover {
  transform: scale(1.08);
}
.card-sound-play-btn.playing {
  padding: 0;
}
.card-sound-play-btn.playing::before {
  content: '❚❚';
  letter-spacing: 1px;
}

.card-sound-bars {
  flex: 1;
  min-width: 0;
  height: 22px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  cursor: pointer;
}

.card-sound-bar {
  flex: 1;
  min-width: 1px;
  height: var(--h, 50%);
  background: var(--pine-border, rgba(46, 117, 89, 0.4));
  border-radius: 1px;
  transition: background 0.15s ease;
}
.card-sound-strip:hover .card-sound-bar {
  background: var(--pine, #245C42);
}

/* Won status + date */
.card-won-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-won-copies {
  font-family: var(--font-mono);
  color: var(--pine, #245C42);
}

/* =========================================================
   BIRDCARD — shared component (birdcard-ui.js) size + reveal variants
   ========================================================= */

/* Hidden reveal state (the game's mystery card): blur the photo and mask
   the name, matching the previous .game-bird-avatar-wrapper.blinded look. */
.birdcard.reveal-hidden .card-photo {
  filter: blur(14px) grayscale(0.6);
  opacity: 0.45;
}
.birdcard.reveal-hidden .blind-cover-badge {
  display: flex;
}
.birdcard:not(.reveal-hidden) .blind-cover-badge {
  display: none;
}

/* Compact size: used in Statistik's per-bird breakdown rows — a smaller
   card next to (not instead of) the existing hint-distribution bars. */
.birdcard.birdcard-compact {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 10px;
}
.birdcard-compact .card-header-strip {
  display: none;
}
.birdcard-compact .card-photo-wrapper {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  margin-bottom: 0;
  border-radius: 10px;
}
/* At 64px the full-size card's blurred bleed layer just muddies the photo —
   hide it and let the sharp foreground image fill the thumbnail instead. */
.birdcard-compact .card-photo-bg {
  display: none;
}
.birdcard-compact .card-photo {
  object-fit: cover;
}
.birdcard-compact .card-nameplate {
  min-height: 0;
  flex: 1;
  min-width: 0;
}
.birdcard-compact .card-obs-col,
.birdcard-compact .card-sound-strip,
.birdcard-compact .card-won-status {
  display: none;
}

/* Hero size: the game's mystery-card avatar and the win-reveal popup. */
.birdcard-hero {
  cursor: default;
  max-width: 280px;
}
.birdcard-hero:hover {
  transform: none;
}
.birdcard-hero .card-photo-wrapper {
  height: 220px;
}

/* Scouting Report / Description Snippet */
.card-desc-box {
  margin-top: 8px;
  height: 38px;
  overflow: hidden;
}

/* Unclamped variant: the game passes clampDesc:false so the fuller stored
   text (up to ~400 chars) reads as a real hint, not a 2-line teaser. */
/* Unclamped still needs a ceiling — most descriptions run a few lines, but
   a handful (e.g. Sørgedue's, ~980 characters) are 3-4x the norm and would
   otherwise stretch the card past anything the surrounding layout budgeted
   for it. Scrolls internally past ~7 lines instead of growing the card. */
.card-desc-box.desc-unclamped {
  height: auto;
  max-height: 132px;
  overflow-y: auto;
}
.card-desc-box.desc-unclamped .desc-text {
  -webkit-line-clamp: unset;
  display: block;
}

.desc-text {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Locked placeholder shown before the description hint is earned */
.desc-text.desc-locked {
  font-style: italic;
  opacity: 0.75;
}

/* Right-hand cluster of the header strip: category badges sit flush against
   the difficulty pill, reading as one continuous piece rather than two
   separate elements floating in the row. */
.card-header-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Habitat/diet/size badges — collector-card style icon tokens, icon-only,
   bordered to match the difficulty pill's own bordered-chip look. */
.card-category-badges-inline {
  display: flex;
  align-items: center;
  gap: 3px;
}
.card-category-badges-inline .category-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--bg-surface);
  cursor: default;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card-category-badges-inline .category-badge:hover {
  transform: translateY(-1px) scale(1.08);
  border-color: var(--pine-border);
}
.card-category-badges-inline svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

/* CC-BY-NC attribution for arter.dk-sourced description text */
.desc-attribution {
  display: block;
  margin-top: 4px;
  font-size: 0.64rem;
  color: var(--text-muted);
  text-decoration: none;
}
.desc-attribution:hover {
  color: var(--pine, #245C42);
  text-decoration: underline;
}

/* Load More Container */
.cards-load-more-box {
  display: flex;
  justify-content: center;
  margin-top: 36px;
  padding: 10px 0;
}

.load-more-cards-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  color: var(--pine);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: var(--r-pill);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s ease;
}
.load-more-cards-btn:hover {
  background: var(--pine);
  border-color: var(--pine);
  color: #FFFFFF;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* =========================================================
   EXPANDED BACK-OF-CARD MODAL
   ========================================================= */
.card-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 25, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.card-modal-backdrop.active {
  display: flex;
}

.card-modal {
  background: var(--bg-surface);
  border-radius: var(--r-card);
  border: 1.5px solid var(--border-subtle);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  padding: 26px;
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.16s ease;
}
.modal-close-btn:hover {
  background: var(--wrong-red);
  color: #fff;
  border-color: var(--wrong-red);
  transform: scale(1.08);
}

.modal-gallery-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-photo-stage {
  position: relative;
  width: 100%;
  height: 280px;
  border-radius: 14px;
  overflow: hidden;
  background: #14221B;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-hero-photo-bg {
  position: absolute;
  inset: -15px;
  width: calc(100% + 30px);
  height: calc(100% + 30px);
  object-fit: cover;
  object-position: center;
  filter: blur(16px) brightness(0.72) saturate(1.25);
  opacity: 0.52;
  pointer-events: none;
}
.modal-hero-photo {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.35));
}

.modal-photo-annotation-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

.modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.16s ease;
}
.modal-nav-btn:hover {
  background: #FFFFFF;
  transform: translateY(-50%) scale(1.1);
}
.modal-nav-btn.prev { left: 8px; }
.modal-nav-btn.next { right: 8px; }

.modal-photo-counter {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

.modal-photo-thumbnails {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
}
.modal-thumb-item {
  width: 52px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-subtle);
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.16s ease;
}
.modal-thumb-item.active,
.modal-thumb-item:hover {
  border-color: var(--pine);
  transform: scale(1.05);
}
.modal-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-titles h2 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  color: var(--pine);
  line-height: 1.2;
  margin: 0;
}
.modal-titles p {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  margin: 0;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-stat-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.modal-stat-val {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.modal-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.modal-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.16s ease;
}
.modal-action-btn.play {
  background: var(--pine);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-pine);
}
.modal-action-btn.play:hover {
  background: #1B4733;
  transform: translateY(-1px);
}
.modal-action-btn.play.playing {
  background: var(--wrong-red);
}
.modal-action-btn.wave {
  background: var(--pine-tint);
  border: 1.5px solid var(--pine-border);
  color: var(--pine);
  font-weight: 700;
}
.modal-action-btn.wave:hover {
  background: var(--pine);
  color: #FFFFFF;
  border-color: var(--pine);
  transform: translateY(-1px);
}
.modal-action-btn.external {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-main);
}
.modal-action-btn.external:hover {
  border-color: var(--pine);
  color: var(--pine);
}

/* =========================================================
   SOURCES SUMMARY BAR (Merged from sources.html)
   ========================================================= */
.sources-summary-bar {
  max-width: 1200px;
  margin: 16px auto 8px;
  padding: 0 24px;
}
.sources-bar-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--r-card);
  padding: 12px 18px;
  box-shadow: var(--shadow-sm);
}
.sources-metric-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}
.sources-metric-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.sources-metric-info {
  display: flex;
  flex-direction: column;
}
.sources-metric-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--pine);
  line-height: 1.1;
}
.sources-metric-lbl {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* =========================================================
   MODAL SOURCES & DOCUMENTATION PANEL
   ========================================================= */
.modal-sources-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1.5px solid var(--border-subtle);
}
.modal-sources-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--pine);
  margin-bottom: 12px;
}
.modal-sources-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.source-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.source-card-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.source-card-content {
  font-size: 0.78rem;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.source-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--pine);
  text-decoration: none;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  width: fit-content;
  transition: all 0.14s ease;
}
.source-link-pill:hover {
  background: var(--pine-tint);
  border-color: var(--pine-border);
}
/* "Create the missing article" call to action — same warning-amber pairing
   as .source-badge-tag.warning below, just as a real class instead of an
   inline style so it can't drift out of sync with the design tokens. */
.source-link-pill.wiki-missing {
  border-color: var(--birch);
  color: #8C531B;
}
.source-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  width: fit-content;
}
.source-badge-tag.verified {
  background: rgba(36, 92, 66, 0.12);
  color: var(--pine);
}
.source-badge-tag.warning {
  background: rgba(216, 164, 104, 0.2);
  color: #8C531B;
}

/* =========================================================
   STANDALONE SOURCES & LICENSING PAGE (sources.html)
   ========================================================= */
.sources-page-container {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 24px 60px;
}
.sources-page-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sources-page-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  color: var(--pine);
  margin: 0;
}
.sources-page-intro {
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0;
}
.sources-page-subheading {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--text-main);
  margin: 12px 0 0;
}
.sources-page-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.source-note {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

/* =========================================================
   BIOACOUSTIC WAVEFORM STUDIO MODAL
   ========================================================= */
.waveform-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.22s ease-out;
}
.waveform-studio-modal {
  position: relative;
  width: 100%;
  max-width: 960px;
  max-height: 92vh;
  overflow-y: auto;
  background: #FAFDF8;
  border-radius: 20px;
  border: 1.5px solid var(--border-medium);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}
.studio-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s ease;
  z-index: 10;
}
.studio-close-btn:hover {
  background: var(--wrong-red);
  color: #FFFFFF;
  border-color: var(--wrong-red);
}

/* Studio Header */
.studio-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--border-subtle);
}
.studio-bird-thumb-wrap {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--pine);
  flex-shrink: 0;
  background: #15241C;
  box-shadow: var(--shadow-sm);
}
.studio-bird-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.studio-bird-meta {
  flex: 1;
  min-width: 0;
}
.studio-tags-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.studio-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}
.studio-tag.series { background: var(--bg-subtle); color: var(--text-muted); }
.studio-tag.num { background: var(--pine-tint); color: var(--pine); }
.studio-tag.birdnet { background: rgba(216, 164, 104, 0.2); color: #8C531B; }

.studio-bird-name {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  color: var(--pine);
  margin: 0;
  line-height: 1.2;
}
.studio-sci-name {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.studio-source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--pine);
  text-decoration: none;
  transition: all 0.16s ease;
  white-space: nowrap;
}
.studio-source-link:hover {
  background: var(--pine);
  color: #FFFFFF;
  border-color: var(--pine);
}

/* Studio Controls Bar */
.studio-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  padding: 10px 16px;
}
.studio-playback-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.studio-hero-play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--pine);
  color: #FFFFFF;
  border: none;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-pine);
  transition: all 0.16s ease;
}
.studio-hero-play-btn:hover {
  background: #1B4733;
  transform: scale(1.05);
}
.studio-hero-play-btn.playing {
  background: var(--wrong-red);
}
.studio-timecode-wrap {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 4px;
}
.studio-time-sep { color: var(--text-muted); }
.studio-jump-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--birch-tint);
  border: 1.5px solid var(--birch);
  color: #784E1A;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all 0.16s ease;
}
.studio-jump-btn:hover {
  background: var(--birch);
  color: #FFFFFF;
}

.studio-track-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.studio-track-lbl {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}
.studio-track-select {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  background: #FFFFFF;
  color: var(--text-main);
}

.studio-option-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Studio Timeline & Canvas */
.studio-timeline-card {
  width: 100%;
}
.studio-timeline-container {
  position: relative;
  width: 100%;
  height: 96px;
  background: #F4F1EA;
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.16s;
}
.studio-timeline-container:hover {
  border-color: var(--pine-border);
}
.studio-waveform-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.studio-call-blocks-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}
.studio-playhead-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--pine);
  box-shadow: 0 0 10px rgba(36, 92, 66, 0.8);
  pointer-events: none;
  transform: translateX(0);
  z-index: 25;
}
.studio-timeline-ticks {
  position: absolute;
  bottom: 4px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Call Blocks */
.studio-call-blocks-layer .call-block {
  position: absolute;
  top: 6px;
  bottom: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 6px;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
  z-index: 10;
}
.studio-call-blocks-layer .call-block.target {
  background: rgba(36, 92, 66, 0.28);
  border: 1.5px solid #245C42;
  color: #1C4532;
  backdrop-filter: blur(2px);
}
.studio-call-blocks-layer .call-block.background {
  background: rgba(216, 164, 104, 0.32);
  border: 1.5px solid #C48E50;
  color: #784E1A;
  backdrop-filter: blur(2px);
}
.studio-call-blocks-layer .call-block:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  z-index: 20;
}

/* Studio Legend & Chips */
.studio-legend-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.74rem;
  font-weight: 600;
}
.studio-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend-dot.target { background: #245C42; }
.legend-dot.bg { background: #C48E50; }

.studio-chips-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.studio-chips-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.studio-chips-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
  padding: 2px;
}
.studio-chips-row .call-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.16s ease;
}
.studio-chips-row .call-chip.target {
  border-color: var(--pine-border);
  color: var(--pine);
}
.studio-chips-row .call-chip.background {
  border-color: var(--birch);
  color: #784E1A;
}
.studio-chips-row .call-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.studio-chips-row .call-chip.active {
  background: var(--pine);
  color: #FFFFFF;
  border-color: var(--pine);
}
.studio-chips-row .call-chip.background.active {
  background: var(--birch);
  color: #FFFFFF;
}
.call-chip-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  opacity: 0.85;
}
.call-chip-conf {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Studio Footer */
.studio-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
.studio-view-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all 0.16s ease;
}
.studio-view-card-btn:hover {
  border-color: var(--pine);
  color: var(--pine);
}

/* =========================================================
   RESPONSIVE DESIGN
   ========================================================= */
@media (max-width: 768px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }
  .card-photo-wrapper {
    height: 175px;
  }
  .sources-bar-inner {
    grid-template-columns: 1fr 1fr;
  }
  .modal-sources-grid {
    grid-template-columns: 1fr;
  }
  .waveform-studio-modal {
    padding: 18px 18px;
  }
}

@media (max-width: 480px) {
  .cards-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .card-photo-wrapper {
    height: 230px;
  }
  .sources-bar-inner {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-stats-grid {
    grid-template-columns: 1fr;
  }
  .studio-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .studio-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .studio-playback-left {
    justify-content: space-between;
  }
}
