/* Turbo — a text-mode desktop in the VGA palette.
   Everything is flat colour on a character grid: no radius, no blur, no easing. */

:root {
  /* palette — verbatim from manifest.json */
  --bg: #0000a8;         /* VGA blue: desktop and windows */
  --surface: #000000;    /* VGA black: DOS boxes, code, shadows */
  --fg: #a8a8a8;         /* VGA light gray: body text, bar and dialog face */
  --muted: #00a8a8;      /* VGA cyan: file names, meta, selection bar */
  --accent: #fcfc54;     /* VGA yellow: links, the one button, the cursor */
  --accent-fg: #000000;
  --bright: #fcfcfc;     /* VGA bright white: frames, headings */
  --hot: #a80000;        /* VGA red: hotkey letters on gray */
  --border: color-mix(in srgb, var(--fg) 45%, var(--bg));

  --font-display: "VT323", "IBM Plex Mono", ui-monospace, monospace;
  --font-text: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --text-sm: 0.8125rem;
  --text-base: 1rem;
  --text-chrome: 1.375rem;                         /* VT323 UI rows */
  --text-lg: 1.75rem;
  --text-xl: clamp(2rem, 1.7rem + 1.2vw, 2.75rem);
  --text-2xl: clamp(2.75rem, 2.2rem + 2.4vw, 4rem);
  --text-hero: clamp(5rem, 3rem + 9vw, 10rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 1rem;
  --space-4: 1.5rem;  --space-5: 2.5rem; --space-6: 4rem;

  --bar-h: 2rem;
  --frame: 6px;                                    /* double rule: 2px line, 2px gap, 2px line */
  --shadow: 1rem 0.75rem 0 var(--surface);         /* two columns right, one row down */
}

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

html { color-scheme: dark; scrollbar-color: var(--muted) var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(var(--bar-h) + var(--space-5));
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--text-base)/1.5 var(--font-text);
}

::selection { background: var(--fg); color: var(--bg); }

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { background: var(--accent); color: var(--accent-fg); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 0; top: -4rem; z-index: 30;
  padding: var(--space-2) var(--space-3);
  background: var(--accent); color: var(--accent-fg);
}
.skip-link:focus { top: 0; }

/* the desktop: a dithered blue field behind everything */
.desk { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; }
.desk pattern rect { fill: color-mix(in srgb, var(--fg) 38%, var(--bg)); }

/* ── bars: gray face, black text, red hotkeys ─────────────────────────── */
.bar {
  display: flex; align-items: stretch; justify-content: space-between;
  height: var(--bar-h);
  background: var(--fg); color: var(--surface);
  font: 400 var(--text-chrome)/var(--bar-h) var(--font-display);
  white-space: nowrap;
}
.bar nav { display: flex; }
.bar a { padding: 0 1ch; color: inherit; text-decoration: none; }
.bar a:hover, .bar a:focus-visible { background: var(--surface); color: var(--fg); outline: none; }
.bar b, .bar kbd { font: inherit; font-weight: 400; color: var(--hot); }
.bar a:hover b, .bar a:focus-visible b,
.bar a:hover kbd, .bar a:focus-visible kbd { color: var(--accent); }
.bar kbd { margin-right: 0.5ch; }
.bar-id { margin: 0; padding: 0 2ch; }
.bar-id span { margin-left: 1.5ch; }

.menubar { position: sticky; top: 0; z-index: 20; }
.menu-sys { font-family: var(--font-text); font-size: var(--text-base); }
.led {
  display: inline-block; width: 0.6em; height: 0.6em; margin-right: 0.5ch;
  background: var(--hot);
}

.statusbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; }

/* ── layout ───────────────────────────────────────────────────────────── */
.desktop {
  width: min(100% - 2 * var(--space-4), 76rem);
  margin: var(--space-5) auto 0;
}
.desktop-split {
  display: grid; grid-template-columns: minmax(0, 1fr) 21rem;
  align-items: start;
}
.stack {
  display: grid; gap: var(--space-5);
  margin: var(--space-6) 0 0 calc(-1 * var(--space-5));   /* windows overlap, as windows do */
  position: relative; z-index: 2;
}
.desktop-split > .win-main { padding-right: calc(var(--space-5) + 3ch); }

