/* SPDX-License-Identifier: GPL-2.0-or-later */
/* SPDX-FileCopyrightText: 2026 Sasha Kot */
/* Calm technical identity: graphite and soft silver, amber accent.
   Tokens on :root; dark theme redefines them (system preference or manual). */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --fg: #1c2128; --muted: #4f5a66;
  --line: #d8dde3; --line-soft: #e6e9ed;
  --accent: #ffb000;            /* decorative amber */
  --link: #8a4b00;              /* amber, dark enough for text */
  --link-hover: #5f3300;
  --code-bg: #eceff3; --code-fg: #1c2128;
  --mark: #2b3038;              /* logo graphite */
  --note-bg: #fff6df; --note-line: #e0a100;
  --tk-kw: #8a4b00; --tk-str: #1f6a4d; --tk-num: #354f94; --tk-com: #56616d; --tk-bi: #6b3f9b;
  --shadow: 0 1px 2px rgba(20,24,30,.06), 0 4px 14px rgba(20,24,30,.05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  --topbar: 3.5rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1a1e24; --fg: #e3e6ea; --muted: #a0a9b4;
    --line: #2d333b; --line-soft: #242a31;
    --accent: #ffb000; --link: #ffb829; --link-hover: #ffd37a;
    --code-bg: #1e242b; --code-fg: #e3e6ea; --mark: #cfd5dc;
    --note-bg: #2a2412; --note-line: #b88400;
    --tk-kw: #ffb829; --tk-str: #8fd3b2; --tk-num: #a3bdf2; --tk-com: #8f9aa7; --tk-bi: #c9b4f2;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --surface: #1a1e24; --fg: #e3e6ea; --muted: #a0a9b4;
  --line: #2d333b; --line-soft: #242a31;
  --accent: #ffb000; --link: #ffb829; --link-hover: #ffd37a;
  --code-bg: #1e242b; --code-fg: #e3e6ea; --mark: #cfd5dc;
  --note-bg: #2a2412; --note-line: #b88400;
  --tk-kw: #ffb829; --tk-str: #8fd3b2; --tk-num: #a3bdf2; --tk-com: #8f9aa7; --tk-bi: #c9b4f2;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar) + 1rem); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.65 var(--font); }
a { color: var(--link); text-underline-offset: .15em; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent); color: #1c2128; }
.mk { fill: var(--mark); }
.mk-a { fill: var(--accent); }

.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--surface); color: var(--fg);
  border: 2px solid var(--link); padding: .5rem .9rem; border-radius: 6px; }
.skip:focus { top: .6rem; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: .75rem;
  padding: 0 max(16px, calc((100vw - 78rem) / 2 + 16px)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--fg); text-decoration: none; font-weight: 650;
  font-size: 1.1rem; letter-spacing: -.01em; margin-right: auto; }
