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

:root {
  --orange: #ff8c42;
  --orange-dark: #e06a1a;
  --bg: #060612;
  --panel-bg: rgba(8, 8, 22, 0.96);
  --border: rgba(255, 140, 66, 0.25);
  --text: #e8e8f0;
  --text-dim: rgba(232, 232, 240, 0.55);
  --panel-width: 340px;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

/* ───────────── Layout shell ───────────── */
#app { position: relative; width: 100vw; height: 100vh; }

#globe-container {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* CesiumJS widget fills container */
#globe-container .cesium-widget,
#globe-container .cesium-widget canvas {
  width: 100% !important;
  height: 100% !important;
}


/* ───────────── Header ───────────── */
header {
  position: absolute;
  top: 20px;
  left: 24px;
  z-index: 20;
  pointer-events: none;
}

.logo {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--orange);
  text-shadow: 0 0 20px rgba(255, 140, 66, 0.6);
  margin: 0;
  padding: 0;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 3px;
  letter-spacing: 0.05em;
}

/* ───────────── Loading overlay ───────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
  background: var(--bg);
  transition: opacity 0.6s ease;
}

#loading-overlay.fade-out { opacity: 0; pointer-events: none; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 140, 66, 0.2);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes streak-bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}


#loading-text { font-size: 0.9rem; color: var(--text-dim); }

/* ───────────── Hover tooltip ───────────── */
#tooltip {
  position: absolute;
  background: rgba(10, 10, 30, 0.9);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  transition: opacity 0.15s;
}
#tooltip.hidden { opacity: 0; }

/* ───────────── Info panel ───────────── */
#info-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--panel-width), 100vw);
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(0);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
}

/* Push panel below browser address bar on touch devices */
@media (pointer: coarse) {
  #info-panel { padding-top: 64px; }
}

#info-panel.hidden { transform: translateX(100%); }

#close-panel {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  z-index: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
#close-panel:hover { color: var(--text); background: rgba(255,255,255,0.08); }

/* Bird image */
#bird-image-container {
  width: 100%;
  height: clamp(120px, 22vh, 200px);
  flex-shrink: 0;
  overflow: hidden;
  background: #0d0d22;
  position: relative;
}

#bird-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s;
}
#bird-image[src=''] { opacity: 0; }

#image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: rgba(255, 140, 66, 0.15);
  pointer-events: none;
}

/* Info text */
#bird-info {
  padding: 18px 18px 12px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,140,66,0.3) transparent;
}

#bird-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 4px;
  line-height: 1.3;
}

#bird-scientific {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 8px;
}

#bird-location {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}

#bird-description {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 12px;
}

#recording-credit {
  font-size: 0.72rem;
  color: rgba(232, 232, 240, 0.35);
  margin-top: auto;
}

#bird-image-container.hidden { display: none; }
#bird-info.hidden { display: none; }

/* Audio player */
#audio-player {
  flex-shrink: 0;
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

#player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

#play-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--orange);
  border: none;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  padding-left: 2px; /* optical center for ▶ */
}
#play-btn:hover { background: var(--orange-dark); }
#play-btn:active { transform: scale(0.93); }
#play-btn.playing { padding-left: 0; }

#progress-bar {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
}

#progress {
  height: 100%;
  width: 0%;
  background: var(--orange);
  border-radius: 3px;
  transition: width 0.1s linear;
  pointer-events: none;
}

#time-display {
  font-size: 0.72rem;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}


/* ───────────── Bird markers — Explorer mode (HTML photo circles) ───────────── */
.bird-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: #0d1b3e;
  border: 2px solid rgba(255, 255, 255, 0.8);
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bird-marker:hover {
  transform: translate(-50%, -50%) scale(1.35);
  box-shadow: 0 0 8px 3px rgba(255, 255, 255, 0.35);
  z-index: 100;
}

/* ───────────── Error banner ───────────── */
#error-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(180, 40, 40, 0.9);
  color: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 60;
  text-align: center;
  max-width: 80%;
}
#error-banner.hidden { display: none; }

/* ───────────── Stats bar ───────────── */
#stats-bar {
  position: absolute;
  bottom: 16px;
  left: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
  pointer-events: auto;
}

#stats-bar a {
  color: var(--orange);
  text-decoration: none;
}
#stats-bar a:hover { text-decoration: underline; }

#about-btn {
  background: none;
  border: none;
  color: var(--orange);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
#about-btn:hover { text-decoration: underline; }

/* ───────────── About modal ───────────── */
#about-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
#about-overlay.hidden { display: none; }

#about-modal {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 36px;
  max-width: 460px;
  width: 90%;
  color: var(--text);
  line-height: 1.65;
}

#about-modal h2 {
  font-size: 1.4rem;
  color: var(--orange);
  margin-bottom: 10px;
}

#about-modal h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 20px 0 8px;
}

#about-modal p {
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 8px;
}

#about-modal ul {
  padding-left: 18px;
  font-size: 0.86rem;
  color: var(--text);
}

#about-modal ul li { margin-bottom: 6px; }

#about-modal a {
  color: var(--orange);
  text-decoration: none;
}
#about-modal a:hover { text-decoration: underline; }

.about-footer {
  margin-top: 20px !important;
  font-size: 0.78rem !important;
  color: var(--text-dim) !important;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 14px;
}

#close-about {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
#close-about:hover { color: var(--text); background: rgba(255,255,255,0.08); }

/* ───────────── Puzzle UI ───────────── */
#puzzle-ui {
  flex-shrink: 0;
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

#puzzle-ui.hidden { display: none; }

#puzzle-prompt {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}

#puzzle-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-btn {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 140, 66, 0.2);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.option-btn:hover:not(:disabled) {
  background: rgba(255, 140, 66, 0.12);
  border-color: rgba(255, 140, 66, 0.5);
}

.option-btn.correct {
  background: rgba(76, 175, 80, 0.2);
  border-color: #4caf50;
  color: #a5d6a7;
  animation: pop 0.3s ease;
}

.option-btn.wrong {
  background: rgba(224, 82, 82, 0.2);
  border-color: #e05252;
  color: #ef9a9a;
  animation: shake 0.4s ease;
}

.option-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

#puzzle-result {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text);
  margin-top: 12px;
  line-height: 1.5;
}

#puzzle-result.hidden { display: none; }

#puzzle-reveal-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--orange);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  padding: 4px;
}

#puzzle-reveal-btn:hover { text-decoration: underline; }
#puzzle-reveal-btn.hidden { display: none; }

#streak-display {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 600;
}

#streak-display.bumped {
  animation: streak-bump 0.4s ease;
}

.bird-marker-img.active {
  animation: pin-pulse 0.8s ease-out;
}

#streak-display.hidden { display: none; }
#streak-sep.hidden { display: none; }

#mode-toggle {
  background: rgba(255, 140, 66, 0.12);
  border: 1px solid rgba(255, 140, 66, 0.35);
  border-radius: 999px;
  color: var(--orange);
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  padding: 3px 10px;
  transition: background 0.15s, border-color 0.15s;
}
#mode-toggle:hover {
  background: rgba(255, 140, 66, 0.22);
  border-color: var(--orange);
}
#mode-toggle.explorer {
  background: rgba(100, 180, 255, 0.1);
  border-color: rgba(100, 180, 255, 0.4);
  color: #90caf9;
}
#mode-toggle.explorer:hover {
  background: rgba(100, 180, 255, 0.2);
  border-color: #90caf9;
}
