/* Inter is optional: drop InterVariable.woff2 into static/fonts/ to use it.
   Without it, the stack falls back to the system UI font. */
@font-face {
  font-family: "Inter";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Theme: light by default; dark follows the OS unless the reader picked a
   theme (html[data-theme], set by theme.js before first paint). */
:root {
  color-scheme: light;
  --bg: #f8f9fb; --fg: #1c2433; --muted: #646d7b; --line: #e1e5eb; --card: #ffffff;
  --accent: #0b6cf2; --accent-hover: #0959cc; --accent-fg: #ffffff;
  --link: #0a5fd6; --focus: #0b6cf2; --code: #eef1f5;
  --radius: 12px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #101318; --fg: #edf0f5; --muted: #a0a9b7; --line: #2a303a; --card: #181d25;
    --accent: #2f8fff; --accent-hover: #5aa7ff; --accent-fg: #0b1220;
    --link: #6cb2ff; --focus: #6cb2ff; --code: #222a35;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101318; --fg: #edf0f5; --muted: #a0a9b7; --line: #2a303a; --card: #181d25;
  --accent: #2f8fff; --accent-hover: #5aa7ff; --accent-fg: #0b1220;
  --link: #6cb2ff; --focus: #6cb2ff; --code: #222a35;
}
:root[data-theme="c64"] {
  color-scheme: dark;
  --bg: #40318d; --fg: #d2ccff; --muted: #a39ae8; --line: #6c5eb5; --card: #352879;
  --accent: #F7CA54; --accent-hover: #ffd76f; --accent-fg: #352879;
  --link: #F7CA54; --focus: #F7CA54; --code: #2c2266;
  --sans: ui-monospace, monospace;
  --mono: ui-monospace, monospace;
}
:root[data-theme="c64"] body { font-size: 16px; line-height: 1.6; font-synthesis: none; }
:root[data-theme="c64"] * { letter-spacing: 0 !important; border-radius: 0 !important; }
:root[data-theme="cassette"] {
  color-scheme: light;
  --bg: #ded8c8; --fg: #292c28; --muted: #5e6055; --line: #939181; --card: #f2eddf;
  --accent: #ad3e1d; --accent-hover: #913116; --accent-fg: #fff7e8;
  --link: #963718; --focus: #17646b; --code: #e3ddcc;
  --radius: 3px;
  --sans: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body > main { flex: 1 0 auto; width: 100%; }
button { font-family: var(--sans); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; line-height: 1.25; letter-spacing: -.035em; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--code); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Header */
.top { display: flex; align-items: center; gap: 1.5rem; padding: 1rem max(1.5rem, calc((100% - 1120px) / 2));
  border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand-row { display: flex; align-items: center; gap: .6rem; }
.brand { white-space: nowrap; font-size: 1rem; font-weight: 700; color: var(--fg); letter-spacing: -.01em; }
.brand span { background: var(--accent); color: var(--accent-fg); margin-left: .3em; padding: .05em .4em; border-radius: 5px; }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; flex: 1; }
nav a { color: var(--muted); padding: .45rem .55rem; border-radius: 6px; }
nav a:hover { color: var(--fg); text-decoration: none; }
nav .spacer { flex: 1; }

main { max-width: 1120px; margin: 0 auto; padding: 2.75rem 1.5rem 5rem; min-width: 0; }
main:focus { outline: none; }

/* Buttons and cards */
.btn, button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--fg);
  padding: .6rem 1rem; border-radius: 8px; display: inline-block; line-height: 1.4; text-align: center;
  transition: background-color .15s, border-color .15s; }
.btn:hover, button:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.35rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* Landing */
.eyebrow { font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hero { padding: 3.5rem 0 3.75rem; max-width: 940px; border-bottom: 1px solid var(--line); margin-bottom: 3.5rem; }
.hero .eyebrow { color: var(--link); margin: 0 0 1.5rem; }
.hero h1 { font-size: clamp(2.25rem, 4.5vw, 3.65rem); line-height: 1.12; font-weight: 600; letter-spacing: -.05em; margin-bottom: 0; }
.hero h1 span { color: var(--muted); }
.section-heading { max-width: 780px; margin-bottom: 1.75rem; }
.section-heading h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.025em; margin: 0 0 .65rem; }
.section-heading .eyebrow { color: var(--link); margin: 0 0 .65rem; }

.post-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.post-list .card { display: flex; flex-direction: column; align-items: start; padding: 1.4rem; }
.post-list h3 { margin: .7rem 0 0; font-size: 1.1rem; font-weight: 600; letter-spacing: -.015em; }
.post-list h3 a { color: var(--fg); }
.post-list .card > .muted { line-height: 1.75; flex: 1; margin: .5rem 0 1.25rem; }
.post-list .card > .muted p { margin: 0; }
.post-list .card > a { font-weight: 500; margin-top: auto; }
.empty-state { text-align: center; padding: 4rem 1.5rem; }
.empty-state h2 { font-size: 1.2rem; margin: 0; letter-spacing: -.025em; }

