/* =====================================================
   MathKong — Card-game paper aesthetic
   ===================================================== */

:root {
  --paper: #f4ecd8;         /* warm cream card stock */
  --paper-2: #ebe1c7;       /* slightly darker cream */
  --paper-3: #e4d8b9;       /* shadow cream */
  --card-white: #fbf7ec;    /* card face */
  --ink: #1c1a14;           /* near-black ink */
  --ink-soft: #3a372c;
  --muted: #7a7360;
  --muted-2: #a59d85;
  --rule: #d7cba8;          /* dashed rule color */
  --rule-2: #c8b98f;

  --red: #c7422a;           /* card red suit */
  --red-2: #a6361f;
  --blue: #2a6cc7;          /* card blue suit */
  --green: #2e8b4a;
  --gold: #d99a2a;

  --accent: var(--red);     /* primary accent */
  --accent-ink: #fff8e8;

  --shadow-card: 0 2px 0 rgba(0,0,0,0.04), 0 10px 20px -10px rgba(60,48,20,0.25), 0 22px 40px -22px rgba(60,48,20,0.35);
  --shadow-card-hover: 0 2px 0 rgba(0,0,0,0.04), 0 14px 28px -10px rgba(60,48,20,0.35), 0 30px 55px -24px rgba(60,48,20,0.45);
}

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

