/* ============================================================================
   calc21 — main.css
   Design system v0.1 (first pass, for Claude's review)

   Constraints this follows (DIRECTIVE design brief):
     - independent of MasterMathMentor: no shared layout, colours or visual language
     - light theme + dark mode
     - serif headings, clean sans body
     - generous whitespace
     - one confident accent colour
     - mobile-first, high contrast (WCAG AA)
     - fast: no framework, no CDN, no webfonts, no layout shift

   Deliberate deviation from the reference site (pamoja-or-ke): that site loads Tailwind
   from a CDN and Google Fonts. We ship a plain static stylesheet and use system font
   stacks instead, so there is no render-blocking third-party request, no FOUT/CLS, and
   nothing to fail on a school network that blocks CDNs.
   ========================================================================= */

/* ---- design tokens ------------------------------------------------------- */
:root {
  /* palette: warm paper + ink, one accent. Tune here, everything follows. */
  --paper:        #fbfaf7;
  --paper-2:      #f3f1ec;
  --card:         #ffffff;
  --ink:          #14161a;
  --ink-2:        #3d4249;
  --ink-3:        #6b7280;
  --rule:         #e3e0d9;

  --accent:       #9c3f0f;   /* copper — links, rules, emphasis */
  --accent-soft:  #b45309;
  --accent-wash:  #fdf3ea;
  --on-accent:    #ffffff;   /* text on an accent-filled button — 6.7:1 on the light accent */

  /* type: system stacks only — zero network cost, zero layout shift */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* scale */
  --step--1: 0.875rem;
  --step-0:  1.0625rem;
  --step-1:  1.25rem;
  --step-2:  1.5rem;
  --step-3:  1.9375rem;
  --step-4:  2.5rem;
  --step-5:  3.25rem;

  /* space */
  --sp-1: 0.5rem;
  --sp-2: 1rem;
  --sp-3: 1.5rem;
  --sp-4: 2.25rem;
  --sp-5: 3.5rem;
  --sp-6: 5rem;

  --measure: 68ch;
  --wrap:    68rem;
  --radius:  6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:       #16171a;
    --paper-2:     #1d1f23;
    --card:        #1f2126;
    --ink:         #ecebe7;
    --ink-2:       #c3c2bd;
    --ink-3:       #8f939b;
    --rule:        #32353b;
    --accent:      #e8915a;
    --accent-soft: #f0a878;
    --accent-wash: #241d18;
    --on-accent:   #17130f;    /* dark text on the light dark-mode accent — 7.6:1; white would be 2.4:1 and fail AA */
  }
}
:root[data-theme="dark"] {
  --paper:       #16171a;
  --paper-2:     #1d1f23;
  --card:        #1f2126;
  --ink:         #ecebe7;
  --ink-2:       #c3c2bd;
  --ink-3:       #8f939b;
  --rule:        #32353b;
  --accent:      #e8915a;
  --accent-soft: #f0a878;
  --accent-wash: #241d18;
  --on-accent:   #17130f;    /* dark text on the light dark-mode accent — 7.6:1; white would be 2.4:1 and fail AA */
}

/* ---- reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; height: auto; display: block; }

/* ---- typography ---------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 var(--sp-2);
  text-wrap: balance;
}
h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
p  { margin: 0 0 var(--sp-2); text-wrap: pretty; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-soft); }

.lede { font-size: var(--step-1); color: var(--ink-2); }

/* ---- layout -------------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--sp-3); }
.prose { max-width: var(--measure); }
.section { padding-block: var(--sp-5); }
.section--tight { padding-block: var(--sp-4); }
.stack > * + * { margin-top: var(--sp-3); }

/* the small overline used above section headings */
.kicker {
  font-family: var(--sans); font-size: var(--step--1); font-weight: 650;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
  margin: 0 0 var(--sp-1);
}

/* ---- masthead ------------------------------------------------------------ */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky; top: 0; z-index: 50;
}
.masthead__bar {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 4.25rem;
}
.brand {
  font-family: var(--serif); font-size: var(--step-2); font-weight: 700;
  letter-spacing: -0.02em; color: var(--ink); text-decoration: none;
  display: flex; align-items: baseline; gap: 0.5rem; margin-right: auto;
  min-width: 0; flex-shrink: 1;
}
.brand span { color: var(--accent); }
.brand small {
  font-family: var(--sans); font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap;
}
/* The tagline is the first thing to go when the nav needs the room. */
@media (max-width: 78em) { .brand small { display: none; } }

