/* ==========================================================================
   GeoLab - 🌍 寰宇探秘 (GeoWander & Country Clash) Design System
   Website: https://geolab.fufuk.com/
   ========================================================================== */

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

:root {
  /* Core Palette */
  --bg-dark: #080d19;
  --bg-card: rgba(16, 24, 42, 0.75);
  --bg-card-hover: rgba(24, 36, 62, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(16, 185, 129, 0.4);

  /* Accents */
  --primary: #10b981;        /* Neon Emerald */
  --primary-glow: rgba(16, 185, 129, 0.25);
  --secondary: #06b6d4;      /* Electric Cyan */
  --accent-purple: #8b5cf6;  /* Royal Violet */
  --accent-amber: #f59e0b;   /* Warm Gold */
  --accent-rose: #f43f5e;    /* Crimson Rose */

  /* Text Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.2);

  --font-heading: 'Outfit', 'Noto Sans TC', sans-serif;
  --font-body: 'Inter', 'Noto Sans TC', sans-serif;
}

/* Light Theme Overrides (if toggled) */
body.light-theme {
  --bg-dark: #f0f4f8;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(0, 0, 0, 0.03);
  --border-glass: rgba(0, 0, 0, 0.1);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(139, 92, 246, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 60%);
  background-attachment: fixed;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s ease;
}
a:hover {
  color: var(--secondary);
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
}

/* --- Layout Containers --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 13, 25, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.85rem 1.5rem;
}

.header-container {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}
.brand-logo .logo-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.5));
}
.brand-logo span.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Global Nav Tabs */
.nav-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  gap: 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.55rem 1.1rem;
  border-radius: calc(var(--radius-md) - 4px);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.nav-btn.active {
  background: linear-gradient(135deg, var(--primary), #059669);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* User Profile & Auth Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  padding: 0.4rem 0.8rem;
  border-radius: 30px;
  color: var(--text-main);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-profile-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* --- Main Layout Sections --- */
.main-wrapper {
  max-width: 1320px;
  margin: 1.5rem auto 3rem auto;
  padding: 0 1.25rem;
}

.tab-content {
  display: none;
  animation: fadeIn 0.35s ease;
}

.tab-content.active {
  display: block;
}

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

/* --- Hero Banner / Wanderer Section --- */
.hero-wander-bar {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
}

.wander-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.custom-select, .search-input {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
}

.custom-select:focus, .search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #059669);
  color: #fff;
  border: none;
  padding: 0.75rem 1.6rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--secondary);
}

/* Country Explorer Grid */
.country-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.75rem;
}

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

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.country-hero-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.country-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.country-identity {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.flag-box {
  width: 90px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}
.flag-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.country-titles h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.country-titles p.native-name {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

/* Quick Metrics Cards */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.85rem;
}

.metric-pill {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-pill .label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.metric-pill .value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-heading);
}

/* Weather & Clock Widget */
.weather-clock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.weather-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.weather-temp {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--secondary);
}

.clock-info {
  text-align: right;
}
.clock-time {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent-amber);
}

/* Wikipedia & Wikimedia Gallery */
.wiki-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wiki-extract {
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.7;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.gallery-thumb {
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border-glass);
  transition: all 0.25s ease;
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.gallery-thumb:hover img {
  transform: scale(1.1);
}

/* Speech Audio Greeting Button */
.audio-greeting-btn {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #c084fc;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}
.audio-greeting-btn:hover {
  background: rgba(139, 92, 246, 0.3);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

/* Map Widget Sidebar */
.map-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.map-container {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* --- Country Comparison Tab --- */
.comparison-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.comparison-selector-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.comparison-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.chart-container {
  position: relative;
  height: 380px;
  width: 100%;
}

.winner-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.winner-badge {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.winner-badge i {
  font-size: 1.8rem;
  color: var(--accent-amber);
}

/* --- Quiz Game Tab & Poster --- */
.quiz-container {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.quiz-card {
  text-align: center;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (max-width: 600px) {
  .quiz-options {
    grid-template-columns: 1fr;
  }
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 1rem;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.option-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--primary);
}

.option-btn.correct {
  background: rgba(16, 185, 129, 0.3) !important;
  border-color: var(--primary) !important;
  color: #fff;
}

.option-btn.wrong {
  background: rgba(244, 63, 94, 0.3) !important;
  border-color: var(--accent-rose) !important;
  color: #fff;
}

/* Score Poster Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #0f172a;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.poster-canvas-preview {
  width: 100%;
  max-height: 480px;
  border-radius: var(--radius-md);
  margin: 1rem 0;
  border: 1px solid var(--border-glass);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* Footer SEO Links */
.app-footer {
  margin-top: 4rem;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border-glass);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}
