/* Design tokens -------------------------------------------------------- */
@font-face { font-family: 'Atkinson'; src: url('/assets/fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url('/assets/fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/assets/fonts/bricolage-var.woff2') format('woff2-variations'); font-weight: 300 800; font-display: swap; }

:root {
  --paper: #f6f8fc;
  --sheet: #ffffff;
  --ink: #16213d;
  --ink-soft: #4a5675;
  --pen: #2140c4;
  --pen-dark: #18309a;
  --grid: #e3e8f2;
  --mark: #ffe45c;
  --redpen: #b42335;
  --ok: #1f7a4d;
  --radius-s: 6px;
  --radius-m: 12px;
  --font-body: 'Atkinson', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Bricolage', 'Atkinson', system-ui, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3125rem;
  --step-2: 1.625rem;
  --step-3: 2.125rem;
  --step-4: clamp(2.25rem, 1.6rem + 2.6vw, 3.25rem);
  --measure: 68ch;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--font-body);
}
img { max-width: 100%; height: auto; }
a { color: var(--pen); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--pen-dark); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--sheet); padding: .5rem 1rem; z-index: 10; }

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: var(--step-4); font-weight: 750; letter-spacing: -0.025em; }
h2 { font-size: var(--step-2); font-weight: 700; margin-top: 2.2em; }
h3 { font-size: var(--step-1); font-weight: 650; margin-top: 1.6em; }
p, ul, ol { margin: 0 0 1em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }

/* Header / footer ------------------------------------------------------ */
.site-head { border-bottom: 1px solid var(--grid); background: var(--sheet); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; }
.brand { font-family: var(--font-head); font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--pen); }
.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--step--1); padding: .5rem 0; }
.site-nav a[aria-current="page"], .site-nav a:hover { color: var(--pen); box-shadow: inset 0 -2px 0 var(--pen); }

.site-foot { margin-top: 5rem; border-top: 1px solid var(--grid); background: var(--sheet); font-size: var(--step--1); color: var(--ink-soft); }
.site-foot .wrap { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); padding-top: 2.5rem; padding-bottom: 2.5rem; }
.site-foot h2 { font-size: var(--step-0); margin: 0 0 .5rem; color: var(--ink); }
.site-foot ul { list-style: none; padding: 0; margin: 0; }
.site-foot li { margin: .3rem 0; }
.site-foot a { color: var(--ink-soft); }