body {
  font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01","cv11";
  background-image:
    radial-gradient(circle at 12% 8%, rgba(199,66,42,0.05), transparent 28%),
    radial-gradient(circle at 92% 18%, rgba(42,108,199,0.04), transparent 30%),
    radial-gradient(circle at 20% 88%, rgba(217,154,42,0.05), transparent 30%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0.11  0 0 0 0 0.10  0 0 0 0 0.08  0 0 0 0.07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: auto, auto, auto, 260px 260px;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ---------- Shared type ---------- */
h1, h2, h3, h4 { font-family: 'Fraunces', 'Instrument Serif', Georgia, serif; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
h1 em, h2 em, h3 em { font-style: italic; font-family: 'Caveat', 'Kalam', cursive; font-weight: 500; color: var(--accent); letter-spacing: 0; }

.hand { font-family: 'Caveat', 'Kalam', cursive; font-weight: 500; }
.serif { font-family: 'Fraunces', 'Instrument Serif', Georgia, serif; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 28px; }
.container-narrow { max-width: 820px; margin: 0 auto; padding: 0 28px; }

/* ---------- Nav ---------- */
.nav-wrap {
  position: sticky; top: 0; z-index: 40;
  background: rgba(244,236,216,0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1.5px dashed var(--rule-2);
}
.nav {
  max-width: 1240px; margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.logo {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 24px; letter-spacing: -0.02em;
  color: var(--ink);
}
.logo .k-mark {
  display: inline-block; transform: rotate(-8deg);
  background: var(--red); color: var(--card-white);
  padding: 2px 9px 4px; border-radius: 4px;
  font-family: 'Caveat', cursive; font-weight: 500; font-size: 26px; line-height: 1;
  box-shadow: 2px 2px 0 rgba(28,26,20,0.15);
}
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-group { position: relative; }
.nav-group > .nav-link { display: inline-flex; align-items: center; gap: 6px; }
.nav-group > .nav-link::after { content: '▾'; font-size: 10px; opacity: 0.6; margin-left: 2px; }
.nav-dropdown {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%) translateY(4px);
  min-width: 220px;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 rgba(28,26,20,0.12), 0 10px 24px -10px rgba(60,48,20,0.25);
  padding: 8px;
  margin-top: 6px; /* visual gap, but still inside hover area via ::before bridge */
  opacity: 0; pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 50;
}
/* Transparent bridge so cursor can travel from trigger to menu without losing hover */
.nav-dropdown::before {
  content: ''; position: absolute;
  top: -10px; left: 0; right: 0; height: 10px;
}
.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.nav-dropdown a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--ink-soft);
  gap: 16px;
}
.nav-dropdown a:hover { background: var(--paper-2); color: var(--ink); }
.nav-dropdown a.live { color: var(--red); }
.nav-dropdown a .tag { font-family: 'Caveat', cursive; font-weight: 500; font-size: 14px; color: var(--muted); }
.nav-dropdown a.live .tag { color: var(--red); }
.nav-dropdown .divider { height: 1px; background: var(--rule); margin: 6px 4px; border-top: 1px dashed var(--rule-2); }

/* Grade row with sub-menu */
.grade-row { position: relative; }
.grade-row > .grade-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 6px; font-size: 14px; font-weight: 600;
  color: var(--ink-soft); gap: 16px; cursor: default;
}
.grade-row > .grade-item::after { content: '›'; color: var(--muted); font-size: 16px; line-height: 1; }
.grade-row:hover > .grade-item,
.grade-row:focus-within > .grade-item { background: var(--paper-2); color: var(--ink); }
.grade-row.live > .grade-item { color: var(--red); }
.grade-row.live > .grade-item .tag { color: var(--red); }
.grade-row .sub-menu {
  position: absolute; top: -8px; left: calc(100% + 10px);
  min-width: 180px;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 rgba(28,26,20,0.12), 0 10px 24px -10px rgba(60,48,20,0.25);
  padding: 8px;
  opacity: 0; pointer-events: none;
  transform: translateX(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 60;
}
.grade-row .sub-menu::before {
  content: ''; position: absolute;
  left: -12px; top: 0; bottom: 0; width: 12px;
}
.grade-row:hover .sub-menu,
.grade-row:focus-within .sub-menu {
  opacity: 1; pointer-events: auto; transform: translateX(0);
}
.grade-row.locked .sub-menu { display: none; }
.grade-row .sub-menu a {
  padding: 9px 11px; font-size: 13.5px;
}
.grade-row .soon-note {
  padding: 9px 11px; font-size: 13px; color: var(--muted); font-style: italic;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.grade-row .soon-note .tag { font-family: 'Caveat', cursive; font-size: 14px; }

/* Footer grades block */
.foot-col .grade-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.foot-col .grade-list li { display: flex; align-items: baseline; gap: 10px; font-size: 14.5px; color: var(--ink-soft); line-height: 1.4; flex-wrap: wrap; }
.foot-col .grade-list li .g-label { font-weight: 600; color: var(--ink); min-width: 62px; }
.foot-col .grade-list li .g-links { display: flex; gap: 10px; font-size: 13.5px; }
.foot-col .grade-list li .g-links a { color: var(--red); }
.foot-col .grade-list li .g-sep { color: var(--muted); }
.foot-col .grade-list li .g-soon { font-family: 'Caveat', cursive; font-size: 15px; color: var(--muted); }
.nav-link {
  padding: 8px 14px; font-size: 14.5px; font-weight: 600; color: var(--ink-soft);
  border-radius: 8px; transition: color 140ms ease, background 140ms ease;
  position: relative;
}
.nav-link:hover { color: var(--ink); background: rgba(28,26,20,0.04); }
.nav-link.active { color: var(--red); }
.nav-link.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px;
  background: var(--red);
  border-radius: 2px;
}
.nav-cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; background: var(--ink); color: var(--paper);
  border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: 2px 2px 0 rgba(199,66,42,0.5);
  transition: transform 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}
.nav-cta:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(199,66,42,0.6); }

