:root[data-accent="phosphor"] .kdbar {
  --pri: #39ff14;
  --dim: #12401f;
  --sec: #ffb000;
  --urg: #ff3131;
  --deep: #000a03;
  --text: #b8ffc8;
  --var: #04120a;
  --pdark: #1f8f0c;
  --bd: #02120a;
  --muted: #8ac297;
  --line: #104f08;
  --line-soft: #082c05;
  --glow: rgb(57 255 20 / 0.35);
  --scan: rgb(0 0 0 / 0.3);
  --crt-hue: 72deg;
  --crt-sat: 3.00;
  color-scheme: dark;
}
:root[data-accent="amber"] .kdbar {
  --pri: #ffb000;
  --dim: #4a2f00;
  --sec: #ff6b1a;
  --urg: #ff3131;
  --deep: #0d0600;
  --text: #ffd9a0;
  --var: #160d02;
  --pdark: #8a5f00;
  --bd: #140b02;
  --muted: #c2a478;
  --line: #513600;
  --line-soft: #2f1e00;
  --glow: rgb(255 176 0 / 0.35);
  --scan: rgb(0 0 0 / 0.3);
  --crt-hue: 2deg;
  --crt-sat: 3.00;
  color-scheme: dark;
}
:root[data-accent="ice"] .kdbar {
  --pri: #4dd7ff;
  --dim: #123a4a;
  --sec: #7aa2ff;
  --urg: #ff4d6d;
  --deep: #00080d;
  --text: #bfeeff;
  --var: #031420;
  --pdark: #1f7fa0;
  --bd: #021a26;
  --muted: #8fb4c2;
  --line: #164251;
  --line-soft: #0b252f;
  --glow: rgb(77 215 255 / 0.35);
  --scan: rgb(0 0 0 / 0.3);
  --crt-hue: 154deg;
  --crt-sat: 3.00;
  color-scheme: dark;
}
.kdbar, :root[data-accent="bone"] .kdbar {
  --pri: #f4f0e2;
  --dim: #3a3833;
  --sec: #b9b3a1;
  --urg: #ff5a5a;
  --deep: #0a0a09;
  --text: #ded9cb;
  --var: #141412;
  --pdark: #8f8b7e;
  --bd: #161512;
  --muted: #a9a59a;
  --line: #4c4a46;
  --line-soft: #2b2a27;
  --glow: rgb(244 240 226 / 0.35);
  --scan: rgb(0 0 0 / 0.3);
  --crt-hue: 8deg;
  --crt-sat: 1.35;
  color-scheme: dark;
}
:root[data-accent="norton"] .kdbar {
  --pri: #ffd75f;
  --dim: #1c3f8f;
  --sec: #5fd7ff;
  --urg: #ff5f5f;
  --deep: #00021a;
  --text: #f0f6ff;
  --var: #000f3c;
  --pdark: #a88a20;
  --bd: #000214;
  --muted: #b4b9c6;
  --line: #473e2d;
  --line-soft: #242024;
  --glow: rgb(255 215 95 / 0.35);
  --scan: rgb(0 0 0 / 0.3);
  --crt-hue: 6deg;
  --crt-sat: 3.00;
  color-scheme: dark;
}
:root[data-accent="borland"] .kdbar {
  --pri: #5fd7d7;
  --dim: #24494d;
  --sec: #ffd75f;
  --urg: #ff5f5f;
  --deep: #020e12;
  --text: #f0fcfc;
  --var: #07181c;
  --pdark: #2f8f8f;
  --bd: #010c0f;
  --muted: #b4c0c2;
  --line: #1c4649;
  --line-soft: #0f2a2e;
  --glow: rgb(95 215 215 / 0.35);
  --scan: rgb(0 0 0 / 0.3);
  --crt-hue: 141deg;
  --crt-sat: 1.80;
  color-scheme: dark;
}
:root[data-accent="perfect"] .kdbar {
  --pri: #ffffff;
  --dim: #1a3a7a;
  --sec: #b8cdf0;
  --urg: #ff8080;
  --deep: #000f42;
  --text: #eef4ff;
  --var: #001c5e;
  --pdark: #6f8fc8;
  --bd: #000c38;
  --muted: #b2bbd0;
  --line: #475277;
  --line-soft: #24315c;
  --glow: rgb(255 255 255 / 0.35);
  --scan: rgb(0 0 0 / 0.3);
  --crt-hue: -39deg;
  --crt-sat: 0.00;
  color-scheme: dark;
}
:root[data-accent="paper"] .kdbar {
  --pri: #1a5fb4;
  --dim: #c9c6bd;
  --sec: #9c6500;
  --urg: #a51d2d;
  --deep: #fbfaf6;
  --text: #1a1a17;
  --var: #f2f0e9;
  --pdark: #5b5750;
  --bd: #eceae2;
  --muted: #52524f;
  --line: #bccfe4;
  --line-soft: #dce4ed;
  --glow: rgb(26 95 180 / 0.35);
  --scan: rgb(0 0 0 / 0.06);
  --crt-hue: 174deg;
  --crt-sat: 2.24;
  color-scheme: light;
}
/* ██╗  ██╗██████╗  ██████╗ ███████╗
 * ██║ ██╔╝██╔══██╗██╔═══██╗██╔════╝
 * █████╔╝ ██║  ██║██║   ██║███████╗
 * ██╔═██╗ ██║  ██║██║   ██║╚════██║
 * ██║  ██╗██████╔╝╚██████╔╝███████║
 * ╚═╝  ╚═╝╚═════╝  ╚═════╝ ╚══════╝
 * ---------------------------------
 *   kdos.dev — the bar at the top of both books
 * ---------------------------------
 *
 * mksite.py puts the site's bar at the top of every page of the KDOS book
 * and KDOS from Scratch, and serves this file as assets/bar.css after the
 * accents' custom properties, which it writes on .kdbar rather than on
 * <html>: each book has properties of the same names, and the bar must
 * leave the book's own colours alone. Every rule is under .kdbar for the
 * same reason, and sets what a book's own element rules would otherwise
 * give the bar (link colours, list styles, fonts).
 *
 * The bar is laid over the top of the page, the full width of the window
 * whatever width the book gives its body, and .kdbar-space keeps the
 * book's text below it. It scrolls away with the page and is not pinned,
 * so a #fragment a reader opens lands with its heading in sight.
 *
 * Text is set only in --text, --muted or --pri, on --deep, --var or
 * --line-soft, and the skip link in --deep on --pri: the pairs mksite.py
 * checks, and one of them reversed.
 */

