/* ==========================================================================
   PLANESPOTR - Modern Aviation Trivia Game Stylesheet
   Design System: Modern Minimalist Cockpit & Sky Aesthetic
   Features: Responsive Grid, Dark/Light Themes, Glassmorphism, Accessibility
   ========================================================================== */

:root {
  /* Color Palette - Dark Cockpit (Default) */
  --bg-main: #0b1120;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --bg-card-solid: #1e293b;
  --bg-element: #0f172a;
  
  --border-color: rgba(255, 255, 255, 0.1);
  --border-active: #38bdf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-blue: #0284c7;
  --accent-sky: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;

  --success-bg: rgba(16, 185, 129, 0.15);
  --success-border: #10b981;
  --success-text: #34d399;

  --error-bg: rgba(244, 63, 94, 0.15);
  --error-border: #f43f5e;
  --error-text: #fb7185;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Override */
[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --bg-card-solid: #ffffff;
  --bg-element: #e2e8f0;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-active: #0284c7;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.15);

  --success-bg: rgba(16, 185, 129, 0.1);
  --success-text: #059669;

  --error-bg: rgba(244, 63, 94, 0.1);
  --error-text: #e11d48;
}

/* Fallback auto dark/light preference if not overridden manually */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg-main: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(241, 245, 249, 0.95);
    --bg-card-solid: #ffffff;
    --bg-element: #e2e8f0;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-active: #0284c7;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.15);
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-text: #059669;
    --error-bg: rgba(244, 63, 94, 0.1);
    --error-text: #e11d48;
  }
}

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

html {
  font-family: var(--font-family);
  font-size: 16px;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5rem 1rem 3rem 1rem;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
  position: relative;
}

/* Accessibility Focus States */
:focus-visible {
  outline: 3px solid var(--accent-sky);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 10px;
  background: var(--accent-sky);
  color: #000;
  padding: 8px 16px;
  z-index: 1000;
  font-weight: bold;
  border-radius: var(--radius-sm);
  transition: top 0.2s;
}
.skip-link:focus {
  top: 10px;
}

/* Canvas Confetti Container */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* Main Container */
.app-container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Header Navbar */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 2.2rem;
  height: 2.2rem;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-sky));
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
  transform: rotate(-10deg);
  transition: transform var(--transition-fast);
}

.brand:hover .brand-icon {
  transform: rotate(0deg) scale(1.05);
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-main) 60%, var(--accent-sky));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--bg-element);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.icon-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-sky);
  color: var(--accent-sky);
}

/* Mode Switcher Pill */
.mode-toggle {
  display: flex;
  background: var(--bg-element);
  border-radius: var(--radius-full);
  padding: 3px;
  border: 1px solid var(--border-color);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

/* Game Score Bar */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.score-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.score-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-active);
}

.score-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.score-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.streak-flame {
  color: var(--accent-amber);
  animation: pulse-flame 1.5s infinite alternate;
}

@keyframes pulse-flame {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.5)); }
  100% { transform: scale(1.2); filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.8)); }
}

/* Main Gameplay Area Card */
.game-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Image Container Area */
.image-container {
  position: relative;
  width: 100%;
  height: 340px;
  background: var(--bg-element);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.aircraft-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: opacity var(--transition-normal), transform var(--transition-slow);
  opacity: 0;
}

.aircraft-img.loaded {
  opacity: 1;
}

.aircraft-img:hover {
  transform: scale(1.03);
}

/* Loading Shimmer Placeholder */
.image-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-element) 0%, var(--bg-card-solid) 50%, var(--bg-element) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* Zoom Image Button & Photo Credit Badge */
.photo-credit-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(15, 23, 42, 0.75);
  color: var(--accent-sky);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  z-index: 5;
}

.image-zoom-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.image-zoom-btn:hover {
  background: rgba(2, 132, 199, 0.85);
  transform: scale(1.05);
}

/* Timer Bar (Optional Feature) */
.timer-container {
  width: 100%;
  height: 6px;
  background: var(--bg-element);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: none;
}

.timer-container.active {
  display: block;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-sky), var(--accent-emerald));
  transition: width 0.1s linear;
}

.timer-bar.warning {
  background: linear-gradient(90deg, var(--accent-amber), var(--accent-rose));
}

/* Stage Stepper Indicator */
.stage-stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-element);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.step-indicator.active {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent-sky);
  color: var(--text-main);
  box-shadow: var(--shadow-glow);
}

.step-indicator.completed {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.step-indicator.failed {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.step-badge {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-card-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.step-indicator.active .step-badge {
  background: var(--accent-sky);
  color: #000;
}

.step-indicator.completed .step-badge {
  background: var(--accent-emerald);
  color: #fff;
}

.step-indicator.failed .step-badge {
  background: var(--accent-rose);
  color: #fff;
}

/* Question Header */
.question-box {
  text-align: center;
}

.question-stage-tag {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-sky);
  margin-bottom: 0.25rem;
}

.question-text {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

@media (max-width: 600px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
  .scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }
}

.option-btn {
  background: var(--bg-card-solid);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.option-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.option-btn:active:not(:disabled) {
  transform: translateY(0);
}

.option-key-tag {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-element);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Feedback Choice States */
.option-btn.correct {
  background: var(--success-bg) !important;
  border-color: var(--success-border) !important;
  color: var(--success-text) !important;
}

.option-btn.wrong {
  background: var(--error-bg) !important;
  border-color: var(--error-border) !important;
  color: var(--error-text) !important;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Round Summary Result Card */
.result-card {
  background: var(--bg-element);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.3s ease-out;
}

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

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.result-score-badge {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-sky));
  color: #fff;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 0.9rem;
}

.result-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: var(--bg-card-solid);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
}

.breakdown-label {
  color: var(--text-muted);
  font-weight: 600;
}

.breakdown-val {
  font-weight: 700;
  color: var(--text-main);
}

.aircraft-fact {
  font-size: 0.88rem;
  color: var(--text-muted);
  background: rgba(56, 189, 248, 0.05);
  border-left: 3px solid var(--accent-sky);
  padding: 0.6rem 0.8rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Action Controls Bar */
.action-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), #0369a1);
  color: #ffffff;
  border: none;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0284c7, #075985);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

.btn-secondary {
  background: var(--bg-card-solid);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  border: 1px solid var(--accent-sky);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s ease-out forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-box {
  background: var(--bg-element);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  text-align: center;
}

.stat-box-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-sky);
}

.stat-box-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

/* Image Zoom Lightbox */
.lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* Footer */
.app-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: underline;
}

/* Screenreader Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
