/* =============================================
   base.css — CSS variables, resets, layout primitives
   iOS 26 Liquid Glass edition
   ============================================= */

:root {
  --safe-top:    env(safe-area-inset-top,    44px);
  --safe-bottom: env(safe-area-inset-bottom, 34px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);

  /* ---- Liquid Glass material ---- */
  /* iOS 26 uses layered translucency: a tinted base + a bright specular rim */
  --glass-bg:        rgba(255,255,255,0.07);
  --glass-bg-hover:  rgba(255,255,255,0.11);
  --glass-border:    rgba(255,255,255,0.22);
  --glass-shadow:    0 8px 32px rgba(0,0,0,0.45),
                     inset 0 1.5px 0 rgba(255,255,255,0.18),
                     inset 0 -1px 0 rgba(0,0,0,0.15);
  --glass-blur:      blur(28px) saturate(200%);

  /* Specular highlight overlay — the "glint" at the top-left */
  --glass-specular: linear-gradient(
    135deg,
    rgba(255,255,255,0.18) 0%,
    rgba(255,255,255,0.06) 30%,
    transparent 55%
  );

  /* ---- Accent palette ---- */
  --accent1:        #7c6cff;   /* vivid violet */
  --accent2:        #c66eff;   /* bright purple */
  --accent3:        #5fffb0;   /* mint green   */
  --accent-danger:  #ff5e7e;
  --accent-warm:    #ffb85e;
  --accent-gold:    #ffd700;

  /* ---- Typography ---- */
  --text-primary:   rgba(255,255,255,0.96);
  --text-secondary: rgba(255,255,255,0.60);
  --text-tertiary:  rgba(255,255,255,0.35);

  /* ---- Geometry ---- */
  --radius-xl:  36px;
  --radius-lg:  28px;
  --radius-md:  18px;
  --radius-sm:  12px;

  /* ---- Spring physics (cubic-bezier approximations) ---- */
  --spring-bounce:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-snappy:    cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --spring-smooth:    cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Fonts ---- */
  --font-display: 'SF Pro Display', -apple-system, 'Helvetica Neue', sans-serif;
  --font-body:    'SF Pro Text',    -apple-system, 'Helvetica Neue', sans-serif;
  --font-rounded: 'SF Pro Rounded', -apple-system, 'Helvetica Neue', sans-serif;
}

/* ========== RESET ========== */
* {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0612;
  font-family: var(--font-body);
  color: var(--text-primary);
}

#app {
  width: 100%; height: 100%;
  position: relative;
  overflow: hidden;
}

/* ========== ANIMATED DEEP-SPACE BACKGROUND ========== */
.bg-canvas {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 90% 70% at 15% 10%, #1e0850 0%, transparent 55%),
    radial-gradient(ellipse 70% 80% at 85% 90%, #320a6a 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 50% 40%, #0d0420 0%, #120820 100%);
  animation: bgShift 20s ease-in-out infinite alternate;
}
@keyframes bgShift {
  0%   { filter: hue-rotate(0deg)   brightness(1);    }
  50%  { filter: hue-rotate(15deg)  brightness(1.05); }
  100% { filter: hue-rotate(-10deg) brightness(0.97); }
}

/* Noise grain texture — adds depth like iOS materials */
.bg-canvas::after {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.35;
  pointer-events: none;
}

/* Floating ambient orbs */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  animation: orbFloat 12s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
  will-change: transform;
}
.orb1 {
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(124,108,255,0.22), transparent 70%);
  top: -100px; left: -80px;
  animation-duration: 14s; animation-delay: 0s;
}
.orb2 {
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(198,110,255,0.18), transparent 70%);
  bottom: 80px; right: -70px;
  animation-duration: 11s; animation-delay: -4s;
}
.orb3 {
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(95,255,176,0.1), transparent 70%);
  top: 45%; left: 55%;
  animation-duration: 16s; animation-delay: -8s;
}
.orb4 {
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(255,184,94,0.09), transparent 70%);
  top: 30%; left: 10%;
  animation-duration: 18s; animation-delay: -2s;
}

@keyframes orbFloat {
  0%   { transform: translate(0px, 0px)   scale(1); }
  25%  { transform: translate(25px,-35px) scale(1.06); }
  50%  { transform: translate(-18px,22px) scale(0.94); }
  75%  { transform: translate(30px, 10px) scale(1.03); }
  100% { transform: translate(0px, 0px)   scale(1); }
}

/* ========== LIQUID GLASS UTILITY ========== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  position: relative;
}
/* Specular glint pseudo-element */
.glass::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--glass-specular);
  pointer-events: none;
  z-index: 0;
}

