/* ============================================
   EduAI — Main Stylesheet
   ============================================ */

:root {
  --clr-primary: #2563eb;
  --clr-primary-dark: #1d4ed8;
  --clr-primary-light: #eff6ff;
  --clr-success: #16a34a;
  --clr-success-light: #f0fdf4;
  --clr-warning: #d97706;
  --clr-warning-light: #fffbeb;
  --clr-danger: #dc2626;
  --clr-danger-light: #fef2f2;
  --clr-text: #1e293b;
  --clr-text-muted: #64748b;
  --clr-border: #e2e8f0;
  --clr-bg: #f8fafc;
  --clr-card: #ffffff;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  font-size: 15px;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }

/* ── HEADER ── */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--clr-border);
  position: sticky; top: 0; z-index: 100;
  padding: .75rem 0;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 1.2rem; font-weight: 700; color: var(--clr-primary); text-decoration: none; display: flex; align-items: center; gap: .4rem; }
.logo span { color: var(--clr-text); }
nav { display: flex; gap: 1.25rem; }
nav a { color: var(--clr-text-muted); text-decoration: none; font-size: 14px; transition: color .15s; }
nav a:hover, nav a.active { color: var(--clr-primary); }

/* ── FOOTER ── */
.site-footer { background: #fff; border-top: 1px solid var(--clr-border); padding: 1.5rem 0; margin-top: 4rem; }
.site-footer p { color: var(--clr-text-muted); font-size: 13px; text-align: center; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.2rem; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1.5px solid transparent; transition: all .15s; text-decoration: none;
}
.btn-primary { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); }
.btn-primary:hover { background: var(--clr-primary-dark); border-color: var(--clr-primary-dark); }
.btn-outline { background: #fff; color: var(--clr-primary); border-color: var(--clr-primary); }
.btn-outline:hover { background: var(--clr-primary-light); }
.btn-sm { padding: .35rem .75rem; font-size: 13px; }
.btn-lg { padding: .75rem 1.75rem; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

/* ── HERO ── */
.hero { text-align: center; padding: 4rem 1rem 3rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; color: var(--clr-text); margin-bottom: .75rem; }
.hero p { font-size: 1.1rem; color: var(--clr-text-muted); margin-bottom: 2rem; max-width: 540px; margin-inline: auto; }
.hero .btn { margin: 0 .4rem; }

/* ── LEVEL GRID ── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin: 0 0 3rem;
}
.level-card {
  background: var(--clr-card); border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-lg); padding: 1.4rem 1rem;
  text-align: center; text-decoration: none; color: var(--clr-text);
  transition: transform .15s, border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: .4rem;
}
.level-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--clr-primary); }
.level-icon { font-size: 2rem; }
.level-card h3 { font-size: 15px; font-weight: 700; }
.level-card p { font-size: 12px; color: var(--clr-text-muted); }
.level-card ul { list-style: none; font-size: 12px; color: var(--clr-text-muted); text-align: left; margin-top: .4rem; }
.level-card ul li::before { content: "✓ "; color: var(--clr-success); }

.level-baby { border-top: 3px solid #f9a8d4; }
.level-nursery { border-top: 3px solid #86efac; }
.level-primary { border-top: 3px solid #93c5fd; }
.level-secondary { border-top: 3px solid #a5b4fc; }
.level-shs { border-top: 3px solid #fcd34d; }
.level-uni { border-top: 3px solid #6ee7b7; }
.level-masters { border-top: 3px solid #c4b5fd; }

/* ── ZONE HEADER ── */
.zone-header { display: flex; align-items: center; gap: 1rem; padding: 2rem 0 1.25rem; }
.zone-emoji { font-size: 2.5rem; }
.zone-header h1 { font-size: 1.8rem; font-weight: 800; }
.zone-subtitle { color: var(--clr-text-muted); font-size: 14px; margin-top: 2px; }

/* ── AGE / TOPIC FILTER PILLS ── */
.age-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 1.25rem; }
.age-pill {
  padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--clr-border);
  background: #fff; font-size: 13px; cursor: pointer; color: var(--clr-text-muted); transition: all .15s;
}
.age-pill.active, .age-pill:hover { border-color: var(--clr-primary); background: var(--clr-primary-light); color: var(--clr-primary); }