/* ---------- Playing card atom ---------- */
.card {
  position: relative;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  font-family: 'Fraunces', serif;
  overflow: hidden;
}
.card::before {
  content: ''; position: absolute; inset: 6px;
  border: 1px dashed rgba(28,26,20,0.18);
  border-radius: 6px;
  pointer-events: none;
}
.card .corner {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  font-weight: 600; line-height: 1;
}
.card .corner .val { font-size: 22px; }
.card .corner .suit { font-size: 14px; margin-top: 2px; }
.card .tl { top: 10px; left: 12px; }
.card .br { bottom: 10px; right: 12px; transform: rotate(180deg); }
.card .center {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 64px; font-weight: 500;
}
.card.red, .card.red .corner, .card.red .center { color: var(--red); }
.card.blue, .card.blue .corner, .card.blue .center { color: var(--blue); }
.card.green, .card.green .corner, .card.green .center { color: var(--green); }
.card.gold, .card.gold .corner, .card.gold .center { color: var(--gold); }
.card.op .center { font-family: 'Caveat', cursive; font-weight: 500; font-size: 96px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 72px 0 120px;
  overflow: hidden;
}
.hero-inner {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px;
  align-items: center;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 8px;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  box-shadow: 3px 3px 0 rgba(28,26,20,0.08);
  transform: rotate(-1.5deg);
}
.hero-eyebrow .dot { width: 8px; height: 8px; background: var(--red); border-radius: 50%; box-shadow: 0 0 0 3px rgba(199,66,42,0.2); }
.hero h1 {
  font-size: clamp(44px, 6.2vw, 88px);
  line-height: 0.98; letter-spacing: -0.035em;
  margin: 22px 0 18px; font-weight: 600;
  max-width: 14ch; text-wrap: balance;
}
.hero h1 em { display: inline-block; transform: rotate(-2deg); }
.hero .lede {
  font-size: 19px; line-height: 1.55; color: var(--ink-soft);
  max-width: 48ch; margin: 0 0 30px;
}
.cta-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 10px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  border: 1.5px solid var(--ink);
  cursor: pointer; transition: transform 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}
.btn-primary { background: var(--red); color: var(--paper); box-shadow: 3px 3px 0 var(--ink); }
.btn-primary:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: 3px 3px 0 rgba(28,26,20,0.15); }
.btn-ghost:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 rgba(28,26,20,0.2); background: rgba(28,26,20,0.03); }

/* Split button: primary CTA + grade picker */
.btn-split { position: relative; display: inline-flex; }
.btn-start {
  border: 0; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 14px;
  justify-content: space-between;
}
.btn-start-chev {
  display: inline-block; transition: transform 200ms ease;
  font-size: 14px; line-height: 1; opacity: 0.85;
}
.btn-start[aria-expanded="true"] .btn-start-chev { transform: rotate(180deg); }
.btn-split.open .btn-start { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.btn-split-menu {
  position: absolute; top: calc(100% + 10px); left: 0;
  background: var(--paper); border: 1.5px solid var(--ink);
  border-radius: 10px; box-shadow: 4px 4px 0 var(--ink);
  padding: 8px; min-width: 240px;
  opacity: 0; pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease;
  display: flex; flex-direction: column; gap: 2px;
  z-index: 40;
  font-family: 'Fraunces', serif;
}
.btn-split.open .btn-split-menu { opacity: 1; pointer-events: auto; transform: translateY(0); }
.gpm-head {
  font-family: 'JetBrains Mono', 'Plus Jakarta Sans', monospace;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(28,26,20,0.45);
  padding: 6px 12px 8px;
}
.gpm-item {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-size: 15px;
  cursor: pointer;
}
.gpm-item:hover:not([aria-disabled="true"]) { background: rgba(28,26,20,0.06); }
.gpm-item[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.gpm-num {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
  font-family: 'Caveat', cursive;
}
.gpm-item.is-live .gpm-num { background: var(--red); }
.gpm-label { font-weight: 500; }
.gpm-tag {
  font-family: 'JetBrains Mono', 'Plus Jakarta Sans', monospace;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(28,26,20,0.55);
}
.gpm-item.is-live .gpm-tag { color: var(--red); }
.btn-dark { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 rgba(199,66,42,0.5); }
.btn-dark:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 rgba(199,66,42,0.6); }

/* Hand-written annotation */
.note {
  font-family: 'Caveat', cursive; font-weight: 500;
  color: var(--ink-soft); font-size: 22px; line-height: 1.1;
  display: inline-flex; align-items: center; gap: 8px;
}
.note svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* Card fan in hero */
.card-fan { position: relative; height: 420px; }
.card-fan .card {
  position: absolute;
  width: 150px; height: 220px;
  transition: transform 280ms cubic-bezier(.2,.7,.2,1);
}
.card-fan .card:hover { z-index: 10; transform: translateY(-10px) rotate(0deg) !important; box-shadow: var(--shadow-card-hover); }
.card-fan .c1 { left: 8%;  top: 30%; transform: rotate(-18deg); }
.card-fan .c2 { left: 26%; top: 16%; transform: rotate(-9deg); }
.card-fan .c3 { left: 44%; top: 8%;  transform: rotate(-1deg); z-index: 3; }
.card-fan .c4 { left: 62%; top: 16%; transform: rotate(8deg); }
.card-fan .c5 { left: 80%; top: 30%; transform: rotate(18deg); }

.scribble {
  position: absolute; font-family: 'Caveat', cursive; font-weight: 500; color: var(--red);
  font-size: 24px; line-height: 1; display: flex; align-items: center; gap: 8px;
}
.scribble svg { stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.scribble-1 { top: 6%; right: -4%; transform: rotate(6deg); }
.scribble-2 { bottom: -2%; left: 38%; transform: rotate(-4deg); color: var(--blue); }

/* ---------- Strip of 'how it works' cards ---------- */
.how {
  padding: 80px 0 60px;
  background: var(--paper-2);
  border-top: 2px dashed var(--rule-2);
  border-bottom: 2px dashed var(--rule-2);
  position: relative;
}
.how .section-head { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-bottom: 48px; align-items: end; }
.eyebrow { font-family: 'Caveat', cursive; font-size: 24px; color: var(--red); font-weight: 500; }
.section-title { font-size: clamp(32px, 4vw, 52px); line-height: 1.05; margin: 8px 0 0; font-weight: 600; letter-spacing: -0.02em; max-width: 18ch; }
.section-sub { color: var(--ink-soft); font-size: 16.5px; line-height: 1.6; max-width: 44ch; justify-self: end; }

.how-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.step {
  position: relative;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  padding: 24px 22px 28px;
  box-shadow: var(--shadow-card);
  min-height: 220px;
}
.step:nth-child(1) { transform: rotate(-1deg); }
.step:nth-child(2) { transform: rotate(0.8deg); }
.step:nth-child(3) { transform: rotate(-0.6deg); }
.step:nth-child(4) { transform: rotate(1.2deg); }
.step-num {
  font-family: 'Caveat', cursive; font-size: 42px; line-height: 1;
  color: var(--red); font-weight: 500;
}
.step h3 { font-size: 18px; margin: 8px 0 6px; font-weight: 600; }
.step p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-soft); }
.step .op {
  position: absolute; top: 14px; right: 16px;
  font-family: 'Caveat', cursive; font-size: 36px; line-height: 1; color: var(--rule-2);
}

