/* =============================================================
   DESIGN SYSTEM — "The Exercise Book"
   Shared across every page of this site. Do not fork per-page;
   add new components here.

   Concept: a well-kept maths exercise book. Cream squared paper,
   fountain-pen blue ink, highlighter-yellow for the primary CTA,
   red-pen squiggles for emphasis, green ticks for marking,
   sticky notes for asides, and a chalkboard for the final CTA.

   Palette
   - Paper (cream)      : page background, with faint squared grid
   - Paper-deep         : alternate sections (.section--mist)
   - Ink / Ink-deep     : headings, footer
   - Pen blue           : links, grid lines, hand-drawn circles
   - Highlight (yellow) : primary CTA + <mark> highlighter swipes
   - Pen red            : squiggle underlines, cross-list marks
   - Tick green         : checklist marks
   - Board              : chalkboard sections (.section--ink)

   Type: Fraunces (display headings) + Rubik (body/UI)
   Spacing: multiples of 8px via --space-* tokens
   ============================================================= */

:root {
  --paper: #fbf6ec;
  --paper-deep: #f3ecdc;
  --ink: #1d3154;
  --ink-deep: #14243f;
  --body-text: #4a5468;
  --body-soft: #6b7488;
  --pen-blue: #2b4c89;
  --highlight: #ffd84d;
  --highlight-soft: #ffefaf;
  --pen-red: #d9502f;
  --tick: #2f8f5b;
  --board: #1f3d33;
  --chalk: #f2efe4;
  --line: #e5dcc6;
  --grid-line: rgba(43, 76, 137, 0.08);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Rubik", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4.5rem;

  --radius: 12px;
  --radius-pill: 999px;
  --shadow-paper: 4px 4px 0 rgba(29, 49, 84, 0.08);
  --max-width: 1080px;
}

/* ---------- Reset & base ---------- */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--body-text);
  /* Squared exercise-book paper */
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--highlight);
  color: var(--ink);
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--pen-blue);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--pen-blue);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.005em;
}

h1 { font-size: clamp(2.25rem, 5.5vw, 3.25rem); }
h2 { font-size: clamp(1.65rem, 3.5vw, 2.25rem); }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }

.lead {
  font-size: 1.15rem;
}

.small {
  font-size: 0.875rem;
  color: var(--body-soft);
}

/* Highlighter swipe — wrap key phrases in <mark> */
mark {
  background: linear-gradient(
    to top,
    transparent 4%,
    rgba(255, 216, 77, 0.9) 4%,
    rgba(255, 216, 77, 0.9) 62%,
    transparent 62%
  );
  color: inherit;
  padding: 0 0.1em;
}

/* ---------- Layout ---------- */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.section {
  padding: var(--space-6) 0;
}

/* Alternate "deeper paper" section — solid so the grid pauses */
.section--mist {
  background: var(--paper-deep);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* Chalkboard section */
.section--ink {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, 0.05), transparent 55%),
    var(--board);
  color: var(--chalk);
}

.section--ink h2,
.section--ink h3 {
  color: var(--chalk);
}

.section--ink p {
  color: rgba(242, 239, 228, 0.82);
}

/* Chalk frame — wrap chalkboard content in <div class="chalk-frame"> */
.chalk-frame {
  border: 2px dashed rgba(242, 239, 228, 0.4);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-4);
}

.section-intro {
  max-width: 660px;
  margin-bottom: var(--space-5);
}

.section-intro p {
  margin-top: var(--space-3);
}

/* Red-pen squiggle under section headings */
.section-intro h2::after {
  content: "";
  display: block;
  width: 110px;
  height: 10px;
  margin-top: 0.6rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10' preserveAspectRatio='none'%3E%3Cpath d='M2 7 Q 12 2 25 6 T 50 6 T 75 6 T 98 5' fill='none' stroke='%23d9502f' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat center / contain;
}

