/* Base styles, version 2: reset, type, layout helpers, shared header and footer, buttons, section rhythm.
   Uses only tokens.css values. Page files add their own slice under assets/css/pages/.

   Class names pages may rely on (stable):
     layout      .wrap  .field (a colour field, set its background in the page file)  .on-ink  .sr-only  .skip
     wave        svg.wave with style="--from:#hex;--mid:#hex;--to:#hex" closes one colour field and opens the next; add .flip to mirror it
     sticker     .sticker on a heading (ink label, tilted, amber hard shadow)
     button      .btn  (.btn-alt for the cream one; aria-pressed="true" turns it sun yellow)
     number tile .bento (12-column grid)  .tile  .big (.unit, .plus)  .what  .meta
     card        .card  with h3, .what, .meta
     chips       ul.chips > li
     photo       figure.photo > img (credits are on the Sources page)
     table       .table-scroll around a wide table: edge shadows show where it scrolls
     lead        .lead (large intro line)
     plain page  .field-cream (cream field for ordinary text)  .page-title (h1 size outside a hero)
   Tokens (tokens.css): colour fields --ink --deep --panel --teal --teal-2 --teal-3 --teal-dark --mint --sun --cream --cream-2 --amber --sand --dune --dune-2 --coral --coral-deep --coral-strong;
     the six disciplines --disc-power --disc-renewable --disc-electronics --disc-control --disc-comms --disc-computing, each with an ink for text on it: --disc-<name>-ink;
     type --font-display --font-body --fs-hero --fs-h2 --fs-h3 --fs-big --fs-lead --fs-body --fs-small; space --s1 to --s10; shape --r-sm --r --r-lg; motion --spring --glide. */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ink); scroll-padding-top: calc(var(--header-h) + var(--s4)); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--ink); color: var(--ink); font: 400 var(--fs-body)/1.55 var(--font-body); overflow-wrap: break-word; -webkit-font-smoothing: antialiased; overflow-x: clip; }
h1, h2, h3, h4, p, ul, ol, figure, dl, dd, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video, canvas { max-width: 100%; }
button { font: inherit; color: inherit; }

/* ---------- type ---------- */
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.025em; line-height: 0.95; text-wrap: balance; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); line-height: 1.05; letter-spacing: -0.015em; }
p { max-width: 38ch; }
.lead { font-size: var(--fs-lead); line-height: 1.35; font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.sr-only-focusable:focus-within { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; clip-path: none; white-space: normal; }

/* ---------- layout ---------- */
.wrap { width: min(100% - 2 * var(--gutter), var(--w-page)); margin-inline: auto; }
.field { position: relative; padding-block: var(--s9); }
.field > .wrap { position: relative; z-index: 1; }
.on-ink { color: var(--cream); }
/* a hard-edged dune wave closes a colour field and opens the next one */
.wave { display: block; width: 100%; height: clamp(48px, 8vw, 120px); margin-block: -1px; background: var(--from); }
.wave .m { fill: var(--mid); }
.wave .t { fill: var(--to); }
.wave.flip path { transform: scaleX(-1); transform-box: fill-box; transform-origin: center; }

/* ---------- links and focus ---------- */
a { color: inherit; text-underline-offset: 5px; }
:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; box-shadow: 0 0 0 7px var(--ink); border-radius: 6px; }
.on-ink :focus-visible, .site-header :focus-visible, .site-footer :focus-visible { outline-color: var(--sun); box-shadow: 0 0 0 7px var(--ink); }

.skip { position: absolute; left: var(--s4); top: -90px; z-index: 50; background: var(--sun); color: var(--ink); padding: var(--s3) var(--s5); border-radius: var(--r-sm); font-weight: 700; text-decoration: none; }
.skip:focus-visible { top: var(--s4); }

/* ---------- buttons: a chunky pill that presses into its own shadow ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 52px; padding: 0 var(--s6); font: 700 18px/1 var(--font-body); letter-spacing: 0.01em; color: var(--ink); background: var(--amber); border: 0; border-radius: 999px; box-shadow: 0 6px 0 var(--ink); text-decoration: none; cursor: pointer; touch-action: manipulation;
  transition: transform 160ms var(--spring), box-shadow 160ms var(--spring); }
.btn[aria-pressed="true"] { background: var(--sun); }
@media (hover: hover) { .btn:hover { transform: translateY(-3px); box-shadow: 0 9px 0 var(--ink); } }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.btn-alt { background: var(--cream); }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 40; background: var(--ink); color: var(--cream); }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 6px; background: linear-gradient(90deg, var(--coral) 0 25%, var(--amber) 25% 50%, var(--teal-3) 50% 75%, var(--panel) 75% 100%); }
.site-header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s5); min-height: var(--header-h); padding-block: var(--s2); }
.wordmark { display: inline-flex; align-items: center; gap: var(--s3); min-height: 48px; font: 800 30px/1 var(--font-display); letter-spacing: -0.03em; color: var(--cream); text-decoration: none; }
.wordmark svg { width: 30px; height: 30px; flex: none; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: var(--s2); }
.site-nav a { display: flex; align-items: center; min-height: 44px; padding: 0 var(--s4); border-radius: 999px; font: 600 17px/1 var(--font-body); white-space: nowrap; color: var(--cream); text-decoration: none; transition: transform 160ms var(--spring); }
@media (hover: hover) { .site-nav a:hover { background: var(--cream); color: var(--ink); transform: translateY(-2px); } }
.site-nav a[aria-current="page"] { background: var(--amber); color: var(--ink); }
.site-header .menu-toggle { display: none; min-height: 48px; min-width: 96px; padding: 0 var(--s5); background: var(--amber); box-shadow: 0 4px 0 #000; }

@media (max-width: 900px) {
  :root { --header-h: 64px; }
  .site-header .menu-toggle { display: inline-flex; }
  .site-nav { flex-basis: 100%; }
  .menu-toggle[aria-expanded="false"]:not([hidden]) + .site-nav { display: none; }
  .menu-toggle:not([hidden]) + .site-nav ul { flex-direction: column; padding-bottom: var(--s4); }
  .menu-toggle:not([hidden]) + .site-nav a { min-height: 52px; font-size: 20px; }
}
/* short phone screens: slimmer menu links so the open menu covers less of the page */
@media (max-width: 900px) and (max-height: 700px) {
  .menu-toggle:not([hidden]) + .site-nav a { min-height: 48px; font-size: 18px; }
}