@font-face {
  font-family: "Terminus";
  src: url(fonts/terminus.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}

.kdbar-space { height: 56px; }
/* The link past the bar to the page's first heading: above the window
 * until the keyboard reaches it. */
.kdbar .kdbar-skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 1002;
  padding: 10px 14px;
  background: var(--pri);
  color: var(--deep);
  font-weight: 700;
}
.kdbar .kdbar-skip:focus { top: 8px; outline: 3px solid var(--text); }
.kdbar, .kdbar * { box-sizing: border-box; }
.kdbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 56px;
  background: var(--deep);
  color: var(--text);
  border-bottom: 1px solid var(--line);
  font: 400 16px/1 "Terminus", ui-monospace, "DejaVu Sans Mono", monospace;
  text-align: left;
}
.kdbar__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}
.kdbar a, .kdbar a:visited, .kdbar summary {
  color: var(--text);
  text-decoration: none;
  font: inherit;
  background: none;
}
.kdbar ul { list-style: none; margin: 0; padding: 0; }
.kdbar li { margin: 0; }
.kdbar p { margin: 0; }
.kdbar :focus-visible { outline: 3px solid var(--pri); outline-offset: 2px; }

.kdbar__brand {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.kdbar .kdbar__brand { font-size: 20px; }
.kdbar__brand img { width: 28px; height: 28px; image-rendering: pixelated; }

.kdbar__nav { flex: 1; }
.kdbar .nav__list { display: flex; align-items: center; gap: 2px; }
.kdbar .nav__list > li { position: relative; }
.kdbar .nav__link, .kdbar .dd__panel a, .kdbar__panel a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 3px;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.kdbar .nav__link { text-transform: uppercase; }
.kdbar .nav__link:hover, .kdbar .dd[open] > .nav__link,
.kdbar .dd__panel a:hover, .kdbar__panel a:hover {
  background: var(--line-soft);
  color: var(--pri);
}
/* The group that holds the book being read is marked as the site marks
 * the section a page is in, and the book's own entry in it. */
.kdbar .nav__link.is-here, .kdbar .dd__panel a[aria-current], .kdbar__panel a[aria-current] {
  color: var(--pri);
}
.kdbar .nav__link.is-here::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: -10px;
  height: 3px;
  background: var(--pri);
}
.kdbar .dd__panel a[aria-current]::before, .kdbar__panel a[aria-current]::before { content: "> "; }
.kdbar details > summary { list-style: none; }
.kdbar details > summary::-webkit-details-marker { display: none; }
.kdbar .dd__caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}
.kdbar .dd__panel, .kdbar__panel {
  position: absolute;
  top: calc(100% + 10px);
  min-width: 240px;
  background: var(--var);
  border: 1px solid var(--line);
  border-top: 2px solid var(--pri);
  box-shadow: 6px 6px 0 var(--line-soft);
  padding: 6px;
  z-index: 1001;
}
.kdbar .dd__panel { left: 0; }

.kdbar__menu { display: none; position: relative; margin-left: auto; }
.kdbar__menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.kdbar__menu[open] > summary { background: var(--line-soft); color: var(--pri); }
.kdbar__icon, .kdbar__icon::before, .kdbar__icon::after {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
}
.kdbar__icon { position: relative; }
.kdbar__icon::before, .kdbar__icon::after { content: ""; position: absolute; left: 0; }
.kdbar__icon::before { top: -5px; }
.kdbar__icon::after { top: 5px; }
.kdbar__panel {
  right: 0;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.kdbar .menu__top { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 6px; border-bottom: 1px dotted var(--line); }
.kdbar .menu__top a { text-transform: uppercase; }
.kdbar .menu__group { padding: 6px 0; border-bottom: 1px dotted var(--line); }
.kdbar .menu__group:last-child { border-bottom: 0; }
.kdbar .menu__label {
  margin: 4px 11px 2px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

@media (max-width: 1040px) {
  .kdbar__nav { display: none; }
  .kdbar__menu { display: block; }
}

@media print {
  .kdbar, .kdbar-space { display: none; }
}