.section--ink .section-intro h2::after {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10' preserveAspectRatio='none'%3E%3Cpath d='M2 7 Q 12 2 25 6 T 50 6 T 75 6 T 98 5' fill='none' stroke='%23ffd84d' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat center / contain;
}

.grid {
  display: grid;
  gap: var(--space-3);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid--3,
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .grid--2,
  .grid--3,
  .grid--4 { grid-template-columns: 1fr; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 0.85rem 1.7rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  text-align: center;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    background 0.12s ease, color 0.12s ease;
}

/* Highlighter-yellow primary — the one loud thing on the page */
.btn--primary {
  background: var(--highlight);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.btn--primary:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.btn--primary:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn--secondary:hover {
  background: var(--ink);
  color: var(--paper);
}

/* Secondary button on chalkboard */
.section--ink .btn--secondary {
  color: var(--chalk);
  border-color: rgba(242, 239, 228, 0.7);
}

.section--ink .btn--secondary:hover {
  background: var(--chalk);
  color: var(--board);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* ---------- Header & nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 246, 236, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--ink);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 74px;
}

.site-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--ink);
  text-decoration: none;
}

.site-logo .logo-dot {
  color: var(--pen-red);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.site-nav a {
  color: var(--body-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--ink);
}

/* Active page gets a highlighter swipe */
.site-nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  background: linear-gradient(
    to top,
    transparent 8%,
    rgba(255, 216, 77, 0.9) 8%,
    rgba(255, 216, 77, 0.9) 55%,
    transparent 55%
  );
  padding: 0 0.2em;
}

.site-nav .btn {
  padding: 0.55rem 1.2rem;
  font-size: 0.92rem;
  box-shadow: 2px 2px 0 var(--ink);
}

.site-nav a.btn--primary {
  color: var(--ink);
  font-weight: 600;
}

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  padding: var(--space-1);
  color: var(--ink);
}

.nav-toggle svg {
  width: 28px;
  height: 28px;
}

@media (max-width: 880px) {
  .nav-toggle {
    display: block;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--paper);
    border-bottom: 2px solid var(--ink);
    padding: var(--space-2) var(--space-3) var(--space-3);
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav a {
    padding: 0.8rem 0;
    border-bottom: 1px dashed var(--line);
  }

  .site-nav a[aria-current="page"] {
    background: none;
    color: var(--pen-red);
  }

  .site-nav a:last-of-type {
    border-bottom: 0;
  }

  .site-nav .btn {
    margin-top: var(--space-2);
    border-bottom: 0;
  }
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding: var(--space-6) 0 calc(var(--space-6) + 1rem);
  overflow: hidden;
  /* Slightly stronger grid on the first page of the "book" */
  background-image:
    linear-gradient(rgba(43, 76, 137, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(43, 76, 137, 0.11) 1px, transparent 1px);
  background-size: 28px 28px;
  border-bottom: 1px solid var(--line);
}

/* Exercise-book red margin line */
.hero::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: clamp(1rem, 4vw, 3.5rem);
  width: 2px;
  background: rgba(217, 80, 47, 0.35);
}

.hero .container {
  position: relative;
}

.hero h1 {
  max-width: 660px;
}

.hero .lead {
  max-width: 580px;
  margin-top: var(--space-3);
}

/* Faint maths doodles floating in the margins */
.doodle {
  position: absolute;
  font-family: var(--font-display);
  font-style: italic;
  color: rgba(43, 76, 137, 0.16);
  user-select: none;
  pointer-events: none;
  line-height: 1;
}

.doodle--1 { top: 8%;  right: 4%;  font-size: 3.2rem; transform: rotate(-8deg); }
.doodle--2 { top: 42%; right: 14%; font-size: 2.2rem; transform: rotate(6deg); }
.doodle--3 { bottom: 12%; right: 6%; font-size: 2.6rem; transform: rotate(-4deg); }
.doodle--4 { top: 68%; right: 26%; font-size: 1.8rem; transform: rotate(10deg); }

@media (max-width: 880px) {
  .doodle { display: none; }
}

.hero-points {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-4);
  padding: 0;
}

