/* WSRPC landing page.
   Dark by default, light under prefers-color-scheme. The logo gradient is
   the only colour event: the arrow mark behind the headline, the rule that
   joins the two peers, and the pulse that runs along it on every frame. */

:root {
  --paper: #07090d;
  --surface: #0b0f15;
  --panel: #10151c;
  --ink: #e9eef5;
  --ink-2: #8c99a9;
  --rule: #1e2731;
  --accent: #35b6ec;
  --mark: #ff4f8f;
  --grad: linear-gradient(90deg, #27aae1, #ed1164);

  --s-key: #8ab6d6;
  --s-str: #86c79e;
  --s-com: #6f7c88;
  --s-num: #d0a176;

  --glow-a: rgb(39 170 225 / 16%);
  --glow-b: rgb(237 17 100 / 12%);
  --art: 0.14;
  --lift: 0 24px 48px -32px rgb(0 0 0 / 80%);
  --inset: inset 0 1px 0 rgb(255 255 255 / 4%);

  --radius: 10px;
  --radius-sm: 6px;
  --measure: 34rem;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --paper: #ffffff;
    --surface: #f8fafb;
    --panel: #f4f6f9;
    --ink: #121820;
    --ink-2: #5a6675;
    --rule: #e1e6ec;
    --accent: #0d7ba6;
    --mark: #cf1961;

    --s-key: #2d6b96;
    --s-str: #3c7d5c;
    --s-com: #7b8794;
    --s-num: #8a6033;

    --glow-a: rgb(39 170 225 / 10%);
    --glow-b: rgb(237 17 100 / 7%);
    --art: 0.2;
    --lift: 0 20px 44px -34px rgb(10 20 35 / 45%);
    --inset: inset 0 1px 0 rgb(255 255 255 / 70%);

    color-scheme: light;
  }
}

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

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

body {
  position: relative;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Archivo, "Helvetica Neue", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  font-synthesis-weight: none;
}

/* The light that the two brand colours cast on the page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 12% -8%, var(--glow-a), transparent 65%),
    radial-gradient(52rem 38rem at 92% 6%, var(--glow-b), transparent 60%);
}

code,
pre,
kbd {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: -0.035em;
  line-height: 1;
}

h2 {
  font-size: clamp(1.625rem, 3vw, 2.125rem);
}

h3 {
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 1rem;
  max-width: var(--measure);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -200vw;
}

.skip:focus {
  position: static;
  display: inline-block;
  margin: 0.75rem;
}

.top,
.hero,
.section,
.footer {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 3rem);
}

/* Header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.5rem 0.5rem;
}

.brand {
  display: block;
  line-height: 0;
}

.brand img {
  display: block;
  width: 64px;
  height: 64px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.875rem, 2.5vw, 1.75rem);
  font-size: 0.9375rem;
}

.top-nav > a {
  color: var(--ink-2);
  text-decoration: none;
}

.top-nav > a:hover {
  color: var(--ink);
}

.langs {
  position: relative;
}

.langs summary {
  cursor: pointer;
  list-style: none;
  color: var(--ink-2);
}

.langs summary::-webkit-details-marker {
  display: none;
}

.langs[open] summary,
.langs summary:hover {
  color: var(--ink);
}

.langs ul {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 0.6rem);
  z-index: 5;
  min-width: 11rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--lift);
}

.langs a {
  display: block;
  padding: 0.35rem 0.6rem;
  text-decoration: none;
  border-radius: 4px;
}

.langs a:hover {
  background: var(--surface);
}

.langs a[aria-current] {
  color: var(--accent);
}

/* Layout rails */

.rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.section {
  padding-block: clamp(3.5rem, 7vw, 5.5rem) 0;
}

/* A section that spans the window */
.band {
  position: relative;
  margin-top: clamp(3.5rem, 7vw, 5.5rem);
  padding-block: clamp(3rem, 6vw, 4.5rem);
}

.band::before {
  content: "";
  position: absolute;
  inset: 0 calc(50% - 50vw);
  z-index: -1;
  background: var(--surface);
  border-block: 1px solid var(--rule);
}

.section-head {
  margin-bottom: 1.75rem;
}

.section-head h2 {
  margin-bottom: 0.625rem;
}