/* Page head ------------------------------------------------------------ */
.crumbs { font-size: var(--step--1); color: var(--ink-soft); margin: 1.5rem 0 1rem; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: 0; }
.crumbs li + li::before { content: '/'; margin-right: .35rem; color: #9aa4bd; }
.crumbs a { color: var(--ink-soft); }
.lede { font-size: var(--step-1); color: var(--ink-soft); max-width: 60ch; line-height: 1.5; }

/* Tool ----------------------------------------------------------------- */
.tool {
  margin: 2rem 0 1rem;
  background-color: var(--sheet);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  border: 1px solid #cfd7e6;
  border-radius: var(--radius-m);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) { .tool { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.tool-inputs, .tool-result { min-width: 0; }
.tool-inputs { padding: 1.5rem; background: rgba(255,255,255,.9); border-radius: var(--radius-m) var(--radius-m) 0 0; }
@media (min-width: 900px) { .tool-inputs { border-radius: var(--radius-m) 0 0 var(--radius-m); border-right: 1px solid var(--grid); } }
.tool-result { padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; min-height: 220px; }

.field { margin-bottom: 1.1rem; }
.field label, .field .label { display: block; font-weight: 700; margin-bottom: .3rem; }
.field .hint { display: block; font-size: var(--step--1); color: var(--ink-soft); margin-top: .25rem; }
.input-wrap { position: relative; max-width: 16rem; }
.input-wrap .unit { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); color: var(--ink-soft); pointer-events: none; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1.5px solid #b9c3d8;
  border-radius: var(--radius-s);
  padding: .65rem .8rem;
  min-height: 48px;
}
.input-wrap input { padding-right: 2.2rem; }
textarea { min-height: 140px; resize: vertical; font-variant-numeric: tabular-nums; }
input:focus, textarea:focus, select:focus { border-color: var(--pen); outline: 3px solid rgba(33,64,196,.18); outline-offset: 0; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--redpen); }
.error { color: var(--redpen); font-size: var(--step--1); font-weight: 700; margin-top: .3rem; }
.error:empty { display: none; }

.rows { width: 100%; border-collapse: collapse; margin-bottom: .75rem; }
.rows th { text-align: left; font-size: var(--step--1); color: var(--ink-soft); font-weight: 700; padding: 0 .4rem .3rem 0; }
.rows td { padding: 0 .4rem .5rem 0; vertical-align: top; }
.rows input { min-height: 44px; }
.icon-btn { background: none; border: 0; color: var(--ink-soft); font-size: 1.4rem; line-height: 1; width: 44px; height: 44px; cursor: pointer; border-radius: var(--radius-s); }
.icon-btn:hover { color: var(--redpen); background: #fbeef0; }

.btn { font: 700 var(--step-0)/1 var(--font-body); border-radius: var(--radius-s); padding: .85rem 1.3rem; cursor: pointer; border: 1.5px solid var(--pen); min-height: 48px; }
.btn-primary { background: var(--pen); color: #fff; }
.btn-primary:hover { background: var(--pen-dark); border-color: var(--pen-dark); }
.btn-quiet { background: transparent; color: var(--pen); }
.btn-quiet:hover { background: #eef1fb; }
.link-btn { border: 0; padding: 0; font: inherit; color: var(--pen); text-decoration: underline; cursor: pointer; background: none; min-height: 24px; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.group-label { font-weight: 700; margin: 0 0 .4rem; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1.5px solid #b9c3d8; border-radius: var(--radius-s); overflow: hidden; margin-bottom: 1rem; }
.seg button { font: 700 var(--step--1) var(--font-body); background: var(--sheet); color: var(--ink-soft); border: 0; padding: .6rem 1rem; cursor: pointer; min-height: 44px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* The one loud element: the highlighted answer */
.answer-label { font-weight: 700; color: var(--ink-soft); margin: 0 0 .25rem; }
.answer {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2.75rem, 2rem + 3vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 0 0 .5rem;
  display: inline-block;
  align-self: flex-start;
  padding: 0 .15em;
  background: linear-gradient(100deg, transparent 0 2%, var(--mark) 2% 97%, transparent 97%) no-repeat 0 62% / 100% 58%;
}
.answer.is-bad { background-image: linear-gradient(100deg, transparent 0 2%, #ffc9cf 2% 97%, transparent 97%); }
.answer-note { margin: 0; max-width: 36ch; }
.answer-empty { color: var(--ink-soft); }
.result-extra { margin-top: 1rem; font-size: var(--step--1); color: var(--ink-soft); }
.stat-list { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: .5rem 0 0; font-variant-numeric: tabular-nums; }
.stat-list dt { color: var(--ink-soft); }
.stat-list dd { margin: 0; font-weight: 700; }
.mini-table { border-collapse: collapse; font-size: var(--step--1); margin-top: .75rem; font-variant-numeric: tabular-nums; }
.mini-table th, .mini-table td { border-bottom: 1px solid var(--grid); padding: .35rem .9rem .35rem 0; text-align: left; }
.mini-table th { color: var(--ink-soft); }

/* Working: an actual sequence, so numbered */
.working { background: var(--sheet); border: 1px solid var(--grid); border-left: 4px solid var(--pen); border-radius: var(--radius-s); padding: 1rem 1.25rem; margin: 0 0 2rem; }
.working h2 { font-size: var(--step-1); margin: 0 0 .5rem; }
.working ol { margin: 0; padding-left: 1.4rem; font-variant-numeric: tabular-nums; }
.working li { margin: .35rem 0; }
.working[hidden] { display: none; }

/* Article + aside ------------------------------------------------------ */
.page-body { display: grid; gap: 3rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .page-body { grid-template-columns: minmax(0, var(--measure)) 1fr; } }
.article { max-width: var(--measure); }
.article h2:first-child { margin-top: 0; }
.formula { font-family: var(--font-head); font-size: var(--step-1); background: var(--sheet); border: 1px solid var(--grid); border-radius: var(--radius-s); padding: .9rem 1.1rem; overflow-x: auto; white-space: nowrap; }
.example { background: #fffbe0; border: 1px solid #f1e3a0; border-radius: var(--radius-s); padding: 1rem 1.25rem; margin: 1rem 0 1.5rem; }
.example p:last-child { margin-bottom: 0; }
.faq details { border-bottom: 1px solid var(--grid); padding: .9rem 0; }
.faq summary { font-weight: 700; cursor: pointer; font-size: var(--step-0); }
.faq details p { margin: .6rem 0 0; }
.aside { font-size: var(--step--1); }
@media (min-width: 1000px) { .aside-inner { position: sticky; top: 1.5rem; } }
.aside h2 { font-size: var(--step-0); margin: 0 0 .6rem; }
.aside ul { list-style: none; padding: 0; margin: 0 0 2rem; }
.aside li { border-top: 1px solid var(--grid); }
.aside li a { display: block; padding: .6rem 0; text-decoration: none; font-weight: 700; }
.aside li a:hover { text-decoration: underline; }
.updated { font-size: var(--step--1); color: var(--ink-soft); }

/* Hubs and home -------------------------------------------------------- */
.tool-index { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); border-top: 1px solid var(--grid); }
.tool-index li { border-bottom: 1px solid var(--grid); }
.tool-index a { display: block; padding: 1rem 1rem 1rem 0; text-decoration: none; color: var(--ink); }
.tool-index a strong { display: block; font-family: var(--font-head); font-size: var(--step-1); color: var(--pen); }
.tool-index a:hover strong { text-decoration: underline; }
.tool-index a span { color: var(--ink-soft); font-size: var(--step--1); }
.home-hero { padding: 3rem 0 1rem; }
.home-hero h1 { max-width: 18ch; }
.prose { max-width: var(--measure); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .site-head, .site-foot, .aside, .btn-row { display: none; } .tool { background-image: none; } }

/* GPA rows: short grade/credit fields, readable level menu */
.rows input[data-key="grade"], .rows input[data-key="credits"] { max-width: 5.5rem; }
.rows select { min-width: 7.5rem; min-height: 44px; padding-right: 1.6rem; }
@media (max-width: 560px) {
  .tool-inputs, .tool-result { padding: 1.1rem; }
  .rows { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rows input[data-key="name"], .rows input[data-key="label"] { min-width: 7rem; }
  .rows input[data-key="score"], .rows input[data-key="weight"], .rows input[data-key="earned"], .rows input[data-key="possible"] { min-width: 4.5rem; }
  .rows select { min-width: 6.5rem; }
}