.brand:hover { color: var(--fg); }
.logo-s { width: 1.75rem; height: 1.75rem; }
.icon-btn { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); border-radius: 8px; cursor: pointer; padding: 0; }
.icon-btn:hover { border-color: var(--muted); }
.icon-btn[hidden], .search[hidden] { display: none; }
.search { position: relative; width: min(22rem, 40vw); }
.search input { width: 100%; height: 2.4rem; padding: 0 .8rem; font: inherit; font-size: .92rem; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.search input::placeholder { color: var(--muted); }
.results { list-style: none; margin: 0; padding: 0; position: absolute; right: 0; top: 2.9rem; width: min(30rem, calc(100vw - 32px));
  max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.results:empty { display: none; }
.results a { display: block; padding: .55rem .85rem; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--line-soft); }
.results li:last-child a { border-bottom: 0; }
.results a:hover, .results a:focus-visible { background: var(--code-bg); outline-offset: -2px; }
.r-title { display: block; font-weight: 600; font-size: .93rem; }
.r-sum { display: block; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.r-none { padding: .7rem .85rem; color: var(--muted); font-size: .9rem; }

/* Draft banner */
.draft-banner { background: var(--note-bg); color: var(--fg); border-bottom: 1px solid var(--note-line); padding: .45rem 16px;
  text-align: center; font-size: .9rem; }
.badge { display: inline-block; vertical-align: .25em; margin-left: .6rem; padding: .1rem .55rem; font-size: .72rem; font-weight: 650;
  letter-spacing: .06em; text-transform: uppercase; color: var(--fg); background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 999px; }

/* Layout */
.layout { display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); gap: 0 3rem; max-width: 78rem; margin: 0 auto; padding: 0 16px; }
.sidebar { position: sticky; top: var(--topbar); align-self: start; height: calc(100vh - var(--topbar)); overflow-y: auto;
  padding: 1.5rem .5rem 2rem 0; font-size: .92rem; overscroll-behavior: contain; }
.sidebar details { margin: 0 0 .35rem; }
.sidebar summary { cursor: pointer; list-style: none; padding: .3rem .5rem; border-radius: 6px; font-size: .74rem; font-weight: 650;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: ""; width: .45rem; height: .45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; }
.sidebar details[open] > summary::after { transform: rotate(45deg); }
.sidebar summary:hover { color: var(--fg); }
.sidebar ul { list-style: none; margin: .1rem 0 .4rem; padding: 0; border-left: 1px solid var(--line); margin-left: .6rem; }
.sidebar li a { display: block; padding: .28rem .75rem; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted);
  text-decoration: none; line-height: 1.4; }
.sidebar li a:hover { color: var(--fg); }
.sidebar a[aria-current] { color: var(--fg); font-weight: 600; border-left-color: var(--accent); background: linear-gradient(90deg, var(--code-bg), transparent); }

main { min-width: 0; padding: 2.25rem 0 3rem; outline: none; }
article { max-width: 46rem; }
article h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 1.5rem; text-wrap: balance; }
article h2 { font-size: 1.45rem; line-height: 1.3; letter-spacing: -.01em; margin: 2.6rem 0 .8rem; padding-top: 1.4rem; border-top: 1px solid var(--line); text-wrap: balance; }
article h3 { font-size: 1.15rem; line-height: 1.35; margin: 2rem 0 .5rem; }
article h4 { font-size: 1rem; margin: 1.5rem 0 .4rem; }
article p, article ul, article ol { margin: 0 0 1rem; }
article li { margin: .25rem 0; }
article li > ul, article li > ol { margin: .25rem 0 .4rem; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.anchor { margin-left: .4rem; color: var(--muted); text-decoration: none; font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--link); }

code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); color: var(--code-fg); padding: .12em .38em; border-radius: 4px;
  border: 1px solid var(--line-soft); overflow-wrap: anywhere; }
pre { background: var(--code-bg); color: var(--code-fg); margin: 0 0 1.25rem; padding: .9rem 1rem; overflow-x: auto; border-radius: 8px;
  border: 1px solid var(--line-soft); font: .86rem/1.55 var(--mono); tab-size: 4; }
pre code { padding: 0; background: none; border: 0; font: inherit; overflow-wrap: normal; }
code.illustrative, pre.illustrative { border: 1px dashed var(--muted); }
.hl .k, .hl .kc, .hl .kd, .hl .kn, .hl .kp, .hl .kr, .hl .kt, .hl .ow { color: var(--tk-kw); }
.hl .s, .hl .sa, .hl .sb, .hl .sc, .hl .dl, .hl .sd, .hl .s2, .hl .se, .hl .sh, .hl .si, .hl .sx, .hl .sr, .hl .s1, .hl .ss { color: var(--tk-str); }
.hl .m, .hl .mb, .hl .mf, .hl .mh, .hl .mi, .hl .il, .hl .mo, .hl .no { color: var(--tk-num); }
.hl .c, .hl .ch, .hl .cm, .hl .c1, .hl .cs, .hl .cp, .hl .cpf, .hl .gh, .hl .gu { color: var(--tk-com); font-style: italic; }
.hl .nb, .hl .bp, .hl .nd, .hl .nt, .hl .ni, .hl .ne { color: var(--tk-bi); }
.hl .nf, .hl .nc, .hl .fm, .hl .nn { font-weight: 600; }
.hl .gd { color: var(--tk-kw); } .hl .gi { color: var(--tk-str); }
.hl .err { color: inherit; }

