/* docs.css: the xs docs, in the look of www.cross.stream. Built the same
   way as that page's site.css: every value is a token, raw tags are styled
   once and make most of the page, and a class names a block, never a look.
   Fonts and colour ramps come from the splash page's stellar.css, and the
   colours, spaces and light mode both share from its base.css. */

/* ---- tokens -------------------------------------------------------------- */

:root {
  --brand-amber: var(--named-amber-0);

  --leading: 1.6;
  --leading-code: 1.7;
  --bar: 2.25rem;      /* a terminal's title bar */

  --side: 16rem;       /* the sidebar */
  --measure: 46rem;    /* a line of prose */
  --dot: 0.65rem;
}

/* Light mode: the colours are in base.css. Code is olive in daylight, and
   the name catches the sun rather than glowing. */
@media (prefers-color-scheme: light) {
  :root { --brand-amber: #56682a; }
  .wordmark > span { text-shadow: 0 0 1px color-mix(in srgb, var(--glow) 60%, transparent); }
}

/* ---- raw tags ------------------------------------------------------------ */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--font-size-0)/var(--leading) var(--font-mono);
  -webkit-font-smoothing: antialiased;
  --gutter: clamp(var(--space-3), 4vw, var(--space-5));
}
h1, h2, h3, h4 { font-weight: normal; color: var(--fg); line-height: 1.3; margin: var(--space-6) 0 var(--space-3); }
h1 { font-size: var(--font-size-4); margin-top: 0; }
h2 { font-size: var(--font-size-2); color: var(--accent); padding-bottom: var(--space-2); border-bottom: var(--line) solid var(--line-c); }
h3 { font-size: var(--font-size-0); color: var(--brand-amber); margin-top: var(--space-5); }
h4 { font-size: var(--font-size-0); color: var(--fg-quiet); }
p, ul, ol, table, blockquote, figure, pre, mux-player { margin: 0 0 var(--space-3); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
strong { font-weight: normal; color: var(--accent-strong); }
code { font: inherit; color: var(--brand-amber); }
small { font-size: var(--font-size--1); color: var(--fg-quiet); }
hr { border: 0; border-top: var(--line) solid var(--line-c); margin: var(--space-5) 0; }
img { max-width: 100%; height: auto; border-radius: var(--radius); }
li + li { margin-top: var(--space-1); }
ul ul, ol ol, li > ul, li > ol { margin: var(--space-1) 0 0; }

/* code: a terminal pane, without the title bar unless it is a session */
pre {
  font: var(--font-size-0)/var(--leading-code) var(--font-mono);
  background: var(--term-bg);
  border: var(--line) solid var(--line-c);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
}
pre code { color: var(--fg); }
/* every code block's copy button, at the end of its first line; a check
   shows for a moment once it has copied */
pre { position: relative; }
pre > .copy { position: absolute; top: var(--space-3); right: var(--space-4); height: calc(var(--font-size-0) * var(--leading-code)); padding: 0; border: 0; background: none; color: var(--fg-quiet); cursor: pointer; }
pre > .copy:hover { color: var(--fg); }
pre > .copy > svg + svg, pre > .copy[data-copied] > svg:first-child { display: none; }
pre > .copy[data-copied] > svg + svg { display: inline; }
/* syntax.css colours the code, on a background of its own: the pane wins */
pre.code, pre .code { background: var(--term-bg); }

table { border-collapse: collapse; font-size: var(--font-size-0); display: block; overflow-x: auto; }
th, td { padding: var(--space-1) var(--space-3); border: var(--line) solid var(--line-c); text-align: left; vertical-align: top; }
th { font-weight: normal; color: var(--accent); background: var(--surface); }

blockquote {
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: var(--line) solid var(--line-c);
  border-radius: var(--radius);
}
blockquote > :last-child { margin-bottom: 0; }

button {
  font: var(--font-size-0) var(--font-mono);
  color: var(--fg);
  background: var(--bg);
  border: var(--line) solid var(--line-c);
  border-radius: calc(var(--radius) / 2);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
  transition: border-color var(--fade), color var(--fade);
}
button:hover { border-color: var(--accent); }

/* ---- the name: cross.stream, the "stream" glowing ------------------------ */

.wordmark { color: var(--fg); text-decoration: none; letter-spacing: 0.02em; }
.wordmark > span {
  background: linear-gradient(45deg, var(--glow), var(--accent), var(--accent-strong), var(--accent), var(--glow)) 0 50% / 200% 200%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 0 0 10px color-mix(in srgb, var(--glow) 60%, transparent), 0 0 24px color-mix(in srgb, var(--glow) 40%, transparent);
  animation: flow var(--flow) ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .wordmark > span { animation: none; } }

/* ---- search: a field in the bar, the results under it --------------------- */

search { position: relative; flex: 0 1 18rem; margin-right: auto; }
search input {
  width: 100%;
  font: var(--font-size-0) var(--font-mono);
  color: var(--fg);
  background: var(--surface);
  border: var(--line) solid var(--line-c);
  border-radius: calc(var(--radius) / 2);
  padding: var(--space-1) var(--space-3);
}
search input:focus { outline: none; border-color: var(--accent); }
#results:not(:empty) {
  position: absolute; top: calc(100% + var(--space-2)); left: 0; width: min(32rem, 90vw);
  max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: var(--line) solid var(--line-c); border-radius: var(--radius);
  box-shadow: 0 var(--space-3) var(--space-5) color-mix(in srgb, black 50%, transparent);
  padding: var(--space-2);
}
#results ul { list-style: none; margin: 0; padding: 0; }
#results li + li { margin-top: 0; }
#results a { display: block; padding: var(--space-2) var(--space-3); border-radius: calc(var(--radius) / 2); color: var(--fg); text-decoration: none; }
#results a:hover, #results a:focus { background: var(--surface-2); }
#results a > span { color: var(--accent); }
#results p { margin: var(--space-1) 0 0; font-size: var(--font-size--1); color: var(--fg-quiet); }
#results > p { padding: var(--space-2) var(--space-3); margin: 0; font-size: var(--font-size--1); color: var(--fg-quiet); }