/* ── TABS ── */
.zone-tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--clr-border); margin-bottom: 1.25rem; }
.zone-tab {
  padding: .55rem 1rem; font-size: 13px; cursor: pointer;
  border: none; background: none; color: var(--clr-text-muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; transition: all .15s;
}
.zone-tab.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── MISC ── */
.muted-text { color: var(--clr-text-muted); font-size: 13px; }
.badge-success { background: var(--clr-success-light); color: var(--clr-success); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-warning { background: var(--clr-warning-light); color: var(--clr-warning); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-danger { background: var(--clr-danger-light); color: var(--clr-danger); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* ============================================
   GAMIFICATION — XP toast (shared across all pages)
   ============================================ */
.xp-toast {
  background: linear-gradient(135deg,#fbbf24,#f59e0b); color: #78350f; font-weight: 700;
  font-size: 13px; padding: .55rem 1rem; border-radius: 999px; box-shadow: 0 8px 24px rgba(245,158,11,.4);
  animation: xpToastIn .25s ease; pointer-events: none;
}
.xp-toast-out { animation: xpToastOut .35s ease forwards; }
@keyframes xpToastIn { from { opacity:0; transform:translateX(30px) scale(.9);} to { opacity:1; transform:translateX(0) scale(1);} }
@keyframes xpToastOut { to { opacity:0; transform:translateX(30px) scale(.9);} }

/* Progress ring (used on dashboard) */
.progress-ring-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.progress-ring-label { position: absolute; text-align: center; }
.progress-ring-label .pr-num { display: block; font-size: 18px; font-weight: 800; }
.progress-ring-label .pr-sub { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; color: var(--clr-text-muted); }

/* ============================================
   ACCESSIBILITY (WCAG 2.2 AA-oriented)
   Skip link, adjustable text size, high contrast, dyslexia-friendly font.
   Driven by js/a11y.js — preferences persist in localStorage.
   ============================================ */

/* Text size scaling: --a11y-scale is set inline on <html> by a11y.js */
:root { --a11y-scale: 1; }
html { font-size: calc(16px * var(--a11y-scale, 1)); }
body { font-size: calc(15px * var(--a11y-scale, 1)); }

/* Skip-to-content link — invisible until keyboard-focused */
.a11y-skip-link {
  position: absolute; top: -48px; left: 0; z-index: 100000;
  background: var(--clr-primary); color: #fff; padding: .75rem 1.25rem;
  font-weight: 700; font-size: 14px; text-decoration: none;
  border-radius: 0 0 8px 0; transition: top .15s;
}
.a11y-skip-link:focus { top: 0; }

/* Floating toggle button */
.a11y-toggle-btn {
  position: fixed; bottom: 18px; left: 18px; z-index: 99998;
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--clr-primary); color: #fff; font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.a11y-toggle-btn:hover { filter: brightness(1.1); }
.a11y-toggle-btn:focus-visible, .a11y-panel button:focus-visible,
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #f59e0b; outline-offset: 2px;
}

.a11y-panel {
  position: fixed; bottom: 72px; left: 18px; z-index: 99998;
  background: var(--clr-card); border: 1.5px solid var(--clr-border); border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 1rem 1.1rem; width: 240px;
}
.a11y-panel-title { font-size: 14px; font-weight: 800; margin-bottom: .75rem; }
.a11y-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: .7rem; }
.a11y-switch-row input { width: 18px; height: 18px; accent-color: var(--clr-primary); cursor: pointer; }
.a11y-btn-group { display: flex; gap: 4px; }
.a11y-btn-group button {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--clr-border);
  background: var(--clr-bg); cursor: pointer; font-size: 12px; font-weight: 700;
}
.a11y-panel-note { font-size: 10.5px; color: var(--clr-text-muted); margin-top: .25rem; }

/* High contrast theme: pure black/white/yellow-accent, stronger borders */
html[data-contrast="high"] {
  --clr-primary: #0033cc;
  --clr-primary-dark: #001f80;
  --clr-primary-light: #e6ecff;
  --clr-success: #006600;
  --clr-success-light: #e6ffe6;
  --clr-warning: #995c00;
  --clr-warning-light: #fff2e0;
  --clr-danger: #b30000;
  --clr-danger-light: #ffe6e6;
  --clr-text: #000000;
  --clr-text-muted: #333333;
  --clr-border: #000000;
  --clr-bg: #ffffff;
  --clr-card: #ffffff;
}
html[data-contrast="high"] body { background: #fff; }
html[data-contrast="high"] * { text-shadow: none !important; }
html[data-contrast="high"] .card, html[data-contrast="high"] button, html[data-contrast="high"] input,
html[data-contrast="high"] select, html[data-contrast="high"] textarea { border-width: 2px !important; }

/* Dyslexia-friendly mode: no true OpenDyslexic font bundled, so this widens
   letter/word/line spacing and switches to a plainer sans-serif — the
   spacing changes are the part with the most evidence behind them. */
html[data-dyslexia="1"] body {
  font-family: Verdana, Tahoma, Arial, sans-serif;
  letter-spacing: 0.04em;
  word-spacing: 0.12em;
  line-height: 1.9;
}
html[data-dyslexia="1"] p, html[data-dyslexia="1"] li { max-width: 70ch; }

/* Never rely on color alone (WCAG 1.4.1) — correct/wrong quiz options also
   get a prefix icon via content, not just a background/border color. */
.option-btn.correct::before { content: "✓ "; font-weight: 800; }
.option-btn.wrong::before { content: "✗ "; font-weight: 800; }
