/* Themes are variables. Green is the default; theme.js sets data-theme on <html>. */
:root {
  --bg: #000000;
  --fg: #33ff33;
  --dim: #1fa81f;
  --line: #1fa81f;
  --ctl: #1fa81f;
  --sel-bg: #33ff33;
  --sel-fg: #000000;
  --link: #33ff33;
  --card: transparent;
  --well: transparent;
  --chip-fg: var(--dim);
  --on-link: var(--sel-fg);
  --font: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 0;
  --upper: uppercase;
}
[data-theme="blue"] {
  --bg: #0000aa; --fg: #ffffff; --dim: #b8b8ff; --line: #ffffff; --ctl: #ffffff;
  --sel-bg: #ffffff; --sel-fg: #0000aa; --link: #ffff55;
}
[data-theme="amber"] {
  --bg: #000000; --fg: #ffb000; --dim: #b87c00; --line: #b87c00; --ctl: #b87c00;
  --sel-bg: #ffb000; --sel-fg: #000000; --link: #ffb000;
}
[data-theme="light"] {
  --bg: #ffffff; --fg: #111111; --dim: #555555; --line: #111111; --ctl: #111111;
  --sel-bg: #111111; --sel-fg: #ffffff; --link: #0b3d91;
}
[data-theme="web"] {
  --bg: #f5f7fa; --fg: #14181f; --dim: #5b6573; --line: #d5dbe3; --ctl: #7d8796;
  --sel-bg: #dbe6ff; --sel-fg: #1d3a9a; --link: #1d4ed8; --card: #ffffff;
  --well: #eef1f6; --chip-fg: #47515f; --on-link: #ffffff;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --upper: none;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { color-scheme: dark; caret-color: var(--fg); scrollbar-color: var(--ctl) var(--bg); }
::selection { background: var(--sel-bg); color: var(--sel-fg); }
[data-theme="light"], [data-theme="web"] { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
}
.wrap { max-width: 62rem; margin: 0 auto; padding: 0 1rem; }
a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--fg);
  outline-offset: 2px;
}
[data-theme="web"] a:focus-visible, [data-theme="web"] button:focus-visible, [data-theme="web"] input:focus-visible {
  outline-color: var(--link);
}
code, pre, .n, .prompt { font-family: var(--mono); }
h1, h2, h3 { line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.6rem; margin: 1.5rem 0 .5rem; }
h2 { font-size: 1.05rem; margin: 2rem 0 .6rem; text-transform: var(--upper); letter-spacing: .04em; }
[data-theme="web"] h2 { font-size: 1.15rem; letter-spacing: 0; }
.lead { color: var(--dim); max-width: 46rem; margin: 0 0 1.25rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--sel-bg); color: var(--sel-fg); padding: .4rem .8rem; }
.skip:focus { left: 0; z-index: 10; }

