/* Base rules and shared parts for every page. Colours and fonts come only from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { scrollbar-color: var(--color-dim) var(--color-desk); scroll-padding-top: var(--space-3xl); -webkit-text-size-adjust: 100%; background: var(--color-desk); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--color-desk);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--color-ice-ink);
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--color-sand); color: var(--color-ink); }
:focus-visible { outline: var(--rule-ring) solid var(--color-focus); outline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: var(--display-weight); font-synthesis: none; letter-spacing: var(--tracking-display); line-height: 1.04; overflow-wrap: break-word; min-width: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd, figure { margin: 0; }
b, strong { font-weight: var(--weight-strong); }
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { display: block; max-width: 100%; height: auto; }
svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-dim); }

/* Rookie (js/rookie.js): flat body, one line colour. The drawing is the team's; only its tokens live here. */
.rookie { display: block; flex: none; overflow: hidden; }
.rookie .rk-l { fill: var(--rk-line); }
.rookie .rk-b { fill: var(--rk-body); }
.rookie .rk-e { fill: var(--rk-eye); }
.rookie .rk-p { fill: var(--rk-page); }
.rookie .rk-k { fill: var(--rk-cover, var(--color-ice)); }
.rookie .rk-a { fill: var(--rk-tassel); }
.rookie .rk-blinker { opacity: 0; }
.rookie.is-alive .rk-blinker { animation: rk-blink 5.2s steps(1, end) infinite; }
.rookie.is-alive .rk-ears { animation: rk-ears 4.4s steps(1, end) infinite; }
.rookie.is-hearing .rk-ears { animation: rk-hear 0.34s steps(1, end) infinite; }
@keyframes rk-blink { 0%, 94% { opacity: 0; } 95%, 97% { opacity: 1; } 98% { opacity: 0; } }
@keyframes rk-ears { 0%, 84% { transform: translateY(0); } 85%, 90% { transform: translateY(-1px); } 91% { transform: translateY(0); } }
@keyframes rk-hear { 0% { transform: translateY(-1px); } 50% { transform: translateY(0); } }

/* Keys: a round pill with a bead at its start, standing on a step. Pressed, it goes down onto the step.
   The main key is ink with a yellow bead; a quiet key is white with an ink edge. */
.btn {
  position: relative; display: inline-flex; align-items: center; flex: none;
  height: var(--key-h); margin-bottom: var(--key-foot);
  padding: 0 calc(var(--key-h) * 0.5) 0 calc(var(--key-h) + var(--space-sm));
  border: 0; border-radius: var(--radius-pill);
  background: var(--color-ink); color: var(--color-on-ink);
  box-shadow: 0 var(--key-foot) 0 var(--color-foot);
  font-family: var(--font-body); font-weight: var(--weight-strong); font-size: var(--text-lg); line-height: 1.08; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-press) var(--ease-out), box-shadow var(--dur-press) var(--ease-out);
}
.btn::before { content: ""; position: absolute; left: 5px; top: 5px; width: calc(var(--key-h) - 10px); height: calc(var(--key-h) - 10px); border-radius: var(--radius-pill); background: var(--color-sand); }
.btn::after { content: ""; position: absolute; left: calc(var(--key-h) / 2 - 8px); top: calc(50% - 6px); width: 12px; height: 12px; border-top: 3.5px solid var(--color-ink); border-right: 3.5px solid var(--color-ink); border-radius: 2px; transform: rotate(45deg); }
.btn:hover { background: var(--color-ink-2); }
.btn:active { transform: translateY(var(--key-foot)); box-shadow: 0 0 0 var(--color-foot); }
.btn:focus-visible { outline: var(--rule-ring) solid var(--color-focus); outline-offset: 3px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.quiet { background: var(--color-card); color: var(--color-ink); box-shadow: inset 0 0 0 2.5px var(--color-ink), 0 var(--key-foot) 0 var(--color-foot); }
.btn.quiet:hover { background: var(--color-cell); }
.btn.quiet:active { box-shadow: inset 0 0 0 2.5px var(--color-ink), 0 0 0 var(--color-foot); }
.btn.quiet::before { background: var(--color-ice); }
.btn.sm { --key-h: 44px; --key-foot: 4px; padding: 0 var(--space-lg); font-size: var(--text-md); }
.btn.sm::before, .btn.sm::after { content: none; }
.btn.is-loading { pointer-events: none; opacity: 0.7; cursor: progress; }
.link { background: none; border: 0; padding: 0; color: var(--color-ink); font-weight: var(--weight-strong); text-decoration: underline; text-decoration-thickness: 2.5px; text-underline-offset: 0.22em; cursor: pointer; }
.link:hover { text-decoration-thickness: 4px; }
.link:active { transform: translateY(1px); }

/* A chip that says a state. Green is right, coral is wrong, yellow is Rookie's notes, blue is the lecture. */
.mark { display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--space-sm); border-radius: var(--radius-pill); background: var(--color-cell); color: var(--color-text-2); font-size: var(--text-sm); font-weight: var(--weight-strong); line-height: 1; white-space: nowrap; }
.mark.ok { background: var(--color-sage); color: var(--color-ink); }
.mark.bad { background: var(--color-coral); color: var(--color-ink); }
.mark.note { background: var(--color-sand); color: var(--color-ink); }
.mark.lec { background: var(--color-ice); color: var(--color-ink); }