/* ---------- The deck (grades as cards) ---------- */
.deck { padding: 80px 0; }
.deck .section-head { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-bottom: 48px; align-items: end; }
.deck-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.grade-card {
  position: relative;
  aspect-ratio: 5 / 7;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 18px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform 220ms ease, box-shadow 220ms ease;
  overflow: hidden;
}
.grade-card::before {
  content: ''; position: absolute; inset: 8px;
  border: 1px dashed rgba(28,26,20,0.18);
  border-radius: 7px; pointer-events: none;
}
.grade-card:hover { transform: translateY(-6px) rotate(-1deg); box-shadow: var(--shadow-card-hover); }
.grade-card .g-top { display: flex; justify-content: space-between; align-items: flex-start; position: relative; z-index: 1; }
.grade-card .g-num {
  font-family: 'Fraunces', serif; font-size: 86px; line-height: 0.9; font-weight: 500;
}
.grade-card .g-suit { font-size: 18px; font-weight: 600; }
.grade-card .g-mid {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: 'Caveat', cursive; font-size: 84px; color: rgba(28,26,20,0.06); font-weight: 500;
  pointer-events: none;
}
.grade-card .g-bot { position: relative; z-index: 1; }
.grade-card .g-label { font-family: 'Caveat', cursive; font-size: 22px; color: var(--ink-soft); font-weight: 500; line-height: 1; }
.grade-card .g-topics { font-size: 12px; line-height: 1.45; color: var(--muted); margin-top: 6px; }
.grade-card .g-status {
  display: inline-block; margin-top: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px;
  background: var(--paper-3); color: var(--ink-soft);
}
.grade-card.live .g-status { background: var(--red); color: var(--paper); }
.grade-card.live { border-color: var(--red); border-width: 2px; }
.grade-card.live .g-num, .grade-card.live .g-suit { color: var(--red); }
.grade-card .g-arrow {
  position: absolute; bottom: 14px; right: 14px;
  font-family: 'Caveat', cursive; font-size: 32px; color: var(--ink-soft);
  transition: transform 160ms ease;
}
.grade-card:hover .g-arrow { transform: translateX(4px) rotate(-8deg); color: var(--red); }

