/* ==========================================================================
   FAST MATHS - Core Design System & Tokens
   Learn Faster. Calculate Smarter. Score Higher.
   ========================================================================== */

/* Self-hosted Brush Font for Hero Headline (Polo Brush Copr.1993 Richard William Mueller) */
@font-face {
  font-family: 'PoloBrush';
  src: url('../assets/fonts/PoloBrush.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   FAST MATHS - ONLY TWO THEMES: "DARK" AND "LIGHT BLUE"
   WCAG AA Compliant contrast tokens across all components.
   ========================================================================== */

/* Universal Layout & Theme Transitions */
html {
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  height: auto;
  min-height: 100dvh;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}
body {
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  height: auto;
  min-height: 100dvh;
  max-width: 100%;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* 1) LIGHT BLUE THEME (Default on first visit) */
:root,
[data-theme="light-blue"],
[data-theme="light"],
[data-theme="blue"] {
  color-scheme: only light;
  --theme-id: 'light-blue';
  --bg: #EAF4FF;
  --surface: #FFFFFF;
  --surface-2: #DBEAFE;
  --border: #BFDBFE;
  --text: #0B1B33;
  --text-muted: #3F5878;
  --accent: #2563EB;
  --accent-contrast: #FFFFFF;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --on-primary: #FFFFFF;
  --success: #047857;
  --danger: #B91C1C;
  --warning: #B45309;
  --info: #1D4ED8;
  --shadow: 0 4px 14px rgba(11, 27, 51, 0.08);
  --glow: 0 0 16px rgba(37, 99, 235, 0.2);
  --gradient-primary: linear-gradient(135deg, #3B82F6, #2563EB);
  --input-bg: #FFFFFF;
  --input-border: #BFDBFE;
  --key-bg: #FFFFFF;
  --key-text: #0B1B33;
  --timer-bg: linear-gradient(135deg, #1E40AF, #2563EB);
  --timer-text: #FFFFFF;

  --c-purple: #6D28D9;
  --c-purple-strong: #5B21B6;
  --c-blue: #2563EB;
  --c-blue-strong: #1D4ED8;
  --c-green: #047857;
  --c-green-strong: #065F46;
  --c-red: #B91C1C;
  --c-red-strong: #991B1B;
  --c-amber: #B45309;
  --c-amber-strong: #92400E;
  --c-orange: #C2410C;
  --c-orange-strong: #9A3412;
  --c-cyan: #0E7490;
  --c-cyan-strong: #155E75;
  --c-pink: #BE185D;
  --c-pink-strong: #9D174D;
  --c-slate: #3F5878;
  --c-slate-strong: #1E3A8A;

  --bg-primary: var(--bg);
  --bg-secondary: var(--surface);
  --bg-surface: var(--surface);
  --bg-card: var(--surface);
  --bg-card-hover: var(--surface-2);
  --bg-tertiary: var(--surface-2);
  --bg-glass: rgba(255, 255, 255, 0.95);
  --bg-code: var(--surface-2);
  --text-primary: var(--text);
  --text-main: var(--text);
  --text-secondary: var(--text-muted);
  --text-inverse: var(--bg);
  --border-light: var(--border);
  --border-subtle: var(--border);
  --border-focus: var(--accent);
  --brand-primary: var(--primary);
  --brand-primary-hover: var(--primary-hover);
  --brand-gradient: var(--gradient-primary);
  --brand-gradient-hover: var(--gradient-primary);
  --btn-gradient: var(--gradient-primary);
  --shadow-sm: 0 1px 3px rgba(11, 27, 51, 0.06);
  --shadow-md: var(--shadow);
  --shadow-lg: 0 10px 24px rgba(11, 27, 51, 0.12);
  --shadow-xl: 0 18px 32px rgba(11, 27, 51, 0.16);
  --shadow-glow: var(--glow);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-math: 'KaTeX_Math', 'Cambria Math', serif;

  /* Dimensions & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --sidebar-width: 0px;
  --navbar-height: 58px;
  --navbar-h: 58px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 2) SOFT DARK (SLATE-BLUE) THEME TOKENS DEFINED IN css/dark-tokens.css
   Kept free of duplicated raw hex tokens; css/dark-tokens.css sets html.dark / [data-theme="dark"]. */
.brand-logo-3d-wrapper .official-brand-logo {
  transition: filter 300ms ease;
}
html.dark .logo-variant-light,
[data-theme="dark"] .logo-variant-light { display: none !important; }
html.dark .logo-variant-dark,
[data-theme="dark"] .logo-variant-dark { display: block !important; }
html.dark .brand-logo-3d-wrapper .official-brand-logo,
[data-theme="dark"] .brand-logo-3d-wrapper .official-brand-logo {
  filter: var(--logo-glow-soft, drop-shadow(0 0 8px rgba(255, 201, 20, 0.28)));
  animation: none;
}

:root:not(.dark):not([data-theme="dark"]) .logo-variant-dark,
[data-theme="light-blue"] .logo-variant-dark,
[data-theme="light"] .logo-variant-dark { display: none !important; }
:root:not(.dark):not([data-theme="dark"]) .logo-variant-light,
[data-theme="light-blue"] .logo-variant-light,
[data-theme="light"] .logo-variant-light { display: block !important; }
[data-theme="light-blue"] .brand-logo-3d-wrapper .official-brand-logo,
[data-theme="light"] .brand-logo-3d-wrapper .official-brand-logo {
  filter: drop-shadow(0 0 6px rgba(245, 179, 1, 0.3)) drop-shadow(0 2px 8px rgba(11, 27, 51, 0.08));
  animation: logoGoldenGlowLight 4s ease-in-out infinite alternate;
}

@keyframes logoGoldenGlowDark {
  0% {
    filter: drop-shadow(0 0 8px rgba(245, 179, 1, 0.38)) drop-shadow(0 0 18px rgba(255, 215, 0, 0.22));
  }
  100% {
    filter: drop-shadow(0 0 14px rgba(245, 179, 1, 0.6)) drop-shadow(0 0 28px rgba(255, 215, 0, 0.38));
  }
}

@keyframes logoGoldenGlowLight {
  0% {
    filter: drop-shadow(0 0 5px rgba(245, 179, 1, 0.25)) drop-shadow(0 2px 6px rgba(11, 27, 51, 0.08));
  }
  100% {
    filter: drop-shadow(0 0 10px rgba(245, 179, 1, 0.45)) drop-shadow(0 2px 10px rgba(11, 27, 51, 0.12));
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-logo-3d-wrapper .official-brand-logo {
    animation: none !important;
  }
  html, body, * {
    transition-duration: 0.01ms !important;
  }
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  height: auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  background-color: var(--bg-primary);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Typography styles */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }

p {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-primary-hover);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Layout Architecture - Clean Full Width without Vertical Sidebar */
#sidebar-container,
.sidebar,
.sidebar-backdrop {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  position: absolute !important;
}

.app-container {
  display: block !important;
  width: 100% !important;
  min-height: 100vh;
  position: relative;
  background-color: var(--bg-primary);
}

.main-wrapper {
  display: block !important;
  width: 100% !important;
  margin-left: 0 !important;
  min-width: 0;
}

.main-content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  box-sizing: border-box;
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}


/* ==========================================================================
   FAST MATHS - Accessibility, Glassmorphism & Print Tokens
   ========================================================================== */

/* Glassmorphism Card System */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Tabular Numerals for Timers, Counters and Calculations */
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* WCAG AA Visible Focus Ring */
:focus-visible {
  outline: 2px solid var(--brand-primary) !important;
  outline-offset: 2px !important;
}

/* Accessible Reduced Motion Support & Low-Power Toggle */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
body.no-animations *, body.no-animations *::before, body.no-animations *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Clean Print Stylesheet for Official Reports */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .navbar, .sidebar, .jumbo-navigation-bar, .ctrl-btn, 
  .practice-keypad-container, .results-actions-bar,
  #achievement-toast-container, .setup-modal-overlay {
    display: none !important;
  }
  .app-container {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }
  .main-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  .results-hero-card, .review-table-card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
}
