/* ============================================
   FenceX - Design System Tokens
   Blue primary · Cold purple ambient · Glass surfaces
   ============================================ */

:root {
  /* ---- Spacing scale (8px base) ---- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 80px;

  /* ---- Typography scale ---- */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  /* ---- Font families ---- */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Space Grotesk', 'Inter', sans-serif;

  /* ---- Layout ---- */
  --container-max: 1200px;
  --container-gutter: 40px;

  /* ---- Radii ---- */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 999px;

  /* ---- Timing ---- */
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 350ms;

  /* ---- Primary accent: Blue ---- */
  --color-accent: #3b82f6;
  --color-accent-hover: #60a5fa;
  --color-accent-soft: rgba(59, 130, 246, 0.12);
  --color-accent-strong: rgba(59, 130, 246, 0.25);

  /* ---- Ambient: Cold purple (background haze only) ---- */
  --color-ambient-purple: rgba(99, 60, 180, 0.12);
  --color-ambient-purple-deep: rgba(76, 40, 155, 0.08);
  --color-ambient-blue: rgba(59, 130, 246, 0.10);

  /* ---- Colors (dark default) ---- */
  --color-bg-base: #0a0e17;
  --color-bg-alt: #0f1520;
  --color-surface: rgba(255, 255, 255, 0.04);
  --color-surface-solid: #141c2b;
  --color-text-primary: #e4eaf4;
  --color-text-muted: rgba(228, 234, 244, 0.55);
  --color-border: rgba(255, 255, 255, 0.08);
  --color-shadow: 0 40px 80px rgba(0, 0, 0, 0.5);
  --color-card-glass: rgba(15, 21, 32, 0.85);
  --blur-strength: 22px;
  --carousel-dim-opacity: 0.72;
  --carousel-dim-brightness: 0.85;
  --carousel-dim-saturate: 0.9;

  /* ---- Aurora haze (dark mode) ---- */
  --aurora-gradient: radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59, 130, 246, 0.15), transparent 60%),
                     radial-gradient(ellipse 60% 40% at 85% 10%, var(--color-ambient-purple), transparent 60%),
                     radial-gradient(ellipse 50% 60% at 50% 80%, var(--color-ambient-purple-deep), transparent 50%);

  /* ---- Icon color tokens ---- */
  --icon-color: #e4eaf4;
  --icon-color-muted: rgba(228, 234, 244, 0.6);
  --icon-filter: brightness(0) invert(1);
  --icon-filter-accent: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(190deg);
}

:root[data-theme='light'] {
  --color-bg-base: #f5f7fb;
  --color-bg-alt: #ffffff;
  --color-surface: rgba(12, 26, 43, 0.05);
  --color-surface-solid: #ffffff;
  --color-text-primary: #0f172a;
  --color-text-muted: rgba(15, 23, 42, 0.55);
  --color-border: rgba(15, 23, 42, 0.08);
  --color-accent: #2563eb;
  --color-accent-hover: #3b82f6;
  --color-accent-soft: rgba(37, 99, 235, 0.1);
  --color-accent-strong: rgba(37, 99, 235, 0.18);
  --color-shadow: 0 35px 65px rgba(15, 23, 42, 0.1);
  --color-card-glass: rgba(255, 255, 255, 0.9);
  --blur-strength: 12px;
  --carousel-dim-opacity: 0.9;
  --carousel-dim-brightness: 0.96;
  --carousel-dim-saturate: 0.95;

  /* Ambient purple (light mode - softer) */
  --color-ambient-purple: rgba(140, 100, 220, 0.06);
  --color-ambient-purple-deep: rgba(110, 70, 200, 0.04);
  --color-ambient-blue: rgba(37, 99, 235, 0.06);

  /* Aurora haze (light mode) */
  --aurora-gradient: radial-gradient(ellipse 80% 50% at 20% -10%, rgba(37, 99, 235, 0.08), transparent 60%),
                     radial-gradient(ellipse 60% 40% at 85% 10%, var(--color-ambient-purple), transparent 60%),
                     radial-gradient(ellipse 50% 60% at 50% 80%, var(--color-ambient-purple-deep), transparent 50%);

  /* Icon color tokens */
  --icon-color: #0f172a;
  --icon-color-muted: rgba(15, 23, 42, 0.55);
  --icon-filter: brightness(0);
  --icon-filter-accent: none;
}

html {
  background: var(--color-bg-base);
}

body {
  background: var(--color-bg-base);
  color: var(--color-text-primary);
  transition: background var(--duration-normal) var(--ease-out),
              color var(--duration-normal) var(--ease-out);
}

/* ============================================
   Aurora Ambient Background
   Slow-moving CSS-only haze
   ============================================ */
.fx-aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 520ms var(--ease-out);
}

.fx-aurora.fx-aurora--visible {
  opacity: 1;
}

.fx-aurora::before,
.fx-aurora::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  will-change: transform;
}

.fx-aurora::before {
  width: 600px;
  height: 600px;
  top: -15%;
  left: -5%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, transparent 70%);
  animation: fx-aurora-drift-1 18s ease-in-out infinite alternate;
}

.fx-aurora::after {
  width: 500px;
  height: 500px;
  bottom: -10%;
  right: -5%;
  background: radial-gradient(circle, rgba(99, 60, 180, 0.12) 0%, transparent 70%);
  animation: fx-aurora-drift-2 22s ease-in-out infinite alternate;
}

:root[data-theme='light'] .fx-aurora::before {
  background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, transparent 70%);
  opacity: 0.5;
}

:root[data-theme='light'] .fx-aurora::after {
  background: radial-gradient(circle, rgba(140, 100, 220, 0.06) 0%, transparent 70%);
  opacity: 0.4;
}

@keyframes fx-aurora-drift-1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(24px, 18px) scale(1.01); }
  100% { transform: translate(-18px, 12px) scale(1); }
}

@keyframes fx-aurora-drift-2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-22px, -14px) scale(1.01); }
  100% { transform: translate(18px, -10px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .fx-aurora {
    opacity: 1;
    transition: none;
  }

  .fx-aurora::before,
  .fx-aurora::after {
    animation: none !important;
  }
}

/* ============================================
   Shared Theme Classes
   ============================================ */
.nike-header {
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--color-border);
}

:root[data-theme='light'] .nike-header {
  background: rgba(245, 247, 251, 0.95);
}

.brand-logo,
.nav-link,
.login-btn,
.logout-btn,
.user-greeting-text {
  color: var(--color-text-primary);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-card-glass);
  color: var(--color-text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-out);
}

.theme-toggle:hover {
  background: var(--color-accent-soft);
}

.card-glass {
  background: var(--color-card-glass);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: var(--color-shadow);
  backdrop-filter: blur(var(--blur-strength));
}

.btn-primary,
.btn-secondary,
.btn-cta {
  font-weight: 600;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border: none;
}

.btn-secondary {
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.nike-footer {
  background: var(--color-bg-alt);
  color: var(--color-text-primary);
  border-top: 1px solid var(--color-border);
}

.footer-links a {
  color: var(--color-text-muted);
}

.experience-card,
.training-panel,
.ai-chat,
.training-events-list li {
  border-color: var(--color-border);
}

input,
select,
textarea {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

:root[data-theme='light'] input,
:root[data-theme='light'] select,
:root[data-theme='light'] textarea {
  background: rgba(247, 249, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.1);
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .fx-aurora::before,
  .fx-aurora::after {
    animation: none !important;
  }
}