/* ---------- Invent-your-game strip ---------- */
.invent {
  padding: 80px 0;
  background: var(--ink);
  color: var(--paper);
  position: relative; overflow: hidden;
}
.invent .eyebrow { color: var(--gold); }
.invent h2 { color: var(--paper); max-width: 20ch; }
.invent h2 em { color: var(--gold); }
.invent .lede { font-size: 18px; line-height: 1.6; color: rgba(244,236,216,0.75); max-width: 52ch; margin: 20px 0 32px; }
.invent-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 60px; align-items: center; }
.invent .rule-list {
  display: grid; gap: 14px; padding: 0; list-style: none; margin: 0;
}
.invent .rule-list li {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start;
  padding: 16px 18px;
  background: rgba(244,236,216,0.04);
  border: 1px dashed rgba(244,236,216,0.18);
  border-radius: 10px;
  transform: rotate(-0.4deg);
}
.invent .rule-list li:nth-child(even) { transform: rotate(0.4deg); }
.invent .rule-list .n {
  font-family: 'Caveat', cursive; font-size: 34px; line-height: 0.9; color: var(--gold); font-weight: 500;
  width: 44px; text-align: center;
}
.invent .rule-list strong { display: block; font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.invent .rule-list p { margin: 0; font-size: 14.5px; line-height: 1.55; color: rgba(244,236,216,0.72); }

/* Invent cards preview */
.card-preview { position: relative; height: 420px; }
.card-preview .card {
  position: absolute;
  background: var(--card-white);
  width: 140px; height: 200px;
}
.card-preview .card.red .corner, .card-preview .card.red .center { color: var(--red); }
.card-preview .card.blue .corner, .card-preview .card.blue .center { color: var(--blue); }
.card-preview .p1 { left: 4%;  top: 14%; transform: rotate(-10deg); }
.card-preview .p2 { left: 26%; top: 34%; transform: rotate(4deg); }
.card-preview .p3 { left: 50%; top: 10%; transform: rotate(-3deg); z-index: 3; }
.card-preview .p4 { left: 66%; top: 38%; transform: rotate(12deg); }
.card-preview .p5 { right: 2%; top: 20%; transform: rotate(-8deg); }
.card-preview .eq {
  position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
  font-family: 'Caveat', cursive; font-size: 30px; color: var(--gold); font-weight: 500;
  display: flex; gap: 14px; align-items: center;
}

/* ---------- About / story strip ---------- */
.story {
  padding: 80px 0;
  border-top: 2px dashed var(--rule-2);
}
.story-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: start; }
.story p { font-size: 16.5px; line-height: 1.7; color: var(--ink-soft); }
.story p + p { margin-top: 14px; }

/* Notebook mock — handwriting panel */
.notebook {
  background: #fbf7ec;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 0;
  transform: rotate(-1deg);
  overflow: hidden;
}
.notebook-tab {
  background: var(--red); color: var(--paper);
  font-family: 'Caveat', cursive; font-weight: 500; font-size: 22px;
  padding: 6px 16px;
  display: inline-block;
  margin: 12px 0 0 18px;
  border-radius: 6px 6px 0 0;
  transform: rotate(-2deg);
}
.notebook-body {
  padding: 20px 28px 28px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(28,26,20,0.08) 31px 32px);
}
.notebook-body .line {
  font-family: 'Caveat', cursive; font-size: 22px; line-height: 32px; color: var(--ink);
  font-weight: 500;
}
.notebook-body .hand-eq {
  font-family: 'Caveat', cursive; font-size: 28px; line-height: 32px;
  color: var(--blue); font-weight: 500;
}
.notebook-body .red-mark { color: var(--red); }

