/* Dark-first, to match the app it advertises — an operator's tool that lives
   on a dark screen in a dark room. Light is offered to anyone who asks for it
   at the OS level. */

:root {
  color-scheme: dark light;

  --bg: #0b0e14;
  --bg-raised: #131824;
  --bg-sunken: #070a0f;
  --line: #222a3a;
  --line-soft: #1a2130;
  --fg: #e6eaf2;
  --fg-dim: #9aa6bd;
  /* Both of these clear 4.5:1 against --bg *and* --bg-raised. The faint one
     used to be #6b7688, which measured 4.2 and failed on captions. */
  --fg-faint: #828da0;
  --brand: #4a9eff;
  --brand-strong: #7bb8ff;
  --brand-dim: #16304f;
  --accent: #46d3a4;

  --radius: 10px;
  --wrap: 72rem;
  /* The demo alone: two applications side by side want every pixel the page
     can spare, and they are the one thing here that is not prose. */
  --wrap-wide: 92rem;
  --narrow: 44rem;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-raised: #f6f8fc;
    --bg-sunken: #eef2f8;
    --line: #d7dfeb;
    --line-soft: #e6ecf5;
    --fg: #101623;
    --fg-dim: #4d5a70;
    --fg-faint: #606b7a;
    --brand: #0b63d6;
    --brand-strong: #084ba5;
    --brand-dim: #dbe8fb;
    --accent: #0f8f6b;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchored headings would otherwise land underneath the sticky header. */
  scroll-padding-top: 5rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2.1rem, 1.3rem + 3.4vw, 3.8rem);
}
h2 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem);
}
h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

a {
  color: var(--brand);
  text-underline-offset: 0.2em;
}
a:hover {
  color: var(--brand-strong);
}

code,
kbd,
pre,
samp {
  font-family: var(--mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 0.1em 0.35em;
}

kbd {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
}

pre {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  line-height: 1.55;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
}

img,
svg,
iframe {
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
  background: var(--bg-raised);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
  margin-right: auto;
}
.brand svg {
  color: var(--brand);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

.site-header nav a {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.94rem;
}
.site-header nav a:hover {
  color: var(--fg);
}
.site-header nav .gh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* The one thing in the header that is an action rather than a destination. */
.site-header nav .nav-app {
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}

@media (width < 46rem) {
  .nav-toggle {
    display: block;
  }
  .site-header nav {
    display: none;
    position: absolute;
    inset: 100% 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem clamp(1rem, 4vw, 2rem) 1rem;
  }
  .site-header nav.open {
    display: flex;
  }
  .site-header nav a {
    padding: 0.6rem 0;
    border-top: 1px solid var(--line-soft);
  }
  /* In the stacked menu it is a row like the others, not a pill floating in
     the middle of one. */
  .site-header nav .nav-app {
    justify-content: center;
    margin-top: 0.75rem;
    padding: 0.65rem 1rem;
    border-top: 0;
  }
}

/* ---------- layout ---------- */

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.wrap.narrow {
  max-width: var(--narrow);
}

.wrap.wide {
  max-width: var(--wrap-wide);
}

.band {
  padding-block: clamp(3rem, 7vw, 5.5rem);
  border-top: 1px solid var(--line-soft);
}

main.page {
  max-width: var(--narrow);
  margin-inline: auto;
  padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 4vw, 2rem);
}

/* ---------- hero ---------- */

.hero {
  padding-block: clamp(3.5rem, 9vw, 7rem);
  background:
    radial-gradient(
    70rem 30rem at 15% -10%,
    var(--brand-dim),
    transparent 60%
  );
}

.eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 1rem;
}

.lede {
  font-size: clamp(1.05rem, 0.98rem + 0.4vw, 1.25rem);
  color: var(--fg-dim);
  max-width: 44rem;
}

.hero .lede strong {
  color: var(--fg);
  font-weight: 600;
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}

.fineprint {
  color: var(--fg-faint);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--fg);
  font-weight: 550;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover {
  border-color: var(--brand);
  color: var(--fg);
}
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #04070d;
}
.btn.primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #04070d;
}
.btn.ghost {
  background: none;
}

.more {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 550;
  text-decoration: none;
}
.more:hover {
  text-decoration: underline;
}

/* ---------- demo ---------- */

.demo .lede {
  max-width: 48rem;
}

.demo-stage {
  margin-top: 2rem;
}

/* Two equal portrait columns. Equal because the panes are the same logical
   box, which is what keeps their tops and bottoms on the same lines. */
