/* docs.palatinelabs.com. The token block is copied from palatine-books/generate.py (itself from
   Jupiter's app.css), so the docs, Books and the room read as one family: greyscale, 1px lines, one
   gold that means "here" or "attention", Inter. Nothing below the token block names a colour. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("inter-latin.woff2") format("woff2");
}

:root {
  --d1: #0b0b0c;
  --d2: #111113;
  --d3: #161619;
  --d4: #1e1e22;
  --d5: #2b2b31;
  --d6: #878790;
  --d7: #b0b0b8;
  --d8: #eeeef1;
  --l1: #f6f6f7;
  --l2: #ffffff;
  --l3: #fafafb;
  --l4: #e6e6e9;
  --l5: #d4d4d9;
  --l6: #6e6e78;
  --l7: #4a4a53;
  --l8: #141416;

  --g1: light-dark(var(--l1), var(--d1));
  --g2: light-dark(var(--l2), var(--d2));
  --g3: light-dark(var(--l3), var(--d3));
  --g4: light-dark(var(--l4), var(--d4));
  --g5: light-dark(var(--l5), var(--d5));
  --g6: light-dark(var(--l6), var(--d6));
  --g7: light-dark(var(--l7), var(--d7));
  --g8: light-dark(var(--l8), var(--d8));

  --bg: var(--g1);
  --panel: var(--g2);
  --raise: var(--g3);
  --inset: var(--g1);
  --border: var(--g4);
  --line-2: var(--g5);
  --text: var(--g8);
  --ink-2: var(--g7);
  --muted: var(--g6);

  /* gold: a mark at 3:1, text at 4.5:1, a fill in the brand gold in both modes */
  --accent: light-dark(#b07f00, var(--gold-raw));
  --accent-ink: light-dark(#7a5300, var(--gold-raw));
  --accent-wash: light-dark(rgb(255 185 0 / 16%), rgb(255 185 0 / 9%));
  --red: light-dark(#b3261e, var(--red-raw));

  --hover: light-dark(rgb(0 0 0 / 4%), rgb(255 255 255 / 3%));
  --sel: light-dark(rgb(255 185 0 / 45%), rgb(255 185 0 / 28%));
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

  --gold-raw: #ffb900;
  --red-raw: #f85149;

  /* Jupiter's radii for boxes */
  --r-canvas: 12px;
  --r-float: 10px;
  --r-ctl: 8px;
  --r-chip: 5px;

  color-scheme: dark;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root { color-scheme: light; }
}

/* --- the page --- */
* { box-sizing: border-box; scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }
::selection { background: var(--sel); color: var(--text); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-2); }
::-webkit-scrollbar-track { background: transparent; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.006em;
  caret-color: var(--accent);
}
a {
  color: var(--text);
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 30;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-ctl);
}
.skip:focus { top: 12px; }

