/*
  Base styles: self-hosted fonts, element defaults, focus, form controls, icons and reading prose.
  Colours, spacing, type sizes and motion come from tokens.css; control and icon sizes are literal.
*/

/* Inter Variable (OFL): one file covers weights 100 to 900 and the optical-size axis. */
@font-face {
  font-family: "Inter Variable";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* JetBrains Mono (OFL) publishes no variable woff2, so the three static weights in use are loaded. */
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-1);
  line-height: var(--lh-ui);
  overflow-wrap: break-word;
}

/* A themed element re-resolves its own colours; inherited ones were computed with the outer theme. */
[data-theme] {
  background-color: var(--bg-0);
  color: var(--fg-0);
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  color: var(--fg-0);
  font-weight: 600;
  line-height: var(--lh-tight);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-5);
  letter-spacing: -0.012em;
}

h2 {
  font-size: var(--fs-4);
  letter-spacing: -0.008em;
}

h3 {
  font-size: var(--fs-3);
}

h4 {
  font-size: var(--fs-2);
}

h5,
h6 {
  font-size: var(--fs-1);
}

p,
ul,
ol,
dl,
dd,
figure,
blockquote,
pre {
  margin: 0;
}

ul,
ol {
  padding-left: 1.25em;
}

strong,
b {
  font-weight: 600;
}

small {
  font-size: var(--fs-0);
}

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-underline-offset: 0.2em;
  transition: text-decoration-color var(--t-fast) var(--ease);
}

a:hover {
  text-decoration-color: currentColor;
}

hr {
  height: 0;
  margin: var(--s-5) 0;
  border: 0;
  border-top: 1px solid var(--line);
}

img,
video,
canvas {
  display: block;
  max-width: 100%;
}

table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

::selection {
  background-color: color-mix(in srgb, var(--accent) 32%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Code: ligatures off so commands read exactly as they must be typed. */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: max(13px, 0.9em);
  font-variant-ligatures: none;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background-color: var(--bg-2);
  color: var(--fg-0);
}

pre {
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background-color: var(--bg-2);
  color: var(--fg-0);
  line-height: var(--lh-read);
  overflow-x: auto;
  tab-size: 4;
}

kbd {
  display: inline-block;
  padding: 0 0.4em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-1);
  background-color: var(--bg-1);
  color: var(--fg-0);
  line-height: 1.5;
}

/* Form controls */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]),
select,
textarea {
  min-height: 36px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background-color: var(--bg-0);
  color: var(--fg-0);
  transition: border-color var(--t-fast) var(--ease);
}

:is(input, select, textarea):hover:not(:disabled) {
  border-color: var(--fg-2);
}

:is(input, select, textarea):focus-visible {
  border-color: var(--accent);
}

:is(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--danger);
}

:is(input, select, textarea):disabled {
  background-color: var(--bg-2);
  color: var(--fg-2);
  cursor: not-allowed;
}

textarea {
  min-height: 96px;
  line-height: var(--lh-read);
  resize: vertical;
}

::placeholder {
  color: var(--fg-2);
  opacity: 1;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

label {
  color: var(--fg-1);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  color: var(--fg-0);
  font-weight: 600;
}

/* Icons from /icons/sprite.svg, built by icon() in /js/dom.js. */
.icon {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Reading column for briefs and articles: 72ch measure, 18px on a 1.6 line height. */
.prose {
  max-width: var(--measure);
  color: var(--fg-1);
  font-size: var(--fs-2);
  line-height: var(--lh-read);
  text-wrap: pretty;
}

.prose > * + * {
  margin-top: 1em;
}

.prose > :is(h2, h3, h4) {
  margin-top: 1.75em;
}

.prose > :is(h2, h3, h4) + * {
  margin-top: 0.5em;
}

.prose strong {
  color: var(--fg-0);
}

.prose li + li {
  margin-top: 0.35em;
}

:is(.prose, .item-md) blockquote {
  padding: var(--s-3) var(--s-4);
  border-left: 3px solid var(--line-strong);
  background: var(--bg-1);
  color: var(--fg-1);
}

:is(.prose, .item-md) blockquote > * + * {
  margin-top: var(--s-3);
}
