*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.15;
  font-weight: 600;
  text-wrap: balance;
}

.display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.015em;
}

p {
  margin: 0 0 0.8em;
  text-wrap: pretty;
}
p:last-child {
  margin-bottom: 0;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

img,
svg {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid var(--select);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection {
  background: var(--select-edge);
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted {
  color: var(--ink-2);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  background: var(--card);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 6px;
}

.katex {
  font-size: 1.08em;
}
.katex-display {
  margin: 0.7em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

/* colour helpers for signalling variables in text and math */
.c-blue { color: var(--blue); }
.c-coral { color: var(--coral); }
.c-teal { color: var(--teal); }
.c-amber { color: var(--warn); }
.c-violet { color: var(--violet); }
.c-pink { color: var(--pink); }
.c-green { color: var(--success); }
.c-red { color: var(--error); }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

[hidden] {
  display: none !important;
}

/* code listings in lessons (js/lib/code.js) */
.code-block {
  margin: 0.8em 0;
  padding: 10px 0;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 0.86em;
  overflow-x: auto;
  counter-reset: ln;
}
.code-block .cd-line { display: block; white-space: pre; padding: 1px 14px; counter-increment: ln; }
.code-block .cd-line::before { content: counter(ln); display: inline-block; width: 1.4em; margin-right: 12px; text-align: right; color: var(--ink-3); font-size: 0.8em; }
.cd-kw { color: var(--violet); font-weight: 650; }
.cd-num { color: var(--warn); }
.cd-str { color: var(--success); }
.cd-com { color: var(--ink-3); font-style: italic; }
