/* ============================================================
   Revision Science , Design System
   Palette: ink navy / cool paper / electric indigo / mint-teal / coral
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700;800;900&family=Atkinson+Hyperlegible:wght@400;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  /* Core palette */
  --ink: #101A2C;
  --ink-soft: #1C2942;
  --paper: #f7f6f2;
  --paper-2: #EEF1F8;
  --line: #e3e0d7;

  --indigo: #3f9d6b;
  --indigo-dark: #348a5c;
  --indigo-tint: rgba(63,157,107,.12);
  --mint: #3f9d6b;
  --mint-tint: rgba(63,157,107,.12);
  --coral: #e8973e;
  --coral-tint: rgba(232,151,62,.14);
  --brand-green: #8FD957;

  --bio: #3f9d6b;    /* biology  = mint  */
  --chem: #7c6cc4;   /* chemistry = indigo */
  --phys: #4a86c9;   /* physics = coral */

  --txt: #2b2f36;
  --txt-muted: #5f6670;
  --txt-faint: #8b93a0;

  /* surfaces (light) */
  --bg: var(--paper);
  --surface: #fdfdfb;
  --surface-2: #f1efe9;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 28px;
  --shadow-sm: 0 1px 2px rgba(16,26,44,.06), 0 2px 8px rgba(16,26,44,.04);
  --shadow: 0 4px 12px rgba(16,26,44,.08), 0 12px 32px rgba(16,26,44,.06);
  --shadow-lg: 0 12px 28px rgba(16,26,44,.12), 0 32px 64px rgba(16,26,44,.10);

  --display: 'Lexend', system-ui, sans-serif;
  --body: 'Lexend', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;

  --ease: cubic-bezier(.22,.61,.36,1);
}

/* dark mode */
[data-theme="dark"] {
  --bg: #0B1220;
  --surface: #141E33;
  --surface-2: #101a2c;
  --line: #263248;
  --txt: #EAF0FB;
  --txt-muted: #9BA9C7;
  --txt-faint: #6C7B9C;
  --indigo-tint: #23244a;
  --mint-tint: #10352c;
  --coral-tint: #3a271c;
  --paper-2: #101a2c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 6px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.5);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--txt);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .4s var(--ease), color .3s var(--ease);
  overflow-x: hidden;
}

h1,h2,h3,h4 { font-family: var(--display); font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.wrap-sm { max-width: 720px; margin: 0 auto; padding: 0 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; border-radius: 100px; border: none;
  font-weight: 600; font-size: 15px; font-family: var(--display);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--indigo); color: #fff; box-shadow: 0 6px 18px rgba(91,75,232,.32); }
.btn-primary:hover { background: var(--indigo-dark); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(91,75,232,.42); }
.btn-ghost { background: transparent; color: var(--txt); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--indigo); color: var(--indigo); transform: translateY(-2px); }
.btn-mint { background: var(--mint); color: #06231b; box-shadow: 0 6px 18px rgba(45,212,167,.32); }
.btn-mint:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(45,212,167,.42); }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 16px 30px; font-size: 17px; }
.btn-sm { padding: 9px 16px; font-size: 13.5px; }