/* ---------- Footer ---------- */
footer {
  padding: 60px 0 40px;
  border-top: 2px dashed var(--rule-2);
  background: var(--paper-2);
}
.foot-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 40px; }
.foot-brand { display: flex; align-items: baseline; gap: 8px; font-family: 'Fraunces', serif; font-weight: 700; font-size: 26px; }
.foot-brand .k-mark { transform: rotate(-8deg); background: var(--red); color: var(--paper); padding: 2px 9px 4px; border-radius: 4px; font-family: 'Caveat', cursive; font-weight: 500; font-size: 26px; line-height: 1; box-shadow: 2px 2px 0 rgba(28,26,20,0.15); }
.foot-col h4 { font-family: 'Fraunces', serif; font-size: 14px; text-transform: uppercase; letter-spacing: 0.12em; margin: 0 0 10px; font-weight: 600; }
.foot-col p, .foot-col a { font-size: 14.5px; line-height: 1.6; color: var(--ink-soft); }
.foot-col a:hover { color: var(--red); }
.foot-bottom {
  margin-top: 40px; padding-top: 20px; border-top: 1px dashed var(--rule-2);
  display: flex; justify-content: space-between; font-size: 13px; color: var(--muted);
  font-family: 'Caveat', cursive; font-size: 18px; font-weight: 500;
}

/* ---------- Sub-hero (used on Grade9/Topic/Practice/About) ---------- */
.sub-hero {
  padding: 56px 0 44px;
  border-bottom: 2px dashed var(--rule-2);
  position: relative;
}
.crumbs {
  display: flex; gap: 8px; align-items: center;
  font-family: 'Caveat', cursive; font-size: 20px; color: var(--muted);
  margin-bottom: 14px;
}
.crumbs a:hover { color: var(--red); }
.crumbs .sep { color: var(--rule-2); }
.sub-hero h1 {
  font-size: clamp(40px, 5.5vw, 72px); line-height: 1; margin: 6px 0 12px;
  letter-spacing: -0.03em; font-weight: 600;
  max-width: 18ch;
}
.sub-hero .lede { font-size: 17px; line-height: 1.6; color: var(--ink-soft); max-width: 60ch; margin: 0; }
.head-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.meta-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  box-shadow: 2px 2px 0 rgba(28,26,20,0.1);
}
.meta-pill .num { color: var(--red); font-weight: 700; }
.meta-pill.download-pill {
  background: var(--ink);
  color: #fff8e8;
  border-color: var(--ink);
  text-decoration: none;
  padding: 7px 14px 7px 12px;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.meta-pill.download-pill:hover {
  background: var(--red);
  transform: translate(-1px,-1px);
  box-shadow: 3px 3px 0 rgba(28,26,20,0.2);
}
.meta-pill.download-pill .dl-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,248,232,0.12);
  color: #fff8e8;
}
.meta-pill.download-pill:hover .dl-icon { background: rgba(255,255,255,0.18); }
.meta-pill.download-pill .dl-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 4px;
  background: rgba(255,248,232,0.14);
  color: #fff8e8;
}

/* ---------- Topic list page ---------- */
.topic-list { padding: 60px 0 100px; }
.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.topic-card {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 20px; align-items: center;
  padding: 20px 22px;
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  transition: transform 160ms ease, box-shadow 160ms ease;
  position: relative;
}
.topic-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-card-hover); }
.topic-num-block {
  font-family: 'Fraunces', serif; font-size: 44px; line-height: 1; color: var(--red);
  font-weight: 500; font-style: italic;
}
.topic-label { font-family: 'Caveat', cursive; font-size: 18px; color: var(--muted); font-weight: 500; }
.topic-name { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; margin: 2px 0 4px; }
.topic-sub { font-size: 13px; color: var(--muted); }
.topic-arrow { font-family: 'Caveat', cursive; font-size: 32px; color: var(--ink-soft); }
.topic-card:hover .topic-arrow { color: var(--red); transform: translateX(3px); }

