/* ==========================================================================
   finance.mathsschools.co.uk — design system
   An "annual report" identity: warm ledger paper, deep green + audit gold,
   serif display headings, and tabular lining figures for every number.
   Deliberately distinct from the parent site's teal, EMS's warm orange and
   the tech dossier's slate/indigo.
   ========================================================================== */

:root {
  --ink: #1b201b;
  --ink-soft: #414a41;
  --muted: #6e766c;
  --paper: #f6f3ea;
  --surface: #fffefa;
  --surface-2: #efeadd;
  --surface-3: #e7e1d0;
  --border: #ded6c2;
  --rule: #e9e3d3;
  --accent: #166a45;
  --accent-dark: #10502f;
  --accent-tint: #e2efe5;
  --gold: #a37e22;
  --gold-bright: #b8933a;
  --gold-tint: #f4ead1;
  --wire: #a8a08a;
  --good: #15803d;
  --good-tint: #dcfce7;
  --warn: #a16207;
  --warn-tint: #fdf2d3;
  --bad: #b91c1c;
  --bad-tint: #fee2e2;
  --pos: #15803d;
  --neg: #b91c1c;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, Cambria, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --container: 1120px;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9efe6;
    --ink-soft: #c4cdc0;
    --muted: #8f998b;
    --paper: #10150f;
    --surface: #171d15;
    --surface-2: #1d251b;
    --surface-3: #242e21;
    --border: #2e3829;
    --rule: #1b2219;
    --accent: #5cbd8b;
    --accent-dark: #82d3ab;
    --accent-tint: #16281d;
    --gold: #d3aa54;
    --gold-bright: #e2be6d;
    --gold-tint: #2a2312;
    --wire: #4d5a45;
    --good: #34d399;
    --good-tint: #0c2a1e;
    --warn: #fbbf24;
    --warn-tint: #2c2410;
    --bad: #f87171;
    --bad-tint: #2c1616;
    --pos: #34d399;
    --neg: #f87171;
  }
}
:root[data-theme="dark"] {
  --ink: #e9efe6; --ink-soft: #c4cdc0; --muted: #8f998b; --paper: #10150f; --surface: #171d15;
  --surface-2: #1d251b; --surface-3: #242e21; --border: #2e3829; --rule: #1b2219; --accent: #5cbd8b;
  --accent-dark: #82d3ab; --accent-tint: #16281d; --gold: #d3aa54; --gold-bright: #e2be6d; --gold-tint: #2a2312;
  --wire: #4d5a45; --good: #34d399; --good-tint: #0c2a1e; --warn: #fbbf24; --warn-tint: #2c2410;
  --bad: #f87171; --bad-tint: #2c1616; --pos: #34d399; --neg: #f87171;
}
:root[data-theme="light"] {
  --ink: #1b201b; --ink-soft: #414a41; --muted: #6e766c; --paper: #f6f3ea; --surface: #fffefa;
  --surface-2: #efeadd; --surface-3: #e7e1d0; --border: #ded6c2; --rule: #e9e3d3; --accent: #166a45;
  --accent-dark: #10502f; --accent-tint: #e2efe5; --gold: #a37e22; --gold-bright: #b8933a; --gold-tint: #f4ead1;
  --wire: #a8a08a; --good: #15803d; --good-tint: #dcfce7; --warn: #a16207; --warn-tint: #fdf2d3;
  --bad: #b91c1c; --bad-tint: #fee2e2; --pos: #15803d; --neg: #b91c1c;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* faint ledger ruling */
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--rule) 31px, var(--rule) 32px);
  background-attachment: fixed;
}
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 700; line-height: 1.14; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: clamp(2.05rem, 4.2vw, 3rem); margin: 0 0 0.4em; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.95rem); margin: 1.7em 0 0.55em; }
h3 { font-size: 1.22rem; margin: 1.3em 0 0.4em; }
h4 { font-size: 1rem; margin: 0 0 0.3em; font-family: var(--font-sans); }
p { margin: 0 0 1em; }
a { color: var(--accent-dark); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
a:hover { text-decoration-thickness: 2px; }
.mt-0 { margin-top: 0; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
img, svg { max-width: 100%; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* every figure in lining tabular numerals */
.num, .stat__value, .ledger td, .kv-num { font-variant-numeric: lining-nums tabular-nums; }
.num.pos { color: var(--pos); }
.num.neg { color: var(--neg); }
.num.muted { color: var(--muted); }

.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.container--narrow { max-width: 780px; }
.section { padding: 3em 0; }
.section--alt { background: var(--surface-2); border-block: 1px solid var(--border); }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 10px 16px; z-index: 100; }
.skip-link:focus { left: 12px; top: 12px; }

/* ---- Header --------------------------------------------------------- */
.site-header { border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.15) blur(8px); position: sticky; top: 0; z-index: 20; }
.site-header__bar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand__mark { flex: none; }
.brand__name { font-family: var(--font-serif); font-size: 1.08rem; letter-spacing: -0.01em; }
.brand__dot { color: var(--gold); }
.brand__tld { color: var(--muted); font-weight: 500; font-style: italic; }
.nav { display: flex; gap: 20px; margin-left: auto; flex-wrap: wrap; }
.nav a { color: var(--ink-soft); text-decoration: none; font-size: 0.92rem; font-weight: 600; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a.is-active { color: var(--accent-dark); border-bottom-color: var(--gold); }

/* ---- Hero ------------------------------------------------------------ */
.hero { padding: 3.2em 24px 1.4em; }
.hero__kicker { font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.76rem; font-weight: 700; color: var(--gold); margin-bottom: 0.9em; }
.hero__kicker::before { content: ""; display: inline-block; width: 26px; height: 1px; background: var(--gold); vertical-align: middle; margin-right: 10px; }
.hero__lede { font-size: 1.16rem; color: var(--ink-soft); max-width: 62ch; }
.hero__meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1.1em; align-items: center; }

.breadcrumbs { padding-top: 1.4em; font-size: 0.85rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs .sep { margin: 0 8px; color: var(--wire); }

/* ---- Stat strip ------------------------------------------------------ */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1.6em 0; }
.stat-strip > div { background: var(--surface); padding: 18px 20px 14px; }
.stat__value { font-family: var(--font-serif); font-size: 1.75rem; font-weight: 700; color: var(--accent-dark); line-height: 1.1; }
.stat__label { font-size: 0.84rem; color: var(--muted); margin-top: 5px; }
.stat__foot { font-size: 0.74rem; color: var(--wire); margin-top: 3px; }

/* ---- Cards / grid ---------------------------------------------------- */
.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; color: inherit; text-decoration: none; transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease; position: relative; }
a.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 10%, transparent); }
.card h3 { margin: 0.15em 0 0.35em; font-size: 1.14rem; }
.card p { margin: 0; color: var(--ink-soft); font-size: 0.94rem; }
.card__eyebrow { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.11em; color: var(--gold); }
.card__foot { margin-top: 0.9em; font-size: 0.85rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- Tables (ledger) ------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
caption { text-align: left; padding: 14px 16px 4px; font-weight: 700; font-family: var(--font-serif); font-size: 1.02rem; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); border-bottom: 2px solid var(--border); background: var(--surface-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-tint) 45%, transparent); }
.table-foot { font-size: 0.8rem; color: var(--muted); padding: 10px 16px 12px; margin: 0; border-top: 1px solid var(--rule); }
/* ledger: figures right-aligned, first column wide */
.ledger td:not(:first-child), .ledger th:not(:first-child) { text-align: right; white-space: nowrap; }
.ledger td:first-child { color: var(--ink-soft); min-width: 220px; }
.ledger .yr { font-family: var(--font-serif); font-weight: 700; letter-spacing: 0; text-transform: none; font-size: 0.9rem; color: var(--ink); }
.ledger tbody tr:has(strong) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* comparison table on network page */
.compare td:not(:first-child), .compare th:not(:first-child) { text-align: right; white-space: nowrap; }

