/* ===== GeoGuessr Reference Guide - Styles ===== */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-tertiary: #242836;
  --bg-card: #1e2230;
  --bg-hover: #2a2f40;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0b0;
  --text-muted: #6b7280;
  --accent-blue: #4a9eff;
  --accent-green: #34d399;
  --accent-yellow: #fbbf24;
  --accent-red: #f87171;
  --accent-purple: #a78bfa;
  --accent-orange: #fb923c;
  --accent-pink: #f472b6;
  --accent-cyan: #22d3ee;
  --border-color: #2d3348;
  --border-light: #383e52;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans TC', 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== Layout ===== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.sidebar-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header h1 .logo {
  font-size: 1.5rem;
}

.sidebar-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Search */
.search-container {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 80px;
  background: var(--bg-secondary);
  z-index: 9;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}

.search-input:focus {
  border-color: var(--accent-blue);
}

.search-container .search-icon {
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

/* Navigation */
.nav-section {
  padding: 8px 0;
}

.nav-section-title {
  padding: 10px 20px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.nav-region {
  cursor: pointer;
  user-select: none;
}

.nav-region-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.nav-region-header:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-region-header .arrow {
  font-size: 0.7rem;
  transition: transform var(--transition);
}

.nav-region.open .nav-region-header .arrow {
  transform: rotate(90deg);
}

.nav-region-header .count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 8px;
}

.nav-country-list {
  display: none;
  padding: 2px 0;
}

.nav-region.open .nav-country-list {
  display: block;
}

.nav-country {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px 6px 32px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-country:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-country.active {
  color: var(--accent-blue);
  background: rgba(74, 158, 255, 0.08);
  border-right: 2px solid var(--accent-blue);
}

.nav-country .flag {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

/* Meta link */
.nav-meta-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-cyan);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border-bottom: 1px solid var(--border-color);
}

.nav-meta-link:hover {
  background: rgba(34, 211, 238, 0.08);
}

/* ===== Main Content ===== */
.main {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb span {
  color: var(--text-primary);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.view-btn {
  padding: 6px 14px;
  font-size: 0.8rem;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.view-btn.active {
  background: var(--accent-blue);
  color: white;
}

/* ===== Content Area ===== */
.content {
  padding: 32px;
  max-width: 1200px;
}

/* Hero/Welcome Section */
.hero {
  text-align: center;
  padding: 60px 20px;
}

.hero h2 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-top: 32px;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-blue);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Region Overview Grid */
.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 40px;
}

.region-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.region-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.region-card .region-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.region-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.region-card .region-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Country Detail Page ===== */
.country-header {
  margin-bottom: 32px;
}

.country-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.country-title .flag-large {
  font-size: 3rem;
}

.country-title h2 {
  font-size: 2rem;
  font-weight: 800;
}

.country-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-left: 4px;
}

/* Quick facts bar */
.quick-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.quick-fact {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.quick-fact .label {
  color: var(--text-muted);
}

.quick-fact .value {
  color: var(--text-primary);
  font-weight: 600;
}

/* Detail sections */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-card-header {
  padding: 14px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-card-header .icon {
  font-size: 1.1rem;
}

.detail-card-header h3 {
  font-size: 0.92rem;
  font-weight: 700;
}

.detail-card-body {
  padding: 16px 20px;
}

.detail-card-body ul {
  list-style: none;
  padding: 0;
}

.detail-card-body li {
  padding: 6px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  line-height: 1.5;
}

.detail-card-body li:last-child {
  border-bottom: none;
}

.detail-card-body li strong {
  color: var(--text-primary);
}

.detail-card.full-width {
  grid-column: 1 / -1;
}

/* Tips section */
.tips-list {
  list-style: none;
  padding: 0;
}

.tips-list li {
  padding: 10px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  line-height: 1.5;
}

.tips-list li:last-child {
  border-bottom: none;
}

.tip-icon {
  color: var(--accent-yellow);
  flex-shrink: 0;
  margin-top: 2px;
}

/* Tag styles */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-blue { background: rgba(74,158,255,0.15); color: var(--accent-blue); }
.tag-green { background: rgba(52,211,153,0.15); color: var(--accent-green); }
.tag-yellow { background: rgba(251,191,36,0.15); color: var(--accent-yellow); }
.tag-red { background: rgba(248,113,113,0.15); color: var(--accent-red); }
.tag-purple { background: rgba(167,139,250,0.15); color: var(--accent-purple); }

/* ===== General Meta Page ===== */
.meta-section {
  margin-bottom: 40px;
}

.meta-section h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-blue);
  display: inline-block;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.meta-table th {
  background: var(--bg-tertiary);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

.meta-table td {
  padding: 10px 16px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.meta-table tr:last-child td {
  border-bottom: none;
}

.meta-table tr:hover td {
  background: var(--bg-hover);
}

/* Meta info block */
.meta-info-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.meta-info-block h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent-blue);
}

.meta-info-block p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== Country Grid View ===== */
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.country-grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.country-grid-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.country-grid-card .card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.country-grid-card .card-flag {
  font-size: 2rem;
}

.country-grid-card .card-name {
  font-size: 1rem;
  font-weight: 700;
}

.country-grid-card .card-region {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.country-grid-card .card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.country-grid-card .mini-fact {
  font-size: 0.75rem;
  padding: 3px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-muted);
}

/* ===== Region List View ===== */
.region-section {
  margin-bottom: 48px;
}

.region-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
}

.region-section-header h3 {
  font-size: 1.4rem;
  font-weight: 800;
}

.region-section-header .region-badge {
  font-size: 0.78rem;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  color: var(--text-muted);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .content {
    padding: 20px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .hero h2 {
    font-size: 1.6rem;
  }

  .stats-bar {
    gap: 16px;
  }

  .country-title h2 {
    font-size: 1.4rem;
  }

  .country-title .flag-large {
    font-size: 2rem;
  }

  .quick-facts {
    gap: 8px;
  }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.3s ease forwards;
}

/* ===== Back to top ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(74, 158, 255, 0.4);
}

/* Highlight for search */
mark {
  background: rgba(251, 191, 36, 0.3);
  color: var(--text-primary);
  padding: 0 2px;
  border-radius: 2px;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Difficulty indicator */
.difficulty {
  display: inline-flex;
  gap: 3px;
}

.difficulty .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-color);
}

.difficulty .dot.filled { background: var(--accent-green); }
.difficulty .dot.filled.medium { background: var(--accent-yellow); }
.difficulty .dot.filled.hard { background: var(--accent-red); }

/* ===== Visual Enhancements ===== */

/* Country header image banner */
.country-banner {
  width: 100%;
  height: 200px;
  background-size: cover;
  background-position: center;
  border-radius: var(--radius);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.country-banner::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(transparent, var(--bg-primary));
}

/* Visual indicators for driving side */
.driving-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
}