/* ── windows: double white rule, title set into the top rule ──────────── */
.win {
  position: relative;
  padding: var(--space-5) 3ch var(--space-4);
  background: var(--bg);
  border: var(--frame) double var(--bright);
  box-shadow: var(--shadow);
}
.win-idle { border: 2px solid var(--fg); padding: var(--space-4) 2ch var(--space-3); }
.win-narrow { max-width: 54rem; margin-inline: auto; }
.win-shell { background: var(--surface); border-color: var(--fg); }

.win-bar {
  position: absolute; top: 0; left: 2ch; right: 2ch;
  display: flex; justify-content: space-between; gap: 2ch;
  margin: 0; transform: translateY(calc(-50% - var(--frame) / 2));
  font: 400 var(--text-chrome)/1 var(--font-display);
  color: var(--bright);
}
.win-bar span { padding: 0 1ch; background: var(--bg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-bar span:first-child:not(:only-child):not([id]) { color: var(--muted); }
.win-idle .win-bar { transform: translateY(-50%); color: var(--fg); }
.win-shell .win-bar span { background: var(--surface); }

/* scroll bar riding the right-hand rule */
.win-scroll {
  position: absolute; top: var(--space-4); bottom: var(--space-4);
  right: calc(-1 * var(--frame)); width: 1rem;
  background: var(--muted);
}
.win-scroll::before, .win-scroll::after, .win-scroll i {
  content: ""; position: absolute; left: 0; width: 1rem; height: 1rem;
}
.win-scroll::before { top: 0; background: var(--bg); clip-path: polygon(50% 25%, 85% 75%, 15% 75%); }
.win-scroll::after { bottom: 0; background: var(--bg); clip-path: polygon(15% 25%, 85% 25%, 50% 75%); }
.win-scroll i { top: 1.5rem; background: var(--bg); }

/* ── home banner ──────────────────────────────────────────────────────── */
.banner {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: var(--space-3) var(--space-5);
  padding-bottom: var(--space-3); margin-bottom: var(--space-4);
  border-bottom: 2px solid var(--border);
}
.wordmark {
  margin: 0;
  font: 400 var(--text-hero)/0.72 var(--font-display);
  color: var(--bright);
}
.cursor {
  display: inline-block; width: 0.36em; height: 0.5em; margin-left: 0.08em;
  background: var(--accent);
}
.banner-copy { flex: 1 1 20ch; max-width: 40ch; color: var(--fg); }
.banner-copy p { margin: 0; }
.banner-copy strong { color: var(--bright); font-weight: 600; }

/* ── DOS lines and directory listings ─────────────────────────────────── */
.dos { margin: 0 0 var(--space-2); }
.dos-prompt { color: var(--bright); margin-right: 1ch; }
.dos-dim { color: var(--muted); }

.dir { list-style: none; margin: var(--space-2) 0 var(--space-3); padding: 0; }
.dir a {
  display: grid; grid-template-columns: 13ch 7ch 9ch minmax(0, 1fr); column-gap: 2ch;
  padding: var(--space-1) 1ch;
  color: var(--fg); text-decoration: none;
}
.dir-name { color: var(--muted); }
.dir-size { text-align: right; }
.dir-title { color: var(--bright); }
.dir-desc { grid-column: 4; color: var(--fg); font-size: var(--text-sm); }
.dir-kind { color: var(--fg); }

/* the selection bar: cyan row, black text — on the newest entry until you move */
.dir a:hover, .dir a:focus-visible, .dir .is-cur a { background: var(--muted); outline: none; }
.dir a:hover *, .dir a:focus-visible *, .dir .is-cur a * { color: var(--surface); }
.dir:has(a:hover) .is-cur a:not(:hover) { background: none; }
.dir:has(a:hover) .is-cur a:not(:hover) .dir-name { color: var(--muted); }
.dir:has(a:hover) .is-cur a:not(:hover) .dir-size,
.dir:has(a:hover) .is-cur a:not(:hover) .dir-date { color: var(--fg); }
.dir:has(a:hover) .is-cur a:not(:hover) .dir-title { color: var(--bright); }

.dir-long a { padding-block: var(--space-2); }
.dir-tags a { grid-template-columns: minmax(0, 1fr) 6ch auto; }
.dir-find a { display: block; color: var(--bright); }

/* ── dialogs: gray face, white double rule, hard shadow ───────────────── */
.dialog {
  position: relative;
  padding: var(--space-5) 3ch var(--space-4);
  background: var(--fg); color: var(--surface);
  box-shadow: var(--shadow);
}
.dialog::before {
  content: ""; position: absolute; inset: var(--space-2) 1ch;
  border: var(--frame) double var(--bright); pointer-events: none;
}
.dialog > * { position: relative; }
.dialog-title {
  position: absolute; top: var(--space-2); left: 50%;
  transform: translate(-50%, calc(-50% + var(--frame) / 2));
  margin: 0; padding: 0 1ch;
  background: var(--fg);
  font: 400 var(--text-chrome)/1 var(--font-display);
  white-space: nowrap;
}
.cfg { margin: 0; font-size: var(--text-sm); }
.cfg div { display: grid; grid-template-columns: 13ch minmax(0, 1fr); }
.cfg dt { white-space: nowrap; }
.cfg dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.cfg dd::before { content: ": "; font-weight: 400; }
.cfg-test { margin: var(--space-3) 0 0; font-size: var(--text-sm); }
.cfg-test .count { font-weight: 600; }
.dialog-actions { margin: var(--space-4) 0 var(--space-2); text-align: center; }

.btn {
  display: inline-block; padding: 0 2ch;
  background: var(--accent); color: var(--accent-fg);
  font: 400 var(--text-chrome)/1.5 var(--font-display);
  text-decoration: none;
  box-shadow: 0.5rem 0.375rem 0 var(--surface);
}
.btn:hover { background: var(--bright); color: var(--surface); }
.btn:active { transform: translate(0.5rem, 0.375rem); box-shadow: none; }
.dialog :focus-visible { outline-color: var(--surface); }

.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-1) 1.5ch; margin: var(--space-3) 0 0; padding: 0; font-size: var(--text-sm); }
.tag-list a { color: var(--surface); }
.tag-list a:hover { background: var(--surface); color: var(--fg); }

