/* attic documentation: shared stylesheet.
 *
 * The docs wear the app's own look ("Desk", picked 2026-10-24): the web app's
 * ink desk, Archivo for reading and headings, Space Mono for every label,
 * kicker, table header, key chip and code. Tokens are the attic palette
 * (assets/attic/tokens/colors.css); app sections carry their band colour as a
 * mono kicker and a dot in the sidebar, the same colours the cards use.
 *
 * Dark is the default. A light mode (warm paper, ink text, not white) follows
 * the system setting until the ◐ button in the top bar picks one, which is
 * then remembered (docs.js, key `attic.docs.theme`, on <html data-theme>).
 * The tokens are spelled once per mode below; the light set is applied both
 * for an explicit choice and for a light system with no choice made.
 *
 * Fonts are vendored in docs/fonts/ as latin woff2 subsets because this site
 * has to open straight off file:// with no CDN.
 */

/* ---------------------------------------------------------------- fonts --- */
@font-face {
  font-family: Archivo; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/archivo-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: Archivo; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/archivo-latin-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: Archivo; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/archivo-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: Archivo; font-style: normal; font-weight: 900; font-display: swap;
  src: url("fonts/archivo-latin-900-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/space-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/space-mono-latin-700-normal.woff2") format("woff2");
}

/* ---------------------------------------------------------------- tokens --- */
:root {
  color-scheme: dark;
  /* Ink: the desk. The sidebar is one step up, like the rail. */
  --page: #0a0a0b;
  --side: #141316;
  --raise: #1c1b1e;
  --sel: #26242a;
  --line: #2e2c32;
  --hairline: #1f1e22;
  --text: #f5f3fa;
  --body: #d4ced2;
  --muted: #a7a0a0;
  --faint: #7d7780;
  --link: #8ccaf2;
  --pill-bg: #ece9e3;
  --pill-fg: #0a0a0b;
  --code-fg: #efe6dc;
  --tip: #a9ecc7;
  --tip-wash: #a9ecc716;
  --warn: #e8b740;
  --warn-wash: #e8b7401a;
  --shadow: 0 1px 2px #00000040, 0 8px 24px #00000038;
  /* How far a band colour is pulled toward ink when it is used as TEXT. On
   * ink the pale bands read as they are; on paper they need darkening. */
  --band-ink: 0%;

  --sans: Archivo, ui-sans-serif, system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 248px;
  --topbar-h: 58px;
  --measure: 70ch;   /* prose */
  --wide: 1060px;    /* tables, code, diagrams break out to this */

  /* App bands, straight off webapp/src/theme/tokens.ts BANDS. */
  --band-todo: #a9ecc7;
  --band-calendar: #a8e0d6;
  --band-shopping: #f0d6ab;
  --band-wiki: #f0d6ab;
  --band-thoughts: #d0c6f0;
  --band-rss: #f2bda6;
  --band-habits: #f2b3d1;
  --band-docs: #a7a0a0;
  --band-stocks: #c6e3a4;
  --band-flows: #9fd9cf;
  --band-applets: #a6dcec;
  --band-chat: #5fb4ec;
  --band-dashboard: #f2cfa0;
  --band-notifications: #e4dbf7;
  --band-bots: #b18cf0;
}

:root[data-theme="light"] {
  color-scheme: light;
  /* Paper: the card colour, so a light page reads like an attic card. */
  --page: #ece9e3;
  --side: #e4e0d9;
  --raise: #dedad2;
  --sel: #cfcbc3;
  --line: #cfcbc3;
  --hairline: #dcd8d0;
  --text: #0a0a0b;
  --body: #26231f;
  --muted: #4a463f;
  --faint: #6b665e;
  --link: #1d5f8f;
  --pill-bg: #0a0a0b;
  --pill-fg: #f5f3fa;
  --code-fg: #1a1613;
  --tip: #2f7a52;
  --tip-wash: #2f7a5214;
  --warn: #8a5f00;
  --warn-wash: #b4870018;
  --shadow: 0 1px 2px #0a0a0b0d, 0 6px 20px #0a0a0b12;
  --band-ink: 50%;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --page: #ece9e3;
    --side: #e4e0d9;
    --raise: #dedad2;
    --sel: #cfcbc3;
    --line: #cfcbc3;
    --hairline: #dcd8d0;
    --text: #0a0a0b;
    --body: #26231f;
    --muted: #4a463f;
    --faint: #6b665e;
    --link: #1d5f8f;
    --pill-bg: #0a0a0b;
    --pill-fg: #f5f3fa;
    --code-fg: #1a1613;
    --tip: #2f7a52;
    --tip-wash: #2f7a5214;
    --warn: #8a5f00;
    --warn-wash: #b4870018;
    --shadow: 0 1px 2px #0a0a0b0d, 0 6px 20px #0a0a0b12;
    --band-ink: 50%;
  }
}