.driving-left {
  background: rgba(248, 113, 113, 0.15);
  color: var(--accent-red);
}

.driving-right {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
}

/* Image gallery in detail cards */
.image-gallery {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.image-gallery img {
  max-width: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  object-fit: contain;
}

/* Fix all inline detail card images - prevent squashing */
.detail-card-body img {
  object-fit: contain;
  height: auto !important;
  max-height: 300px;
  cursor: zoom-in;
  transition: transform 0.2s;
}

/* Lightbox for image zoom */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-overlay img {
  max-width: 85vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
  user-select: none;
}

.lb-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 10;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.lb-close:hover { opacity: 1; }

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  font-size: 3rem;
  padding: 16px 12px;
  cursor: pointer;
  border-radius: 8px;
  z-index: 10;
  opacity: 0.6;
  transition: opacity 0.2s, background 0.2s;
}
.lb-nav:hover { opacity: 1; background: rgba(255,255,255,0.2); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  background: rgba(0,0,0,0.5);
  padding: 4px 16px;
  border-radius: 20px;
}

.lb-hint {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.4);
  font-size: 0.75rem;
}

/* Inline icon badges */
.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  font-size: 1rem;
  margin-right: 8px;
}

/* Road line visual indicator */
.road-line-demo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #333;
  border-radius: 6px;
  margin: 8px 0;
}

.road-line-demo .line {
  height: 4px;
  border-radius: 2px;
  flex: 1;
}

.road-line-demo .line.yellow { background: #fbbf24; }
.road-line-demo .line.white { background: #e8eaed; }
.road-line-demo .line.dashed { background: repeating-linear-gradient(90deg, #e8eaed 0px, #e8eaed 20px, transparent 20px, transparent 30px); height: 4px; }
.road-line-demo .line.yellow-dashed { background: repeating-linear-gradient(90deg, #fbbf24 0px, #fbbf24 20px, transparent 20px, transparent 30px); height: 4px; }

/* Script sample display */
.script-sample {
  font-size: 1.4rem;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: inline-block;
  margin: 4px;
  border: 1px solid var(--border-color);
  font-family: 'Noto Sans', system-ui, sans-serif;
}