.hero-points li {
  font-size: 0.95rem;
  color: var(--body-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hero-points li::before {
  content: "✓";
  color: var(--tick);
  font-weight: 700;
}

/* ---------- Cards ---------- */

.card {
  background: #fffdf7;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-paper);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 6px 6px 0 rgba(29, 49, 84, 0.1);
}

.card h3 {
  margin-bottom: var(--space-1);
}

.card p + p {
  margin-top: var(--space-2);
}

/* Softer card for supporting points — no heavy border */
.card--flat {
  background: #fffdf7;
  border: 1.5px solid var(--line);
  box-shadow: none;
}

.card--flat:hover {
  transform: none;
  box-shadow: none;
}

/* Sticker tag — slightly askew, like a label on a book */
.tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--highlight-soft);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 0.25rem 0.7rem;
  margin-bottom: var(--space-2);
  transform: rotate(-1.5deg);
}

/* ---------- Numbered steps ---------- */

.steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: var(--space-4);
  padding: 0;
  max-width: 720px;
}

.steps li {
  counter-increment: step;
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

/* Hand-circled numbers, like an answer circled in blue pen */
.steps li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--pen-blue);
  background: #fffdf7;
  border: 2.5px solid var(--pen-blue);
  border-radius: 52% 48% 55% 45% / 48% 55% 45% 52%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-3deg);
}

.steps li:nth-child(even)::before {
  border-radius: 46% 54% 48% 52% / 54% 46% 52% 48%;
  transform: rotate(2deg);
}

.steps h3 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

/* ---------- Checklist / cross-list (marking marks) ---------- */

.checklist,
.crosslist {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.checklist li,
.crosslist li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.checklist li::before {
  content: "✓";
  color: var(--tick);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.5;
  flex-shrink: 0;
}

.crosslist li::before {
  content: "✗";
  color: var(--pen-red);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.5;
  flex-shrink: 0;
}

.section--ink .checklist li::before { color: #8fd4ab; }
.section--ink .crosslist li::before { color: #f0a58e; }

/* ---------- Sticky note (was .notice) ---------- */

.notice {
  position: relative;
  background: var(--highlight-soft);
  border: 1.5px solid rgba(29, 49, 84, 0.15);
  border-radius: 4px;
  padding: var(--space-4);
  transform: rotate(-0.8deg);
  box-shadow: 3px 4px 8px rgba(29, 49, 84, 0.08);
}

/* Bit of tape holding the note down */
.notice::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 96px;
  height: 26px;
  transform: translateX(-50%) rotate(-2.5deg);
  background: rgba(240, 234, 214, 0.75);
  border-left: 1px dashed rgba(29, 49, 84, 0.12);
  border-right: 1px dashed rgba(29, 49, 84, 0.12);
}

.notice p + p,
.notice p + ul {
  margin-top: var(--space-2);
}

/* ---------- CTA band ---------- */

.cta-band {
  text-align: center;
}

.cta-band .section-intro {
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0;
}

.cta-band .section-intro h2::after {
  margin-left: auto;
  margin-right: auto;
}

.cta-band .btn-row {
  justify-content: center;
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--ink-deep);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  color: #c9d3e4;
  padding: var(--space-5) 0 var(--space-4);
  font-size: 0.95rem;
}

.site-footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (max-width: 700px) {
  .site-footer__grid {
    grid-template-columns: 1fr;
  }
}

.site-footer h4 {
  color: #fff;
  font-size: 1.05rem;
  margin-bottom: var(--space-2);
}

.site-footer ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}

.site-footer a {
  color: #c9d3e4;
}

.site-footer a:hover {
  color: var(--highlight);
}

.site-footer__strap {
  margin-top: var(--space-1);
  max-width: 340px;
}

.site-footer__legal {
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
  padding-top: var(--space-3);
  font-size: 0.85rem;
  color: #94a2ba;
}

/* ---------- Utilities ---------- */

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

.text-center { text-align: center; }