/* ========== SCREEN SYSTEM ========== */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  z-index: 1;
  /* Default hidden state: scaled down + blurred in */
  transition:
    opacity          0.42s var(--spring-smooth),
    transform        0.42s var(--spring-smooth),
    filter           0.42s var(--spring-smooth);
  will-change: transform, opacity, filter;
}
.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(48px) scale(0.97);
  filter: blur(4px);
}
.screen.slide-left {
  transform: translateX(-48px) scale(0.97);
  filter: blur(4px);
}

/* ========== SCROLL AREA ========== */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 24px);
  scroll-behavior: smooth;
}

/* ========== STATUS BAR ========== */
.status-bar { height: var(--safe-top); flex-shrink: 0; }

/* ========== NAV BAR ========== */
.nav-bar {
  display: flex;
  align-items: center;
  padding: 8px 20px 12px;
  flex-shrink: 0;
  gap: 12px;
  position: relative;
}
/* Frosted underline on scroll — added by JS */
.nav-bar.scrolled {
  background: rgba(10,6,18,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.nav-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  flex: 1;
  text-align: center;
  transition: opacity 0.2s ease;
}

.nav-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--spring-bounce);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Ripple layer */
.nav-btn::before {
  content: '';
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, transparent 70%);
  opacity: 0; transform: scale(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.nav-btn:active { transform: scale(0.88); background: rgba(255,255,255,0.16); }
.nav-btn:active::before { opacity: 1; transform: scale(1); transition: none; }
.nav-btn.invisible { opacity: 0; pointer-events: none; }

/* ========== SECTION LABEL ========== */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 22px 0 10px;
}

/* ========== EMPTY STATE ========== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-tertiary); }
.empty-state-icon { font-size: 44px; margin-bottom: 10px; }
.empty-state-text { font-size: 15px; }

/* ========== GLASS INPUTS ========== */
.glass-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-body);
  -webkit-user-select: text;
  user-select: text;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  -webkit-appearance: none;
}
.glass-input::placeholder { color: var(--text-tertiary); }
.glass-input:focus {
  border-color: rgba(124,108,255,0.6);
  box-shadow: 0 0 0 3px rgba(124,108,255,0.15), 0 0 20px rgba(124,108,255,0.08);
  background: rgba(255,255,255,0.10);
}

/* ========== CTA BUTTONS ========== */
.btn-start-quiz {
  width: 100%;
  margin-top: 10px;
  border-radius: var(--radius-xl);
  padding: 20px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #7c6cff 0%, #c66eff 100%);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
  box-shadow:
    0 10px 40px rgba(124,108,255,0.45),
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -1px 0 rgba(0,0,0,0.1);
  transition: all 0.22s var(--spring-bounce);
  position: relative;
  overflow: hidden;
}
/* Animated shimmer sweep */
.btn-start-quiz::before {
  content: '';
  position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: skewX(-20deg);
  animation: shimmerSweep 3s ease-in-out infinite;
}
@keyframes shimmerSweep {
  0%   { left: -100%; }
  50%  { left: 160%;  }
  100% { left: 160%;  }
}
.btn-start-quiz:active { transform: scale(0.96); box-shadow: 0 4px 18px rgba(124,108,255,0.3); }

.btn-secondary {
  width: 100%;
  padding: 17px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--spring-bounce);
  margin-bottom: 10px;
}
.btn-secondary:active { transform: scale(0.97); background: rgba(255,255,255,0.12); }

/* ========== MASTERED BADGE ========== */
.mastered-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(95,255,176,0.12);
  border: 1px solid rgba(95,255,176,0.28);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  color: var(--accent3);
  margin-left: 6px;
  vertical-align: middle;
}

/* ========== ENTRANCE ANIMATIONS ========== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.85); }
  70%  { transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in          { animation: fadeUp 0.45s var(--spring-bounce) forwards; }
.animate-pop         { animation: popIn  0.4s  var(--spring-bounce) forwards; }
.delay-1             { animation-delay: 0.06s; opacity: 0; }
.delay-2             { animation-delay: 0.12s; opacity: 0; }
.delay-3             { animation-delay: 0.18s; opacity: 0; }
.delay-4             { animation-delay: 0.24s; opacity: 0; }
.delay-5             { animation-delay: 0.30s; opacity: 0; }

/* ========== STAGGERED LIST ========== */
/* Applied by JS: .stagger-item gets --i set inline */
.stagger-item {
  animation: fadeUp 0.4s var(--spring-bounce) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}

/* ========== HAPTIC PRESS SCALE ========== */
/* Attach to any tappable element via JS for native-feel press */
.pressing { transform: scale(0.95) !important; transition: transform 0.08s ease !important; }
