/* The docs: one section at a time, no page scroll. The brand's pixel font by
   default; "Aa" switches the reading text to DM Sans (from Google Fonts) for
   anyone who finds pixels tiring to read. */
@font-face { font-family: 'Pixelify Sans'; src: url('fonts/pixelify-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url('fonts/pixelify-sans-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('fonts/geist-mono-latin-400-normal.woff') format('woff'); font-weight: 400; font-display: swap; }

/* The brand palette (the avatar's eight blues), as on the landing. */
:root {
  --sky: #01061c;
  --navy: #060a22;
  --deep: #0a1030;
  --line: #1a2558;
  --royal: #2446c8;
  --blue: #4f8ef0;
  --ice: #b8d8ff;
  --white: #ffffff;
  --muted: #8ea6d8;
  --read: 'Pixelify Sans', system-ui, sans-serif;
  --size: 18px;
  --leading: 1.6;
}
:root[data-font="classic"] {
  --read: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --size: 17px;
  --leading: 1.65;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(36, 70, 200, 0.18), transparent 60%),
    var(--sky);
  color: var(--white);
  font-family: 'Pixelify Sans', system-ui, sans-serif;
  -webkit-font-smoothing: none;
}
:root[data-font="classic"] .content { -webkit-font-smoothing: antialiased; }
a { color: var(--ice); }
a:hover { color: var(--white); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* --- top bar --- */
.top {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 clamp(16px, 3vw, 40px);
  border-bottom: 2px solid var(--line);
}
.brand { font-weight: 600; font-size: 22px; color: var(--white); text-decoration: none; white-space: nowrap; }
.brand .accent { color: var(--ice); }
.top-title { color: var(--muted); font-size: 18px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 22px; font-size: 22px; }
.top-right a { text-decoration: none; }
.font {
  font-size: 15px;
  height: 34px;
  padding: 0 12px;
  color: var(--ice);
  box-shadow: inset 0 0 0 2px var(--royal);
}
.font:hover, .font[aria-pressed="true"] { background: var(--royal); color: var(--white); }
.font[aria-pressed="true"] { font-family: 'DM Sans', system-ui, sans-serif; }
.menu { display: none; font-size: 26px; width: 34px; }

/* --- layout --- */
.layout {
  height: calc(100svh - 64px);
  display: grid;
  grid-template-columns: clamp(220px, 20vw, 280px) 1fr;
}
.side {
  overflow-y: auto;
  padding: 28px clamp(16px, 2vw, 28px) 40px;
  border-right: 2px solid var(--line);
}
.group { margin-bottom: 26px; }
.group-title { margin: 0 0 10px; color: var(--muted); font-size: 14px; letter-spacing: 0.04em; text-transform: lowercase; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a {
  display: block;
  padding: 6px 10px;
  margin-left: -10px;
  font-size: 16px;
  color: var(--ice);
  text-decoration: none;
}
.side a:hover { color: var(--white); }
.side a { transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease; }
.side a[aria-current="page"] { background: var(--deep); color: var(--white); box-shadow: inset 3px 0 0 var(--blue); }

.content {
  overflow-y: auto;
  padding: clamp(28px, 4vw, 56px) clamp(16px, 5vw, 80px) 48px;
  font-family: var(--read);
  font-size: var(--size);
  line-height: var(--leading);
}
.page { max-width: 760px; }
.page[hidden] { display: none; }
/* A section rises in each time it's shown: going from hidden to shown
   restarts its animation, so a topic change needs no script. The menu
   rises in once, with the page. */
@keyframes page-in { from { opacity: 0; transform: translateY(14px); } }
.page { animation: page-in 0.45s ease-out both; }
.side { animation: page-in 0.6s ease-out 0.1s both; }
@media (prefers-reduced-motion: reduce) {
  .page, .side { animation: none; }
  .side a { transition: none; }
}
.kicker { margin: 0 0 6px; font-family: 'Pixelify Sans', sans-serif; color: var(--blue); font-size: 14px; }
.page h1 {
  margin: 0 0 22px;
  font-family: 'Pixelify Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.tag {
  display: inline-block;
  font-family: 'Pixelify Sans', sans-serif;
  font-weight: 400;
  font-size: 13px;
  line-height: 1;
  padding: 6px 8px;
  color: var(--ice);
  box-shadow: inset 0 0 0 2px var(--royal);
  vertical-align: middle;
}
.page p { margin: 0 0 16px; color: #dfe9ff; }
.page strong { color: var(--white); font-weight: 600; }
.page ul, .page ol { margin: 0 0 18px; padding-left: 1.3em; color: #dfe9ff; }
.page li { margin: 0 0 8px; }
.page li::marker { color: var(--blue); }
.formula {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 0.95em;
  padding: 14px 18px;
  background: var(--navy);
  box-shadow: inset 0 0 0 2px var(--line);
  color: var(--white) !important;
  overflow-wrap: anywhere;
}

/* Tables scroll sideways on their own, never the page. */
.table { overflow-x: auto; margin: 0 0 20px; box-shadow: inset 0 0 0 2px var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 0.9em; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 400; background: var(--navy); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.page figure { margin: 4px 0 24px; }
.page figure img { display: block; width: 100%; height: auto; box-shadow: 0 0 0 2px var(--line); }
.page figcaption { margin-top: 10px; font-size: 0.85em; color: var(--muted); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 2px solid var(--line);
  font-family: 'Pixelify Sans', sans-serif;
  font-size: 16px;
}
.pager a { text-decoration: none; }
.foot { max-width: 760px; margin-top: 28px; color: var(--muted); font-size: 14px; }

/* --- the privacy policy and the terms: one long page that scrolls --- */
body.legal { height: auto; overflow: auto; }
.legal .content { overflow: visible; }
.legal .page h1 { margin-bottom: 10px; }
.page h2 {
  margin: 36px 0 12px;
  font-family: 'Pixelify Sans', sans-serif;
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
}

/* --- phones: the sections open from the menu --- */
@media (max-width: 820px) {
  .menu { display: block; }
  .top { gap: 12px; }
  .top-title { display: none; }
  .layout { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    top: 64px; left: 0; bottom: 0;
    width: min(300px, 85vw);
    background: var(--sky);
    z-index: 5;
    transform: translateX(-100%);
    transition: transform 0.2s steps(4);
  }
  .side.open { transform: none; }
  .pager { flex-direction: column; }
  .pager .next { text-align: right; }
}

/* Moving between the landing and the docs: the pages cross-fade (View
   Transitions; browsers without them switch at once, as before). */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out 0.3s ease-in both; }
::view-transition-new(root) { animation: vt-in 0.45s ease-out both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; } }