/* ---- Dossier (entity facts) ------------------------------------------ */
.dossier { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; margin: 1.3em 0; }
.dossier__row { display: grid; grid-template-columns: 200px 1fr; border-bottom: 1px solid var(--rule); }
.dossier__row:last-child { border-bottom: none; }
.dossier__k { padding: 11px 16px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); border-right: 1px solid var(--rule); }
.dossier__v { padding: 11px 16px; font-size: 0.94rem; }

/* ---- Key facts dl ---------------------------------------------------- */
.key-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 1.2em 0; font-size: 0.95rem; }
.key-facts dt { font-weight: 700; color: var(--ink-soft); }
.key-facts dd { margin: 0; }

/* ---- Badges ---------------------------------------------------------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; border: 1px solid transparent; white-space: nowrap; }
.badge--neutral { background: var(--surface-3); color: var(--ink-soft); border-color: var(--border); }
.badge--accent { background: var(--accent-tint); color: var(--accent-dark); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge--gold { background: var(--gold-tint); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }
.badge--good { background: var(--good-tint); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.badge--warn { background: var(--warn-tint); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge--bad { background: var(--bad-tint); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

/* ---- Callouts / noteboxes -------------------------------------------- */
.callout { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--surface); border-radius: 10px; padding: 16px 20px; margin: 1.4em 0; }
.callout--gold { border-left-color: var(--gold); }
.callout--warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-tint) 40%, var(--surface)); }
.callout--bad { border-left-color: var(--bad); }
.callout__title { font-weight: 700; font-family: var(--font-serif); margin-bottom: 0.35em; font-size: 1.04rem; }
.callout p:last-child { margin-bottom: 0; }
.notebox { background: var(--surface-2); border: 1px dashed var(--wire); border-radius: 10px; padding: 12px 16px; font-size: 0.88rem; color: var(--ink-soft); margin: 1.2em 0; }
.notebox p:last-child { margin-bottom: 0; }