/* Which band a section or sidebar dot takes; set by build.py as data-app. */
[data-app="todo"] { --band: var(--band-todo); }
[data-app="calendar"] { --band: var(--band-calendar); }
[data-app="shopping"] { --band: var(--band-shopping); }
[data-app="wiki"] { --band: var(--band-wiki); }
[data-app="thoughts"] { --band: var(--band-thoughts); }
[data-app="rss"] { --band: var(--band-rss); }
[data-app="habits"] { --band: var(--band-habits); }
[data-app="docs"] { --band: var(--band-docs); }
[data-app="stocks"] { --band: var(--band-stocks); }
[data-app="flows"] { --band: var(--band-flows); }
[data-app="applets"] { --band: var(--band-applets); }
[data-app="chat"] { --band: var(--band-chat); }
[data-app="dashboard"] { --band: var(--band-dashboard); }
[data-app="notifications"] { --band: var(--band-notifications); }
[data-app="bots"] { --band: var(--band-bots); }

/* ------------------------------------------------------------------ base --- */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 1.5rem);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--body);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.7;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in srgb, var(--band-applets) 35%, transparent); }

/* ---------------------------------------------------------------- topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.25rem;
  height: var(--topbar-h);
  padding: 0 1.5rem;
  background: var(--page);
  border-bottom: 1px solid var(--line);
}

.topbar .brand a {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--text); text-decoration: none;
  font-weight: 900; font-size: 1.05rem; letter-spacing: -0.01em;
}
/* The lean-to house: a square whose roof slopes from the right. */
.topbar .brand .mark {
  width: 18px; height: 18px;
  background: var(--text);
  clip-path: polygon(0 36%, 100% 0, 100% 100%, 0 100%);
}
.topbar .brand .sub {
  font-family: var(--mono); font-weight: 400;
  font-size: 0.72rem; color: var(--faint); letter-spacing: 0.02em;
}

.topbar nav { display: flex; align-items: center; gap: 0.3rem; margin-left: auto; }
.topbar nav a {
  color: var(--muted); text-decoration: none;
  font-size: 0.86rem; font-weight: 700;
  padding: 0.28rem 0.85rem; border-radius: 99px;
}
.topbar nav a:hover { color: var(--text); background: var(--raise); }
.topbar nav a.active { color: var(--pill-fg); background: var(--pill-bg); }

.theme-toggle {
  display: grid; place-items: center;
  width: 32px; height: 32px; margin-left: 0.35rem;
  border: 0; border-radius: 50%;
  background: var(--raise); color: var(--text);
  font-size: 0.95rem; line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--sel); }

/* The contents drawer's button: only where the sidebar does not fit. */
.toc-toggle {
  display: none; place-items: center;
  width: 32px; height: 32px; margin-left: 0.35rem;
  border: 0; border-radius: 50%;
  background: var(--raise); color: var(--text);
  font-size: 0.95rem; line-height: 1;
  cursor: pointer;
}
.toc-toggle[aria-expanded="true"] { color: var(--pill-fg); background: var(--pill-bg); }

/* ---------------------------------------------------------------- layout --- */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 1.4rem 0.9rem 3rem;
  background: var(--side);
  scrollbar-width: thin;
}

.sidebar h4 {
  margin: 1.5rem 0.6rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--faint);
}
.sidebar h4:first-child { margin-top: 0.2rem; }