.section-head p {
  color: var(--ink-2);
  max-width: 44rem;
}

/* Hero */

.hero {
  position: relative;
  padding-block: clamp(1.5rem, 4vw, 3rem) 0;
}

.hero-art {
  position: absolute;
  inset-block-start: -1.5rem;
  inset-inline-start: -7%;
  width: min(44rem, 64%);
  aspect-ratio: 187 / 112;
  background: url("/assets/arrows.svg") no-repeat center / contain;
  opacity: var(--art);
  pointer-events: none;
  mask-image: linear-gradient(170deg, #000 30%, transparent 92%);
}

.hero > .rail,
.hero > .wire {
  position: relative;
}

.hero .lead {
  margin-top: 1.25rem;
  font-size: 1.1875rem;
  color: var(--ink-2);
}

/* The command that installs the package of the example below it. */
.install-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem 0.5rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--inset);
}

.install-line code {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9375rem;
  overflow-x: auto;
  white-space: nowrap;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1.5rem;
}

.cta {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.cta:hover {
  background: var(--accent);
  color: #06090d;
}

.cta-plain {
  padding: 0;
  background: none;
  color: var(--accent);
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.cta-plain:hover {
  background: none;
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* Live connection */

.wire {
  padding: 1rem 1.125rem 1.125rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--inset), var(--lift);
}

.wire-chat {
  display: flex;
  flex-direction: column;
}

.wire-log {
  margin-top: 1.25rem;
}

.pane-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-2);
}

.wire-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--ink-2);
}

/* The rule between the peers, and the pulse that runs along it */

.wire-rule {
  position: relative;
  flex: 1 1 auto;
  height: 1px;
  background: var(--grad);
  opacity: 0.85;
}

.wire-rule i {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
}

.wire-rule i.out {
  background: var(--mark);
  box-shadow: 0 0 10px 1px var(--mark);
  animation: run-out 520ms ease-in-out forwards;
}

.wire-rule i.in {
  background: var(--accent);
  box-shadow: 0 0 10px 1px var(--accent);
  animation: run-in 520ms ease-in-out forwards;
}