blockquote { margin: 0 0 1.25rem; padding: .7rem 1rem; background: var(--note-bg); border: 1px solid var(--note-line);
  border-left-width: 4px; border-radius: 6px; }
blockquote > :last-child { margin-bottom: 0; }
blockquote > :first-child { margin-top: 0; }

.table-wrap, table { max-width: 100%; }
table { display: block; overflow-x: auto; border-collapse: collapse; margin: 0 0 1.25rem; font-size: .9rem; line-height: 1.5;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
th, td { padding: .55rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--code-bg); white-space: nowrap; font-weight: 650; }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 550; }

/* On-page contents */
.toc { margin: 0 0 1.75rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: .9rem; }
.toc-title { margin: 0 0 .4rem; font-size: .74rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; columns: 2 14rem; column-gap: 2rem; }
.toc li { margin: .15rem 0; break-inside: avoid; }
.toc li.l3 { padding-left: .9rem; font-size: .86rem; }
.toc a { text-decoration: none; color: var(--muted); }
.toc a:hover { color: var(--link); text-decoration: underline; }

/* Previous / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 46rem; margin-top: 3rem; }
.pager a { display: block; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--fg); }
.pager a:hover { border-color: var(--accent); }
.pager .dir { display: block; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pager .ttl { display: block; font-weight: 600; color: var(--link); }
.pager .next { grid-column: 2; text-align: right; }
.pager .prev { grid-column: 1; }

/* Home */
.hero { display: flex; align-items: center; gap: 1.75rem; padding: 1rem 0 2rem; }
.logo-l { width: 6.5rem; height: 6.5rem; flex: none; }
.hero h1 { font-size: 2.8rem; margin: 0; }
.tagline { font-size: 1.2rem; color: var(--muted); margin: .4rem 0 0; max-width: 34rem; text-wrap: balance; }
.cards { list-style: none; margin: 0 0 2.5rem; padding: 0; display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); max-width: 56rem; }
.cards li { margin: 0; }
.card { display: block; height: 100%; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--fg); box-shadow: var(--shadow); }
.card:hover { border-color: var(--accent); color: var(--fg); }
.card-t { display: block; font-weight: 650; font-size: 1.05rem; margin-bottom: .2rem; }
.card:hover .card-t { color: var(--link); }
.card-d { display: block; color: var(--muted); font-size: .9rem; line-height: 1.5; }
article.is-home { max-width: 56rem; }
article.is-home > p, article.is-home > ul, article.is-home > h2 { max-width: 46rem; }

.footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .85rem; }
.footer-in { max-width: 78rem; margin: 0 auto; padding: 1.2rem 16px; }
.footer p { margin: .15rem 0; }

/* Wide screens: contents as a sticky right column is skipped; keep the box inline. */
@media (max-width: 860px) {
  .layout { display: block; padding: 0 16px; }
  .search { width: auto; flex: 1; max-width: 18rem; }
  .brand span { display: none; }
  .brand { margin-right: 0; }
  .topbar { gap: .5rem; }
  .search { margin-left: auto; }
  article h1 { font-size: 1.75rem; }
  .hero { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .hero h1 { font-size: 2.2rem; }
  .logo-l { width: 4.5rem; height: 4.5rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next, .pager .prev { grid-column: 1; text-align: left; }
  /* Drawer. With JS off the navigation stays in the page, above the content. */
  .sidebar { position: static; height: auto; padding: 1rem 0; border-bottom: 1px solid var(--line); }
  .js-menu .sidebar { position: fixed; z-index: 20; top: var(--topbar); left: 0; bottom: 0; width: min(20rem, 88vw); height: auto;
    background: var(--surface); border-right: 1px solid var(--line); border-bottom: 0; padding: 1rem 1rem 2rem; transform: translateX(-102%);
    visibility: hidden; transition: transform .18s, visibility .18s; }
  .js-menu.menu-open .sidebar { transform: none; visibility: visible; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

