/* --- Core Design System & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  /* Primary Theme Colors */
  --bg-dark: #09090b;
  --bg-surface: rgba(22, 22, 28, 0.55);
  --bg-surface-solid: #16161c;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.25);
  
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  /* Levels Accent Colors */
  --accent-lvl1: #007aff; /* Blue */
  --accent-lvl2: #af52de; /* Purple */
  --accent-lvl3: #ff9500; /* Orange */
  
  /* Active Color Dynamic Accent (Set by JS, fallback to blue) */
  --active-color: #007aff;
  --active-color-rgb: 0, 122, 255;
  
  /* Animation timings */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* --- Dynamic Glow Background --- */
.glow-bg {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(var(--active-color-rgb), 0.2) 0%, rgba(var(--active-color-rgb), 0) 70%);
  z-index: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
  filter: blur(40px);
}

/* --- App Container & Layout --- */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  justify-content: space-between;
  gap: 1.5rem;
}

/* --- Header / Brand --- */
.app-header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.brand h1 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, rgba(255, 255, 255, 0.6) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  background: linear-gradient(135deg, #007aff, #00c6ff);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Levels Section --- */
.levels-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.level-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  padding: 0.3rem;
  border-radius: 14px;
  backdrop-filter: blur(10px);
}

.level-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 0.25rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  transition: var(--transition-fast);
}

.level-tab .lvl-num {
  font-size: 0.75rem;
  opacity: 0.6;
}

.level-tab .lvl-range {
  font-size: 0.7rem;
  opacity: 0.5;
  font-weight: 400;
}

.level-tab:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.02);
}

.level-tab.active {
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Color codes matching active level state */
.level-tab[data-level="1"].active {
  background-color: var(--accent-lvl1);
}
.level-tab[data-level="2"].active {
  background-color: var(--accent-lvl2);
}
.level-tab[data-level="3"].active {
  background-color: var(--accent-lvl3);
}

/* --- Progress Bar --- */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0 0.25rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-bar-bg {
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--active-color) 0%, rgba(var(--active-color-rgb), 0.7) 100%);
  width: 0%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(var(--active-color-rgb), 0.5);
}

/* --- Carousel Container & Swiper --- */
.carousel-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.carousel-viewport {
  display: flex;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  width: 100%;
  padding: 0.5rem 0;
  -ms-overflow-style: none; /* Hide scrollbars for IE/Edge */
  scrollbar-width: none; /* Hide scrollbars for Firefox */
  gap: 0px;
}

.carousel-viewport::-webkit-scrollbar {
  display: none; /* Hide scrollbars for Chrome/Safari/Opera */
}

/* Slider navigation arrows (Desktop only, hidden on mobile) */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(22, 22, 28, 0.7);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: var(--transition-fast);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.nav-arrow:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-focus);
  color: var(--active-color);
  transform: translateY(-50%) scale(1.05);
}

.nav-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.prev-btn {
  left: -20px;
}

.next-btn {
  right: -20px;
}

/* --- Color Card Styling --- */
.slide-item {
  flex: 0 0 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  scroll-snap-align: center;
}

.color-card {
  width: 88%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 28px;
  padding: 2.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s;
}

.color-card:hover {
  border-color: rgba(var(--active-color-rgb), 0.3);
}

/* Ambient color background shine behind card */
.color-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(var(--active-color-rgb), 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Color Circle Sphere */
.color-sphere-wrapper {
  position: relative;
  margin-bottom: 2rem;
  z-index: 1;
}

.color-sphere {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  position: relative;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  animation: floatSphere 6s ease-in-out infinite;
}

.color-card:hover .color-sphere {
  transform: scale(1.05) rotate(10deg);
}

/* Special styling for White colors to remain visible */
.color-sphere.is-white {
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Dynamic text layouts inside card */
.color-info {
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.color-title-en {
  font-family: var(--font-heading);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
  line-height: 1.1;
  text-transform: capitalize;
}

.color-phonetic {
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--text-secondary);
  background-color: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  align-self: center;
  letter-spacing: 0.5px;
}

.color-title-es {
  font-size: 1.45rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.8rem;
  margin-top: 0.3rem;
  text-transform: capitalize;
}

/* --- Pronunciation HUD controls --- */
.controls-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.audio-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.speak-btn {
  flex-grow: 1;
  background: linear-gradient(135deg, var(--active-color) 0%, rgba(var(--active-color-rgb), 0.85) 100%);
  border: none;
  border-radius: 18px;
  padding: 0.9rem 1.5rem;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  transition: var(--transition-smooth);
  box-shadow: 0 6px 20px rgba(var(--active-color-rgb), 0.35);
  user-select: none;
}

.speak-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(var(--active-color-rgb), 0.45);
}

.speak-btn:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(var(--active-color-rgb), 0.25);
}