/* Header and footer */
.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding-top: .9rem; padding-bottom: .9rem; }
.lhs { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.5rem; }
.tools { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.theme { margin-left: auto; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--fg); text-decoration: none; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border: 1px solid var(--line); background: var(--sel-bg); color: var(--sel-fg); font-family: var(--mono); font-weight: 700; font-size: .9rem; border-radius: var(--radius); }
[data-theme="web"] .logo { background: var(--link); color: var(--on-link); border-color: var(--link); border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-sub { color: var(--dim); font-size: .8rem; }
.mode { display: inline-flex; align-items: center; border: 1px solid var(--ctl); border-radius: var(--radius); font-size: .95rem; }
.mode a { color: var(--fg); text-decoration: none; padding: .1rem .9rem; min-height: 1.9rem; display: inline-flex; align-items: center; font-weight: 700; }
.mode a:hover { background: transparent; text-decoration: underline; }
.mode a[aria-current="page"] { background: var(--sel-bg); color: var(--sel-fg); text-decoration: none; }
[data-theme="web"] .mode { background: var(--card); border-radius: 9px; padding: 2px; }
[data-theme="web"] .mode a { border-radius: 7px; }
[data-theme="web"] .mode a[aria-current="page"] { background: var(--link); color: var(--on-link); }
.theme { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .85rem; }
.theme-label { color: var(--dim); margin-right: .2rem; }
.foot { margin-top: 3rem; border-top: 1px solid var(--line); padding: 1rem 0 2rem; color: var(--dim); font-size: .85rem; }

/* Search and chips */
.search { display: flex; align-items: center; gap: .6rem; margin: 1rem 0; border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
.prompt { color: var(--fg); white-space: nowrap; }
.search input {
  flex: 1; min-width: 0; font: inherit; font-family: var(--mono); color: var(--fg);
  background: transparent; border: 0; padding: .25rem 0;
}
.search input::placeholder { color: var(--dim); opacity: 1; }
.search input:focus-visible { outline-offset: 4px; }
.cursor::after { content: "\2588"; color: var(--fg); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor::after { animation: none; } }
[data-theme="web"] .prompt, [data-theme="web"] .cursor { display: none; }
[data-theme="web"] .search { background: var(--card); border: 1px solid var(--ctl); border-radius: 8px; padding: .5rem .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.chips a {
  color: var(--dim); text-decoration: none; border: 1px solid var(--ctl);
  padding: .1rem .7rem; border-radius: var(--radius); font-size: .9rem; min-height: 1.9rem; display: inline-flex; align-items: center;
}
[data-theme="web"] .chips a { border-radius: 14px; background: var(--card); color: var(--chip-fg); }
.chips a:hover { border-color: var(--fg); color: var(--fg); }
.chips a[aria-current="page"] { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); }
.empty { color: var(--dim); }

/* Command lists: terminal rows by default, cards in the web theme */
.group h2 { margin-top: 1.5rem; }
.cmds { list-style: none; margin: 0; padding: 0; }
.cmds a { display: flex; gap: 1.5ch; padding: .2rem .6ch; color: var(--fg); text-decoration: none; }
.cmds .n { min-width: 9ch; font-weight: 700; }
.cmds .d { color: var(--dim); }
.cmds a:hover, .cmds a:focus-visible { background: var(--sel-bg); color: var(--sel-fg); }
.cmds a:hover .d, .cmds a:focus-visible .d { color: var(--sel-fg); }
[data-section="github"] .cmds .n { min-width: 19ch; }
[data-theme="web"] .cmds li { display: flex; }
[data-theme="web"] .cmds li a { flex: 1; }
[data-theme="web"] .cmds { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
[data-theme="web"] .cmds a { flex-direction: column; gap: .15rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
[data-theme="web"] .cmds .n { min-width: 0; font-size: 1.05rem; }
[data-theme="web"] .cmds a:hover, [data-theme="web"] .cmds a:focus-visible { background: var(--card); color: var(--fg); border-color: var(--link); }
[data-theme="web"] .cmds a:hover .d, [data-theme="web"] .cmds a:focus-visible .d { color: var(--dim); }

/* Command page */
.crumbs { margin: 1rem 0 0; color: var(--dim); font-size: .9rem; }
.sub { font-weight: 400; color: var(--dim); font-size: 1rem; margin-left: .4rem; }
article h1 code { font-size: 1.9rem; }
pre { margin: 0; overflow-x: auto; }
.syn, .cmd, .out { border: 1px solid var(--line); padding: .6rem .9rem; border-radius: var(--radius); background: var(--card); }
[data-theme="web"] .syn, [data-theme="web"] .cmd, [data-theme="web"] .out { background: var(--well); border-color: var(--well); border-radius: 8px; }
.cmd code::before { content: "$ "; color: var(--dim); user-select: none; }
.out { border-top: 0; color: var(--dim); }
.ex { margin: 0 0 1.2rem; position: relative; }
.ex figcaption { margin-bottom: .3rem; padding-right: 5rem; }
.copy { position: absolute; right: 0; top: -.35rem; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; padding: .4rem .8rem .4rem 0; border-top: 1px solid var(--line); }
thead th { border-top: 0; color: var(--dim); font-weight: 400; font-size: .85rem; }
td:first-child { white-space: nowrap; padding-right: 1.5rem; }
.notes, .related { padding-left: 1.2rem; }
.related { list-style: none; padding: 0; }
.related .d { color: var(--dim); margin-left: .5ch; }
.updated { color: var(--dim); font-size: .85rem; margin-top: 2rem; }

@media (max-width: 40rem) {
  .lhs { flex-wrap: nowrap; gap: .6rem .8rem; }
  .brand-sub { display: none; }
  .scroll table { min-width: 0; }
  td:first-child { white-space: normal; overflow-wrap: anywhere; width: 38%; padding-right: .8rem; }
  .syn, .cmd, .out { white-space: pre-wrap; overflow-wrap: anywhere; }
  .cmds a { flex-direction: column; gap: 0; padding: .4rem .6ch; }
  .search { flex-wrap: wrap; }
  h1 { font-size: 1.35rem; }
}

/* Buttons: bevelled like DOS and Windows 3.1. Raised at rest, pressed when selected. */
:root { --btn-face: #0a2a0a; --btn-fg: #33ff33; --btn-hi: #33ff33; --btn-lo: #031003; --btn-edge: #1fa81f; }
[data-theme="blue"] { --btn-face: #0000aa; --btn-fg: #ffffff; --btn-hi: #8888ff; --btn-lo: #000066; --btn-edge: #ffffff; }
[data-theme="amber"] { --btn-face: #2a1c00; --btn-fg: #ffb000; --btn-hi: #ffb000; --btn-lo: #0d0900; --btn-edge: #b87c00; }
[data-theme="light"] { --btn-face: #c0c0c0; --btn-fg: #000000; --btn-hi: #ffffff; --btn-lo: #808080; --btn-edge: #000000; }
[data-theme="web"] { --btn-face: #ffffff; --btn-fg: #14181f; --btn-hi: transparent; --btn-lo: transparent; --btn-edge: #7d8796; }
.theme button, .reboot, .copy {
  font: inherit; font-size: .85rem; color: var(--btn-fg); background: var(--btn-face);
  border: 1px solid var(--btn-edge); border-radius: var(--radius); cursor: pointer;
  padding: .1rem .7rem; min-height: 1.9rem;
  box-shadow: inset 2px 2px 0 var(--btn-hi), inset -2px -2px 0 var(--btn-lo);
}
.theme button:active, .theme button[aria-pressed="true"] {
  box-shadow: inset 2px 2px 0 var(--btn-lo), inset -1px -1px 0 var(--btn-hi);
  padding: calc(.1rem + 1px) calc(.7rem - 1px) calc(.1rem - 1px) calc(.7rem + 1px);
}
.theme button::before { content: "\25CB"; content: "\25CB" / ""; margin-right: .45em; }
.theme button[aria-pressed="false"] { filter: brightness(.78); }
.theme button[aria-pressed="false"]:hover { filter: brightness(1); }
.theme button[aria-pressed="true"] { font-weight: 700; }
.theme button[aria-pressed="true"]::before { content: "\25CF"; content: "\25CF" / ""; }
.reboot:active, .copy:active { box-shadow: inset 2px 2px 0 var(--btn-lo), inset -1px -1px 0 var(--btn-hi); }
.reboot:hover, .copy:hover { border-color: var(--btn-edge); filter: brightness(1.12); }
[data-theme="web"] .theme button, [data-theme="web"] .reboot, [data-theme="web"] .copy { border-radius: 8px; }
.theme { gap: .6rem; }
/* Each theme button shows the screen it switches to */
.theme button[data-theme-set="green"] { --btn-face: #0a2a0a; --btn-fg: #33ff33; --btn-hi: #33ff33; --btn-lo: #031003; --btn-edge: #1fa81f; }
.theme button[data-theme-set="blue"] { --btn-face: #0000aa; --btn-fg: #ffffff; --btn-hi: #8888ff; --btn-lo: #000066; --btn-edge: #ffffff; }
.theme button[data-theme-set="amber"] { --btn-face: #2a1c00; --btn-fg: #ffb000; --btn-hi: #ffb000; --btn-lo: #0d0900; --btn-edge: #b87c00; }
.theme button[data-theme-set="light"] { --btn-face: #c0c0c0; --btn-fg: #000000; --btn-hi: #ffffff; --btn-lo: #808080; --btn-edge: #000000; }
.theme button[data-theme-set="web"] {
  --btn-face: #1d4ed8; --btn-fg: #ffffff; --btn-hi: transparent; --btn-lo: transparent; --btn-edge: #1d4ed8;
  border-radius: 14px; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.theme button[data-theme-set="web"][aria-pressed="true"] { --btn-face: #1a3a9a; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .35); }
.theme button[data-theme-set]:focus-visible { outline-color: var(--fg); }

/* Keyboard palette over the command list */
.cmds li.on a { background: var(--sel-bg); color: var(--sel-fg); }
.cmds li.on a .d { color: var(--sel-fg); }
[data-theme="web"] .cmds li.on a { background: var(--card); color: var(--fg); border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
[data-theme="web"] .cmds li.on a .d { color: var(--dim); }
.keys { color: var(--dim); font-size: .85rem; margin: -.5rem 0 1rem; }
.keys kbd { font: inherit; border: 1px solid var(--ctl); padding: 0 .35rem; border-radius: var(--radius); }
@media (hover: none) { .keys { display: none; } }

/* First visit: a short boot sequence over the home page */
html.boot::before { content: ""; position: fixed; inset: 0; z-index: 99; background: var(--bg); animation: boot-failsafe 0s 4s forwards; }
@keyframes boot-failsafe { to { visibility: hidden; } }
#boot { position: fixed; inset: 0; z-index: 100; background: var(--bg); color: var(--fg); display: flex; align-items: center; cursor: pointer; }
#boot pre { margin: 0; font: inherit; font-size: 1.1rem; line-height: 1.8; white-space: pre-wrap; }
#boot .skip-hint { position: absolute; bottom: 1.2rem; left: 0; right: 0; color: var(--dim); font-size: .85rem; }
#boot.out { opacity: 0; transition: opacity .25s ease-out; }