/* ---- Findings -------------------------------------------------------- */
.finding { display: grid; grid-template-columns: 64px 1fr; gap: 18px; padding: 26px 0; border-bottom: 1px solid var(--border); }
.finding:last-child { border-bottom: none; }
.finding__n { font-family: var(--font-serif); font-size: 2rem; font-weight: 700; color: var(--gold); line-height: 1; padding-top: 2px; font-variant-numeric: lining-nums tabular-nums; }
.finding__body h3 { margin: 0 0 0.4em; }
.finding__body p { color: var(--ink-soft); }
.finding__schools { font-size: 0.88rem; }
.finding__src { font-size: 0.8rem; color: var(--muted); margin-bottom: 0; }
.finding__src a { color: var(--muted); }

/* ---- Trend bars ------------------------------------------------------ */
.trend { display: inline-block; vertical-align: middle; }

/* ---- Source list ----------------------------------------------------- */
.source-list { list-style: none; padding: 0; margin: 1em 0; font-size: 0.88rem; color: var(--ink-soft); }
.source-list li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.source-list li:last-child { border-bottom: none; }
.src-n { color: var(--gold); font-weight: 700; flex: none; font-variant-numeric: tabular-nums; }
.source-list a { overflow-wrap: anywhere; }

/* ---- Pills ----------------------------------------------------------- */
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 1em 0; }
.pill-list a, .pill-list span { display: inline-block; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 0.88rem; text-decoration: none; color: var(--ink-soft); }
.pill-list a:hover { border-color: var(--accent); color: var(--accent-dark); }

/* ---- Footer ---------------------------------------------------------- */
.site-footer { margin-top: 4em; border-top: 1px solid var(--border); background: var(--surface-2); padding: 2.6em 0 1.6em; font-size: 0.9rem; }
.site-footer .grid { grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.site-footer h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.7em; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.45em; }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent-dark); text-decoration: underline; }
.foot-note { color: var(--muted); font-size: 0.82rem; margin-top: 0.8em; }
.site-footer .bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 2.2em; padding-top: 1.2em; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 860px) {
  .site-footer .grid { grid-template-columns: 1fr 1fr; }
  .dossier__row { grid-template-columns: 1fr; }
  .dossier__k { border-right: none; border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
  .finding { grid-template-columns: 44px 1fr; gap: 12px; }
  .finding__n { font-size: 1.5rem; }
}
@media (max-width: 560px) {
  .site-header__bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .nav { margin-left: 0; gap: 14px; }
  .key-facts { grid-template-columns: 1fr; gap: 2px; }
  .key-facts dt { margin-top: 0.6em; }
}

/* ---- Print ----------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .skip-link { display: none; }
  body { background: #fff; color: #000; }
  .table-wrap { border: 1px solid #999; }
  a { color: inherit; text-decoration: none; }
}