/* --- the bar: the disc, the lockup, the six pages, the language pair --- */
.bar { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.chrome {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.chrome .bar { display: flex; align-items: center; gap: 22px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex: none; }
.brand img { display: block; width: 32px; height: 32px; }
.wordmark { display: block; }
.wordmark b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.19em;
  line-height: 1;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.wordmark span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.34em;
  line-height: 1;
}
.site {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 28px;
}
nav.pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; margin-left: auto; }
nav.pages a, .lang a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 30px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
nav.pages a:hover, .lang a:hover { color: var(--text); }
/* where you are: gold ink and a 2px gold rule, a shape as well as a colour */
nav.pages a[aria-current="page"] { color: var(--accent-ink); box-shadow: inset 0 -2px 0 var(--accent); }
/* the language pair: one bordered track, the ends carry its corners */
.lang { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; flex: none; border: 1px solid var(--border); border-radius: var(--r-ctl); }
.lang a { justify-content: center; min-width: 44px; padding: 0 10px; }
.lang a:first-child { border-radius: var(--r-ctl) 0 0 var(--r-ctl); }
.lang a:last-child { border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.lang a + a { border-left: 1px solid var(--border); }
.lang a[aria-current="true"] { color: var(--accent-ink); box-shadow: inset 0 -2px 0 var(--accent); }
.lang a:focus-visible { outline-offset: -2px; }

/* --- one reading column; "On this page" beside it when there is room --- */
main { max-width: 1120px; margin: 0 auto; padding: 48px 24px 80px; }
.doc { display: grid; grid-template-columns: minmax(0, 780px); grid-template-areas: "head" "toc" "body"; }
.head { grid-area: head; }
.toc { grid-area: toc; }
.body { grid-area: body; }
@media (min-width: 1100px) {
  .doc.with-toc {
    grid-template-columns: minmax(0, 780px) 220px;
    grid-template-rows: auto 1fr;
    grid-template-areas: "head toc" "body toc";
    column-gap: 64px;
  }
  .doc.with-toc .toc { position: sticky; top: 96px; align-self: start; margin: 8px 0 0; }
}

h1 {
  margin: 0 0 14px;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.lede { margin: 0 0 8px; max-width: 64ch; color: var(--ink-2); font-size: 18px; line-height: 1.55; }
h2 {
  margin: 48px 0 14px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.014em;
  text-wrap: balance;
}
.body > h2:first-child { margin-top: 36px; }
h3 { margin: 32px 0 8px; font-size: 16px; font-weight: 600; line-height: 1.4; }
h2, h3 { scroll-margin-top: 88px; }
p, li { max-width: 72ch; }
p { margin: 0 0 14px; }
.body ul, .body ol { margin: 0 0 16px; padding-left: 22px; }
li { margin: 0 0 6px; padding-left: 4px; }
li::marker { color: var(--muted); }
strong { font-weight: 600; }
code {
  padding: 1px 5px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  font-family: var(--mono);
  font-size: 0.87em;
  overflow-wrap: anywhere;
}
pre {
  margin: 0 0 16px;
  padding: 14px 16px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.55;
}
pre code { padding: 0; border: 0; background: none; font-size: inherit; overflow-wrap: normal; }

/* On this page */
.toc { margin: 24px 0 8px; font-size: 13.5px; }
.toc-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.toc ol { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--border); }
.toc li { margin: 0; padding: 0; }
.toc a { display: block; padding: 4px 0; color: var(--ink-2); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--text); }

/* --- tables: the reading column's full width; the row scrolls, the page never does --- */
.table { margin: 4px 0 20px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; min-width: 120px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
td:first-child { font-weight: 500; }

/* --- the map on the home page: the pieces and which way each connection opens --- */
.map { margin: 8px 0 24px; max-width: 620px; }
.map .node {
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-ctl);
  line-height: 1.45;
}
.map .node b { display: block; font-weight: 600; }
.map .node span { display: block; color: var(--muted); font-size: 13.5px; }
.map .device { padding: 12px; background: var(--raise); }
.map .device > b { padding: 2px 4px 10px; }
.map .inner { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
/* a connection: a 1px line with a drawn head at the end the connection is opened toward */
.map .link {
  position: relative;
  margin-left: 32px;
  padding: 14px 0 14px 22px;
  border-left: 1px solid var(--muted);
  color: var(--ink-2);
  font-size: 13px;
}
.map .link::before {
  content: "";
  position: absolute;
  left: -5px;
  width: 9px;
  height: 9px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
}
.map .link.down::before { bottom: 0; transform: rotate(45deg); }
.map .link.up::before { top: 0; transform: rotate(-135deg); }
.map figcaption { margin-top: 12px; color: var(--muted); font-size: 13.5px; max-width: 72ch; }

footer { border-top: 1px solid var(--border); background: var(--panel); }
footer .bar { padding-top: 22px; padding-bottom: 22px; color: var(--muted); font-size: 13px; }
footer a { color: var(--ink-2); }

/* --- phones: the lockup and the language pair on one line, the pages wrap under them --- */
@media (max-width: 900px) {
  .chrome { position: static; }
  .chrome .bar { flex-wrap: wrap; gap: 6px 16px; padding-top: 12px; padding-bottom: 8px; }
  nav.pages { order: 3; width: 100%; margin: 0; gap: 0 16px; }
  .lang { margin-left: auto; }
  h2, h3 { scroll-margin-top: 16px; }
}
@media (max-width: 560px) {
  .bar, main { padding-left: 16px; padding-right: 16px; }
  main { padding-top: 28px; padding-bottom: 56px; }
  h1 { font-size: 26px; }
  .lede { font-size: 16.5px; }
  h2 { margin-top: 44px; font-size: 19px; }
  .site { display: none; }
  .map .inner { grid-template-columns: minmax(0, 1fr); }
  td { min-width: 140px; }
  /* three columns or more do not fit a phone: each row becomes a block, each cell names its column */
  .stack thead { display: none; }
  .stack tr, .stack td { display: block; min-width: 0; }
  .stack tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .stack tr:last-child { border-bottom: 0; }
  .stack td { padding: 2px 0; border: 0; }
  .stack td + td::before {
    content: attr(data-label);
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .stack tbody tr:hover td { background: none; }
}