/* ---------- Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -.02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand-green);
  display: grid; place-items: center; color: #0e2408; flex-shrink: 0;
  font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1;
  box-shadow: 0 3px 10px rgba(120,200,80,.4);
}
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a { padding: 8px 14px; border-radius: 10px; font-weight: 500; font-size: 14.5px; color: var(--txt-muted); transition: .2s; }
.nav-links a:hover { color: var(--txt); background: var(--paper-2); }
.nav-links a.active { color: var(--indigo); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm); transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.eyebrow {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--indigo); font-weight: 700;
}
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 100px; font-size: 12.5px; font-weight: 600;
  font-family: var(--display);
}
.badge-mint { background: var(--mint-tint); color: #0c6b52; }
.badge-indigo { background: var(--indigo-tint); color: var(--indigo-dark); }
.badge-coral { background: var(--coral-tint); color: #b8460f; }
[data-theme="dark"] .badge-mint { color: var(--mint); }
[data-theme="dark"] .badge-indigo { color: #b3a9f5; }
[data-theme="dark"] .badge-coral { color: var(--coral); }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 7px; font-family: var(--display); }
.input, select.input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface-2); color: var(--txt);
  font-family: var(--body); font-size: 15px; transition: .2s;
}
.input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(91,75,232,.14); }
.input::placeholder { color: var(--txt-faint); }

/* ---------- Utility ---------- */
.grid { display: grid; gap: 22px; }
.g-2 { grid-template-columns: repeat(2,1fr); }
.g-3 { grid-template-columns: repeat(3,1fr); }
.g-4 { grid-template-columns: repeat(4,1fr); }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-s { gap: 10px; } .gap-m { gap: 18px; }
.muted { color: var(--txt-muted); }
.mono { font-family: var(--mono); }
.tac { text-align: center; }
.mt-s{margin-top:8px}.mt-m{margin-top:18px}.mt-l{margin-top:36px}
.mb-s{margin-bottom:8px}.mb-m{margin-bottom:18px}.mb-l{margin-bottom:36px}
.hide { display: none !important; }

/* Progress bar */
.bar { height: 9px; border-radius: 100px; background: var(--paper-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 100px; background: var(--indigo);
  width: 0; transition: width 1.1s var(--ease); }
.bar.mint > span { background: var(--mint); }
.bar.coral > span { background: var(--coral); }

/* Ring / donut */
.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring .track { stroke: var(--paper-2); }
.ring .fill { stroke: var(--indigo); transition: stroke-dashoffset 1.2s var(--ease); }

/* Pill tabs */
.tabs { display: inline-flex; background: var(--paper-2); padding: 5px; border-radius: 100px; gap: 4px; }
.tabs button {
  padding: 8px 18px; border-radius: 100px; border: none; background: transparent;
  font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--txt-muted); transition: .2s;
}
.tabs button.active { background: var(--surface); color: var(--indigo); box-shadow: var(--shadow-sm); }

/* Stat */
.stat-num { font-family: var(--display); font-weight: 700; font-size: 40px; letter-spacing: -.03em; line-height: 1; }
.stat-lbl { font-size: 13.5px; color: var(--txt-muted); margin-top: 6px; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-family: var(--display); font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--txt-faint); padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 14px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.tbl tr:hover td { background: var(--surface-2); }

