/*! Kiln v1 — plain-CSS design system for personal projects. Generated from tokens.json + components/bundle.css.
   Fonts: Inter, Space Grotesk, JetBrains Mono (SIL OFL 1.1), self-hosted in ./fonts. */

/* ---------- Fonts ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url("fonts/inter-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-display: swap; font-weight: 300 700; src: url("fonts/space-grotesk-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-display: swap; font-weight: 100 800; src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); }

/* ---------- Tokens: dark (default) ---------- */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214;
  --surface: #1a1b1e;
  --surface-raised: #24262a;
  --border: #3a3c42;
  --border-strong: #73767e;
  --ink: #ececea;
  --muted: #a3a3a8;
  --accent: #ff9e45;
  --accent-text: #ffad62;
  --accent-hover: #ffb46b;
  --accent-ink: #1f1003;
  --accent-soft: #38200c;
  --focus: rgba(255, 158, 69, 0.45);
  --success: #5fc28a;
  --danger: #f2777a;
  --shadow-card: 0 0 0 1px #3a3c42;
  --shadow-popover: 0 0 0 1px #3a3c42, 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* ---------- Tokens: light (OS preference, or data-theme="light") ---------- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-raised: #f1f1ee;
    --border: #d9d9d4;
    --border-strong: #8a8a90;
    --ink: #18181b;
    --muted: #5a5a62;
    --accent: #ff8a1f;
    --accent-text: #c2410c;
    --accent-hover: #f07a0c;
    --accent-ink: #1f1003;
    --accent-soft: #fff0e0;
    --focus: rgba(255, 138, 31, 0.45);
    --success: #13723a;
    --danger: #b91c1c;
    --shadow-card: 0 1px 2px rgba(24, 24, 27, 0.06), 0 0 0 1px #d9d9d4;
    --shadow-popover: 0 0 0 1px #d9d9d4, 0 12px 32px rgba(24, 24, 27, 0.14);
  }
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-raised: #f1f1ee;
  --border: #d9d9d4;
  --border-strong: #8a8a90;
  --ink: #18181b;
  --muted: #5a5a62;
  --accent: #ff8a1f;
  --accent-text: #c2410c;
  --accent-hover: #f07a0c;
  --accent-ink: #1f1003;
  --accent-soft: #fff0e0;
  --focus: rgba(255, 138, 31, 0.45);
  --success: #13723a;
  --danger: #b91c1c;
  --shadow-card: 0 1px 2px rgba(24, 24, 27, 0.06), 0 0 0 1px #d9d9d4;
  --shadow-popover: 0 0 0 1px #d9d9d4, 0 12px 32px rgba(24, 24, 27, 0.14);
}

:root {
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-4: 16px;
  --space-6: 24px;
  --space-12: 48px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 999px;
}

/* Kiln components — plain CSS on Kiln tokens. Semantic HTML first; classes only where HTML has no word. */