/* ── pages ────────────────────────────────────────────────────────────── */
.page-title {
  margin: 0 0 var(--space-3);
  font: 400 var(--text-2xl)/0.95 var(--font-display);
  color: var(--bright); text-wrap: balance;
}
.page-desc { max-width: 60ch; margin: 0 0 var(--space-4); padding-bottom: var(--space-4); border-bottom: 2px solid var(--border); color: var(--muted); }
.lede { max-width: 68ch; margin-bottom: var(--space-4); }
.lede p { margin: 0; }

.prose { max-width: 68ch; line-height: 1.7; margin-bottom: var(--space-5); }
.prose > * { margin-block: 0; }
.prose > * + * { margin-top: var(--space-3); }
.prose h2 { margin-top: var(--space-5); font: 400 var(--text-xl)/1 var(--font-display); color: var(--bright); }
.prose h3 { margin-top: var(--space-4); font: 400 var(--text-lg)/1.1 var(--font-display); color: var(--bright); }
.prose strong { color: var(--bright); font-weight: 600; }
.prose ul, .prose ol { padding-left: 3ch; }
.prose ul { list-style-type: square; }
.prose li + li { margin-top: var(--space-1); }
.prose li::marker { color: var(--muted); }
.prose blockquote { margin-inline: 0; padding: var(--space-2) 2ch; border-left: 1ch solid var(--muted); color: var(--bright); }
.prose hr { border: 0; border-top: 2px solid var(--border); margin-block: var(--space-4); }
.prose :not(pre) > code { padding: 0 0.5ch; background: var(--surface); color: var(--fg); font-size: inherit; }
.prose pre {
  padding: var(--space-3) 2ch; overflow-x: auto;
  background: var(--surface); color: var(--fg);
  font: 400 var(--text-sm)/1.6 var(--font-text);
}
.prose pre code { font: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.prose th, .prose td { padding: var(--space-1) 1ch; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--muted); color: var(--surface); font-weight: 600; }