/* ---- the page: a bar across the top, the sidebar, the page ---------------- */

body {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}
body > header {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-3) var(--gutter);
  border-bottom: var(--line) solid var(--line-c);
  background: var(--bg);
  position: sticky; top: 0; z-index: 2;
}
/* where you are: the site, then the docs under it */
.crumb { font-size: var(--font-size-2); color: var(--fg-quiet); white-space: nowrap; }

body > header > a { color: var(--fg-quiet); text-decoration: none; font-size: var(--font-size-0); }
.crumb > a:not(.wordmark) { color: inherit; text-decoration: none; }
body > header > a:hover, .crumb > a:not(.wordmark):hover { color: var(--accent); }

#pages {
  padding: var(--space-4) var(--space-4) var(--space-6) var(--gutter);
  border-right: var(--line) solid var(--line-c);
  font-size: var(--font-size-0);
  position: sticky; top: 3.5rem; align-self: start; max-height: calc(100vh - 3.5rem); overflow-y: auto;
}
#pages h2 { font-size: var(--font-size-0); color: var(--fg-quiet); border: 0; padding: 0; margin: var(--space-4) 0 var(--space-2); text-transform: lowercase; }
#pages h2:first-child { margin-top: 0; }
#pages ul { list-style: none; margin: 0; padding: 0; }
#pages li + li { margin-top: 0; }
#pages a { display: block; padding: var(--space-1) var(--space-2); margin-left: calc(-1 * var(--space-2)); border-radius: calc(var(--radius) / 2); color: var(--fg); text-decoration: none; }
#pages a:hover { color: var(--accent); }
#pages a[aria-current] { color: var(--accent); background: var(--surface); }

main { padding: var(--space-5) var(--gutter) var(--space-7); max-width: calc(var(--measure) + 2 * var(--space-6)); }
main > h1 { margin-bottom: var(--space-4); }