@keyframes run-out {
  from {
    left: 0;
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  to {
    left: calc(100% - 7px);
    opacity: 0;
  }
}

@keyframes run-in {
  from {
    right: 0;
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  to {
    right: calc(100% - 7px);
    opacity: 0;
  }
}

.state {
  color: var(--ink-2);
}

.state[data-state="open"] {
  color: var(--accent);
}

.state[data-state="closed"] {
  color: var(--mark);
}

/* The chat that the server draws */

.chat {
  flex: 1 1 auto;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  height: 16rem;
  overflow-y: auto;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.chat li {
  margin-block: 0.5rem;
  padding-inline-start: 0.7rem;
  border-inline-start: 2px solid var(--accent);
  animation: land 180ms ease-out;
}

.chat li[data-mine] {
  border-inline-start-color: var(--mark);
}

.chat .who {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  color: var(--ink-2);
}

.say {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.875rem;
}

.say input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
}

.say input::placeholder {
  color: var(--ink-2);
}

/* The frames */

.log {
  margin: 0.625rem 0 0;
  padding: 0.75rem 0.875rem;
  list-style: none;
  height: 14rem;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  line-height: 1.55;
}

.log li {
  margin-block: 0.45rem;
  padding-inline-start: 0.7rem;
  border-inline-start: 2px solid var(--rule);
  overflow-wrap: anywhere;
  animation: land 140ms ease-out;
}

/* The placeholder lives in the box, so the box keeps its height. */
.log:empty::before {
  content: attr(data-empty);
  color: var(--ink-2);
  font-family: Archivo, system-ui, sans-serif;
  font-size: 0.8125rem;
}

.log li:first-child {
  margin-block-start: 0;
}

.log li[data-dir="out"] {
  border-inline-start-color: var(--mark);
}

.log li[data-dir="in"] {
  border-inline-start-color: var(--accent);
}

.log .kind {
  margin-inline-end: 0.5rem;
  color: var(--ink-2);
}

@keyframes land {
  from {
    opacity: 0;
    transform: translateX(-3px);
  }
}

.act,
.copy {
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.act:hover,
.copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.act[disabled] {
  opacity: 0.45;
  cursor: default;
}

.act-ghost,
.copy {
  color: var(--ink-2);
}

.wire-foot {
  margin: 1rem 0 0;
  max-width: none;
  font-size: 0.8125rem;
  color: var(--ink-2);
}

/* Code tabs */

.tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.tab-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.tablist label {
  padding: 0.5rem 0;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-size: 0.9375rem;
  cursor: pointer;
}

.tab-input:checked + label {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.tab-input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.panel {
  display: none;
}

.tabs:has(#tab-aiohttp:checked) #panel-aiohttp,
.tabs:has(#tab-asgi:checked) #panel-asgi,
.tabs:has(#tab-go:checked) #panel-go,
.tabs:has(#tab-python:checked) #panel-python,
.tabs:has(#tab-typescript:checked) #panel-typescript,
.tabs:has(#tab-browser:checked) #panel-browser {
  display: block;
}

.panel > .install-line {
  margin-top: 1.25rem;
}

.panel-note {
  margin: 1rem 0 0;
  max-width: 44rem;
  font-size: 0.9375rem;
  color: var(--ink-2);
}

.file {
  margin: 1.5rem 0 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--inset), var(--lift);
  overflow: hidden;
}

.file figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.file pre {
  margin: 0;
  padding: 1.125rem 1rem;
  overflow-x: auto;
  tab-size: 4;
  font-size: 0.8125rem;
  line-height: 1.7;
}

.t-c {
  color: var(--s-com);
}

.t-s {
  color: var(--s-str);
}

.t-k {
  color: var(--s-key);
}

.t-d {
  color: var(--s-num);
}

.t-n {
  color: var(--ink);
}

/* Features */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.75rem clamp(1.5rem, 4vw, 3rem);
}

.feature {
  padding-top: 0.875rem;
  border-top: 1px solid var(--rule);
}

.feature h3 {
  margin-bottom: 0.375rem;
}

.feature p {
  margin: 0;
  max-width: none;
  font-size: 0.9375rem;
  color: var(--ink-2);
}

/* Where it runs */

.runtimes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.75rem clamp(1.5rem, 4vw, 3rem);
}

.runtime {
  padding-top: 0.875rem;
  border-top: 1px solid var(--rule);
}

.runtime h3 {
  margin-bottom: 0.3rem;
}

.runtime-pkg {
  margin: 0 0 0.75rem;
  max-width: none;
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.runtime ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--ink-2);
}

/* Protocol figures */

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: clamp(2rem, 4vw, 3rem);
}

.figures figure {
  margin: 0;
}

.diagram {
  display: block;
  width: 100%;
  height: auto;
}

.figures figcaption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.d-life {
  stroke: var(--rule);
  stroke-width: 1;
}

.d-peer {
  font: 500 13px "IBM Plex Mono", ui-monospace, monospace;
}

.d-peer-out {
  fill: var(--mark);
}

.d-peer-in {
  fill: var(--accent);
}

.d-frame,
.d-note {
  font: 400 11px "IBM Plex Mono", ui-monospace, monospace;
  fill: var(--ink-2);
}

.d-out {
  color: var(--mark);
  stroke: currentColor;
  stroke-width: 1.25;
}

.d-in {
  color: var(--accent);
  stroke: currentColor;
  stroke-width: 1.25;
}

.d-busy {
  fill: var(--accent);
  opacity: 0.28;
}

/* Package table */

.table-scroll {
  overflow-x: auto;
}

.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.compare th,
.compare td {
  text-align: start;
  vertical-align: top;
  padding: 0.75rem 1.25rem 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.compare thead th {
  font-weight: 500;
  white-space: nowrap;
}

.compare tbody th {
  font-weight: 400;
  color: var(--ink-2);
  white-space: nowrap;
}

/* Footer */

.footer {
  margin-top: clamp(3.5rem, 8vw, 6rem);
  padding-block: 1.75rem 3rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 0.875rem;
}

.footer a {
  text-decoration: none;
}

.footer a:hover {
  color: var(--ink);
}

.footer p {
  margin: 0;
  max-width: 44rem;
}

@media (max-width: 62rem) {
  .rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-art {
    width: min(30rem, 86%);
    inset-inline-start: -12%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .log li,
  .chat li,
  .wire-rule i {
    animation: none;
  }
}
