/* The docs site's styles: light and dark, by prefers-color-scheme unless
   the header's toggle picks one (data-theme on <html>); no fonts or
   scripts from elsewhere. Colors are the Temper logo's. The header's own
   styles are site/shared/header.css, appended to this in assets/site.css. */

:root {
  --bg: #ffffff;
  --fg: #1d2433;
  --muted: #5b6475;
  --line: #dfe3ea;
  --panel: #f5f6f9;
  --code-bg: #f3f4f7;
  --link: #2f5aa8;
  --accent: #b85e5e;
  --navy: #2b3a55;
  --note: #2f6fd1;
  --tip: #1f883d;
  --important: #8250df;
  --warning: #9a6700;
  --caution: #cf222e;
  /* Highlighting */
  --hl-comment: #6b7280;
  --hl-string: #1a7f37;
  --hl-number: #a3461a;
  --hl-keyword: #a8326e;
  --hl-function: #2f5aa8;
  --hl-type: #8250df;
  --hl-decorator: #9a6700;
  --hl-embed: #b85e5e;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171f;
    --fg: #e2e6ee;
    --muted: #9aa3b5;
    --line: #2c3240;
    --panel: #1b1f29;
    --code-bg: #1d222d;
    --link: #8db4ff;
    --accent: #e8a1a1;
    --navy: #c9d3e8;
    --note: #6ea8ff;
    --tip: #4ac26b;
    --important: #b48cff;
    --warning: #d4a72c;
    --caution: #ff7b72;
    --hl-comment: #8b93a5;
    --hl-string: #7ee2a0;
    --hl-number: #f0a36e;
    --hl-keyword: #f08cbf;
    --hl-function: #8db4ff;
    --hl-type: #c6a6ff;
    --hl-decorator: #e3c26a;
    --hl-embed: #e8a1a1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14171f;
  --fg: #e2e6ee;
  --muted: #9aa3b5;
  --line: #2c3240;
  --panel: #1b1f29;
  --code-bg: #1d222d;
  --link: #8db4ff;
  --accent: #e8a1a1;
  --navy: #c9d3e8;
  --note: #6ea8ff;
  --tip: #4ac26b;
  --important: #b48cff;
  --warning: #d4a72c;
  --caution: #ff7b72;
  --hl-comment: #8b93a5;
  --hl-string: #7ee2a0;
  --hl-number: #f0a36e;
  --hl-keyword: #f08cbf;
  --hl-function: #8db4ff;
  --hl-type: #c6a6ff;
  --hl-decorator: #e3c26a;
  --hl-embed: #e8a1a1;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

code, pre, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 30; background: var(--bg); padding: 4px 8px; }

/* The page: content, and the section's pages beside it. */

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  grid-template-areas: "side doc";
  gap: 40px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

.doc { grid-area: doc; min-width: 0; max-width: 820px; padding: 8px 0 48px; }