.nav { display: flex; align-items: center; gap: 1.15rem; flex-wrap: nowrap; }
.nav a {
  color: var(--ink-2); text-decoration: none; font-size: var(--step--1);
  font-weight: 550; padding-block: 0.35rem; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.nav__toggle { display: none; }
.theme-toggle {
  background: none; border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--ink-2); cursor: pointer; font-size: var(--step--1);
  padding: 0.3rem 0.6rem; font-family: var(--sans);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--sans); font-size: var(--step--1); font-weight: 650;
  line-height: 1; text-decoration: none; cursor: pointer; white-space: nowrap;
  padding: 0.75rem 1.15rem; border-radius: var(--radius);
  border: 1px solid transparent;
}
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-soft); color: var(--on-accent); }
.btn--ghost { border-color: var(--rule); color: var(--ink); background: transparent; }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
/* A button in the masthead: `.nav a` (0,1,1) outranks `.btn--primary` (0,1,0),
   so without this the label is painted in nav-link colour on the accent
   background — dark on brown in light mode, and an AA contrast failure. */
.nav .btn--primary, .nav .btn--primary:hover { color: var(--on-accent); }

/* ---- cards --------------------------------------------------------------- */
.grid { display: grid; gap: var(--sp-3); }
@media (min-width: 46em) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 46em) { .grid--2 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: var(--sp-3); display: flex; flex-direction: column;
}
.card__kicker { font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--sp-1); }
.card h3 { font-size: var(--step-1); margin-bottom: var(--sp-1); }
.card__more { margin-top: auto; padding-top: var(--sp-2); font-size: var(--step--1); }

/* ---- hero ---------------------------------------------------------------- */
.hero { padding-block: var(--sp-5) var(--sp-4); border-bottom: 1px solid var(--rule); }
.hero h1 { max-width: 22ch; }
.hero .lede { max-width: 46ch; }

/* ---- house ad (MasterMathMentor) ----------------------------------------- */
/* Always visually distinct from calc21 content: dashed rule + explicit label. */
.housead {
  border: 1px dashed var(--rule); border-radius: var(--radius);
  background: var(--paper-2); padding: var(--sp-3);
}
.housead__label {
  font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--sp-1);
}
.housead h3 { font-size: var(--step-1); margin-bottom: var(--sp-1); }
.housead p { color: var(--ink-2); font-size: var(--step--1); margin-bottom: var(--sp-2); }

/* ---- signup -------------------------------------------------------------- */
.signup { background: var(--accent-wash); border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule); }
.signup form { display: flex; flex-wrap: wrap; gap: var(--sp-1); max-width: 30rem; }
.signup input[type="email"] {
  flex: 1 1 14rem; padding: 0.7rem 0.8rem; font: inherit; font-size: var(--step--1);
  color: var(--ink); background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--radius);
}
.signup input[type="email"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.signup .note { font-size: 0.75rem; color: var(--ink-3); }

/* Visually hidden, still read by screen readers: labels for the email input. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- footer -------------------------------------------------------------- */
.foot { border-top: 1px solid var(--rule); padding-block: var(--sp-4);
  color: var(--ink-3); font-size: var(--step--1); }
.foot__cols { display: grid; gap: var(--sp-3); }
@media (min-width: 46em) { .foot__cols { grid-template-columns: 2fr 1fr 1fr; } }
.foot a { color: var(--ink-2); text-decoration: none; }
.foot a:hover { color: var(--accent); }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li { margin-bottom: 0.4rem; }
.foot__legal { margin-top: var(--sp-4); padding-top: var(--sp-2);
  border-top: 1px solid var(--rule); font-size: 0.75rem; }

/* ---- utility ------------------------------------------------------------- */
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--sp-2); top: var(--sp-2); background: var(--card);
  padding: 0.5rem 0.75rem; border-radius: var(--radius); z-index: 100; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- article + directory entries (added 2026-10-08 for the first content) -- */
.meta { font-size: var(--step--1); color: var(--ink-3); margin: 0 0 var(--sp-3); }
.prose h2 { margin-top: var(--sp-4); }
.prose h3 { margin-top: var(--sp-3); }
.prose ul, .prose ol { padding-left: 1.25rem; margin: 0 0 var(--sp-2); }
.prose li { margin-bottom: 0.45rem; }
.prose li > ul, .prose li > ol { margin-top: 0.45rem; }
.sources { font-size: var(--step--1); color: var(--ink-2); margin-top: var(--sp-3);
  padding-top: var(--sp-2); border-top: 1px solid var(--rule); }
.sources li { margin-bottom: 0.5rem; }

/* The one-sentence fix closing each item of a pedagogy listicle (2026-10-11). */
.fix { background: var(--paper-2); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--sp-2) var(--sp-3); margin: var(--sp-2) 0 var(--sp-3); }

