/* Hiyu - Copyright Kyle Blizzard - HiyuComputer.com */
/* SPDX-License-Identifier: BSD-3-Clause */

/*
 * The owner's manual. The OS carries the gloss; the site is the paper it came
 * wrapped in: warm paper, black ink, hairline rules, numbered chapters, and
 * one glossy object on the page, the badge. Cobalt from the badge's diamond is
 * the only accent.
 *
 * Layers, top to bottom: tokens, fonts, base, components, pages, print. The
 * account origin and the forum reuse tokens, fonts, base and components.
 *
 * Contrast (WCAG, computed by scripts/contrast.py from the tokens below):
 *   light  ink/paper 15.5  muted/paper 7.2  cobalt/paper 7.6  on-cobalt/cobalt 7.6  cobalt/deep 6.8
 *   dark   ink/paper 14.7  muted/paper 8.3  cobalt/paper 5.6  on-cobalt/cobalt 5.9  cobalt/deep 5.1
 */

/* ── tokens ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light dark;
  --paper: #F4EFE4;
  --paper-deep: #EAE3D2;
  --ink: #17181C;
  --ink-muted: #4B4E57;
  --rule: #D9D1BE;
  --chrome: #AEB2BA;
  --cobalt: #1F43A6;
  --cobalt-deep: #172F7A;
  --on-cobalt: #F4EFE4;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Chivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "DejaVu Sans Mono", Menlo, Consolas, monospace;

  --frame: 1100px;
  --reading: 72ch;
  --gutter: 16px;
  --note: 220px;
}
@media (min-width: 600px) { :root { --gutter: 24px; } }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15161A;
    --paper-deep: #1D1E24;
    --ink: #EDE7D8;
    --ink-muted: #B5AF9F;
    --rule: #2E3039;
    --chrome: #6E737D;
    --cobalt: #6F8AE8;
    --cobalt-deep: #5B79E0;
    --on-cobalt: #0F1118;
  }
}
:root[data-theme="dark"] {
  --paper: #15161A;
  --paper-deep: #1D1E24;
  --ink: #EDE7D8;
  --ink-muted: #B5AF9F;
  --rule: #2E3039;
  --chrome: #6E737D;
  --cobalt: #6F8AE8;
  --cobalt-deep: #5B79E0;
  --on-cobalt: #0F1118;
}

/* ── fonts (self-hosted, Latin subsets; licences beside the files) ───────── */
@font-face { font-family: "Chivo"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../assets/fonts/Chivo-Bold.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../assets/fonts/SourceSerif4-Regular.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 400; font-style: italic; font-display: swap;
  src: url("../assets/fonts/SourceSerif4-It.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../assets/fonts/SourceSerif4-Semibold.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 600; font-style: italic; font-display: swap;
  src: url("../assets/fonts/SourceSerif4-SemiboldIt.woff2") format("woff2"); }
@font-face { font-family: "DejaVu Sans Mono"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../assets/fonts/DejaVuSansMono.woff2") format("woff2"); }
@font-face { font-family: "DejaVu Sans Mono"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../assets/fonts/DejaVuSansMono-Bold.woff2") format("woff2"); }

/* ── base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 18px/1.6 var(--serif);
  font-feature-settings: "kern", "liga", "onum";
  overflow-wrap: break-word;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--cobalt); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--cobalt-deep); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; }
::selection { background: var(--cobalt); color: var(--on-cobalt); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

h1, h2, h3, h4 { font-family: var(--sans); font-weight: 700; color: var(--ink); line-height: 1.1; margin: 0 0 0.6em; letter-spacing: -0.01em; }
h1 { font-size: clamp(44px, 8vw, 96px); line-height: 0.95; letter-spacing: -0.025em; }
h2 { font-size: clamp(28px, 3.2vw, 40px); letter-spacing: -0.02em; }
h3 { font-size: 22px; }
h4 { font-size: 18px; }
p, ul, ol, dl, table, pre, blockquote { margin: 0 0 1.2em; }
ul, ol { padding-left: 1.3em; }
li + li { margin-top: 0.35em; }
.menu li, .links li, .own-grid li { margin: 0; }
strong, b { font-weight: 600; }
em, i { font-style: italic; }
small, .small { font-size: 15px; line-height: 1.55; }
code, kbd, pre { font-family: var(--mono); font-size: 0.86em; }
code, kbd { background: var(--paper-deep); padding: 0.1em 0.35em; border-radius: 2px; }
pre { background: var(--paper-deep); padding: 14px 16px; overflow-x: auto; border-radius: 2px; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: 1em; }
blockquote { border-left: 2px solid var(--cobalt); margin-left: 0; padding-left: 1em; color: var(--ink-muted); }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); }
th { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
dt { font-weight: 600; }
dd { margin: 0 0 0.8em; }
abbr[title] { text-decoration: none; border-bottom: 1px dotted var(--chrome); }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--gutter); top: -100px; background: var(--cobalt); color: var(--on-cobalt); padding: 10px 14px; font-family: var(--mono); font-size: 13px; z-index: 10; }
.skip:focus { top: 8px; }

/* ── components ──────────────────────────────────────────────────────────── */
.frame { max-width: var(--frame); margin: 0 auto; padding: 0 var(--gutter); }
.reading { max-width: var(--reading); }

/* mono labels: the nav, chapter numbers, margin notes, stamps */
.label { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); }

/* the masthead: one hairline, the badge, the wordmark, plain links that wrap */
.masthead { border-bottom: 1px solid var(--rule); }
.masthead .frame { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; margin-right: auto; }
.brand img { width: 30px; height: 30px; }
.brand span { font-family: var(--sans); font-size: 20px; letter-spacing: -0.01em; }
.menu { display: flex; flex-wrap: wrap; gap: 0 4px; margin: 0; padding: 0; list-style: none; }
.menu a { display: inline-block; padding: 12px 10px; font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; color: var(--ink); min-height: 44px; }
.menu a:hover { color: var(--cobalt); text-decoration: underline; }
.menu a[aria-current="page"] { color: var(--cobalt); box-shadow: inset 0 -2px 0 var(--cobalt); }

/* the cover: badge, the one big line, the deck, the stamp */
.cover { padding: clamp(40px, 7vw, 96px) 0 clamp(32px, 5vw, 64px); }
.cover .frame { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: center; }
@media (min-width: 760px) { .cover .frame { grid-template-columns: minmax(140px, 200px) 1fr; gap: 48px; } }
.cover .badge { width: clamp(120px, 20vw, 200px); }
.cover h1 { margin-bottom: 0.3em; }
.cover .deck { font-size: clamp(20px, 2.2vw, 24px); line-height: 1.45; max-width: 36em; margin-bottom: 1em; }
.stamp { display: inline-block; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; background: var(--cobalt); color: var(--on-cobalt); padding: 7px 11px; border-radius: 2px; }

/* a page's own title block, for the inner pages */
.title { padding: clamp(32px, 5vw, 64px) 0 8px; }
.title h1 { font-size: clamp(36px, 5.5vw, 64px); line-height: 1; }
.title .deck { font-size: clamp(19px, 2vw, 22px); line-height: 1.45; max-width: 36em; color: var(--ink-muted); }

/* chapters: a numbered heading, a reading column, a margin note on wide screens */
.chapter { padding: clamp(28px, 4vw, 56px) 0; border-top: 1px solid var(--rule); }
.chapter .frame { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px var(--gutter); }
@media (min-width: 980px) { .chapter .frame { grid-template-columns: minmax(0, var(--reading)) var(--note); column-gap: 56px; } }
.chapter .num { display: block; font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: 0.12em; color: var(--cobalt); margin-bottom: 10px; }
.chapter h2 { margin-bottom: 0.5em; }
.chapter .body { min-width: 0; }
.chapter .body > :last-child { margin-bottom: 0; }
.note { font-family: var(--mono); font-size: 13px; line-height: 1.55; color: var(--ink-muted); border-top: 2px solid var(--ink); padding-top: 10px; align-self: start; }
.note p { margin: 0 0 0.8em; }
.note p:last-child { margin: 0; }
@media (min-width: 980px) { .note { position: sticky; top: 24px; } }

/* the three-up (and four-up) of things you own */
.own-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 28px 32px; margin: 1.5em 0 0; padding: 0; list-style: none; }
.own-grid li { margin: 0; }
.own-grid svg { width: 56px; height: 56px; margin-bottom: 12px; color: var(--ink); }
.own-grid h3 { font-size: 20px; margin-bottom: 0.35em; }
.own-grid p { margin: 0; font-size: 17px; }
.art-fill { fill: var(--cobalt); }
.art-paper { fill: var(--paper); }

/* a plain list of promises, each with a small cobalt square */
.plain { list-style: none; padding: 0; }
.plain li { position: relative; padding-left: 1.4em; }
.plain li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 0.5em; height: 0.5em; background: var(--cobalt); }