/* ---------- footer ---------- */
.site-footer { background: var(--ink); color: var(--cream); padding: var(--s8) 0 var(--s7); }
.site-footer-row { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s5) var(--s7); }
.site-footer p { max-width: none; margin: 0; }
.site-footer .course { font: 800 clamp(40px, 7vw, 88px)/0.9 var(--font-display); letter-spacing: -0.03em; color: var(--amber); margin-bottom: var(--s3); }
.site-footer ul { display: flex; flex-wrap: wrap; gap: var(--s3); }
.site-footer li a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 var(--s5); border-radius: 999px; background: var(--cream); color: var(--ink); font-weight: 700; text-decoration: none; }

@media (max-width: 760px) {
  .field { padding-block: var(--s8); }
}

/* ---------- patterns every page may use (moved here from pages/solar-ai.css) ---------- */
/* plain page: .field-cream is a cream field for ordinary text (the 404 page uses it); .page-title sizes an h1 outside a hero */
.field-cream { background: var(--cream); color: var(--ink); }
.field-cream .wrap > * + * { margin-top: var(--s5); }
.page-title { font-size: var(--fs-h2); }

/* sticker heading: an ink label, tilted, with a hard amber shadow. Put .sticker on a heading; size and tilt come from --st-pad, --st-r, --st-rot. */
.sticker { display: inline-block; background: var(--ink); color: var(--cream); padding: var(--st-pad, 0.07em 0.3em 0.16em); border-radius: var(--st-r, 0.25em); transform: rotate(var(--st-rot, -1.5deg)); box-shadow: 0.05em 0.06em 0 var(--amber); }

/* number tile: .bento is a 12-column grid, .tile a solid colour block holding .big (the number, with .unit and .plus), .what (one line) and .meta (the dated line).
   Colour a tile with a page class or style="background: var(--disc-power); color: var(--disc-power-ink)". */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s5); }
.tile { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: var(--s7); min-height: 280px; }
.tile .big { font: 800 var(--fs-big)/0.88 var(--font-display); letter-spacing: -0.045em; max-width: none; }
.tile .big .unit { font-size: 0.34em; letter-spacing: -0.01em; }
.tile .big .plus { letter-spacing: -0.02em; }
.tile .what { margin-top: var(--s4); max-width: 26ch; font: 600 clamp(19px, 1.8vw, 24px)/1.28 var(--font-body); }
.tile .meta { margin-top: var(--s4); font: 600 16px/1.3 var(--font-body); }

/* card: a solid colour block with an h3, .what and .meta */
.card { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: var(--s7); }
.card h3 { margin: 0 0 var(--s4); font-size: clamp(30px, 3.4vw, 48px); }
.card .what { font: 600 clamp(18px, 1.7vw, 22px)/1.3 var(--font-body); max-width: 34ch; }
.card .meta { margin-top: var(--s4); font: 600 16px/1.3 var(--font-body); }

/* chips: <ul class="chips"><li>short label</li></ul> */
.chips { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }
.chips li { background: var(--amber); color: var(--ink); font: 700 18px/1 var(--font-body); padding: 11px 18px; border-radius: 999px; }

/* photo frame: a figure.photo holding the photo; its credit is on the Sources page. A page adds its own tilt, as .p1 and .p2 do on Solar. */
.photo { position: relative; margin: 0; transition: transform 500ms var(--spring); }
.photo img { display: block; width: 100%; height: auto; border-radius: var(--r-lg); box-shadow: 0 12px 0 var(--ink); }
@media (hover: hover) { .photo:hover { transform: rotate(0) scale(1.025); } }

/* table scroll cue: wrap a wide table in <div class="table-scroll" tabindex="0" role="region" aria-label="...">; a shadow shows on each edge that has more to scroll to */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-sm);
  background: linear-gradient(to right, var(--cream) 30%, rgba(255, 243, 214, 0)) left / 40px 100% no-repeat local,
    linear-gradient(to left, var(--cream) 30%, rgba(255, 243, 214, 0)) right / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(6, 44, 59, 0.45), rgba(6, 44, 59, 0)) left / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(6, 44, 59, 0.45), rgba(6, 44, 59, 0)) right / 14px 100% no-repeat scroll; }
.table-scroll table { min-width: 560px; }

@media (max-width: 900px) {
  .bento { grid-template-columns: 1fr; }
  .tile, .card { padding: var(--s6) var(--s5); }
}
@media (max-width: 480px) {
  .card h3 { font-size: 34px; }
}

/* ---------- off screen: a section that is not on screen pauses its loops (site.js adds both classes; only the play state changes) ---------- */
.rest-loops .off-screen, .rest-loops .off-screen *, .rest-loops .off-screen *::before, .rest-loops .off-screen *::after { animation-play-state: paused !important; }

/* ---------- reduced motion: nothing moves, state changes are instant ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer .btn { display: none; }
}