/* Post */
.post { max-width: 720px; margin: 0 auto; }
.page-heading { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.page-heading .eyebrow { color: var(--link); margin: 0 0 .75rem; }
.page-heading h1 { font-size: clamp(1.9rem, 3.5vw, 2.6rem); line-height: 1.15; font-weight: 600; letter-spacing: -.045em; margin: 0; }
.prose { font-size: 1rem; line-height: 1.75; }
.prose h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.025em; margin: 2.5rem 0 .75rem; }
.prose h3 { font-size: 1.1rem; font-weight: 600; margin: 2rem 0 .5rem; }
.prose a { text-decoration: underline; text-underline-offset: .15em; text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); }
.prose a:hover { text-decoration-color: var(--link); }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }
.prose pre { background: var(--code); padding: .9rem 1rem; border-radius: var(--radius); overflow-x: auto; line-height: 1.6; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose blockquote { border-left: 3px solid var(--accent); padding: .3rem .8rem; color: var(--muted); margin: 1.25rem 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.prose table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); margin: 1.25rem 0; font-size: .9rem; }
.prose th, .prose td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.prose th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.back { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 20; background: var(--card); padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 6px; }
.skip-link:focus { top: 1rem; }

/* Theme switcher */
.theme-symbols { position: absolute; pointer-events: none; }
.theme-picker { position: relative; flex: none; margin-left: auto; }
.theme-picker summary { display: flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.625rem;
  list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); }
.theme-picker summary::-webkit-details-marker { display: none; }
.theme-picker summary:hover, .theme-picker[open] summary { border-color: var(--muted); }
.theme-icon { display: block; flex: none; width: 1.25rem; height: 1.25rem; }
.theme-options { position: absolute; top: calc(100% + .5rem); right: 0; width: min(16rem, calc(100vw - 2rem)); padding: .35rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); box-shadow: 0 8px 24px #0002; z-index: 6; }
.theme-options button { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .65rem .6rem;
  border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: .875rem; }
.theme-options button:hover, .theme-options button:focus-visible { background: var(--code); }
.theme-options button[aria-pressed="true"] { color: var(--link); }
.theme-check { margin-left: auto; visibility: hidden; }
[aria-pressed="true"] > .theme-check { visibility: visible; }

/* Footer */
.foot { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 1rem; padding: 1.5rem 1rem;
  border-top: 1px solid var(--line); font-size: .85rem; }
.foot a { color: var(--muted); }
.foot .muted a { text-decoration: underline; }

/* Cassette futurism: equipment panels and keycaps */
:root[data-theme="cassette"] .top { background: var(--card); border-bottom: 4px solid var(--accent); box-shadow: inset 0 3px #fff9, 0 2px 0 #292c28; }
:root[data-theme="cassette"] :is(.brand, h1, h2, h3) { letter-spacing: -.025em; }
:root[data-theme="cassette"] .eyebrow { font-weight: 700; letter-spacing: .08em; }
:root[data-theme="cassette"] :is(.btn, button, summary, .brand span, nav > a, .theme-options) { border-radius: 3px; }
:root[data-theme="cassette"] :is(.btn, .theme-picker summary) { box-shadow: inset 0 1px 0 #fff5, 0 2px 0 #292c2866; }
:root[data-theme="cassette"] .card { box-shadow: inset 0 1px 0 #fff9, 2px 3px 0 #292c2826;
  background-image: radial-gradient(circle at calc(100% - 9px) 9px, var(--muted) 1.5px, transparent 2px); }
:root[data-theme="cassette"] .hero > .eyebrow { display: inline-block; padding: .35rem .65rem; background: var(--fg); color: var(--card); border-left: 5px solid var(--accent); }
:root[data-theme="cassette"] .prose pre { background: #20251f; color: #f0be70; border: 3px solid #55594d; box-shadow: inset 0 0 18px #0006; }
:root[data-theme="cassette"] .foot { background: var(--card); border-top: 3px double var(--muted); }

@media (max-width: 640px) {
  main { padding: 1.75rem 1rem 3rem; }
  .top { gap: .5rem; padding: .75rem; flex-wrap: nowrap; }
  .brand { font-size: .875rem; }
  nav { flex: 1; justify-content: flex-end; gap: 0; }
  nav .spacer { display: none; }
  nav a { padding: .45rem .4rem; font-size: .875rem; }
  .theme-picker { margin-left: 0; }
  .theme-picker summary { width: 2.25rem; height: 2.5rem; }
  .hero { padding: 2rem 0 2.5rem; margin-bottom: 2.5rem; }
  .hero h1 { font-size: clamp(2rem, 7vw, 2.7rem); }
}
@media (prefers-reduced-motion: reduce) { .btn, button { transition: none; } }