/* ---------- Base ---------- */
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.625 var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 var(--space-2); }
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 650; }
h3 { font-size: 1.125rem; font-weight: 600; }
p { margin: 0 0 var(--space-4); }
.lead { font-size: 1.0625rem; color: var(--muted); max-width: 68ch; }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.875em; }
code, kbd { background: var(--surface-raised); padding: 1px 5px; border-radius: var(--radius-sm); }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: var(--space-12) var(--space-4); box-sizing: border-box; }
@media (min-width: 720px) { .container { padding-inline: var(--space-6); } }
.grid { display: grid; gap: var(--space-6); grid-template-columns: 1fr; }
@media (min-width: 992px) { .grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.grid > article, .grid > .card { margin: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.status { margin: var(--space-2) 0 0; min-height: 20px; font-size: 14px; line-height: 20px; color: var(--muted); }
.status.error { color: var(--danger); }

/* Busy indicator: aria-busy="true" on any element */
[aria-busy="true"]::before {
  content: ""; display: inline-block; width: 1em; height: 1em; margin-right: var(--space-2); vertical-align: -0.15em;
  border: 2px solid var(--border-strong); border-top-color: var(--accent-text); border-radius: 50%;
  animation: kiln-spin .7s linear infinite;
}
@keyframes kiln-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [aria-busy="true"]::before { animation-duration: 2s; } }
a { color: var(--accent-text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ---------- Button ---------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4);
  font: 600 14px/1 var(--font-sans);
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
button:hover, .button:hover { background: var(--accent-hover); }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus); }
button.secondary, .button.secondary { background: transparent; color: var(--accent-text); border-color: var(--accent-text); }
button.secondary:hover, .button.secondary:hover { background: var(--accent-soft); }
button.ghost, .button.ghost { background: transparent; color: var(--ink); }
button.ghost:hover, .button.ghost:hover { background: var(--surface-raised); }
button.danger, .button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.small, .button.small { min-height: 32px; padding: 0 var(--space-2); font-size: 13px; }
button:disabled, button[aria-disabled="true"], .button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- Card ---------- */
article, .card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: var(--space-6); margin: 0 0 var(--space-6);
}
article > header, .card > header {
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--surface-raised); border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
article > footer, .card > footer {
  display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap;
  margin: var(--space-4) calc(var(--space-6) * -1) calc(var(--space-6) * -1);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}
article p:last-child, .card p:last-child { margin-bottom: 0; }
.eyebrow {
  display: block; margin: 0 0 var(--space-1);
  font: 600 12px/16px var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.tag {
  display: inline-block; padding: 2px var(--space-2);
  font: 600 12px/18px var(--font-display); letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent-text); background: var(--accent-soft); border-radius: var(--radius-pill);
}

/* ---------- Field ---------- */
label { display: block; margin: 0 0 var(--space-4); font-weight: 600; font-size: 14px; color: var(--ink); }
input:not([type="checkbox"], [type="radio"], [type="range"]), select, textarea {
  display: block; width: 100%; box-sizing: border-box; margin-top: var(--space-1);
  min-height: 40px; padding: var(--space-2) 12px;
  font: 400 15px/1.4 var(--font-sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
textarea.mono, input.mono { font: 400 13px/1.55 var(--font-mono); }
input[readonly], textarea[readonly] { background: var(--surface-raised); }
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-4); min-width: 0; }
legend { padding: 0; margin: 0 0 var(--space-2); font-weight: 600; font-size: 14px; }
fieldset > label { margin-bottom: var(--space-2); }
input[type="range"] { display: block; width: 100%; margin: var(--space-2) 0 0; accent-color: var(--accent); }
label output, label .value { font: 600 14px var(--font-mono); color: var(--accent-text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--focus); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="false"] { border-color: var(--success); }
/* Small size: compact, inline controls (toolbars, headers, filters) */
input.small, select.small {
  width: auto; min-height: 32px; margin-top: 0; padding: 4px 12px; font-size: 14px;
}
/* Search fields are pill-shaped at any size */
input[type="search"] { border-radius: var(--radius-pill); padding-inline: 14px; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-raised); color: var(--muted); cursor: not-allowed; }
label small { display: block; margin-top: var(--space-1); font-weight: 400; font-size: 13px; line-height: 18px; color: var(--muted); }
input[aria-invalid="true"] + small, textarea[aria-invalid="true"] + small { color: var(--danger); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0 var(--space-2) 0 0; vertical-align: -3px; accent-color: var(--accent); }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { font-weight: 400; font-size: 15px; }

/* ---------- Nav ---------- */
body > header, header.site {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
  padding: 12px var(--space-6); background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { font: 700 18px/1 var(--font-display); letter-spacing: -0.01em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-2); }
.brand::before { content: ""; width: 14px; height: 14px; border-radius: var(--radius-sm); background: var(--accent); }
nav ul { display: flex; align-items: center; gap: var(--space-1); list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
nav a:not(.button) {
  display: block; padding: 6px 12px; border-radius: var(--radius-md);
  font: 500 14px/20px var(--font-sans); color: var(--muted); text-decoration: none;
}
nav a:not(.button):hover { color: var(--ink); background: var(--surface-raised); }
nav a[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); }