/* syntax colours stay inside the sixteen */
.hljs { background: transparent; color: var(--fg); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--muted); font-style: normal; }
.hljs-keyword, .hljs-built_in, .hljs-section, .hljs-name, .hljs-selector-tag { color: var(--bright); }
.hljs-string, .hljs-number, .hljs-literal, .hljs-attr, .hljs-variable, .hljs-symbol { color: var(--accent); }

/* ── 404 and Find ─────────────────────────────────────────────────────── */
.win-shell .page-title { margin-top: var(--space-3); }
.win-shell .dos { max-width: 62ch; }
.arf { margin-block: var(--space-4); font: 400 var(--text-lg)/1.2 var(--font-display); color: var(--bright); }
.arf a { color: var(--bright); text-decoration: none; }
.arf b { font-weight: 400; color: var(--accent); }
.arf a:hover, .arf a:hover b { background: var(--fg); color: var(--surface); }
.arf .cursor { width: 0.5em; height: 0.7em; vertical-align: -0.05em; margin-left: 0.5ch; }

.dialog-find { max-width: 40rem; margin: 0 auto; z-index: 2; }
.dialog-find form { display: grid; gap: var(--space-2); }
.dialog-find label { font: 400 var(--text-chrome)/1 var(--font-display); }
.dialog-find input {
  width: 100%; min-height: 2.5rem; padding: 0 1ch;
  background: var(--bg); color: var(--bright);
  border: 0; border-radius: 0;
  font: 400 var(--text-base)/2.5rem var(--font-text);
  caret-color: var(--accent);
}
.dialog-find input:focus-visible { outline: 2px solid var(--surface); outline-offset: 2px; }
#search-status { margin: var(--space-3) 0 0; font-size: var(--text-sm); }
.win-results { max-width: 54rem; margin: calc(-1 * var(--space-3)) auto 0; padding-top: var(--space-6); min-height: 14rem; }

/* ── motion: one blinking cursor, nothing else ────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .cursor { animation: blink 1.1s steps(1, end) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ── narrow screens: windows tile instead of overlapping ──────────────── */
@media (max-width: 60rem) {
  .desktop-split { grid-template-columns: minmax(0, 1fr); }
  .desktop-split > .win-main { padding-right: 3ch; }
  .stack { margin: var(--space-5) 0 0; }
}
@media (max-width: 40rem) {
  :root { --bar-h: 2.5rem; --shadow: 0.5rem 0.5rem 0 var(--surface); --text-chrome: 1.25rem; }
  .desktop { width: calc(100% - 2 * var(--space-3)); margin-top: var(--space-4); }
  .win, .dialog { padding-inline: 2ch; }
  .desktop-split > .win-main { padding-right: 2ch; }
  .win-scroll, .menubar .bar-id, .statusbar .bar-id { display: none; }
  .bar a { padding: 0 0.75ch; }
  .statusbar nav { overflow: hidden; }
  .dir a { grid-template-columns: minmax(0, 1fr) auto; column-gap: 1ch; }
  .dir-size, .dir-kind { display: none; }
  .dir-title, .dir-desc { grid-column: 1 / -1; }
  .dir-tags a { grid-template-columns: minmax(0, 1fr) auto; }
  .dir-tags .dir-size { display: block; }
  .prose pre { margin-inline: -1ch; }
}
