/*
 * SPDX-FileCopyrightText: 2026 Erich Seifert <dev@erichseifert.de>
 * SPDX-License-Identifier: CC-BY-SA-4.0
 *
 * Weave tokens and the few components this site needs. Components use
 * tokens only; literal values live in the token blocks below.
 */

/* Fonts (self-hosted, SIL OFL 1.1, see LICENSES/) */
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-sans-3-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-sans-3-latin-wght-italic.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
}

/* Theme-independent tokens */
:root {
  --font-ui: "Source Sans 3", "Segoe UI", "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --text-xs: 0.8125rem;   /* 13 px */
  --text-sm: 0.875rem;    /* 14 px */
  --text-base: 0.9375rem; /* 15 px */
  --text-doc: 1rem;       /* 16 px */
  --text-lg: 1.125rem;    /* 18 px */
  --text-xl: 1.25rem;     /* 20 px */
  --text-title: 1.625rem; /* 26 px */
  --text-display: 2.25rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --border-width: 1px;

  --duration: 150ms;
  --page-width: 68rem;
  --measure: 40rem;
  --row-height: 40px;
}

/* Light theme (default) */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-subtle: #eaece7;
  --text: #262b28;
  --text-secondary: #5d6760;
  --border: #d9ddd7;
  --control-border: #7e8780; /* 3.12:1 on surface-subtle, 3.42:1 on bg */
  --accent: #4a5e55;
  --accent-fg: #ffffff;
  --selection: #e5eae5;
  --focus-ring: #4a5e55;
}

/* Dark theme: follows the system unless the visitor picked light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171b19;
    --surface: #1e2321;
    --surface-subtle: #292f2b;
    --text: #e6e9e5;
    --text-secondary: #abb6ad;
    --border: #39413b;
    --control-border: #727e76; /* 3.23:1 on surface-subtle, 4.11:1 on bg */
    --accent: #b0c2b5;
    --accent-fg: #18201b;
    --selection: #303a33;
    --focus-ring: #b0c2b5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171b19;
  --surface: #1e2321;
  --surface-subtle: #292f2b;
  --text: #e6e9e5;
  --text-secondary: #abb6ad;
  --border: #39413b;
  --control-border: #727e76;
  --accent: #b0c2b5;
  --accent-fg: #18201b;
  --selection: #303a33;
  --focus-ring: #b0c2b5;
}

@media (prefers-reduced-motion: reduce) {
  :root { --duration: 0ms; }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.45;
}

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

h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
h2 { font-size: var(--text-xl); line-height: 1.3; }
h3 { font-size: var(--text-lg); line-height: 1.35; }
p { margin: 0; }

a { color: var(--text); text-decoration-color: var(--control-border); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code, pre, kbd { font-family: var(--font-mono); font-variant-ligatures: none; }
code { font-size: 0.93em; }

.icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-2);
  z-index: 10;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: var(--border-width) solid var(--control-border);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.wrap {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}
@media (min-width: 48rem) {
  .wrap { padding-inline: var(--space-8); }
}

/* Header */
.site-header {
  border-bottom: var(--border-width) solid var(--border);
  background: var(--bg);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-6);
  min-height: 56px;
  padding-block: var(--space-2);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 600;
  text-decoration: none;
}
.brand svg { width: 24px; height: 24px; }
.site-nav { margin-right: auto; }
.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  display: inline-block;
  padding-block: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); }

/* Theme switcher: a radio group styled as a segmented control */
.theme-switch {
  display: inline-flex;
  margin: 0;
  padding: 2px;
  border: var(--border-width) solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.theme-switch[hidden] { display: none; }
.theme-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.theme-switch label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 32px;
  min-width: 32px;
  justify-content: center;
  padding-inline: var(--space-2);
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--duration), color var(--duration);
}
.theme-switch label:hover { color: var(--text); }
.theme-switch input:checked + label {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 var(--border-width) var(--control-border);
}
.theme-switch input:focus-visible + label {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
.theme-switch .icon { width: 1rem; height: 1rem; }
@media (max-width: 40rem) {
  .theme-switch .label-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Hero */
.hero { padding-block: var(--space-12); }
.hero h1 {
  max-width: 22ch;
  font-size: clamp(var(--text-title), 5vw, var(--text-display));
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.hero .lede {
  max-width: var(--measure);
  margin-top: var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-lg);
  line-height: 1.5;
}

.notice {
  display: flex;
  gap: var(--space-3);
  max-width: var(--measure);
  margin-top: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid var(--border);
  border-left: 3px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
  line-height: 1.4;
}
.notice strong { font-weight: 600; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}
.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--row-height);
  padding-inline: var(--space-4);
  border: var(--border-width) solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color var(--duration), border-color var(--duration);
}
.button:hover { background: var(--surface-subtle); }
.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}
.button-primary:hover {
  background: var(--accent);
  box-shadow: inset 0 0 0 100vmax color-mix(in srgb, var(--accent-fg) 12%, transparent);
}

/* Sections */
.section {
  padding-block: var(--space-12);
  border-top: var(--border-width) solid var(--border);
}
.section-head { max-width: var(--measure); margin-bottom: var(--space-8); }
.section-head p {
  margin-top: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-doc);
  line-height: 1.6;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-8);
}
@media (min-width: 56rem) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
}

.prose { max-width: var(--measure); font-size: var(--text-doc); line-height: 1.6; }
.prose > * + * { margin-top: var(--space-4); }
.prose ul { padding-left: var(--space-6); }
.prose li + li { margin-top: var(--space-2); }

/* Feature list: separators instead of cards */
.points {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.points li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-3);
  padding-block: var(--space-4);
  border-top: var(--border-width) solid var(--border);
}
.points li:last-child { border-bottom: var(--border-width) solid var(--border); }
.points .icon { margin-top: 3px; color: var(--text-secondary); }
.points strong { font-weight: 600; }
.points p { grid-column: 2; color: var(--text-secondary); }

/* Code */
.code {
  margin: 0;
  overflow: hidden;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.code + .code { margin-top: var(--space-4); }
.code figcaption {
  padding: var(--space-2) var(--space-4);
  border-bottom: var(--border-width) solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
}
.code pre {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.5;
  tab-size: 4;
}
.code .muted { color: var(--text-secondary); }
.code mark {
  background: var(--selection);
  color: inherit;
  border-radius: 2px;
  box-shadow: 0 0 0 2px var(--selection);
}

/* Table */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: 1.4;
}
caption {
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
  text-align: left;
}
th, td {
  padding: var(--space-3) var(--space-3) var(--space-3) 0;
  border-bottom: var(--border-width) solid var(--border);
  text-align: left;
  vertical-align: top;
}
thead th {
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom-color: var(--control-border);
}
td:first-child, th:first-child { white-space: nowrap; }
.version { font-family: var(--font-mono); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
  font-weight: 600;
}
.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.status-active::before { background: currentColor; }
.status-planned { color: var(--text-secondary); font-weight: 400; }

/* Footer */
.site-footer {
  padding-block: var(--space-8);
  border-top: var(--border-width) solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-xs);
}
.site-footer .wrap { display: grid; gap: var(--space-2); }
.site-footer a { color: inherit; }

.after-table { margin-top: var(--space-6); }

/* Error page */
.error-page { padding-block: var(--space-12); }
.error-page h1 { font-size: var(--text-title); line-height: 1.2; }
.error-page p { margin-top: var(--space-3); color: var(--text-secondary); font-size: var(--text-doc); }