/* ---------- Lesson page ---------- */
.lesson-wrap { padding: 50px 0 100px; }
.lesson-layout { display: grid; grid-template-columns: 1fr 260px; gap: 40px; align-items: start; }
.lesson-card {
  background: var(--card-white);
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  padding: 40px 48px;
  box-shadow: var(--shadow-card);
}
.lesson-card h2 { font-family: 'Fraunces', serif; font-size: 28px; margin: 0 0 12px; font-weight: 600; }
.lesson-card h3 { font-family: 'Fraunces', serif; font-size: 20px; margin: 28px 0 10px; font-weight: 600; }
.lesson-card p { font-size: 16px; line-height: 1.75; color: var(--ink-soft); margin: 0 0 14px; }
.lesson-card strong { color: var(--ink); }
.lesson-card em { font-family: 'Caveat', cursive; font-size: 21px; color: var(--red); font-style: normal; font-weight: 500; }
.eq-line {
  font-family: 'Caveat', cursive; font-size: 28px; color: var(--blue); font-weight: 500;
  padding: 14px 20px; margin: 14px 0;
  background: var(--paper-2); border: 1px dashed var(--rule-2); border-radius: 8px;
  text-align: center;
}
.callout {
  margin: 18px 0; padding: 16px 20px;
  background: var(--paper-2); border-left: 4px solid var(--red);
  border-radius: 0 8px 8px 0;
  font-size: 15px; line-height: 1.65; color: var(--ink-soft);
}
.callout .tag {
  display: inline-block; font-family: 'Caveat', cursive; font-weight: 500;
  font-size: 18px; color: var(--red); margin-right: 10px;
}
.steps { padding-left: 22px; margin: 12px 0; }
.steps li { font-size: 15.5px; line-height: 1.7; color: var(--ink-soft); margin-bottom: 8px; }

.side-nav {
  position: sticky; top: 96px;
  background: var(--card-white); border: 1.5px solid var(--ink); border-radius: 12px;
  padding: 18px; box-shadow: var(--shadow-card);
}
.side-nav h4 { font-family: 'Caveat', cursive; font-size: 22px; color: var(--red); font-weight: 500; margin: 0 0 8px; }
.side-link {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 10px;
  border-radius: 6px; font-size: 13.5px; color: var(--ink-soft);
}
.side-link:hover { background: var(--paper-2); color: var(--ink); }
.side-link.active { background: var(--red); color: var(--paper); font-weight: 600; }
.side-link .num { color: var(--muted-2); font-family: 'Caveat', cursive; font-size: 16px; }
.side-link.active .num { color: var(--paper); opacity: 0.8; }
.side-divider { height: 1px; background: var(--rule); margin: 10px 0; border-top: 1px dashed var(--rule-2); }