.demo-stage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.demo-narrow {
  display: none;
  margin-top: 1.5rem;
}

@media (width < 64rem) {
  .demo-narrow {
    display: block;
  }
}

.demo-pane {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.demo-pane figcaption {
  font-size: 0.85rem;
  color: var(--fg-faint);
}

/* The frame is the visible box; the iframe inside it is laid out at desktop
   width and scaled down by fitFrames(). overflow:clip is what keeps the
   un-scaled corner from spilling out during the first paint. */
.demo-frame {
  position: relative;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

/* The iframe's width and height are written inline when it is built (see
   FRAME_W/FRAME_H) and deliberately not set here — a CSS width would win on
   the first layout and hand the app a phone-sized viewport. */
.demo-frame iframe {
  display: block;
  border: 0;
  transform-origin: 0 0;
  /* Undoes the blanket `iframe { max-width: 100% }` further up, which caps
     this at its column and is exactly what must not happen here: the whole
     point is that the iframe is *wider* than its column and then scaled. With
     the cap in place the app saw a ~670px viewport and laid itself out for a
     phone, which is the layout this demo exists to avoid showing. */
  max-width: none;
}

/* Holds the column's shape before fitFrames measures it, so the section does
   not jump when the scale lands. 4:5 matches FRAME_W:FRAME_H. */
.demo-frame {
  aspect-ratio: 4 / 5;
}

.demo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  color: var(--fg-faint);
  font-size: 0.9rem;
}
.demo-meta p {
  margin: 0;
}

/* Below this the demo is not rendered at all — see DEMO_MIN in site.ts, which
   also declines to mount the iframes. Two applications side by side have
   nowhere to go on a phone. Written after .demo-stage and .demo-meta set
   their own `display`, since these carry no extra specificity to win on. */
@media (width < 64rem) {
  .demo-stage,
  .demo-meta {
    display: none;
  }
}

/* .btn and .demo-stage both set `display`, which beats the user-agent rule
   for [hidden] and leaves a "hidden" control on screen. */
[hidden] {
  display: none !important;
}

.notice {
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

/* ---------- features ---------- */

.features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.25rem;
}

.feature {
  padding: 1.35rem 1.4rem;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.feature h3 {
  margin-bottom: 0.4rem;
}
.feature p {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.95rem;
}

/* ---------- gallery ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  gap: 1.5rem;
}

.gallery figure {
  margin: 0;
}

.gallery .shot {
  display: block;
  padding: 0;
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  line-height: 0;
}
.gallery .shot:hover {
  border-color: var(--brand);
}
.gallery img {
  width: 100%;
  height: auto;
  display: block;
}
.gallery figcaption {
  margin-top: 0.6rem;
  color: var(--fg-faint);
  font-size: 0.9rem;
}

.lightbox img {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

/* ---------- diagram ---------- */

.topology {
  width: 100%;
  height: auto;
  margin: 1.5rem 0 2rem;
  color: var(--fg-faint);
}
.topology .node rect {
  fill: var(--bg-raised);
  stroke: var(--line);
}
.topology .node.server rect {
  fill: var(--brand-dim);
  stroke: var(--brand);
}
.topology text {
  fill: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  text-anchor: middle;
}
.topology .node .sub,
.topology .key .sub {
  fill: var(--fg-faint);
  font-size: 11px;
}
.topology .key text {
  text-anchor: start;
  font-size: 12px;
  fill: var(--fg-dim);
}
.topology .swatch-signal {
  fill: var(--fg-faint);
  font-weight: 700;
}
.topology .swatch-data {
  fill: var(--accent);
  font-weight: 700;
}
.topology .edge path {
  fill: none;
  stroke-width: 1.5;
}
.topology .edge.signal path {
  stroke: var(--fg-faint);
  color: var(--fg-faint);
  stroke-dasharray: 4 4;
}
.topology .edge.data path {
  stroke: var(--accent);
  color: var(--accent);
}

/* ---------- run section ---------- */

.shell {
  position: relative;
}

wa-tab-panel wa-copy-button {
  margin-top: -0.5rem;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line-soft);
  padding: 2.5rem clamp(1rem, 4vw, 2rem);
  color: var(--fg-faint);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  align-items: center;
  max-width: var(--wrap);
  margin-inline: auto;
}
.site-footer p {
  margin: 0;
}
.site-footer strong {
  color: var(--fg);
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

/* The docs shell: a sidebar of pages, the prose, and an on-page contents. */

.docs-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 14rem;
  gap: clamp(1.5rem, 4vw, 3rem);
  max-width: 82rem;
  margin-inline: auto;
  padding: 2.5rem clamp(1rem, 4vw, 2rem) 4rem;
  align-items: start;
}

@media (width < 68rem) {
  .docs-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}

@media (width < 48rem) {
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.docs-nav,
.toc {
  position: sticky;
  top: 5rem;
  font-size: 0.92rem;
}

@media (width < 48rem) {
  .docs-nav {
    position: static;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--line-soft);
  }
}

.docs-nav ul,
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-nav-home,
.docs-nav a,
.toc a {
  display: block;
  padding: 0.35rem 0.7rem;
  color: var(--fg-dim);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
}

.docs-nav-home {
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--fg);
}