/* ---- the home page: the contents, every page by section ----------------- */

.lede { font-size: var(--font-size-2); max-width: var(--measure); }
.contents { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: var(--space-5) var(--space-6); margin-top: var(--space-6); }
.contents h2 { margin-top: 0; }
.contents section > p { color: var(--fg-quiet); }
.contents ul { list-style: none; padding: 0; }
.contents li + li { margin-top: var(--space-2); }
.contents li > span { display: block; font-size: var(--font-size--1); color: var(--fg-quiet); }

/* ---- blocks the renderer draws -------------------------------------------- */

/* tabs: a row of keys over the panes */
.tabs { margin: 0 0 var(--space-3); }
.tabs [role=tablist] { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.tabs [role=tab][aria-selected]:not([aria-selected=false]) { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* a command and its output: one terminal, with the title bar and its dots */
figure.session {
  position: relative;
  background: var(--term-bg);
  border: var(--line) solid var(--line-c);
  border-radius: var(--radius);
  padding-top: var(--bar);
  overflow: hidden;
}
figure.session::before {
  content: "";
  position: absolute; z-index: 1; top: calc((var(--bar) - var(--dot)) / 2); left: var(--space-3);
  width: var(--dot); height: var(--dot); border-radius: 50%;
  background: var(--dot-red);
  box-shadow: calc(var(--dot) * 1.6) 0 var(--dot-amber), calc(var(--dot) * 3.2) 0 var(--dot-green);
}
figure.session::after {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: var(--bar);
  background: var(--surface-2);
  border-bottom: var(--line) solid var(--line-c);
}
figure.session pre { margin: 0; border: 0; border-radius: 0; }
/* the command's prompt, drawn by the page, so a copy or a selection never
   takes it */
figure.session > pre:first-child code::before { content: "$ "; color: var(--fg-quiet); }
/* the command and its output close together, the dashed line between */
figure.session > pre:first-child { padding-bottom: var(--space-2); }
figure.session pre + pre { border-top: var(--line) dashed var(--line-c); color: var(--fg-quiet); padding-top: var(--space-2); }
/* output's lines close enough that a table's bars join */
figure.session pre + pre { line-height: 1.25; }
figure.session pre + pre code { color: var(--fg-quiet); }

mux-player {
  display: block; width: 100%; aspect-ratio: 863 / 540;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 30px color-mix(in srgb, var(--glow) 45%, transparent);
}

/* a diagram: drawn by mermaid in the browser, on the page itself */
pre.mermaid { background: none; border: 0; padding: 0; text-align: center; color: var(--fg-quiet); }

/* the demo page: the Markdown and the code, then what they render */
pre.source { background: var(--surface); }
.rendered { border: var(--line) dashed var(--line-c); border-radius: var(--radius); padding: var(--space-4); }

/* the home page has no sidebar: the contents are its body */
body.home { display: block; }
body.home main { max-width: 72rem; margin: 0 auto; }

/* ---- narrow: one column, the page first, the sidebar after it ------------- */

@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); }
  body > header { gap: var(--space-2) var(--space-4); }
  .crumb { margin-right: auto; }
  search { order: 3; flex: 1 1 100%; margin-right: 0; }
  #pages { grid-row: 3; position: static; max-height: none; border-right: 0; border-top: var(--line) solid var(--line-c); padding-left: var(--gutter); }
  main { padding-top: var(--space-4); }
  pre, figure.session, mux-player { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; border-inline: 0; }
  body > header { position: static; }
}

/* ---- the terminal: a panel along the bottom, opened from the top bar ------ */

#term {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 60vh; overflow: auto;
  background: var(--surface); border-top: var(--line) solid var(--line-c);
  box-shadow: 0 calc(-1 * var(--space-3)) var(--space-5) color-mix(in srgb, black 30%, transparent);
  padding: var(--space-2) var(--space-3);
}
#term[hidden] { display: none; }
#term > p { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: 0 0 var(--space-2); font: var(--font-size--1) var(--font-mono); color: var(--fg); }
.term-screen { height: 50vh; }
