/* ==============================
   FEATHERWATCH — STYLESHEET
   ============================== */

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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --accent: #58a6ff;
  --accent2: #3fb950;
  --text: #e6edf3;
  --muted: #8b949e;
  --common: #8b949e;
  --uncommon: #3fb950;
  --rare: #58a6ff;
  --legendary: #d29922;
  --danger: #f85149;
  --font: 'Segoe UI', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

/* -------- SPLASH -------- */
#splash {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #0d2136 0%, #0d1117 70%);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn .6s ease;
}
.splash-inner { text-align: center; }
.logo-icon { font-size: 5rem; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
#splash h1 { font-size: 3.5rem; letter-spacing: .15em; color: #fff; text-shadow: 0 0 40px #58a6ff88; }
.tagline { color: var(--muted); margin: .6rem 0 2rem; font-size: 1.1rem; }
#startBtn {
  padding: .9rem 2.8rem; font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  color: #fff; border: none; border-radius: 50px; cursor: pointer;
  box-shadow: 0 0 30px #1f6feb88;
  transition: transform .2s, box-shadow .2s;
}
#startBtn:hover { transform: scale(1.05); box-shadow: 0 0 45px #388bfd; }

/* -------- APP LAYOUT -------- */
#app {
  display: grid;
  grid-template-rows: 54px 1fr 36px;
  width: 100vw; height: 100vh;
  animation: fadeIn .5s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* -------- HUD -------- */
#hud {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.2rem;
  font-size: .85rem;
  gap: .5rem;
}
.hud-left, .hud-right { display: flex; gap: 1.2rem; align-items: center; flex: 1; }
.hud-right { justify-content: flex-end; }
.hud-center h2 { font-size: 1.1rem; letter-spacing: .12em; color: var(--accent); white-space: nowrap; }
#logbookBtn {
  padding: .3rem .9rem; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; cursor: pointer; font-size: .8rem;
  transition: background .15s;
}
#logbookBtn:hover { background: var(--border); }

/* -------- MAIN AREA -------- */
#mainArea {
  display: grid;
  grid-template-columns: 1fr 360px;
  overflow: hidden;
}

/* -------- HABITAT PANEL -------- */
#habitatPanel {
  display: flex; flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
}
#canvas-wrapper {
  flex: 1; position: relative; overflow: hidden;
  background: #000;
}
#habitatCanvas { width: 100%; height: 100%; display: block; }

/* Binocular vignette overlay */
#binoculars {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 58% 72% at 35% 50%, transparent 90%, #000 100%),
              radial-gradient(ellipse 58% 72% at 65% 50%, transparent 90%, #000 100%);
  pointer-events: none;
}
/* Green scan line */
#scanOverlay {
  position: absolute; inset: 0; pointer-events: none;
  overflow: hidden;
}
.scan-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #3fb95088, transparent);
  animation: scanAnim 2s linear infinite;
  top: 0;
}
@keyframes scanAnim { from{top:0%} to{top:100%} }

/* Crosshair */
#crosshair {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.ch-ring {
  position: absolute;
  border: 2px solid rgba(88,166,255,.6);
  border-radius: 50%;
  width: 80px; height: 80px;
  animation: pulseRing 1.6s ease-in-out infinite;
}
.ch-ring2 { width: 130px; height: 130px; border-color: rgba(88,166,255,.25); animation-delay: .4s; }
@keyframes pulseRing { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.12);opacity:.5} }

/* Detection badge */
#detectionBadge {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); border: 1px solid var(--accent);
  border-radius: 8px; padding: .5rem 1.2rem; text-align: center;
  animation: fadeIn .3s ease;
  backdrop-filter: blur(6px);
}
#detectionName { display: block; font-size: 1.1rem; font-weight: 700; color: #fff; }
#detectionRarity { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.rarity-common    { color: var(--common); }
.rarity-uncommon  { color: var(--uncommon); }
.rarity-rare      { color: var(--rare); }
.rarity-legendary { color: var(--legendary); }

/* Habitat controls */
#habitatControls {
  display: flex; gap: .4rem; flex-wrap: wrap;
  padding: .6rem .8rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.hab-btn {
  padding: .35rem .85rem; font-size: .8rem; border-radius: 20px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.hab-btn:hover { border-color: var(--accent); color: var(--text); }
.hab-btn.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }

/* Action row */
#actionRow {
  display: flex; gap: .5rem; padding: .5rem .8rem;
  background: var(--surface); border-top: 1px solid var(--border);
}
#actionRow button {
  flex: 1; padding: .55rem .5rem; font-size: .85rem; font-weight: 600;
  border-radius: 8px; cursor: pointer; border: 1px solid var(--border);
  transition: all .15s;
}
#scanBtn    { background: #163b2e; color: var(--accent2); border-color: #3fb95055; }
#scanBtn:hover { background: #1e5040; }
#binoBtn    { background: #122236; color: var(--accent); border-color: #58a6ff44; }
#binoBtn:hover { background: #1b3557; }
#recordBtn  { background: #2d2200; color: var(--legendary); border-color: #d2992255; }
#recordBtn:hover:not(:disabled) { background: #3d3000; }
#recordBtn:disabled { opacity: .35; cursor: not-allowed; }

/* -------- INFO PANEL -------- */
#infoPanel {
  display: flex; flex-direction: column;
  background: var(--surface); overflow: hidden;
}
#tabs {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tab-btn {
  flex: 1; padding: .65rem .3rem; font-size: .75rem; font-weight: 600;
  background: none; border: none; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-content {
  flex: 1; overflow-y: auto; padding: .8rem;
}
.tab-hint { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 1.5rem; }