.sidebar a {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.24rem 0.6rem;
  color: var(--muted); text-decoration: none;
  font-size: 0.875rem; line-height: 1.45;
  border-radius: 8px;
}
.sidebar a:hover { color: var(--text); background: var(--raise); }
.sidebar a.active { color: var(--text); background: var(--sel); font-weight: 700; }
.sidebar .dot {
  width: 8px; height: 8px; flex: none;
  border-radius: 2px;
  /* Pulled toward ink on paper, where the pale bands would vanish. */
  background: color-mix(in srgb, var(--band, transparent) calc(100% - var(--band-ink) / 2), #0a0a0b);
}
.sidebar .dot:not([data-app]) { background: none; }
.sidebar .dot[data-app="bots"] { border-radius: 50%; }

.content { flex: 1 1 auto; min-width: 0; padding: 3rem 3.5rem 6rem; }
.content .inner { max-width: var(--wide); margin: 0 auto; }

/* The landing page has no sidebar, so it gets a tighter column. */
body > .content .inner { max-width: 820px; }

/* Prose keeps a reading measure; data breaks out to the full container. */
.inner > p,
.inner > ul,
.inner > ol,
.inner > h1,
.inner > h2,
.inner > h3,
.inner > blockquote { max-width: var(--measure); }

/* ------------------------------------------------------------ typography --- */
h1, h2, h3 {
  color: var(--text);
  font-family: var(--sans);
  font-weight: 900;
  letter-spacing: -0.015em;
  line-height: 1.12;
  text-wrap: balance;
}

h1 { font-size: 2.7rem; margin: 0 0 1rem; line-height: 1; }

h2 {
  font-size: 1.7rem;
  margin: 3.6rem 0 1rem;
  scroll-margin-top: calc(var(--topbar-h) + 1.5rem);
}
/* An app's section opens with its band: a mono kicker, "■ APP · TODO". */
h2[data-kicker]::before {
  content: attr(data-kicker);
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.12em;
  color: color-mix(in srgb, var(--band) calc(100% - var(--band-ink)), #0a0a0b);
}
h1 + h2, .lead + h2 { margin-top: 2.4rem; }

h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 2.3rem 0 0.5rem;
}

p { margin: 0 0 1.1rem; }

.lead {
  font-size: 1.2rem; line-height: 1.6;
  color: var(--muted);
  margin-bottom: 2.4rem;
  max-width: 62ch;
}

strong { font-weight: 700; color: var(--text); }

ul, ol { margin: 0 0 1.2rem; padding-left: 1.35rem; }
li { margin: 0.3rem 0; }
li > ul, li > ol { margin: 0.3rem 0 0.5rem; }
li::marker { color: var(--faint); }

a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}
a:hover { text-decoration-color: currentColor; }

hr { border: none; border-top: 1px solid var(--line); margin: 3rem 0; }

/* ------------------------------------------------------------------ code --- */
/* 1000+ inline spans sit in this prose, so they are a tint, not a chip. */
code {
  font-family: var(--mono);
  font-size: 0.82em;
  color: var(--code-fg);
  background: var(--raise);
  padding: 0.1em 0.3em;
  border-radius: 4px;
  word-break: break-word;
  /* A long identifier may break anywhere rather than push a phone-width
     page wider than the screen. */
  overflow-wrap: anywhere;
}

/* A long unbroken run (a/b/c/d lists, URLs) breaks rather than widen the page. */
.content p, .content li { overflow-wrap: break-word; }

pre {
  background: var(--side);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  line-height: 1.6;
}
pre code {
  background: none; padding: 0; border-radius: 0;
  font-size: 0.82rem;
  word-break: normal;
}

/* ASCII art: hand-aligned, so it must not wrap or re-space. */
.diagram {
  font-family: var(--mono);
  font-size: 0.78rem; line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  background: var(--side);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--muted);
}

/* ----------------------------------------------------------- screenshots --- */
/* Every picture is the app running against demos/masterdata, regenerated by
 * docs/screenshots.py. Figures break out of the prose measure the way tables
 * and diagrams do. Markdown wraps the image in a <p>, hence the nesting. */
.shot { margin: 1.8rem 0; }
.shot p { margin: 0; }
.shot img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Phone screens read as a set, so they sit in a row and wrap on narrow
 * viewports rather than stacking three tall pictures. */
.shot.row p {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  align-items: flex-start;
}

/* ------------------------------------------------------- device frames --- */
/* build.py wraps each screenshot in the device it was taken on, picked from
 * the file name: web-* in a desktop window, tui-* in a terminal window,
 * phone-* in a phone body. The frames are dark in both modes: they are
 * hardware, not page. */