/* The mark: four corner brackets that land round the thing to look at. */
.way {
  --bl: 24px; --bw: 4px; --hue: var(--color-ice-ink);
  background:
    linear-gradient(var(--hue) 0 0) left top / var(--bl) var(--bw) no-repeat, linear-gradient(var(--hue) 0 0) left top / var(--bw) var(--bl) no-repeat,
    linear-gradient(var(--hue) 0 0) right top / var(--bl) var(--bw) no-repeat, linear-gradient(var(--hue) 0 0) right top / var(--bw) var(--bl) no-repeat,
    linear-gradient(var(--hue) 0 0) left bottom / var(--bl) var(--bw) no-repeat, linear-gradient(var(--hue) 0 0) left bottom / var(--bw) var(--bl) no-repeat,
    linear-gradient(var(--hue) 0 0) right bottom / var(--bl) var(--bw) no-repeat, linear-gradient(var(--hue) 0 0) right bottom / var(--bw) var(--bl) no-repeat;
}

/* A book seen side-on: a course. Fill from --sc, type from --si. */
.book {
  --sc: var(--spine-1); --si: var(--spine-1-ink);
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  height: 52px; padding: 0 var(--space-md) 0 var(--space-lg);
  background: var(--sc); color: var(--si);
  border: 0; border-radius: var(--radius-book);
  box-shadow: inset 0 -5px 0 0 color-mix(in oklab, var(--sc) 80%, var(--color-ink));
  font-size: var(--text-md); white-space: nowrap; text-decoration: none; text-align: left;
}
.book b { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--text-xl); line-height: 1.3; letter-spacing: var(--tracking-display); overflow: hidden; text-overflow: ellipsis; }
.book .due { font-variant-numeric: tabular-nums; font-weight: var(--weight-strong); }
.book .due.soon { background: var(--color-ink); color: var(--color-on-ink); padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-pill); }
[data-s="1"] { --sc: var(--spine-1); --si: var(--spine-1-ink); }
[data-s="2"] { --sc: var(--spine-2); --si: var(--spine-2-ink); }
[data-s="3"] { --sc: var(--spine-3); --si: var(--spine-3-ink); }
[data-s="4"] { --sc: var(--spine-4); --si: var(--spine-4-ink); }
[data-s="5"] { --sc: var(--spine-5); --si: var(--spine-5-ink); }
button.book { cursor: pointer; font: inherit; font-size: var(--text-md); width: 100%; transition: filter var(--dur-micro) var(--ease-out); }
button.book:hover { filter: brightness(1.06) saturate(1.1); }
button.book:active { transform: translateY(2px); }

/* A slide from the lecture: a white tile with its number on a blue bead. */
.slides { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); }
.slides > li { display: grid; }
.slide { display: grid; grid-template-rows: auto 1fr; align-content: start; gap: var(--space-xs); min-width: 0; padding: var(--space-sm) var(--space-md) var(--space-md); border-radius: var(--radius-cell); background: var(--color-card); color: var(--color-text); text-decoration: none; transition: transform var(--dur-micro) var(--ease-out); }
.slide .n { justify-self: start; display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--space-sm); border-radius: var(--radius-pill); background: var(--color-ice); color: var(--color-ink); font-size: var(--text-sm); font-weight: var(--weight-strong); font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; }
.slide .t { display: block; font-weight: var(--weight-strong); font-size: var(--text-md); line-height: 1.22; }
.slide p { font-size: var(--text-sm); color: var(--color-dim); line-height: 1.35; }
a.slide:hover { transform: translateY(-2px); }
a.slide:active { transform: translateY(1px); }
@media (max-width: 40rem) { .slides { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--dock-h, 0px) + var(--space-lg)); z-index: var(--z-toast); transform: translate(-50%, 16px); max-width: min(92%, 480px); padding: var(--space-sm) var(--space-lg); background: var(--color-ink); color: var(--color-on-ink); border-radius: var(--radius-pill); font-size: var(--text-md); font-weight: var(--weight-strong); opacity: 0; transition: transform var(--dur-short) var(--ease-out), opacity var(--dur-short) var(--ease-out); pointer-events: none; }
.toast.on { transform: translate(-50%, 0); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .rookie .rk-blinker { opacity: 0 !important; }
}

/* Shown only when a page is opened from disk instead of served */
.file-note { position: relative; z-index: var(--z-toast); margin: 0; padding: var(--space-md) var(--gutter); background: var(--color-ink); color: var(--color-on-ink); font-size: var(--text-sm); }
.file-note a, .file-note code { color: var(--color-sand); }
.file-note a:focus-visible { outline-color: var(--color-sand); }