.docs-nav a:hover,
.toc a:hover {
  color: var(--fg);
  background: var(--bg-raised);
}

.docs-nav a[aria-current="page"],
.docs-nav-home[aria-current="page"] {
  color: var(--brand);
  border-left-color: var(--brand);
  background: var(--bg-raised);
  font-weight: 550;
}

.toc h2 {
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 0.6rem 0.7rem;
}
.toc .lvl-3 a {
  padding-left: 1.5rem;
  font-size: 0.88rem;
}
.toc a.current {
  color: var(--brand);
  border-left-color: var(--brand);
}

/* ---------- prose ---------- */

.docs-main {
  min-width: 0;
}

.prose {
  max-width: 46rem;
}

.prose > h1 {
  font-size: clamp(2rem, 1.5rem + 1.6vw, 2.6rem);
  margin-bottom: 0.25rem;
}

.prose .page-blurb {
  color: var(--fg-dim);
  font-size: 1.08rem;
  margin-bottom: 2rem;
}

.prose h2 {
  margin-top: 2.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
}

.prose h3 {
  margin-top: 1.8rem;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 3px solid var(--brand);
  color: var(--fg-dim);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.93rem;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.prose th {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--line);
  white-space: nowrap;
}

.prose td code {
  white-space: nowrap;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line-soft);
  margin: 2rem 0;
}

/* The heading anchors @deno/gfm emits. Present for everyone who needs them,
   quiet until the heading is hovered. */
.prose .anchor {
  float: left;
  margin-left: -1.2em;
  padding-right: 0.35em;
  color: var(--fg-faint);
  opacity: 0;
  line-height: 1;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose .anchor:focus {
  opacity: 1;
}

@media (width < 48rem) {
  .prose .anchor {
    display: none;
  }
}

/* ---------- docs index ---------- */

.doc-cards {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.doc-cards a {
  display: block;
  padding: 1.1rem 1.25rem;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.doc-cards a:hover {
  border-color: var(--brand);
}
.doc-cards h2 {
  font-size: 1.05rem;
  margin: 0 0 0.2rem;
  color: var(--brand);
  border: 0;
  padding: 0;
}
.doc-cards p {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.94rem;
}

/* Syntax colours for the fences @deno/gfm hands to Prism. Written here rather
   than importing gfm's bundled GitHub stylesheet, which is large and carries a
   whole theme this site does not use. */

.highlight pre,
pre[class*="language-"] {
  margin: 0;
}

.highlight {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 1.2rem 0;
  overflow: hidden;
}

.highlight pre {
  background: none;
  border: 0;
  border-radius: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.875rem;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--fg-faint);
  font-style: italic;
}

.token.punctuation,
.token.operator {
  color: var(--fg-dim);
}

.token.keyword,
.token.atrule,
.token.important,
.token.rule {
  color: #c792ea;
}

.token.string,
.token.char,
.token.attr-value,
.token.regex {
  color: #a5e075;
}

.token.function,
.token.class-name {
  color: var(--brand-strong);
}

.token.number,
.token.boolean,
.token.constant,
.token.symbol {
  color: #f78c6c;
}

.token.property,
.token.tag,
.token.selector,
.token.attr-name {
  color: var(--accent);
}

.token.variable,
.token.parameter {
  color: var(--fg);
}

.token.deleted {
  color: #ff6b81;
}
.token.inserted {
  color: var(--accent);
}

@media (prefers-color-scheme: light) {
  .token.keyword,
  .token.atrule,
  .token.important,
  .token.rule {
    color: #8b2fb8;
  }
  .token.string,
  .token.char,
  .token.attr-value,
  .token.regex {
    color: #1a7f37;
  }
  .token.number,
  .token.boolean,
  .token.constant,
  .token.symbol {
    color: #b8500f;
  }
  .token.deleted {
    color: #c0273d;
  }
}