.side {
  grid-area: side;
  position: sticky;
  top: 52px;
  align-self: start;
  max-height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 24px 0 32px;
  font-size: 14px;
}
.side-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: block;
  padding: 3px 10px;
  border-left: 2px solid var(--line);
  color: var(--fg);
  text-decoration: none;
  line-height: 1.4;
}
.side li a:hover { color: var(--link); }
.side li a[aria-current] { border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.side li.depth-1 > a { padding-left: 22px; }
.side li.depth-2 > a { padding-left: 34px; }
.side .toc a { padding-left: 22px; font-size: 13px; color: var(--muted); }
.side li.depth-1 .toc a { padding-left: 34px; }

.foot {
  border-top: 1px solid var(--line);
  padding: 16px 24px 32px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.foot p { margin: 0 auto; max-width: 720px; }
.foot code { font-size: 1em; }

/* Content */

.doc h1, .doc h2, .doc h3, .doc h4, .doc h5, .doc h6 {
  line-height: 1.25;
  margin: 1.6em 0 0.6em;
  scroll-margin-top: 64px;
}
.doc h1 { font-size: 2em; margin-top: 0.8em; color: var(--navy); }
.doc h2 { font-size: 1.45em; padding-bottom: 0.25em; border-bottom: 1px solid var(--line); }
.doc h3 { font-size: 1.2em; }
.doc h4 { font-size: 1.05em; }
.hash {
  margin-left: 0.35em;
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
}
.doc :is(h1, h2, h3, h4, h5, h6):hover .hash, .hash:focus { opacity: 1; }

.doc p, .doc ul, .doc ol, .doc dl, .doc table, .doc pre, .doc blockquote, .doc details { margin: 0 0 1em; }
.doc li > p { margin: 0 0 0.5em; }
.doc li + li { margin-top: 0.2em; }
.doc img { max-width: 100%; height: auto; }
.doc .logo { margin: 0 auto; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

/* A `temper inert` block, Temper that isn't compiled: tinted, labeled. */
.doc pre.inert {
  position: relative;
  background: linear-gradient(rgba(128, 128, 128, 0.08), rgba(128, 128, 128, 0.08)), var(--code-bg);
}

.doc .inert-label {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.72em;
  line-height: 1.6;
  color: var(--muted);
  cursor: help;
  user-select: none;
}

.doc :not(pre) > code {
  background: var(--code-bg);
  padding: 0.12em 0.35em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.doc pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  line-height: 1.45;
}
.doc pre code { font-size: 0.86em; }

.doc blockquote {
  margin-left: 0;
  padding: 2px 16px;
  border-left: 4px solid var(--line);
  color: var(--muted);
}
.doc blockquote > :last-child { margin-bottom: 0.4em; }

.table-wrap { overflow-x: auto; margin: 0 0 1em; }
.table-wrap table { margin: 0; }
.doc table { border-collapse: collapse; font-size: 0.95em; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 12px; vertical-align: top; }
.doc th { background: var(--panel); text-align: left; }
.doc td[align="center"], .doc th[align="center"] { text-align: center; }
.doc td[align="right"], .doc th[align="right"] { text-align: right; }
.doc tr[valign="bottom"] td { vertical-align: bottom; }
.doc p[align="center"] { text-align: center; }

.doc details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
}
.doc details > summary {
  cursor: pointer;
  padding: 8px 0;
  font-weight: 600;
}
.doc details[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.doc details > pre:last-child { margin-bottom: 14px; }

/* GitHub's alerts */

.alert {
  margin: 0 0 1em;
  padding: 8px 16px;
  border-left: 4px solid var(--alert);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--alert) 7%, transparent);
}
.alert > :last-child { margin-bottom: 0.4em; }
.alert-title { margin: 0 0 0.3em !important; font-weight: 700; color: var(--alert); }
.alert-note { --alert: var(--note); }
.alert-tip { --alert: var(--tip); }
.alert-important { --alert: var(--important); }
.alert-warning { --alert: var(--warning); }
.alert-caution { --alert: var(--caution); }

/* Mermaid diagrams: drawn at build time, light and dark, with their
   source below; or, built with --no-diagrams, the source alone. */

.diagram { margin: 0 0 1em; }
.diagram-art { overflow-x: auto; padding: 4px 0; }
.diagram-art svg { display: block; height: auto; margin: 0 auto; }
.diagram-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .diagram-light { display: none; }
  :root:not([data-theme="light"]) .diagram-dark { display: block; }
}
:root[data-theme="dark"] .diagram-light { display: none; }
:root[data-theme="dark"] .diagram-dark { display: block; }
.diagram-source summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.diagram-source pre { margin: 6px 0 0; }
.diagram figcaption {
  display: inline-block;
  margin-bottom: -1px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
.diagram figcaption + pre { margin: 0; border-top-left-radius: 0; }

/* Temper highlighting */

.c { color: var(--hl-comment); font-style: italic; }
.s { color: var(--hl-string); }
.n { color: var(--hl-number); }
.k { color: var(--hl-keyword); }
.o { color: var(--hl-keyword); }
.f { color: var(--hl-function); }
.t { color: var(--hl-type); }
.d { color: var(--hl-decorator); }
.e { color: var(--hl-embed); }

/* Phones and narrow windows: the content first, the section's pages after. */

@media (max-width: 860px) {
  .doc h1, .doc h2, .doc h3, .doc h4, .doc h5, .doc h6 { scroll-margin-top: 12px; }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "doc" "side";
    gap: 0;
    padding: 0 16px;
  }
  .side {
    position: static;
    max-height: none;
    border-top: 1px solid var(--line);
    padding-top: 20px;
  }
  .doc { padding-bottom: 24px; }
  .doc h1 { font-size: 1.7em; }
  .hash { opacity: 0.6; }
}

/* The site's header, shared by the docs and the playground (header.py
   makes it): the logo, the sections, and the theme toggle, with its own
   colors so it looks the same on both. The theme is the system's, unless
   the toggle sets data-theme on <html> (header.js). */

:root {
  --top-bg: #ffffff;
  --top-fg: #1d2433;
  --top-muted: #5b6475;
  --top-line: #dfe3ea;
  --top-hover: #eef0f4;
  --top-accent: #b85e5e;
  --top-link: #2f5aa8;
  --logo-ink: #2b3a55;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --top-bg: #14171f;
    --top-fg: #e2e6ee;
    --top-muted: #9aa3b5;
    --top-line: #2c3240;
    --top-hover: #232836;
    --top-accent: #e8a1a1;
    --top-link: #8db4ff;
    --logo-ink: #ffffff;
  }
}

