/* Audio error modal */
.audio-error-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
}
.audio-error-modal[hidden] {
  display: none !important;
}
.audio-error-modal .error-content {
  background: #222;
  color: #fff;
  border-radius: 10px;
  padding: 32px 28px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  text-align: center;
}
.audio-error-modal h2 {
  margin-top: 0;
  color: #ff4a4a;
}
.audio-error-modal .retry-btn {
  margin-top: 18px;
  padding: 10px 24px;
  font-size: 1rem;
  background: var(--accent, #4a90e2);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.audio-error-modal .retry-btn:hover {
  background: #357abd;
}

.theme-gtasa {
  --theme-bg: #1a2d1a;
  --theme-accent: #e6c200;
  --theme-text: #e6e6e6;
  --theme-card: #2e4d2e;
  --theme-divider: #3a523a;
}
/* Base styles and resets */
:root {
  /* Theme variables (defaults = GTA 3 for now) */
  --bg-start: #9cbac2;
  --bg-end: #4792a9;
  --accent: #4a90e2;
  --accent-2: #4a90e2;
  --surface: #f0f4ff;
  --text-on-accent: #ffffff;
  --text-primary: #333333;
  /* Scrollbar (defaults) */
  --scrollbar-track: #f1f1f1;
  --scrollbar-thumb: var(--accent);
  --scrollbar-thumb-hover: #357abd; /* a darker blue for hover */
  /* Manual global bias for logo horizontal alignment (negative = left); couldn't for the life of me figure out how to align it automatically */
  --logo-manual-shift: -20px;
}

/* Future themes can override these vars by applying a class on <body> */
.theme-gtaiii {
  --bg-start: #9cbac2;
  --bg-end: #4792a9;
  --accent: #4a90e2;
  --accent-2: #4a90e2;
  --surface: #f0f4ff;
  --scrollbar-track: #eaf2ff;
  --scrollbar-thumb: #4a90e2;
  --scrollbar-thumb-hover: #357abd;
}

/* Vice City theme (neon pink/teal vibes) */
.theme-gtavc {
  --bg-start: #0bbcd6; /* teal */
  --bg-end: #ff5fa2; /* neon pink */
  --accent: #ea7f99;
  --accent-2: #ea7f99;
  --surface: #f3eef9; /* soft lilac surface */
  --scrollbar-track: #fbe6f1;
  --scrollbar-thumb: #ea7f99;
  --scrollbar-thumb-hover: #ff5fa2;
}

/* San Andreas theme placeholder (to be tuned) */
.theme-gtasa {
  --bg-start: #b3cea5;
  --bg-end: #f5b170;
  --accent: #7a9b5f;
  --accent-2: #7a9b5f;
  --surface: #e9f1f4; /* cool grey */
  --scrollbar-track: #e7efd9;
  --scrollbar-thumb: #7a9b5f;
  --scrollbar-thumb-hover: #5f7d48;
}

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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  min-height: 100vh;
  padding: 20px;
  color: var(--text-primary);
  /* Firefox scrollbar */
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
  transition: background 1400ms ease-in-out; /* slightly faster fade between theme backgrounds */
}

/* Background audio visualizer canvas */
.bg-visualizer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1; /* below main content container which uses higher stacking contexts */
  pointer-events: none;
  opacity: 0.25; /* keep subtle */
}

/* Ensure main content sits above visualizer */
.container,
header,
.carousel-container,
.station-info,
.modal,
.now-playing-toast {
  position: relative;
  z-index: 2;
}

/* WebKit scrollbars (Chrome, Edge, Safari) */
body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
body::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
body::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 10px;
}
body::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  position: relative; /* keep content above bg fader */
  z-index: 1;
}

/* Mobile: align wrapper with viewport to keep carousel centered */
@media (max-width: 600px) {
  :root {
    /* Override logo manual shift for mobile devices */
    --logo-manual-shift: -12px;
  }
  
  body {
    padding: 0; /* avoid vw vs wrapper width mismatch */
  }
  .container {
    padding: 0; /* let wrapper span full viewport width */
  }
}

header {
  text-align: center;
  margin-bottom: 40px;
  color: white;
}

.game-logo-container {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px; /* reserve space to prevent layout jitter */
  width: 240px; /* match base image width for perfect centering */
  margin-left: auto;
  margin-right: auto;
}

.game-logo {
  height: 120px;
  width: 240px; /* fixed width box to avoid center shift across varying aspect ratios */
  display: block;
  margin: 0 auto; /* center within container */
  object-fit: contain;
  transform: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  transition: opacity 900ms ease-in-out, filter 900ms ease-in-out; /* slightly faster */
}

/* Background fader sits behind content to smooth theme changes */
.bg-fader {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0; /* sits above body background, below content */
  opacity: 0;
  /* Use dedicated vars so JS can freeze previous colors on fader */
  background: linear-gradient(
    135deg,
    var(--fader-bg-start, var(--bg-start)) 0%,
    var(--fader-bg-end, var(--bg-end)) 100%
  );
  filter: blur(10px);
  transition: opacity 1400ms ease-in-out, filter 1400ms ease-in-out;
}

/* Very small screens: scale logo down a bit more */
@media (max-width: 360px) {
  .game-logo {
    height: 96px;
  }
}

/* Scale logo up on larger screens */
@media (min-width: 768px) {
  .game-logo {
    height: 140px;
    width: 280px;
  }
  .game-logo-container {
    width: 280px;
  }
}

@media (min-width: 1200px) {
  .game-logo {
    height: 160px;
    width: 320px;
  }
  .game-logo-container {
    width: 320px;
  }
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Header controls: mode toggle + listening indicator */
/* removed header mode/listening controls */

/* Smaller subtitle on mobile */
@media (max-width: 480px) {
  .subtitle {
    font-size: 0.95rem;
  }
}

.station-info {
  text-align: center;
  color: white;
  margin: 20px 0;
  min-height: 80px;
}

.station-info .genre-name {
  margin-top: 4px;
  font-size: 1.1rem;
  font-style: italic;
}

.station-info h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.station-info p {
  font-size: 1.2rem;
  opacity: 0.9;
  font-style: italic;
}

.volume-control {
  margin-top: 70px;
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.volume-control input[type="range"] {
  width: 220px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Now Playing Toast */
.now-playing-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 1000;
}

.now-playing-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.now-playing-toast img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.now-playing-toast .toast-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