/* small metadata pills used on Library and Who's Who entries */
.tag { display: inline-block; font-size: 0.6875rem; font-weight: 650;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-wash); border: 1px solid var(--rule);
  border-radius: 999px; padding: 0.15rem 0.55rem; margin: 0 0.35rem 0.35rem 0; }
.entry h3 { font-size: var(--step-1); margin-bottom: var(--sp-1); }
.entry__best { color: var(--ink-2); }
.entry__foot { margin-top: auto; padding-top: var(--sp-2); font-size: var(--step--1); }

/* ---- first-year checklist page (added 2026-10-14) ------------------------ */
/* A printable one-pager: tick-boxes, right-aligned weightings, a print-only footer. */
.checklist { list-style: none; padding-left: 0; }
.checklist li { position: relative; padding-left: 1.6em; }
.checklist li::before {
  content: ""; position: absolute; left: 0; top: 0.45em;
  width: 0.8em; height: 0.8em; border: 1.5px solid var(--ink-3); border-radius: 2px;
}
.units { list-style: none; padding-left: 0; }
.units li {
  display: flex; justify-content: space-between; gap: var(--sp-2);
  border-bottom: 1px dotted var(--rule); padding: 0.28rem 0;
}
.units span { color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.plain { padding-left: 1.1rem; }
.fine { font-size: var(--step--1); color: var(--ink-2); }
.callout {
  background: var(--paper-2); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-3);
}
.callout p { margin: 0; }
.hero__aside { color: var(--ink-3); font-size: var(--step--1); }
.print-only { display: none; }

/* ---- print --------------------------------------------------------------- */
/* The checklist must fit one printed page. Forcing white paper / black ink matters:
   without it a dark-mode reader prints near-white text onto white paper. */
@page { margin: 10mm; }
@media print {
  :root,
  :root[data-theme="dark"],
  :root:not([data-theme="light"]) {
    --paper: #fff !important;
    --paper-2: #fff !important;
    --card: #fff !important;
    --ink: #000 !important;
    --ink-2: #1c1c1c !important;
    --ink-3: #3a3a3a !important;
    --rule: #8a8a8a !important;
    --accent: #000 !important;
    --accent-soft: #000 !important;
    --accent-wash: #fff !important;
    --on-accent: #fff !important;
  }
  body { font-size: 9pt; line-height: 1.3; background: #fff; }
  .skip, .masthead, .foot, .signup, .no-print { display: none !important; }
  .print-only { display: block; }
  a { color: #000; text-decoration: none; }
  .wrap { max-width: none; padding-inline: 0; }
  .prose { max-width: none; }
  .hero { padding-block: 0 0.3rem; }
  .hero h1 { font-size: 15pt; max-width: none; margin-bottom: 0.25rem; }
  .hero .lede { font-size: 9.5pt; max-width: none; margin-bottom: 0.2rem; }
  .hero .meta { margin-bottom: 0; font-size: 8pt; }
  .section, .section--tight { padding-block: 0.3rem; }
  h1, h2, h3, h4 { break-after: avoid; }
  h2 { font-size: 11pt; margin-bottom: 0.2rem; }
  h3 { font-size: 9.5pt; margin-bottom: 0.15rem; }
  p { margin-bottom: 0.35rem; }
  .prose h2 { margin-top: 0.5rem; }
  .prose h3 { margin-top: 0.35rem; }
  .prose ul, .prose ol { margin-bottom: 0.35rem; }
  .checklist li, .units li, .plain li { break-inside: avoid; margin-bottom: 0.15rem; }
  .checklist li::before { border-color: #000; top: 0.38em; }
  .units li { padding: 0.16rem 0; }
  .fine { font-size: 8pt; }
  .sources { font-size: 7.2pt; line-height: 1.28; }
  .printfoot {
    margin-top: 0.25rem; padding-top: 0.25rem; border-top: 1px solid #8a8a8a;
    color: #333; font-size: 7.2pt;
  }
}

/* ---- small screens ------------------------------------------------------- */
@media (max-width: 45.99em) {
  h1 { font-size: var(--step-4); }
  .nav__toggle {
    display: inline-block; margin-left: auto; background: none;
    border: 1px solid var(--rule); border-radius: var(--radius);
    color: var(--ink); padding: 0.35rem 0.6rem; font: inherit; font-size: var(--step--1);
    cursor: pointer;
  }
  .nav {
    display: none; flex-basis: 100%; flex-direction: column; align-items: flex-start;
    gap: 0; padding-bottom: var(--sp-2);
  }
  .masthead__bar { flex-wrap: wrap; }
  .nav[data-open="true"] { display: flex; }
  .nav a { padding-block: 0.6rem; width: 100%; }
}
