/* =========================================================================
   EastMath — Design System
   A clean, modern, international math-learning site.
   Brand metaphor: East = sunrise = the dawn of understanding.
   No build step. Pure CSS. Deployable anywhere.
   ========================================================================= */

/* ----------  Design tokens  ---------- */
:root {
  /* surfaces */
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-muted: #f1f5f9;
  --surface: #ffffff;

  /* ink */
  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-muted: #64748b;
  --ink-faint: #94a3b8;
  --line: #e6e9f0;

  /* brand — indigo */
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-700: #3730a3;
  --brand-soft: #eef2ff;

  /* sunrise / dawn accents */
  --dawn-amber: #f59e0b;
  --dawn-coral: #fb7185;
  --dawn-violet: #a855f7;

  /* night base (used in dark sections) */
  --night: #0a1230;
  --night-2: #111a40;
  --night-line: rgba(255, 255, 255, 0.10);

  /* gradients */
  --grad-dawn: linear-gradient(100deg, #f59e0b 0%, #fb7185 48%, #a855f7 100%);
  --grad-brand: linear-gradient(120deg, #6366f1 0%, #4f46e5 100%);

  /* shape */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-pill: 999px;

  /* shadow */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow: 0 14px 34px -14px rgba(15, 23, 42, 0.22);
  --shadow-lg: 0 36px 70px -22px rgba(15, 23, 42, 0.35);
  --ring: 0 0 0 4px rgba(79, 70, 229, 0.16);

  /* layout */
  --maxw: 1160px;
  --gutter: clamp(18px, 4vw, 40px);

  /* type */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

/* ----------  Reset / base  ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 17px;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }

/* ----------  Layout helpers  ---------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(56px, 9vw, 112px); }
.section--tight { padding-block: clamp(40px, 6vw, 72px); }
.center { text-align: center; }
.measure { max-width: 60ch; }
.mx-auto { margin-inline: auto; }
.stack > * + * { margin-top: 1rem; }

/* ----------  Typography  ---------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5em;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--brand-600);
}
.eyebrow::before {
  content: ""; width: 22px; height: 2px; border-radius: 2px;
  background: var(--grad-dawn);
}
.eyebrow.is-light { color: #fcd9a6; }
.eyebrow.is-light::before { background: var(--grad-dawn); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.08; letter-spacing: -0.02em; color: var(--ink); }
.h-display { font-size: clamp(2.6rem, 6vw, 4.3rem); }
h1 { font-size: clamp(2.2rem, 4.6vw, 3.3rem); }
h2 { font-size: clamp(1.9rem, 3.6vw, 2.7rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.4rem); font-weight: 600; }
.lead { font-size: clamp(1.08rem, 1.6vw, 1.28rem); color: var(--ink-soft); line-height: 1.6; }
.muted { color: var(--ink-muted); }
.grad-text {
  background: var(--grad-dawn);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ----------  Buttons  ---------- */
.btn {
  --_bg: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55em;
  padding: 0.82em 1.35em; border: 1px solid transparent; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 0.98rem; letter-spacing: -0.01em;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.btn svg { width: 1.05em; height: 1.05em; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 10px 22px -10px rgba(79, 70, 229, 0.7); }
.btn-primary:hover { background: var(--brand-600); transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(79, 70, 229, 0.75); }
.btn-dawn { background: var(--grad-dawn); color: #311; font-weight: 700; box-shadow: 0 12px 26px -10px rgba(251, 113, 133, 0.6); }
.btn-dawn:hover { transform: translateY(-1px); filter: saturate(1.06) brightness(1.03); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-xs); }
.btn-ghost:hover { border-color: #cdd3e0; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-light { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.22); backdrop-filter: blur(4px); }
.btn-light:hover { background: rgba(255,255,255,0.18); }
.btn-lg { padding: 1.02em 1.7em; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ----------  Pills / badges  ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 0.45em;
  padding: 0.34em 0.85em; border-radius: var(--radius-pill);
  font-size: 0.8rem; font-weight: 600; background: var(--brand-soft); color: var(--brand-700);
}
.pill--soon { background: #fff7ed; color: #b45309; }
.pill--free { background: #ecfdf5; color: #047857; }
.pill--pro { background: linear-gradient(120deg, #fde68a, #fbcfe8); color: #7c2d12; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ===================================================================
   Header / Navigation
   =================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.site-header.is-scrolled { border-color: var(--line); box-shadow: var(--shadow-xs); }
.nav { display: flex; align-items: center; gap: 1.5rem; height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.18rem; letter-spacing: -0.02em; }
.brand .logo { width: 34px; height: 34px; flex: none; }
.brand b { color: var(--brand); font-weight: 800; }
.brand span { font-family: var(--font-display); }

.nav-links { display: flex; align-items: center; gap: 0.35rem; margin-left: auto; }
.nav-links > a {
  padding: 0.5rem 0.85rem; border-radius: var(--radius-xs); font-weight: 500; font-size: 0.96rem;
  color: var(--ink-soft); transition: color 0.15s ease, background 0.15s ease;
}
.nav-links > a:hover { color: var(--ink); background: var(--bg-muted); }
.nav-links > a.active { color: var(--brand-700); font-weight: 600; }
.nav-cta { margin-left: 0.4rem; }

/* language switcher */
.lang { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.5rem 0.7rem; border-radius: var(--radius-xs);
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  font-weight: 600; font-size: 0.9rem;
}
.lang-btn:hover { background: var(--bg-muted); }
.lang-btn svg { width: 0.9em; height: 0.9em; transition: transform 0.2s ease; }
.lang[data-open="true"] .lang-btn svg { transform: rotate(180deg); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 6px; opacity: 0; visibility: hidden;
  transform: translateY(-6px); transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}
.lang[data-open="true"] .lang-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.lang-menu li { list-style: none; }
.lang-menu button, .lang-menu a {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.5rem 0.7rem; border-radius: var(--radius-xs); background: transparent; border: 0;
  font-size: 0.92rem; color: var(--ink); text-align: left;
}
.lang-menu button:not(:disabled):hover { background: var(--bg-muted); }
.lang-menu button.active { color: var(--brand-700); font-weight: 700; }
.lang-menu button:disabled { color: var(--ink-faint); cursor: not-allowed; }
.lang-menu .tag { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #b45309; background: #fff7ed; padding: 2px 7px; border-radius: 999px; }

/* mobile toggle */
.nav-toggle { display: none; width: 42px; height: 42px; border-radius: var(--radius-xs); border: 1px solid var(--line); background: var(--surface); align-items: center; justify-content: center; }
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after { content: ""; display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; position: relative; transition: transform 0.2s ease, opacity 0.2s ease; }
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after { position: absolute; top: 6px; }
body.nav-open .nav-toggle span { background: transparent; }
body.nav-open .nav-toggle span::before { transform: translateY(6px) rotate(45deg); }
body.nav-open .nav-toggle span::after { transform: translateY(-6px) rotate(-45deg); }

/* ===================================================================
   Hero
   =================================================================== */
.hero { position: relative; overflow: hidden; background: var(--night); color: #eef1ff; isolation: isolate; }
.hero__sky {
  position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(120% 90% at 50% 118%, rgba(251,113,133,0.55) 0%, rgba(245,158,11,0.42) 22%, rgba(168,85,247,0.20) 46%, rgba(10,18,48,0) 68%),
    linear-gradient(180deg, #0a1230 0%, #0e1740 55%, #15214f 100%);
}
.hero__grid {
  position: absolute; inset: 0; z-index: -1; opacity: 0.5;
  background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(120% 80% at 50% 110%, #000 35%, transparent 75%);
  mask-image: radial-gradient(120% 80% at 50% 110%, #000 35%, transparent 75%);
}
.hero__sun {
  position: absolute; left: 50%; bottom: -42%; transform: translateX(-50%);
  width: min(760px, 96vw); aspect-ratio: 1; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle at 50% 50%, rgba(255,224,178,0.9) 0%, rgba(251,146,60,0.55) 30%, rgba(251,113,133,0.18) 55%, transparent 70%);
  filter: blur(2px);
}
.hero .container { position: relative; padding-block: clamp(72px, 12vw, 128px); }
.hero__inner { max-width: 760px; }
.hero h1 { color: #fff; }
.hero h1 .grad-text { filter: drop-shadow(0 4px 24px rgba(251,113,133,0.25)); }
.hero .lead { color: #c7cdf0; margin-top: 1.3rem; max-width: 54ch; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 2rem; }
.hero__chip { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.4em 0.9em; border-radius: 999px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); font-size: 0.85rem; color: #dfe4ff; }
.hero__meta { display: flex; flex-wrap: wrap; gap: 1.4rem 2.2rem; margin-top: 2.6rem; }
.hero__meta .num { font-family: var(--font-display); font-size: 1.7rem; color: #fff; line-height: 1; }
.hero__meta .lbl { font-size: 0.82rem; color: #aab2e0; margin-top: 0.3rem; }
.hero__wave { position: absolute; left: 0; right: 0; bottom: -1px; z-index: -1; line-height: 0; }
.hero__wave svg { width: 100%; height: auto; }

/* ===================================================================
   Generic sections / cards
   =================================================================== */
.section-head { max-width: 64ch; }
.section-head.center { margin-inline: auto; }
.section-head .lead { margin-top: 0.9rem; }

.grid { display: grid; gap: clamp(16px, 2.4vw, 26px); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(20px, 2.4vw, 30px); box-shadow: var(--shadow-xs);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #d8def0; }
.card__icon {
  width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 1.1rem;
}
.card__icon svg { width: 26px; height: 26px; }
.card__icon.dawn { background: linear-gradient(135deg, #fff4e0, #ffe1e8); color: #ea580c; }
.card h3 { margin-bottom: 0.4rem; }
.card p { color: var(--ink-muted); font-size: 0.98rem; }

/* ===================================================================
   Learning path / curriculum roadmap
   =================================================================== */
.path { position: relative; }
.path__line { position: absolute; left: 27px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--dawn-amber), var(--dawn-coral), var(--dawn-violet), var(--brand)); border-radius: 2px; opacity: 0.5; }
.stage { position: relative; padding-left: 74px; padding-block: 14px; }
.stage__num {
  position: absolute; left: 0; top: 12px; width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; font-family: var(--font-display); font-size: 1.3rem; font-weight: 600;
  color: #fff; background: var(--grad-brand); box-shadow: var(--shadow-sm); z-index: 1;
}
.stage:nth-child(2) .stage__num { background: linear-gradient(135deg, #fbbf24, #f97316); }
.stage:nth-child(3) .stage__num { background: linear-gradient(135deg, #fb7185, #ec4899); }
.stage:nth-child(4) .stage__num { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.stage__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem 1rem; }
.stage__level { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.stage h3 { font-size: 1.35rem; }
.stage p { color: var(--ink-muted); margin-top: 0.25rem; max-width: 58ch; }
.modules { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.module {
  display: inline-flex; align-items: center; gap: 0.45em;
  padding: 0.45em 0.85em; border-radius: var(--radius-pill);
  background: var(--bg-soft); border: 1px solid var(--line); font-size: 0.88rem; font-weight: 500; color: var(--ink-soft);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.module:hover { background: #fff; border-color: var(--brand); color: var(--brand-700); transform: translateY(-1px); }
.module .module__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dawn-coral); }

/* ===================================================================
   Stats band
   =================================================================== */
.band { background: var(--bg-soft); border-block: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; text-align: center; }
.stat .num { font-family: var(--font-display); font-size: clamp(2rem, 4vw, 2.9rem); color: var(--ink); line-height: 1; }
.stat .num .grad-text { font-family: var(--font-display); }
.stat .lbl { color: var(--ink-muted); font-size: 0.92rem; margin-top: 0.5rem; }

/* ===================================================================
   CTA band (dark)
   =================================================================== */
.cta-band { position: relative; overflow: hidden; background: var(--night); color: #fff; border-radius: clamp(20px, 3vw, 30px); padding: clamp(36px, 6vw, 64px); isolation: isolate; }
.cta-band::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(90% 130% at 85% -10%, rgba(251,113,133,0.5), transparent 55%), radial-gradient(80% 120% at 5% 120%, rgba(99,102,241,0.5), transparent 55%); }
.cta-band h2 { color: #fff; }
.cta-band .lead { color: #c9cff2; }
.cta-band__row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1.8rem; }

/* ===================================================================
   Footer
   =================================================================== */
.site-footer { background: #0b1020; color: #aeb6d6; padding-block: clamp(48px, 6vw, 72px) 32px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 2rem; }
.site-footer .brand { color: #fff; }
.site-footer .brand b { color: #c7b3ff; }
.footer-about { color: #8b93b8; font-size: 0.95rem; margin-top: 1rem; max-width: 34ch; }
.footer-col h4 { font-family: var(--font-sans); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: #6b739a; font-weight: 700; margin-bottom: 1rem; }
.footer-col a { display: block; padding: 0.32rem 0; color: #aeb6d6; font-size: 0.95rem; transition: color 0.15s ease; }
.footer-col a:hover { color: #fff; }
.footer-col .tag { font-size: 0.64rem; color: #b45309; background: #2a2110; padding: 1px 6px; border-radius: 999px; margin-left: 6px; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.88rem; color: #6b739a; }

/* ===================================================================
   Article / lesson typography
   =================================================================== */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--ink-muted); }
.breadcrumb a:hover { color: var(--brand-700); }
.breadcrumb .sep { color: var(--ink-faint); }

.lesson-hero { background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }

.prose { max-width: 72ch; }
.prose > * + * { margin-top: 1.15rem; }
.prose h2 { margin-top: 2.6rem; }
.prose h3 { margin-top: 1.8rem; font-size: 1.2rem; }
.prose p, .prose li { color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: 0.4rem; }
.prose a { color: var(--brand-700); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(79,70,229,0.35); }
.prose a:hover { text-decoration-color: var(--brand); }

.callout { display: flex; gap: 0.9rem; padding: 1.1rem 1.3rem; border-radius: var(--radius-sm); background: var(--brand-soft); border: 1px solid #dfe2fb; }
.callout .ico { flex: none; width: 26px; height: 26px; color: var(--brand); }
.callout--tip { background: #fff7ed; border-color: #fde4c8; }
.callout--tip .ico { color: #ea580c; }
.callout p { margin: 0; color: var(--ink-soft); font-size: 0.97rem; }
.callout strong { display: block; margin-bottom: 0.15rem; color: var(--ink); }

.example { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-xs); }
.example__head { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1.2rem; background: var(--bg-soft); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 0.92rem; }
.example__head .tag { font-size: 0.7rem; color: var(--brand-700); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; }
.example__body { padding: 1.2rem; }
.example__body p { margin-top: 0; }
.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps li { position: relative; padding-left: 2.2rem; min-height: 1.6rem; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--brand); color: #fff; font-size: 0.78rem; font-weight: 700; display: grid; place-items: center; font-family: var(--font-sans); }

.math-display { overflow-x: auto; padding: 0.6rem 0; }

/* practice */
.practice { display: grid; gap: 1rem; }
.problem { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1.1rem 1.3rem; background: var(--surface); }
.problem__q { font-weight: 600; color: var(--ink); }
.problem__reveal { margin-top: 0.8rem; background: transparent; border: 1px dashed var(--brand); color: var(--brand-700); padding: 0.5em 1em; border-radius: var(--radius-pill); font-weight: 600; font-size: 0.88rem; }
.problem__reveal:hover { background: var(--brand-soft); }
.problem__a { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--line); color: var(--ink-soft); display: none; }
.problem.is-open .problem__a { display: block; animation: fadeUp 0.25s ease; }
.problem.is-open .problem__reveal { display: none; }

/* lesson diagram */
.figure { margin: 1.6rem 0; text-align: center; }
.figure svg { margin-inline: auto; }
.figure figcaption { font-size: 0.86rem; color: var(--ink-muted); margin-top: 0.7rem; }

/* lesson side nav (next/prev) */
.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; }
.lesson-nav a { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem 1.2rem; box-shadow: var(--shadow-xs); transition: border-color 0.15s ease, transform 0.15s ease; }
.lesson-nav a:hover { border-color: var(--brand); transform: translateY(-2px); }
.lesson-nav .dir { font-size: 0.78rem; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.lesson-nav .ttl { font-weight: 600; color: var(--ink); margin-top: 0.2rem; }
.lesson-nav .next { text-align: right; }

/* ===================================================================
   Pricing
   =================================================================== */
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(16px, 2.4vw, 26px); align-items: stretch; }
.price-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px, 2.6vw, 32px); box-shadow: var(--shadow-xs); }
.price-card.is-featured { border-color: transparent; box-shadow: var(--shadow-lg); position: relative; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad-dawn) border-box; border: 2px solid transparent; }
.price-card.is-featured::after { content: "Most popular"; position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: var(--grad-dawn); color: #311; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; padding: 4px 14px; border-radius: 999px; text-transform: uppercase; }
.price-card h3 { font-family: var(--font-sans); font-weight: 700; font-size: 1.1rem; }
.price-amt { font-family: var(--font-display); font-size: 2.8rem; line-height: 1; margin: 0.6rem 0 0.2rem; }
.price-amt .per { font-family: var(--font-sans); font-size: 0.95rem; color: var(--ink-muted); font-weight: 500; }
.price-card .desc { color: var(--ink-muted); font-size: 0.95rem; min-height: 2.8em; }
.price-card ul { list-style: none; padding: 0; margin: 1.3rem 0; display: grid; gap: 0.7rem; }
.price-card li { display: flex; gap: 0.6rem; font-size: 0.95rem; color: var(--ink-soft); }
.price-card li svg { flex: none; width: 20px; height: 20px; color: #059669; margin-top: 2px; }
.price-card li.off { color: var(--ink-faint); }
.price-card li.off svg { color: var(--ink-faint); }
.price-card .btn { margin-top: auto; }

/* ===================================================================
   Misc / utilities
   =================================================================== */
.faq { display: grid; gap: 0.7rem; max-width: 760px; margin-inline: auto; }
.faq details { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 0.4rem 0.4rem; }
.faq summary { list-style: none; cursor: pointer; padding: 0.9rem 1rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; color: var(--brand); font-weight: 400; line-height: 1; transition: transform 0.2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { padding: 0 1rem 1rem; color: var(--ink-muted); margin: 0; }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in { opacity: 1; transform: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: 0.7rem 1rem; border-radius: 0 0 8px 0; z-index: 100; }
.skip-link:focus { left: 0; }

/* ===================================================================
   Responsive
   =================================================================== */
@media (max-width: 940px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem 1.4rem; }
  .footer-about { grid-column: 1 / -1; max-width: none; }
}
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: fixed; inset: 72px 0 auto 0; flex-direction: column; align-items: stretch;
    gap: 0.2rem; padding: 1rem var(--gutter) 1.6rem; margin: 0;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
    transform: translateY(-12px); opacity: 0; visibility: hidden; transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s;
  }
  body.nav-open .nav-links { transform: none; opacity: 1; visibility: visible; }
  .nav-links > a { padding: 0.8rem 0.6rem; border-bottom: 1px solid var(--bg-muted); }
  .nav-cta, .nav-links .btn { margin: 0.6rem 0 0; }
  .lang { margin-top: 0.4rem; }
  .lang-menu { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; padding: 4px 0 0; min-width: 0; }
  .lang[data-open="false"] .lang-menu { display: none; }
  .lang-btn { width: 100%; justify-content: space-between; }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 1.6rem 1rem; }
  .price-grid { grid-template-columns: 1fr; }
  .price-card.is-featured { order: -1; }
  .lesson-nav { grid-template-columns: 1fr; }
  .hero__meta { gap: 1.2rem 1.8rem; }
}
@media (min-width: 721px) and (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ===================================================================
   Interactive learning widgets (.emw)
   =================================================================== */
.emw {
  margin: 1.8rem 0; padding: 1.1rem 1.2rem 1.2rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fff, var(--bg-soft));
  box-shadow: var(--shadow-xs);
}
.emw svg { width: 100%; height: auto; touch-action: none; }
.emw__head { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.emw__tag { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-700); background: var(--brand-soft); padding: 3px 9px; border-radius: 999px; }
.emw__hint { font-size: 0.82rem; color: var(--ink-muted); }
.emw button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: var(--radius-xs); padding: 0.35em 0.7em; font-weight: 700; font-size: 0.95rem;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.emw button:hover { border-color: var(--brand); color: var(--brand-700); background: var(--brand-soft); }
.emw button:active { transform: translateY(1px); }

/* number line */
.emw--numline .emw__handle { cursor: grab; }
.emw--numline svg:active .emw__handle { cursor: grabbing; }
.emw__ctrl { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 0.4rem; }
.emw__read { font-family: var(--font-display); font-size: 1.5rem; min-width: 2.4ch; text-align: center; color: var(--ink); }

/* fraction */
.emw__fracrow { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.4rem; margin-top: 0.9rem; }
.emw__stepper { display: inline-flex; align-items: center; gap: 0.4rem; }
.emw__stepper .emw__lbl { font-size: 0.8rem; color: var(--ink-muted); margin-right: 0.2rem; }
.emw__stepper b { font-family: var(--font-display); font-size: 1.25rem; min-width: 1.6ch; text-align: center; }
.emw__result { margin-left: auto; font-size: 1.05rem; color: var(--ink-soft); }
.emw__result b { color: var(--brand-700); }
.emw__frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; }
.emw__frac i { font-style: normal; font-weight: 700; padding: 0 0.35em; }
.emw__frac i:first-child { border-bottom: 2px solid currentColor; }

/* base-ten */
.emw__btinput { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; justify-content: center; }
.emw__btinput input { width: 5.5rem; text-align: center; font-family: var(--font-display); font-size: 1.2rem; padding: 0.3em 0.5em; border: 1px solid var(--line); border-radius: var(--radius-xs); }
.emw__btcols { display: flex; gap: 1.4rem; justify-content: center; align-items: flex-end; margin: 1.2rem 0 0.4rem; flex-wrap: wrap; min-height: 70px; }
.emw__col { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.emw__grid { display: grid; gap: 2px; align-content: end; min-height: 56px; }
.emw__grid--h { grid-template-columns: repeat(5, 1fr); }
.emw__grid--t { grid-template-columns: 1fr; }
.emw__grid--o { grid-template-columns: repeat(3, 1fr); }
.emw__blk { width: 12px; height: 12px; border-radius: 3px; }
.emw__blk.h { background: #a855f7; }
.emw__blk.t { background: #fb7185; width: 12px; height: 12px; }
.emw__blk.o { background: #f59e0b; }
.emw__collbl { font-size: 0.8rem; color: var(--ink-muted); font-weight: 600; }
.emw__btsum { text-align: center; font-size: 1.05rem; color: var(--ink-soft); margin-top: 0.4rem; }
.emw__btsum b { font-family: var(--font-display); color: var(--ink); }
@media (max-width: 540px) { .emw__result { margin-left: 0; width: 100%; } }

/* shared wide control row */
.emw__ctrl--wide { flex-wrap: wrap; gap: 0.5rem; }

/* decimal / percent hundred-grid */
.emw__decwrap { display: flex; gap: 1.6rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.emw__decgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; width: 220px; aspect-ratio: 1 / 1; flex: none; }
.emw__cell { background: #eef1f7; border-radius: 2px; aspect-ratio: 1 / 1; cursor: pointer; transition: background 0.12s ease; }
.emw__cell:hover { background: #dfe4f2; }
.emw__cell.on { background: var(--dawn-coral); }
.emw__cell.on:hover { background: #f43f5e; }
.emw__decread { font-size: 1.1rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; max-width: 14rem; }
.emw__decread b { color: var(--brand-700); font-family: var(--font-display); }
.emw__deceq { color: var(--ink-faint); font-weight: 600; }

/* ratio */
.emw__beads { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 26px; margin: 0.5rem 0 0.2rem; }
.emw__bead { width: 24px; height: 24px; border-radius: 50%; box-shadow: var(--shadow-xs); }
.emw__bead--a { background: var(--dawn-amber); }
.emw__bead--b { background: var(--dawn-violet); }
.emw__lbl--a::before, .emw__lbl--b::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.emw__lbl--a::before { background: var(--dawn-amber); }
.emw__lbl--b::before { background: var(--dawn-violet); }

/* exponent + expression shared read-outs */
.emw__expread, .emw__exprsub { font-size: 1.15rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.emw__expread b, .emw__exprsub b { color: var(--brand-700); font-family: var(--font-display); }
.emw__pow { font-family: var(--font-display); font-size: 1.45rem; color: var(--ink); }
.emw__pow b { color: var(--ink); }
.emw__pow sup { font-size: 0.62em; vertical-align: super; }
.emw__expand { color: var(--ink-soft); }
.emw__expval { font-size: 1.3rem; }

/* expression evaluator */
.emw__exprlabel { text-align: center; margin: 0.4rem 0 0.2rem; }
.emw__exprform { font-family: var(--font-display); font-size: 1.7rem; color: var(--ink); }
.emw__exprsub { justify-content: center; }

/* balance scale */
.emw__balrow { display: flex; align-items: stretch; justify-content: center; gap: 0.8rem; margin: 0.6rem 0; }
.emw__balside { flex: 1 1 0; max-width: 220px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1.6rem; color: var(--ink); background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem; min-height: 64px; }
.emw__baleq { display: flex; align-items: center; font-size: 1.6rem; color: var(--ink-faint); font-weight: 700; }
.emw__balmsg { text-align: center; color: var(--ink-soft); margin: 0.4rem 0 0.7rem; min-height: 1.4em; }
.emw__balmsg b { color: var(--brand-700); }

/* ── Stage 4–5: grapher + geometry widgets ── */
.emw__eq { text-align: center; font-family: var(--font-display); font-size: 1.45rem; color: var(--ink); margin: 0.1rem 0 0.6rem; min-height: 1.3em; display: flex; flex-direction: column; gap: 0.05rem; align-items: center; justify-content: center; }
.emw__eq .emw__l1 { color: #4338ca; }
.emw__eq .emw__l2 { color: #be123c; }
.emw__note { display: block; font-family: Inter, system-ui, sans-serif; font-size: 0.8rem; line-height: 1.4; color: var(--ink-muted); font-weight: 500; margin-top: 0.25rem; }
.emw__result--graph { margin-left: 0; width: 100%; text-align: center; margin-top: 0.5rem; font-size: 1rem; line-height: 1.5; }
.emw__fracrow--graph { justify-content: center; gap: 0.8rem 1.5rem; }
.emw--graph svg, .emw--tri svg, .emw--angle svg, .emw--area svg,
.emw--circle svg, .emw--pyth svg, .emw--prism svg, .emw--transform svg,
.emw--rtri svg, .emw--unit svg, .emw--law svg {
  max-width: 430px; display: block; margin: 0.2rem auto 0;
}
.emw--ineq svg, .emw--wave svg { max-width: 580px; display: block; margin: 0.2rem auto 0; }
.emw__fnrow { gap: 0.4rem; margin-bottom: 0.2rem; }
.emw button.is-on { border-color: var(--brand); color: var(--brand-700); background: var(--brand-soft); font-weight: 700; }
.emw__handle { cursor: grab; }
.emw svg:active .emw__handle { cursor: grabbing; }
.emw--graph .emw__plot, .emw--graph .emw__pts { pointer-events: none; }
.emw--transform .emw__ctrl--wide, .emw--ineq .emw__ctrl--wide { justify-content: center; }

/* ===================================================================
   3D math intro (home landing) — .intro3d
   Three.js scene behind a centred overlay + "Let's Start!" button.
   Degrades to the dawn gradient + a working link if WebGL/CDN fail.
   =================================================================== */
.intro3d {
  position: relative; min-height: 100svh; display: grid; place-items: center;
  overflow: hidden; isolation: isolate; color: #eef1ff;
  background:
    radial-gradient(120% 90% at 50% 120%, rgba(251,113,133,0.50) 0%, rgba(245,158,11,0.34) 22%, rgba(168,85,247,0.18) 46%, rgba(10,18,48,0) 66%),
    linear-gradient(180deg, #070d24 0%, #0a1230 46%, #0e1740 100%);
}
.intro3d__stage { position: absolute; inset: 0; z-index: 0; opacity: 0; transition: opacity 1.1s ease; }
.intro3d__stage.is-ready { opacity: 1; }
.intro3d__stage canvas { display: block; width: 100% !important; height: 100% !important; }
.intro3d__veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(circle at 50% 44%, rgba(7,13,36,0) 28%, rgba(7,13,36,0.42) 72%, rgba(7,13,36,0.72) 100%);
}
.intro3d__overlay {
  position: relative; z-index: 2; text-align: center; padding: 0 var(--gutter);
  max-width: 860px; display: flex; flex-direction: column; align-items: center;
  transition: opacity 0.5s ease, transform 0.6s ease;
}
.intro3d__overlay.is-leaving { opacity: 0; transform: scale(1.08); }
.intro3d__overlay .eyebrow.is-light { margin-bottom: 0.6rem; }
.intro3d__title {
  font-family: var(--font-display); font-weight: 600; line-height: 1.04; letter-spacing: -0.02em;
  font-size: clamp(2.7rem, 7vw, 5rem); color: #fff;
  text-shadow: 0 2px 40px rgba(7,13,36,0.55);
}
.intro3d__title .grad-text { filter: drop-shadow(0 4px 30px rgba(251,113,133,0.35)); }
.intro3d__lead {
  margin-top: 1.2rem; max-width: 46ch; font-size: clamp(1.05rem, 1.7vw, 1.3rem);
  color: #cdd3f3; line-height: 1.6; text-shadow: 0 1px 20px rgba(7,13,36,0.6);
}

/* the star CTA */
.btn-start {
  position: relative; display: inline-flex; align-items: center; gap: 0.6em;
  margin-top: 2.2rem; padding: 1.05em 2.3em; border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-weight: 800; letter-spacing: -0.01em;
  font-size: clamp(1.05rem, 1.7vw, 1.28rem); color: #2a1206;
  background: var(--grad-dawn); background-size: 220% 100%; overflow: hidden; isolation: isolate;
  box-shadow: 0 16px 42px -12px rgba(251,113,133,0.7);
  transition: transform 0.18s ease, box-shadow 0.25s ease;
  animation: startGrad 6s ease infinite, startGlow 3.6s ease-in-out infinite;
}
.btn-start svg { width: 1.1em; height: 1.1em; }
.btn-start::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(110deg, transparent 32%, rgba(255,255,255,0.6) 50%, transparent 68%);
  transform: translateX(-130%); animation: startShine 3.6s ease-in-out infinite;
}
.btn-start:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 26px 64px -14px rgba(251,113,133,0.85), 0 0 44px -4px rgba(245,158,11,0.6); }
.btn-start:active { transform: translateY(0) scale(1); }
@keyframes startGrad { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes startGlow { 0%, 100% { box-shadow: 0 16px 42px -12px rgba(251,113,133,0.6); } 50% { box-shadow: 0 18px 50px -12px rgba(251,113,133,0.85), 0 0 38px -2px rgba(245,158,11,0.55); } }
@keyframes startShine { 0%, 55% { transform: translateX(-130%); } 82%, 100% { transform: translateX(130%); } }

.intro3d__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 2rem; }

.intro3d__scroll {
  position: absolute; left: 50%; bottom: clamp(20px, 5vh, 42px); transform: translateX(-50%);
  z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  color: rgba(231,236,255,0.72); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; transition: color 0.15s ease;
}
.intro3d__scroll:hover { color: #fff; }
.intro3d__scroll svg { width: 20px; height: 20px; animation: introBob 1.9s ease-in-out infinite; }
@keyframes introBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

.intro3d .hero__wave { position: absolute; left: 0; right: 0; bottom: -1px; z-index: 2; line-height: 0; }
.intro3d .hero__wave svg { width: 100%; height: auto; }

/* ---- Transparent header while over the dark intro (home page only) ---- */
body.page-home .site-header { background: transparent; backdrop-filter: none; border-color: transparent; box-shadow: none; }
body.page-home .site-header .brand { color: #fff; }
body.page-home .site-header .brand b { color: #c7b3ff; }
body.page-home .site-header .nav-links > a { color: rgba(231,236,255,0.86); }
body.page-home .site-header .nav-links > a:hover { color: #fff; background: rgba(255,255,255,0.12); }
body.page-home .site-header .nav-links > a.active { color: #fff; }
body.page-home .site-header .lang-btn { color: rgba(231,236,255,0.9); border-color: rgba(255,255,255,0.24); }
body.page-home .site-header .lang-btn:hover { background: rgba(255,255,255,0.12); }
body.page-home .site-header .nav-toggle { border-color: rgba(255,255,255,0.28); background: rgba(255,255,255,0.08); }
body.page-home .site-header .nav-toggle span,
body.page-home .site-header .nav-toggle span::before,
body.page-home .site-header .nav-toggle span::after { background: #fff; }

/* once scrolled past the intro, restore the normal light header */
body.page-home .site-header.is-scrolled { background: rgba(255,255,255,0.82); backdrop-filter: saturate(1.4) blur(14px); border-color: var(--line); box-shadow: var(--shadow-xs); }
body.page-home .site-header.is-scrolled .brand { color: var(--ink); }
body.page-home .site-header.is-scrolled .brand b { color: var(--brand); }
body.page-home .site-header.is-scrolled .nav-links > a { color: var(--ink-soft); }
body.page-home .site-header.is-scrolled .nav-links > a:hover { color: var(--ink); background: var(--bg-muted); }
body.page-home .site-header.is-scrolled .nav-links > a.active { color: var(--brand-700); }
body.page-home .site-header.is-scrolled .lang-btn { color: var(--ink-soft); border-color: var(--line); }
body.page-home .site-header.is-scrolled .nav-toggle { border-color: var(--line); background: var(--surface); }
body.page-home .site-header.is-scrolled .nav-toggle span,
body.page-home .site-header.is-scrolled .nav-toggle span::before,
body.page-home .site-header.is-scrolled .nav-toggle span::after { background: var(--ink); }

/* on the mobile dropdown the links sit on a white panel — keep them dark */
@media (max-width: 860px) {
  body.page-home .site-header .nav-links { background: var(--surface); }
  body.page-home .site-header .nav-links > a { color: var(--ink-soft); }
  body.page-home .site-header .nav-links > a:hover { color: var(--ink); background: var(--bg-muted); }
}

@media (prefers-reduced-motion: reduce) {
  .btn-start, .btn-start::before, .intro3d__scroll svg { animation: none !important; }
  .intro3d__stage { transition: none; }
}