/* dot */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-mint{background:var(--mint)} .dot-coral{background:var(--coral)} .dot-indigo{background:var(--indigo)}
.dot-grey{background:var(--txt-faint)}

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0%{transform:scale(.8);opacity:0} 60%{transform:scale(1.05)} 100%{transform:scale(1);opacity:1} }
@keyframes flicker { 0%,100%{transform:scale(1) rotate(-2deg);opacity:1} 50%{transform:scale(1.08) rotate(2deg);opacity:.85} }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave { 0%,100%{transform:scaleY(.4)} 50%{transform:scaleY(1)} }
@keyframes grow-in { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.reveal { opacity: 0; }
.reveal.in { animation: rise .7s var(--ease) forwards; }
.reveal.d1 { animation-delay: .08s; } .reveal.d2 { animation-delay: .16s; }
.reveal.d3 { animation-delay: .24s; } .reveal.d4 { animation-delay: .32s; }
.reveal.d5 { animation-delay: .40s; } .reveal.d6 { animation-delay: .48s; }

.flame { display: inline-block; animation: flicker 1.6s ease-in-out infinite; }
.float { animation: float 6s ease-in-out infinite; }

/* Sound-wave hero motif */
.wave { display: flex; align-items: flex-end; gap: 4px; height: 44px; }
.wave i { width: 5px; background: var(--indigo); border-radius: 4px; height: 100%;
  transform-origin: bottom; animation: wave 1.1s ease-in-out infinite; }
.wave i:nth-child(2n){ background: var(--mint); } .wave i:nth-child(3n){ background: var(--coral); }

.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------- Auth split layout ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { background: linear-gradient(150deg, var(--ink), var(--ink-soft));
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside::after { content:''; position:absolute; width:420px; height:420px; border-radius:50%;
  background: radial-gradient(circle, rgba(91,75,232,.5), transparent 70%); bottom:-140px; right:-120px; filter: blur(20px); }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 420px; }

/* ---------- App shell (dashboards) ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 22px 16px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 22px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  color: var(--txt-muted); font-weight: 500; font-size: 14.5px; transition: .18s; }
.side-nav a:hover { background: var(--paper-2); color: var(--txt); }
.side-nav a.active { background: var(--indigo-tint); color: var(--indigo-dark); font-weight: 600; }
[data-theme="dark"] .side-nav a.active { color: #c4bcf9; }
.side-nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.main { padding: 30px 36px 60px; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg,var(--indigo),var(--mint));
  color: #fff; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 15px; }

.theme-toggle { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; color: var(--txt-muted); transition: .2s; }
.theme-toggle:hover { color: var(--indigo); border-color: var(--indigo); }

/* Chips */
.chip { display:inline-flex; align-items:center; gap:6px; padding: 6px 12px; border-radius: 100px;
  background: var(--paper-2); font-size: 13px; font-weight: 600; font-family: var(--display); }

/* Quiz specific */
.answer { display: block; width: 100%; text-align: left; padding: 16px 18px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: var(--surface); font-size: 15.5px; font-weight: 500;
  margin-bottom: 12px; transition: .18s; color: var(--txt); }
.answer:hover:not(:disabled) { border-color: var(--indigo); transform: translateX(4px); }
.answer.correct { border-color: var(--mint); background: var(--mint-tint); }
.answer.wrong { border-color: #ef5b5b; background: #fdecec; }
[data-theme="dark"] .answer.wrong { background: #3a1e1e; }
.answer:disabled { cursor: default; }

/* toast */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 14px 24px; border-radius: 100px; font-weight: 600;
  font-family: var(--display); box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: .3s var(--ease); z-index: 999; font-size: 14.5px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* footer */
.footer { border-top: 1px solid var(--line); padding: 40px 0; margin-top: 80px; color: var(--txt-muted); font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .g-4 { grid-template-columns: repeat(2,1fr); }
  .g-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; z-index: 60; transition: left .3s var(--ease); box-shadow: var(--shadow-lg); }
  .side.open { left: 0; }
  .main { padding: 20px; }
  .nav-links { display: none; }
  .nav-links.open { display: flex; position: absolute; top: 68px; left: 0; right: 0; flex-direction: column;
    background: var(--surface); padding: 16px; border-bottom: 1px solid var(--line); }
  .menu-btn { display: grid !important; }
}
@media (max-width: 620px) {
  .g-2, .g-4 { grid-template-columns: 1fr; }
  .stat-num { font-size: 32px; }
  h1 { font-size: 34px !important; }
}
.menu-btn { display: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); place-items: center; color: var(--txt); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; }
}

/* focus visible */
:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   ACCESSIBILITY ENGINE , dyslexia, low-vision, motor, focus
   Toggled via data-attributes on <html>, persisted in storage.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700&display=swap');

/* Dyslexia-friendly font: Lexend is proven to improve reading fluency */
html[data-font="dyslexic"] body,
html[data-font="dyslexic"] .btn,
html[data-font="dyslexic"] h1,
html[data-font="dyslexic"] h2,
html[data-font="dyslexic"] h3,
html[data-font="dyslexic"] h4,
html[data-font="dyslexic"] .input {
  font-family: 'Lexend', system-ui, sans-serif !important;
  letter-spacing: .02em; word-spacing: .08em; line-height: 1.8;
}

/* Text size scaling */
html[data-textsize="large"]   { font-size: 112.5%; }
html[data-textsize="xlarge"]  { font-size: 128%; }

