/* Shimsy Maths — site styles.
   The palette is the app's own "revision desk": cream paper and ink by day, a warm
   evening desk by night. Colours are defined once as tokens and redefined for dark. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Kalam";
  src: url("fonts/kalam-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f7f2e9;
  --paper-raised: #fffdf8;
  --paper-sunken: #efe8da;
  --ink: #23211c;
  --ink-soft: #6e665a;
  --rule: #e0d7c6;
  --brand: #2a3a5c;
  --brand-contrast: #fffdf8;
  --amber-ink: #94601f;
  --highlighter: #e8a33d;
  --tick: #2f7147;
  --sticky: #f7de86;
  --sticky-ink: #5c4000;
  --grid: rgba(42, 58, 92, 0.07);
  --margin: rgba(194, 96, 63, 0.28);
  --shadow: rgba(35, 33, 28, 0.08);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hand: "Kalam", "Comic Neue", "Segoe Print", cursive;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1916;
    --paper-raised: #262320;
    --paper-sunken: #14130f;
    --ink: #ece5d7;
    --ink-soft: #a69e8e;
    --rule: #39342c;
    --brand: #9db2dd;
    --brand-contrast: #1b1916;
    --amber-ink: #e8a33d;
    --tick: #70c58e;
    --sticky: #463819;
    --sticky-ink: #e8c97a;
    --grid: rgba(236, 229, 215, 0.045);
    --margin: rgba(194, 96, 63, 0.35);
    --shadow: rgba(0, 0, 0, 0.35);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  /* Squared exercise-book paper. */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
}

a { color: var(--brand); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--highlighter); outline-offset: 2px; border-radius: 2px; }

.skip {
  position: absolute; left: 16px; top: -48px;
  background: var(--brand); color: var(--brand-contrast);
  padding: 8px 12px; border-radius: 4px; z-index: 10;
}
.skip:focus { top: 12px; }

/* ── Page frame ─────────────────────────────────────────────────────────── */

.page {
  position: relative;
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 16px;
}

/* The margin rule an exercise book is printed with. */
.page::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 4px;
  width: 2px; background: var(--margin);
  pointer-events: none;
}
@media (min-width: 720px) {
  .page { padding: 0 40px 0 72px; }
  .page::before { left: 48px; }
}

.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}
.brand { display: inline-flex; color: var(--ink); text-decoration: none; }
.brand picture { display: block; }
.wordmark { display: block; height: 30px; width: auto; }
@media (min-width: 720px) { .wordmark { height: 36px; } }

.site-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-nav a { color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: 0.95rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

main { padding: 32px 0 56px; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.1rem); margin: 0 0 16px; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); margin: 48px 0 12px; }
h3 { font-size: 1.2rem; margin: 28px 0 8px; }
p, ul, ol { margin: 0 0 16px; }
li + li { margin-top: 6px; }

.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 38rem; }

/* ── Home ───────────────────────────────────────────────────────────────── */

.hero { display: grid; gap: 28px; align-items: center; padding-top: 8px; }
@media (min-width: 900px) { .hero { grid-template-columns: 1.35fr 1fr; gap: 48px; } }

/* The headline is handwritten, like the app's own labels. Only Kalam Regular ships, so the
   weight stays at 400 rather than a faked bold. */
.headline {
  font-family: var(--hand); font-weight: 400;
  font-size: clamp(2.4rem, 1.6rem + 3.2vw, 3.8rem); line-height: 1.15;
  letter-spacing: 0;
}

.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 24px; }
.button {
  display: inline-block;
  background: var(--brand); color: var(--brand-contrast);
  font-weight: 700; text-decoration: none;
  padding: 12px 20px; border-radius: 6px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.button[aria-disabled="true"] { cursor: default; }

.hand-note {
  font-family: var(--hand); font-size: 1.2rem; color: var(--ink-soft);
  display: inline-block; transform: rotate(-2deg);
}

.sticky {
  font-family: var(--hand);
  background: var(--sticky); color: var(--sticky-ink);
  padding: 22px 24px 20px;
  font-size: 1.35rem; line-height: 1.35;
  transform: rotate(-1.6deg);
  box-shadow: 4px 6px 0 var(--shadow);
  max-width: 24rem; justify-self: center;
  position: relative;
}
.sticky::before { /* a strip of tape */
  content: ""; position: absolute; top: -12px; left: 50%;
  width: 84px; height: 24px; transform: translateX(-50%) rotate(2deg);
  background: color-mix(in srgb, var(--paper-raised) 70%, transparent);
  border: 1px solid var(--rule);
}
.sticky ul { list-style: none; padding: 0; margin: 0; }
.sticky li::before { content: "✓ "; }

.card-grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card {
  background: var(--paper-raised);
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  padding: 20px 22px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.card h3 { margin-top: 0; }
/* Written in the margin in marker, the way the app labels things by hand. */
.card .tag {
  display: inline-block; font-family: var(--hand); font-size: 1.25rem; line-height: 1.2;
  color: var(--amber-ink); margin-bottom: 4px; transform: rotate(-1.5deg);
}
.card ul { padding-left: 1.2em; margin-bottom: 0; }

/* ── Legal and support text ─────────────────────────────────────────────── */

.prose { max-width: 44rem; }
.prose h2 { font-size: 1.4rem; margin-top: 36px; }
.updated { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: 28px; }
.summary {
  background: var(--paper-raised); border-left: 4px solid var(--brand);
  padding: 16px 20px; border-radius: 0 6px 6px 0; margin: 0 0 28px;
}
.summary p:last-child, .summary ul:last-child { margin-bottom: 0; }

details {
  background: var(--paper-raised); border: 1.5px solid var(--rule);
  border-radius: 6px; padding: 12px 18px; margin-bottom: 10px;
}
summary { cursor: pointer; font-weight: 700; }
details[open] summary { margin-bottom: 8px; }
details p:last-child { margin-bottom: 0; }

/* ── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 24px 0 40px;
  color: var(--ink-soft); font-size: 0.9rem;
}
.site-footer p { margin-bottom: 8px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 12px; }
.site-footer nav a { color: var(--ink-soft); }

@media (prefers-reduced-motion: no-preference) {
  .button { transition: transform 120ms ease, box-shadow 120ms ease; }
  .button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
}