/* ---------- Quiz ---------- */
.quiz-block {
  margin-top: 30px;
  background: var(--card-white);
  border: 2px solid var(--ink); border-radius: 14px;
  padding: 30px 40px 32px;
  box-shadow: var(--shadow-card);
}
.quiz-progress-bar { height: 6px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.quiz-progress-bar .fill { height: 100%; background: var(--red); transition: width 280ms ease; }
.q-meta { display: flex; justify-content: space-between; margin: 14px 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); font-family: 'Caveat', cursive; font-size: 18px; font-weight: 500; }
.quiz-block h2 { font-family: 'Fraunces', serif; font-size: 24px; margin: 0 0 18px; font-weight: 600; }
.answers { display: grid; gap: 10px; margin-bottom: 14px; }
.ans {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  background: var(--paper-2);
  border: 1.5px solid var(--ink); border-radius: 10px;
  font-size: 15.5px; font-weight: 500; cursor: pointer;
  transition: transform 100ms ease, background 140ms ease, border-color 140ms ease;
}
.ans:hover { background: var(--paper-3); transform: translate(-1px,-1px); }
.ans .dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted-2); }
.ans.correct { background: #e2efd8; border-color: var(--green); color: var(--green); }
.ans.wrong { background: #f7e0db; border-color: var(--red); color: var(--red); }
.ans .check { color: var(--green); font-weight: 700; }
.ans .xmark { color: var(--red); font-weight: 700; }
.feedback {
  padding: 14px 18px; border-radius: 10px;
  border: 1px dashed var(--rule-2); background: var(--paper-2);
  font-size: 14.5px; line-height: 1.55; color: var(--ink-soft); margin-bottom: 14px;
}
.feedback.correct { border-color: var(--green); background: #eef5e3; }
.feedback.incorrect { border-color: var(--red); background: #faebe5; }
.feedback strong { display: block; font-family: 'Caveat', cursive; font-size: 22px; color: var(--red); font-weight: 500; margin-bottom: 2px; }
.feedback.correct strong { color: var(--green); }
.quiz-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.score { font-size: 14px; color: var(--ink-soft); font-family: 'Caveat', cursive; font-size: 19px; font-weight: 500; }
.score strong { color: var(--red); margin-left: 4px; }

/* ---------- Practice setup ---------- */
.practice-wrap { padding: 60px 0 100px; }
.practice-card {
  background: var(--card-white);
  border: 2px solid var(--ink); border-radius: 14px;
  padding: 32px 40px;
  box-shadow: var(--shadow-card);
}
.practice-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.practice-head h3 { font-family: 'Fraunces', serif; font-size: 22px; margin: 0; font-weight: 600; }
.link-btn { font-family: 'Caveat', cursive; font-size: 19px; color: var(--red); font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.topic-selector { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.topic-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1.5px solid var(--ink); border-radius: 8px;
  background: var(--paper-2); cursor: pointer; font-size: 14.5px;
  transition: background 140ms ease, transform 100ms ease;
}
.topic-toggle:hover { background: var(--paper-3); transform: translate(-1px,-1px); }
.topic-toggle.checked { background: var(--red); color: var(--paper); border-color: var(--ink); }
.topic-toggle .tbox {
  width: 20px; height: 20px; border-radius: 4px; border: 1.5px solid var(--ink);
  background: var(--card-white); display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: 0 0 auto;
}
.topic-toggle.checked .tbox { background: var(--paper); color: var(--red); }
.topic-toggle .tnum { font-family: 'Caveat', cursive; font-size: 18px; color: var(--red); margin-right: 4px; font-weight: 500; }
.topic-toggle.checked .tnum { color: var(--paper); }
.practice-cta { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; padding-top: 18px; border-top: 1px dashed var(--rule-2); }
.count-note { font-family: 'Caveat', cursive; font-size: 20px; color: var(--ink-soft); font-weight: 500; }
.count-note strong { color: var(--red); }

/* ---------- About page ---------- */
.about-section { padding: 70px 0; }
.about-section.alt { background: var(--paper-2); border-top: 2px dashed var(--rule-2); border-bottom: 2px dashed var(--rule-2); }
.about-cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 60px; align-items: start; }
.about-cols h2 { font-size: clamp(32px, 4vw, 48px); margin: 10px 0 0; font-weight: 600; letter-spacing: -0.02em; max-width: 16ch; }
.values-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 40px; }
.value {
  background: var(--card-white); border: 1.5px solid var(--ink); border-radius: 12px;
  padding: 26px 24px; box-shadow: var(--shadow-card);
}
.value:nth-child(1) { transform: rotate(-0.8deg); }
.value:nth-child(2) { transform: rotate(0.6deg); }
.value:nth-child(3) { transform: rotate(-0.4deg); }
.v-num { font-family: 'Caveat', cursive; font-size: 40px; color: var(--red); font-weight: 500; line-height: 1; }
.value h4 { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; margin: 8px 0 6px; }
.value p { font-size: 14.5px; line-height: 1.6; color: var(--ink-soft); margin: 0; }

.fact-strip { padding: 40px 0; background: var(--ink); color: var(--paper); }
.fact-strip .container { display: grid; grid-template-columns: repeat(4, 1fr); gap: 40px; text-align: center; }
.f-num { font-family: 'Fraunces', serif; font-size: 58px; font-weight: 500; color: var(--gold); line-height: 1; }
.f-label { font-family: 'Caveat', cursive; font-size: 20px; color: rgba(244,236,216,0.7); font-weight: 500; margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .hero-inner, .how .section-head, .deck .section-head, .invent-grid, .story-grid, .about-cols { grid-template-columns: 1fr; gap: 32px; }
  .how-grid, .deck-grid { grid-template-columns: repeat(2, 1fr); }
  .topic-grid, .topic-selector, .values-grid, .foot-grid, .fact-strip .container { grid-template-columns: 1fr; }
  .lesson-layout { grid-template-columns: 1fr; }
  .side-nav { position: static; }
  .lesson-card { padding: 28px 24px; }
  .nav-links { display: none; }
  .card-fan, .card-preview { height: 320px; }
  .section-sub { justify-self: start; }
}