.speaker-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.speaker-icon {
  transition: transform 0.2s;
}

.speak-btn:hover .speaker-icon {
  transform: scale(1.1);
}

/* Sound playing animated waves */
.wave {
  opacity: 0.4;
  transform-origin: center;
}

.speaking .wave-1 {
  animation: wavePulse 1.2s infinite;
  opacity: 1;
}

.speaking .wave-2 {
  animation: wavePulse 1.2s infinite 0.3s;
  opacity: 1;
}



/* --- Quick Settings Pills --- */
.quick-settings {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.setting-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
}

.setting-pill:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.setting-pill.active {
  background: rgba(var(--active-color-rgb), 0.1);
  border-color: rgba(var(--active-color-rgb), 0.3);
  color: var(--text-primary);
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-muted);
  transition: background-color 0.2s;
}

.setting-pill.active .pill-dot {
  background-color: var(--active-color);
  box-shadow: 0 0 8px var(--active-color);
}

/* --- Settings Bottom Drawer --- */
.settings-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
}

.settings-drawer.open {
  visibility: visible;
  opacity: 1;
}

.drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.drawer-content {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 600px;
  background: var(--bg-surface-solid);
  border-top: 1px solid var(--border-light);
  border-radius: 28px 28px 0 0;
  padding: 1.75rem;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.1, 0.76, 0.55, 0.94);
}

.settings-drawer.open .drawer-content {
  transform: translateX(-50%) translateY(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.drawer-header h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

.close-drawer {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.close-drawer:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-item label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 0.75rem;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  transition: var(--transition-fast);
  cursor: pointer;
}

.form-control:focus {
  border-color: var(--active-color);
  background-color: rgba(255, 255, 255, 0.05);
}

.range-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Custom styled inputs for range sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--active-color);
  box-shadow: 0 0 10px rgba(var(--active-color-rgb), 0.5);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* --- Footer Area --- */
.app-footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.app-footer p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.brand-footer {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.25px;
}

/* --- Keyframe Animations --- */
@keyframes floatSphere {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes wavePulse {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
}

/* Pulsing label for speaking mode */
.animate-pulse.speaking {
  animation: accentPulse 1.8s infinite;
}

@keyframes accentPulse {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(var(--active-color-rgb), 0.35);
  }
  50% {
    box-shadow: 0 6px 28px rgba(var(--active-color-rgb), 0.65);
  }
}

/* --- Responsiveness & Breakpoints --- */

@media (max-width: 480px) {
  .app-container {
    padding: 1rem 0.5rem;
    gap: 1rem;
  }
  
  .brand h1 {
    font-size: 1.55rem;
  }
  
  .level-tab {
    font-size: 0.8rem;
    padding: 0.5rem 0.2rem;
  }
  
  .color-card {
    padding: 1.8rem 1.2rem;
  }
  
  .color-sphere {
    width: 130px;
    height: 130px;
  }
  
  .color-title-en {
    font-size: 2.1rem;
  }
  
  .color-title-es {
    font-size: 1.25rem;
    padding-top: 0.6rem;
  }
  
  .nav-arrow {
    display: none; /* Hide arrows entirely on mobile; rely on swiping */
  }
}

@media (min-width: 481px) {
  /* Provide subtle margins to desktop viewport snaps */
  .carousel-viewport {
    gap: 0px;
  }
}