/* Nearby list */
#nearbyList, #speciesList, #challengeList {
  list-style: none; display: flex; flex-direction: column; gap: .4rem;
}
.bird-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .8rem; cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex; align-items: center; gap: .7rem;
}
.bird-item:hover { border-color: var(--accent); transform: translateX(2px); }
.bird-item .bird-emoji { font-size: 1.6rem; }
.bird-item-info { flex: 1; min-width: 0; }
.bird-item-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bird-item-sub { font-size: .75rem; color: var(--muted); }
.bird-item-rarity {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  padding: .15rem .5rem; border-radius: 20px; white-space: nowrap;
}
.rarity-badge-common    { background: #21262d; color: var(--common); }
.rarity-badge-uncommon  { background: #12261a; color: var(--uncommon); }
.rarity-badge-rare      { background: #0d2236; color: var(--rare); }
.rarity-badge-legendary { background: #2d1f00; color: var(--legendary); }

.spotted { border-left: 3px solid var(--accent2) !important; }
.not-spotted { opacity: .55; }

/* Species search */
#speciesSearch {
  width: 100%; padding: .5rem .8rem; margin-bottom: .6rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .85rem;
  outline: none;
}
#speciesSearch:focus { border-color: var(--accent); }

/* Map canvas */
#mapCanvas {
  width: 100%; border-radius: 8px;
  border: 1px solid var(--border); background: #0a2636;
}
#mapLegend {
  display: flex; gap: .8rem; margin-top: .5rem; flex-wrap: wrap;
}
.leg {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  padding: .15rem .5rem; border-radius: 20px;
}
.leg.common    { background: #21262d; color: var(--common); }
.leg.uncommon  { background: #12261a; color: var(--uncommon); }
.leg.rare      { background: #0d2236; color: var(--rare); }
.leg.legendary { background: #2d1f00; color: var(--legendary); }

/* Challenge items */
.challenge-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: .65rem .9rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.challenge-title { font-weight: 600; font-size: .9rem; }
.challenge-desc  { font-size: .78rem; color: var(--muted); }
.challenge-progress-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: .2rem;
}
.challenge-fill  { height: 100%; background: var(--accent2); border-radius: 3px; transition: width .4s; }
.challenge-complete .challenge-fill { background: var(--legendary); }
.challenge-complete .challenge-title { color: var(--legendary); }
.challenge-reward { font-size: .72rem; color: var(--legendary); }
.challenge-pct   { font-size: .72rem; color: var(--muted); text-align: right; }

/* -------- STATUS BAR -------- */
#statusBar {
  background: var(--surface2); border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1rem; gap: 1rem;
  font-size: .78rem; color: var(--muted);
}
#xpBar { flex: 0 0 160px; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
#xpFill { height: 100%; background: linear-gradient(90deg, #1f6feb, #58a6ff); border-radius: 4px; transition: width .6s ease; width: 0%; }

/* -------- MODALS -------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; animation: fadeIn .2s ease;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.8rem; position: relative;
  max-width: 540px; width: 90vw; max-height: 85vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: .8rem; right: .9rem;
  background: none; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-box h2 { margin-bottom: 1rem; color: var(--text); }

/* Field log list */
#logList { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.log-entry {
  background: var(--surface2); border-radius: 8px; padding: .6rem .9rem;
  display: flex; gap: .8rem; align-items: center;
}
.log-time { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.log-bird { font-weight: 600; font-size: .9rem; }
.log-details { font-size: .78rem; color: var(--muted); }
#logStats { margin-bottom: .8rem; color: var(--muted); font-size: .88rem; }

/* Bird detail modal */
.bird-detail-box { max-width: 480px; }
#birdDetailContent {}
.detail-header { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.detail-emoji  { font-size: 3.5rem; }
.detail-title  h3 { font-size: 1.4rem; }
.detail-title  p  { color: var(--muted); font-size: .85rem; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .5rem;
  margin: 1rem 0;
}
.detail-stat {
  background: var(--surface2); border-radius: 8px; padding: .5rem .7rem;
}
.detail-stat label { display: block; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.detail-stat span  { font-weight: 600; font-size: .95rem; }
.detail-desc { font-size: .85rem; line-height: 1.6; color: var(--muted); }
.detail-sounds { margin-top: .8rem; }
.detail-sounds h4 { font-size: .85rem; margin-bottom: .4rem; color: var(--accent); }
.call-item {
  background: var(--surface2); border-radius: 6px; padding: .4rem .7rem;
  font-size: .8rem; margin-bottom: .3rem; border-left: 3px solid var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Bird canvas animations — injected via JS */
.flying-bird {
  position: absolute; user-select: none; pointer-events: none;
  font-size: 1.4rem; transition: opacity .5s;
  animation: birdFly linear forwards;
}
@keyframes birdFly {
  from { opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  to   { opacity: 0; }
}

/* Notification toast */
#toast {
  position: fixed; bottom: 50px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--accent);
  border-radius: 10px; padding: .7rem 1.5rem; font-size: .9rem;
  z-index: 200; animation: toastIn .3s ease;
  pointer-events: none; white-space: nowrap;
}
@keyframes toastIn { from{opacity:0;bottom:40px} to{opacity:1;bottom:50px} }