/* High contrast */
html[data-contrast="high"] {
  --txt: #000; --txt-muted: #1a1a1a; --bg: #fff; --surface: #fff;
  --line: #000; --indigo: #0000CC; --mint: #007A5A; --coral: #C24A00;
}
html[data-contrast="high"][data-theme="dark"] {
  --txt: #fff; --txt-muted: #eee; --bg: #000; --surface: #0a0a0a;
  --line: #fff; --indigo: #A9A0FF; --mint: #4FE6BE; --coral: #FFB08A;
}
html[data-contrast="high"] .card,
html[data-contrast="high"] .answer,
html[data-contrast="high"] .input { border-width: 2px; }

/* Reading-friendly line length + weight */
html[data-readable="on"] p { max-width: 62ch; line-height: 1.9; }
html[data-readable="on"] .muted { color: var(--txt) !important; opacity: .85; }

/* Colour overlay / tint (Irlen-style) */
.overlay-tint { position: fixed; inset: 0; pointer-events: none; z-index: 9998; mix-blend-mode: multiply; display: none; }
html[data-overlay="cream"]  .overlay-tint { display:block; background:#fff4d6; opacity:.28; }
html[data-overlay="blue"]   .overlay-tint { display:block; background:#bfe3ff; opacity:.30; }
html[data-overlay="green"]  .overlay-tint { display:block; background:#c8f0d8; opacity:.30; }
html[data-overlay="pink"]   .overlay-tint { display:block; background:#ffd6ec; opacity:.28; }

/* Manual reduce-motion toggle */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after {
  animation-duration:.001ms !important; transition-duration:.001ms !important;
}

/* Read-aloud highlight */
.speaking { background: #fff2a8 !important; border-radius: 6px; box-shadow: 0 0 0 4px #fff2a8; }
[data-theme="dark"] .speaking { background: #6b5e1a !important; box-shadow: 0 0 0 4px #6b5e1a; color:#fff; }

/* Floating accessibility button */
.a11y-fab { position: fixed; right: 20px; bottom: 20px; z-index: 9990;
  width: 56px; height: 56px; border-radius: 50%; border: none; font-size: 26px;
  background: var(--indigo); color: #fff; box-shadow: var(--shadow-lg); display: grid; place-items: center;
  transition: transform .2s var(--ease); }
.a11y-fab:hover { transform: scale(1.08) rotate(8deg); }
.a11y-panel { position: fixed; right: 20px; bottom: 88px; z-index: 9991; width: 320px; max-width: calc(100vw - 40px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 20px; transform: translateY(16px) scale(.96); opacity: 0; pointer-events: none; transition: .22s var(--ease); }
.a11y-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.a11y-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.a11y-row:last-child { border-bottom: none; }
.a11y-row .opts { display: flex; gap: 5px; flex-wrap: wrap; }
.a11y-opt { padding: 5px 10px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface-2);
  font-size: 12.5px; font-weight: 600; font-family: var(--display); cursor: pointer; color: var(--txt); }
.a11y-opt.on { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.speak-btn { display:inline-flex; align-items:center; gap:6px; padding:7px 12px; border-radius:100px;
  border:1.5px solid var(--line); background:var(--surface); font-size:13px; font-weight:600; color:var(--txt);
  font-family:var(--display); cursor:pointer; }
.speak-btn:hover { border-color: var(--indigo); color: var(--indigo); }

/* Flashcard flip */
.flashcard { perspective: 1200px; cursor: pointer; height: 200px; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform .6s var(--ease); transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius);
  display: grid; place-items: center; padding: 24px; text-align: center; }
.flashcard-front { background: var(--surface); border: 2px solid var(--line); }
.flashcard-back { background: var(--indigo); color: #fff; transform: rotateY(180deg); }

@keyframes shine{to{background-position:200% center}}
@media (prefers-reduced-motion:reduce){[style*="animation:shine"]{animation:none !important}}

/* ===== Match StudyBeats front page (friendly light) ===== */
body{background:linear-gradient(180deg,#f7f6f2,#f2f0ea) fixed;}
