/* Plain CSS, no build step. Three files: base (tokens, reset, text), components, pages.
   The site is black and white on purpose: one ink, one paper, hairlines instead of boxes.
   A dark theme swaps the two. Sections marked "inverted" always use the opposite of the page. */

@view-transition { navigation: auto; }

:root {
  color-scheme: light;

  --bg: #ffffff;
  --fg: #0a0a0a;
  --fg-2: #262626;
  --muted: #5c5c5c;
  --faint: #9a9a9a;
  --line: #e6e6e6;
  --line-2: #d2d2d2;
  --soft: #f6f6f6;

  /* the opposite of the page */
  --inv-bg: #0a0a0a;
  --inv-fg: #fafafa;
  --inv-muted: #a8a8a8;
  --inv-line: #2a2a2a;

  /* code is always dark in light mode; in dark mode it is a step lighter than the page */
  --code-bg: #0a0a0a;
  --code-fg: #ececec;
  --code-dim: #8c8c8c;
  --code-line: #262626;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --maxw: 72rem;
  --header-h: 3.75rem;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.16s;
  --t: 0.4s;
  --t-slow: 0.8s;

  --font: "Inter var", Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --fg: #fafafa;
  --fg-2: #d6d6d6;
  --muted: #a3a3a3;
  --faint: #6e6e6e;
  --line: #222222;
  --line-2: #333333;
  --soft: #111111;
  --inv-bg: #fafafa;
  --inv-fg: #0a0a0a;
  --inv-muted: #5c5c5c;
  --inv-line: #d9d9d9;
  --code-bg: #121212;
  --code-line: #2a2a2a;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0a0a;
    --fg: #fafafa;
    --fg-2: #d6d6d6;
    --muted: #a3a3a3;
    --faint: #6e6e6e;
    --line: #222222;
    --line-2: #333333;
    --soft: #111111;
    --inv-bg: #fafafa;
    --inv-fg: #0a0a0a;
    --inv-muted: #5c5c5c;
    --inv-line: #d9d9d9;
    --code-bg: #121212;
    --code-line: #2a2a2a;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1.5rem); }

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.65 var(--font);
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--fg); color: var(--bg); }

a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 0.22em; text-decoration-thickness: 1px; transition: text-decoration-color var(--t-fast); }
a:hover { text-decoration-color: currentColor; }

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

.container { width: calc(100% - 2.5rem); max-width: var(--maxw); margin-inline: auto; }

.skip { position: absolute; left: -999px; top: 0; padding: 0.6rem 1rem; border-radius: 10px; background: var(--fg); color: var(--bg); }
.skip:focus { left: 1rem; top: 1rem; z-index: 100; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

h1, h2, h3, h4 { margin: 0; line-height: 1.1; letter-spacing: -0.03em; font-weight: 650; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 6.4vw, 4.6rem); letter-spacing: -0.05em; line-height: 1.01; }
h2 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); }
h3 { font-size: 1.1rem; letter-spacing: -0.015em; }
p { text-wrap: pretty; }

.lead { max-width: 40rem; margin: 1.25rem 0 0; color: var(--muted); font-size: clamp(1.05rem, 1.6vw, 1.25rem); line-height: 1.55; }
.meta { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.eyebrow { margin: 0 0 1rem; color: var(--muted); font: 600 0.75rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }

code, kbd { font-family: var(--mono); }
:not(pre) > code { -webkit-box-decoration-break: clone; box-decoration-break: clone; }
:not(pre) > code { padding: 0.12em 0.4em; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); font-size: 0.86em; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
[data-rise] { animation: rise var(--t-slow) var(--ease) both; animation-delay: calc(var(--i, 0) * 80ms); }

.site-header { view-transition-name: header; }
main { view-transition-name: page; }
::view-transition-old(page) { animation: fade-out 0.14s var(--ease) both; }
::view-transition-new(page) { animation: fade-in 0.32s var(--ease) both; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; transition-delay: 0ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
