@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Color System */
  --bg-main: #06080e;
  --bg-gradient: radial-gradient(circle at 75% 30%, #0f1322 0%, #040508 100%);
  --panel-bg: rgba(10, 14, 26, 0.65);
  --panel-border: rgba(255, 255, 255, 0.07);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-color: #00f2fe; /* Cyber Teal */
  --accent-glow: rgba(0, 242, 254, 0.4);
  --accent-purple: #7f00ff;
  --accent-purple-glow: rgba(127, 0, 255, 0.3);
  --success-color: #10b981; /* Pulsing green */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --card-radius: 20px;
  --transition-speed: 0.8s;
}

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

body {
  background: var(--bg-main);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  font-family: var(--font-body);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Base Layout */
#app-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 10;
}

/* Sidebar Panel (Glassmorphism) */
#sidebar {
  width: 440px;
  height: calc(100vh - 40px);
  margin: 20px;
  padding: 30px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--card-radius);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 
              inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 20;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateX(0);
}

/* Logo/Branding */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  background-color: var(--accent-color);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
  animation: pulse-glow 2s infinite ease-in-out;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ffffff;
}

.status-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--success-color);
  border-radius: 50%;
  animation: blink 1.5s infinite ease-in-out;
}

/* Audio Control Button */
.audio-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 4px 10px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
}

.audio-btn:hover {
  background: rgba(0, 242, 254, 0.08);
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

.audio-btn.playing {
  background: rgba(0, 242, 254, 0.05);
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.1);
}


/* Image Container with Crossfade */
.display-card {
  position: relative;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0; /* allows flex item to shrink below content size */
  justify-content: center;
}

.image-frame {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 14px;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.species-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity var(--transition-speed) ease-in-out, transform var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  transform: scale(1.05);
}

.species-image.active {
  opacity: 1;
  transform: scale(1);
}

/* Metadata Styling */
.meta-content {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.meta-content.active {
  opacity: 1;
  transform: translateY(0);
}

.names-group {
  margin-bottom: 16px;
}

.scientific-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1.25;
  color: #ffffff;
  margin-bottom: 4px;
}

.scientific-name i {
  font-style: italic;
}

.common-name {
  font-size: 1rem;
  color: var(--accent-color);
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* Taxonomy Pills */
.taxonomy-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tax-pill {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
}

.tax-pill.highlight {
  border-color: rgba(0, 242, 254, 0.2);
  color: var(--accent-color);
  background: rgba(0, 242, 254, 0.02);
}

/* Geo Info panel */
.geo-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 14px;
  border-radius: 12px;
  font-family: monospace;
  font-size: 0.75rem;
  margin-bottom: 12px;
}

.geo-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.geo-label {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

.geo-val {
  color: var(--text-primary);
  font-weight: 500;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.geo-val.coords {
  color: var(--accent-color);
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

/* Dynamic Attribution Details */
.record-attribution {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: auto;
}

.record-attribution a {
  color: var(--text-secondary);
  text-decoration: underline;
  transition: color 0.3s;
}

.record-attribution a:hover {
  color: var(--accent-color);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Canvas / Globe Container */
#globe-container {
  flex-grow: 1;
  height: 100vh;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

#globe-canvas {
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  margin: auto;
  cursor: grab;
}

#globe-canvas:active {
  cursor: grabbing;
}

/* Global Footer (Static License Text) */
#global-footer {
  position: absolute;
  bottom: 20px;
  right: 30px;
  z-index: 15;
  text-align: right;
  max-width: 450px;
  pointer-events: none;
}

.license-disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.license-disclaimer p {
  margin-bottom: 2px;
}

.license-link {
  color: var(--text-secondary);
  text-decoration: underline;
  pointer-events: auto;
  transition: color 0.3s;
}

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

/* Loader Screen Overlay */
#loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-main);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), visibility 1s;
}

#loader-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-spinner {
  width: 80px;
  height: 80px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loader-circle {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 50%;
}

.loader-circle-accent {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid transparent;
  border-top: 1px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 2s linear infinite;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

.loader-circle-accent-2 {
  position: absolute;
  width: 70%;
  height: 70%;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--accent-purple);
  border-radius: 50%;
  animation: spin-reverse 1.5s linear infinite;
}

.loader-text {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-secondary);
  animation: text-pulse 2s infinite ease-in-out;
  margin-top: 10px;
}

/* Keyframe Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes spin-reverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.7;
    box-shadow: 0 0 8px var(--accent-color), 0 0 15px var(--accent-color);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 15px var(--accent-color), 0 0 30px var(--accent-color);
  }
}

@keyframes blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes text-pulse {
  0%, 100% { opacity: 0.5; color: var(--text-muted); }
  50% { opacity: 1; color: var(--text-primary); }
}

/* Mobile Responsive */
@media (max-width: 950px) {
  body {
    flex-direction: column;
    overflow-y: auto;
    height: auto;
  }
  
  #app-container {
    flex-direction: column-reverse;
    height: auto;
  }

  #sidebar {
    width: calc(100% - 32px);
    margin: 16px;
    height: auto;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  #globe-container {
    width: 100%;
    height: 50vh;
    min-height: 380px;
  }

  #global-footer {
    position: static;
    text-align: center;
    max-width: none;
    padding: 20px;
    pointer-events: auto;
  }
}
