/* ==========================================================================
   StudentHPC — Base
   Reset, document typography, layout primitives. No components live here.
   Depends on: tokens.css
   ========================================================================== */

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Sticky header + utility bar must not cover anchored headings. */
  scroll-padding-top: calc(var(--topbar-h) + var(--sp-6));
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv05' 1, 'ss01' 1;  /* Inter: single-storey l, disambiguated I/l */
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* The `hidden` attribute is only `display: none` in the UA stylesheet, so ANY
   class that sets a display value silently overrides it. That is how the old
   site rendered an empty status bar above its form: `.form-status` set
   `display: flex`, which outranks `[hidden]`. Make the attribute win. */
[hidden] { display: none !important; }

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
svg { flex-shrink: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }

ul[role='list'], ol[role='list'] { list-style: none; }

table { border-collapse: collapse; border-spacing: 0; }

hr {
  border: none;
  border-top: 1px solid var(--border-hair);
  margin: var(--sp-8) 0;
}

::selection { background: var(--blue-100); color: var(--blue-800); }

/* --------------------------------------------------------------------------
   Typography — document defaults
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-heading);
  color: var(--text);
  text-wrap: balance;   /* progressive: avoids orphaned words in headings */
}

h1 { font-size: var(--fs-3xl); letter-spacing: var(--ls-display); font-weight: var(--fw-bold); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-base); }
h6 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: var(--ls-caps); color: var(--text-secondary); }

p { text-wrap: pretty; }

a {
  color: var(--text-link);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--motion-fast) var(--ease);
}
a:hover { color: var(--text-link-hover); text-decoration-thickness: 2px; }

strong, b { font-weight: var(--fw-semibold); }

abbr[title] { text-decoration: underline dotted; cursor: help; text-underline-offset: 0.2em; }

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-feature-settings: 'liga' 0;  /* no ligatures: != must not render as a glyph */
}

/* --------------------------------------------------------------------------
   Focus — one ring, applied once, never removed
   -------------------------------------------------------------------------- */
:focus { outline: none; }   /* superseded immediately by :focus-visible */
:focus-visible {
  outline: var(--focus-w) solid var(--focus-color);
  outline-offset: var(--focus-offset);
  border-radius: var(--r-1);
}
/* On dark grounds the blue ring loses contrast; switch to white. */
.on-dark :focus-visible,
.footer :focus-visible,
.utility-bar :focus-visible,
.docs-sidebar :focus-visible { outline-color: var(--white); }

/* --------------------------------------------------------------------------
   Skip link — first tabbable element on every page
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: 0;
  left: var(--sp-4);
  z-index: var(--z-modal);
  transform: translateY(-120%);
  background: var(--pine-700);
  color: var(--white);
  padding: var(--sp-3) var(--sp-5);
  border-radius: 0 0 var(--r-2) var(--r-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transition: transform var(--motion-base) var(--ease);
}
.skip-link:focus { transform: translateY(0); color: var(--white); }

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--w-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--content { max-width: var(--w-content); }
.container--narrow  { max-width: var(--w-narrow); }

.section { padding-block: var(--sp-20); }
.section--tight { padding-block: var(--sp-12); }
.section--flush { padding-block: 0; }

/* Section grounds. These are the ONLY four page backgrounds.
   Each step is visually distinct — the old palette used three near-identical
   near-whites, so section transitions read as accidental rather than authored. */
.ground-white  { background: var(--surface); }
.ground-subtle { background: var(--surface-subtle); border-block: 1px solid var(--border-hair); }
.ground-invert { background: var(--surface-invert); color: var(--text-invert); }
.ground-brand  { background: var(--surface-brand-dk); color: var(--text-invert); }

.ground-invert h1, .ground-invert h2, .ground-invert h3,
.ground-brand  h1, .ground-brand  h2, .ground-brand  h3 { color: var(--text-invert); }

/* Grid */
.grid { display: grid; gap: var(--sp-6); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Auto-fit variant for card decks that must not orphan a lone card. */
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.stack > * + * { margin-top: var(--flow, var(--sp-4)); }
.stack--lg { --flow: var(--sp-6); }
.stack--xl { --flow: var(--sp-10); }

.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.cluster--between { justify-content: space-between; }

/* --------------------------------------------------------------------------
   Section headers
   -------------------------------------------------------------------------- */
.eyebrow {
  display: block;
  font-size: var(--fs-3xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-brand);
  margin-bottom: var(--sp-3);
}
.ground-invert .eyebrow, .ground-brand .eyebrow { color: var(--pine-300); }

.section-title {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-display);
  line-height: var(--lh-tight);
}
.section-title--sm { font-size: var(--fs-2xl); }

.section-lede {
  font-size: var(--fs-lg);
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
  max-width: 62ch;
  margin-top: var(--sp-4);
}
.ground-invert .section-lede, .ground-brand .section-lede { color: var(--text-on-invert); }

.section-head { margin-bottom: var(--sp-12); }
.section-head--center { text-align: center; margin-inline: auto; max-width: 720px; }
.section-head--center .section-lede { margin-inline: auto; }

/* Rule that sits under a section title — institutional, not decorative. */
.rule-brand {
  width: 56px;
  height: 3px;
  background: var(--border-brand);
  margin-top: var(--sp-5);
}
.section-head--center .rule-brand { margin-inline: auto; }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.mono { font-family: var(--font-mono); font-feature-settings: 'liga' 0; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }   /* aligned figures in spec tables */

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section { padding-block: var(--sp-16); }
}
@media (max-width: 768px) {
  :root { --gutter: var(--sp-4); }
  .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
  .section { padding-block: var(--sp-12); }
  .section-title { font-size: var(--fs-2xl); }
  .section-head { margin-bottom: var(--sp-8); }
}
@media (max-width: 480px) {
  .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* --------------------------------------------------------------------------
   Spacing utilities
   A deliberately small set. They exist so page markup never needs a style
   attribute -- an inline style is how raw hex values leak past the token
   layer, which is exactly what this system is built to prevent.
   -------------------------------------------------------------------------- */
.mt-4  { margin-top: var(--sp-4); }
.mt-5  { margin-top: var(--sp-5); }
.mt-6  { margin-top: var(--sp-6); }
.mt-8  { margin-top: var(--sp-8); }
.mt-10 { margin-top: var(--sp-10); }
.mt-12 { margin-top: var(--sp-12); }
.mb-4  { margin-bottom: var(--sp-4); }
.mb-5  { margin-bottom: var(--sp-5); }
.mb-6  { margin-bottom: var(--sp-6); }
.measure { max-width: 70ch; }