/* the honest status box */
.status { border: 1px solid var(--rule); background: var(--paper-deep); padding: 16px 20px; border-radius: 2px; margin: 0 0 1.5em; }
.status .label { display: block; margin-bottom: 6px; }
.status p { margin: 0; }
.status p + p { margin-top: 0.6em; }

/* the one button */
.button { display: inline-block; font-family: var(--sans); font-size: 16px; background: var(--cobalt); color: var(--on-cobalt); text-decoration: none; padding: 12px 20px; border-radius: 3px; min-height: 44px; line-height: 20px; }
.button:hover { background: var(--cobalt-deep); color: var(--on-cobalt); }

/* a definition-style fact list (the hardware list, the licence map) */
.facts { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0 0 1.4em; }
.facts div { display: grid; grid-template-columns: 1fr; gap: 2px 20px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 600px) { .facts div { grid-template-columns: 11em 1fr; } }
.facts dt { font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); padding-top: 4px; }
.facts dd { margin: 0; }

/* two-column prose on wide screens, for long legal text */
@media (min-width: 980px) { .columns { columns: 2; column-gap: 48px; } .columns > * { break-inside: avoid; } }

/* the footer */
.footer { border-top: 1px solid var(--rule); margin-top: clamp(40px, 6vw, 80px); padding: 28px 0 40px; font-size: 15px; color: var(--ink-muted); }
.footer .frame { display: grid; gap: 14px; }
.footer .links { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0; padding: 0; list-style: none; }
.footer .links a { font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; color: var(--ink); padding: 10px 14px 10px 0; display: inline-block; min-height: 44px; }
.footer .links a:hover { color: var(--cobalt); text-decoration: underline; }
.footer p { margin: 0; }
.footer .copyright { color: var(--ink); }

/* ── pages ───────────────────────────────────────────────────────────────── */
.apps { columns: 2; column-gap: 32px; font-size: 16px; }
@media (min-width: 600px) { .apps { columns: 3; } }
.apps li { break-inside: avoid; margin: 0 0 0.2em; }

.error .frame { padding-top: clamp(48px, 10vw, 120px); padding-bottom: 48px; }
.error h1 { font-size: clamp(40px, 7vw, 88px); }

/* ── print ───────────────────────────────────────────────────────────────── */
@media print {
  :root { --paper: #fff; --paper-deep: #fff; --ink: #000; --ink-muted: #333; --rule: #999; --cobalt: #000; }
  .masthead, .footer .links, .skip { display: none; }
  a { color: inherit; text-decoration: none; }
  .note { position: static; }
  .chapter { page-break-inside: avoid; }
}