:root[data-theme="dark"] {
  --top-bg: #14171f;
  --top-fg: #e2e6ee;
  --top-muted: #9aa3b5;
  --top-line: #2c3240;
  --top-hover: #232836;
  --top-accent: #e8a1a1;
  --top-link: #8db4ff;
  --logo-ink: #ffffff;
}

/* The logo, here and in pages: the petals' colors are the same in both
   themes, the wordmark's ink isn't. */
.logo { display: block; height: auto; max-width: 100%; }
.logo-1 { fill: #e8c4c4; }
.logo-2 { fill: #fff; }
.logo-3 { fill: #ce7777; }
.logo-4 { fill: var(--logo-ink); }
.logo-5 { opacity: 0.5; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 51px;
  padding: 8px 24px;
  background: var(--top-bg);
  color: var(--top-fg);
  border-bottom: 1px solid var(--top-line);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* The playground's: shorter, to leave the editor the height. */
.top.compact { gap: 16px; min-height: 41px; padding: 4px 16px; }

.top :focus-visible { outline: 2px solid var(--top-link); outline-offset: 2px; }

.top .brand { display: flex; flex: none; border-radius: 4px; }
.top .brand .logo { width: auto; height: 30px; }
.top.compact .brand .logo { height: 24px; }

.top .sections {
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.top .sections::-webkit-scrollbar { display: none; }

.top .sections a {
  flex: none;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--top-fg);
  text-decoration: none;
  white-space: nowrap;
}
.top .sections a:hover { background: var(--top-hover); }
.top .sections a[aria-current] { background: var(--top-hover); color: var(--top-accent); font-weight: 600; }
/* The playground's link (.play) is styled as any other: it's last, and
   marked only when current, so it never looks selected elsewhere. */

.top-tools { display: flex; flex: none; align-items: center; gap: 6px; margin-left: auto; }

.top .top-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--top-line);
  border-radius: 6px;
  background: transparent;
  color: var(--top-fg);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.top.compact .top-button { height: 28px; }
.top .top-button:hover, .about .top-button:hover { background: var(--top-hover); border-color: var(--top-muted); }

.theme-toggle.top-button { width: 30px; padding: 0; }
.top.compact .theme-toggle.top-button { width: 28px; }
.theme-toggle .icon {
  display: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle .icon .fill { fill: currentColor; stroke: none; }
.theme-toggle[data-theme="system"] .icon-system,
.theme-toggle[data-theme="light"] .icon-light,
.theme-toggle[data-theme="dark"] .icon-dark { display: block; }

.menu-button.top-button { display: none; }

/* About: the playground's, a popover below the header. */
.about {
  position: fixed;
  inset: 48px 12px auto auto;
  width: min(23rem, calc(100vw - 24px));
  margin: 0;
  padding: 10px 16px 12px;
  border: 1px solid var(--top-line);
  border-radius: 8px;
  background: var(--top-bg);
  color: var(--top-fg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.about :focus-visible { outline: 2px solid var(--top-link); outline-offset: 2px; }
.about-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.about h2 { margin: 0; font-size: 15px; }
.about .top-button {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--top-line);
  border-radius: 6px;
  background: transparent;
  color: var(--top-fg);
  font: inherit;
  cursor: pointer;
}
.about ul { margin: 8px 0 0; padding-left: 1.1em; }
.about li + li { margin-top: 4px; }
.about a { color: var(--top-link); }
.about code { font-size: 0.95em; }

/* Phones and narrow windows: the sections behind a Menu button (with a
   script; without one, they wrap below the logo). */
@media (max-width: 860px) {
  .top { position: relative; flex-wrap: wrap; gap: 8px 10px; padding: 8px 16px; min-height: 0; }
  .top.compact { padding: 4px 16px; }
  .top .brand .logo { height: 26px; }
  .top.compact .brand .logo { height: 24px; }
  html:not(.js) .top .sections { order: 3; flex-basis: 100%; flex-wrap: wrap; gap: 2px; overflow: visible; margin-left: -8px; }
  html:not(.js) .top .sections a { padding: 2px 8px; font-size: 14px; }
  .js .menu-button.top-button { display: inline-flex; margin-left: auto; }
  .js .top-tools { margin-left: 0; }
  .js .top .sections {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 6px 8px 10px;
    background: var(--top-bg);
    border-bottom: 1px solid var(--top-line);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
  }
  .js .top.open .sections { display: flex; }
  .js .top .sections a { padding: 9px 12px; font-size: 16px; }
  .menu-button[aria-expanded="true"] { background: var(--top-hover); }
}