.device img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.device-web,
.device-tui {
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #00000099;
  box-shadow: var(--shadow);
}
.device-bar {
  display: block;
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: #8d8b93;
  background:
    radial-gradient(circle at 18px 50%, #ff5f57 0 5.5px, transparent 6px),
    radial-gradient(circle at 38px 50%, #febc2e 0 5.5px, transparent 6px),
    radial-gradient(circle at 58px 50%, #28c840 0 5.5px, transparent 6px),
    #2b2a30;
  border-bottom: 1px solid #00000066;
}
.device-tui .device-bar { background-color: #2a241f; color: #a7988a; }

/* Every phone shot is the same size, alone or in a row: a 540x1200 screen in
 * a dark body with a camera hole and side buttons. */
.device-phone {
  display: block;
  position: relative;
  width: 240px;
  max-width: 100%;
  padding: 8px;
  border-radius: 22px;
  background: #0d0d10;
  box-shadow: var(--shadow), inset 0 0 0 1.5px #3b3a42;
}
.shot.row .device-phone { display: inline-block; }
.device-phone img { border-radius: 14px; }
.device-phone::before {
  content: "";
  position: absolute;
  top: 17px; left: 50%;
  width: 9px; height: 9px; margin-left: -4.5px;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 1.5px #1c1c22;
}
.device-phone::after {
  content: "";
  position: absolute;
  top: 96px; right: -3px;
  width: 3px; height: 64px;
  border-radius: 0 2px 2px 0;
  background: #2c2b32;
}

/* ---------------------------------------------------------------- tables --- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}
thead th {
  font-family: var(--mono);
  font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--faint);
  text-align: left;
  padding: 0 0.85rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 0.62rem 0.85rem;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--side); }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }
/* Table cells are data, so a code span in one should not also be a box. */
td code, th code { background: none; padding: 0; font-size: 0.86em; }

/* -------------------------------------------------------------- callouts --- */
/* A tinted box with a mono label, the app's way, rather than a side stripe. */
.note {
  background: var(--tip-wash);
  border-radius: 12px;
  padding: 0.9rem 1.15rem;
  margin: 1.6rem 0;
  font-size: 0.95rem;
  max-width: var(--measure);
}
.note::before {
  content: "NOTE";
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--mono);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.12em;
  color: var(--tip);
}
.note.warn { background: var(--warn-wash); }
.note.warn::before { content: "WATCH OUT"; color: var(--warn); }
/* markdown wraps the callout's prose in a <p>; don't let that pad the box. */
.note > p:first-child, footer > p:first-child { margin-top: 0; }
.note > p:last-child, footer > p:last-child { margin-bottom: 0; }

/* ----------------------------------------------------------------- chips --- */
kbd {
  font-family: var(--mono);
  font-size: 0.74em; font-weight: 700;
  background: var(--raise);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05em 0.4em;
  color: var(--text);
  white-space: nowrap;
}

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.12em 0.6em;
  border-radius: 99px;
  background: var(--raise);
  color: var(--text);
}

/* ----------------------------------------------------- cards (landing) --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 2.5rem 0;
  max-width: var(--wide);
}
.card {
  display: block;
  padding: 1.4rem 1.5rem;
  border-radius: 16px;
  background: var(--side);
  color: inherit; text-decoration: none;
  transition: background .16s ease;
}
.card:hover { background: var(--raise); }
.card h3 { margin: 0 0 0.4rem; font-size: 1.15rem; font-weight: 900; color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 0.94rem; line-height: 1.6; }

/* ---------------------------------------------------------------- footer --- */
footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.85rem;
  max-width: var(--measure);
}

/* ------------------------------------------------------------ responsive --- */
@media (max-width: 1000px) {
  .sidebar { display: none; }
  .toc-toggle { display: grid; }
  /* Open: the sidebar becomes the whole screen under the top bar. */
  .toc-open .sidebar {
    display: block;
    position: fixed; z-index: 15;
    top: var(--topbar-h); left: 0; right: 0; bottom: 0;
    width: auto; height: auto;
    padding: 1.2rem 1rem 3rem;
  }
  .toc-open .sidebar a { padding: 0.5rem 0.6rem; font-size: 1rem; }
  body.toc-open { overflow: hidden; }
  .content { padding: 2.25rem 1.5rem 4rem; }
  .topbar { padding: 0 1rem; gap: 0.75rem; }
  .topbar .brand .sub { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  /* The brand already goes home; the pills need the room. */
  .topbar nav a[href="index.html"] { display: none; }
  .topbar .theme-toggle, .topbar .toc-toggle { margin-left: 0.15rem; }
  .content { padding: 1.75rem 1rem 3rem; }
  .topbar nav a { padding: 0.25rem 0.55rem; font-size: 0.8rem; }
  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.4rem; }
  .lead { font-size: 1.06rem; }
}
