/* Signal: matte near-black canvas, mono display, one amber indicator. Dark is the default theme. */
:root {
  color-scheme: dark;
  --color-canvas: oklch(0.17 0.008 70);
  --color-surface: oklch(0.21 0.009 70);
  --color-surface-raised: oklch(0.26 0.01 70);
  --color-text: oklch(0.94 0.008 80);
  --color-text-muted: oklch(0.66 0.012 75);
  --color-line: oklch(0.30 0.01 70);
  --color-indicator: oklch(0.78 0.16 70);
  --color-indicator-echo: oklch(0.78 0.16 70 / 0.7);
  --color-on-indicator: oklch(0.17 0.01 70);

  --font-display: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-display: clamp(2rem, 1.2rem + 3vw, 3.25rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;

  --gutter: clamp(1rem, 4vw, 3rem);
  --measure: 68ch;
  --radius: 4px;
  --radius-float: 8px;
  --shadow-float: 0 12px 32px oklch(0 0 0 / 0.35);
  --glow-indicator: radial-gradient(circle, oklch(0.78 0.16 70 / 0.22), transparent 60%);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --color-canvas: oklch(0.985 0.005 85);
    --color-surface: oklch(0.955 0.008 85);
    --color-surface-raised: oklch(1 0 0);
    --color-text: oklch(0.2 0.012 70);
    --color-text-muted: oklch(0.45 0.014 70);
    --color-line: oklch(0.87 0.01 80);
    --color-indicator: oklch(0.64 0.16 62);
    --color-indicator-echo: oklch(0.64 0.16 62 / 0.55);
    --color-on-indicator: oklch(0.15 0.01 62);
  }
}

/* ---- Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.15; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; text-decoration-color: var(--color-text-muted); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--color-indicator); }
:focus-visible { outline: 2px solid var(--color-indicator); outline-offset: 2px; }
code, pre, kbd { font-family: var(--font-display); font-size: 0.92em; }
img { max-width: 100%; }
ul, ol { margin: 0; padding-left: 1.25em; }

.skip { position: absolute; left: -999px; top: var(--space-4); padding: var(--space-2) var(--space-3); background: var(--color-surface-raised); border-radius: var(--radius); }
.skip:focus { left: var(--space-4); }

.eyebrow { font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.indicator { display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--color-indicator); vertical-align: 0.05em; }

/* ---- Wordmark */
.wordmark { font-family: var(--font-display); font-weight: 500; font-size: 1.625rem; letter-spacing: -0.03em; text-decoration: none; display: inline-block; line-height: 1; }
.wordmark.small { font-size: 1rem; }
.wordmark .i { position: relative; display: inline-block; }
.wordmark .dot { position: absolute; left: 50%; top: 0.08em; width: 0.17em; height: 0.17em; border-radius: 50%; background: var(--color-indicator); transform: translateX(-50%); }
.wordmark .dot::after { content: ""; position: absolute; inset: -0.35em; border-radius: 50%; border: 0.05em solid var(--color-indicator); opacity: 0; animation: ping 2.4s ease-out infinite; }
@keyframes ping { 0% { transform: scale(0.3); opacity: 0.9; } 70%, 100% { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .wordmark .dot::after { animation: none; }
  .sig-line, .scene.active .sig-line { clip-path: none; animation: none; }
  .sig-dot .indicator, .sig-dot::before { opacity: 1; animation: none; }
  .scene.active .sig-dot .indicator::after, .scene.active .sig-pulse, .hero.echo::before { animation: none; }
  .sig-out .toast, .scene.active .toast { opacity: 1; animation: none; }
  .scroll-hint svg { animation: none; }
}

/* ---- Nav and footer */
.nav, .footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) var(--gutter); }
.nav { border-bottom: 1px solid var(--color-line); }
.brand { display: flex; align-items: center; gap: var(--space-3); margin: 0; }
.tag { font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); padding: 0.1em var(--space-2); border: 1px solid var(--color-line); border-radius: var(--radius); line-height: 1.6; }
.footer { border-top: 1px solid var(--color-line); margin-top: var(--space-16); color: var(--color-text-muted); font-size: var(--text-sm); }
.nav nav, .footer nav { display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; }
.nav nav a { font-family: var(--font-display); font-size: var(--text-sm); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; color: var(--color-text-muted); }
.nav nav a:hover { color: var(--color-text); }
.footer nav a { text-decoration: none; }
.footer nav a:hover { color: var(--color-text); }
.install { font-size: var(--text-sm); padding: var(--space-1) var(--space-2); border: 1px solid var(--color-line); border-radius: var(--radius); }

/* ---- Buttons */
.button { display: inline-block; font-family: var(--font-display); font-size: var(--text-sm); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-line); border-radius: var(--radius); text-decoration: none; }
.button:hover { border-color: var(--color-text-muted); }
.button.primary { background: var(--color-indicator); color: var(--color-on-indicator); border-color: var(--color-indicator); font-weight: 500; }
.button.primary:hover { filter: brightness(1.08); }

/* ---- Landing */
main > section { padding: var(--space-16) var(--gutter); max-width: 1280px; margin-inline: auto; }
main > section + section { border-top: 1px solid var(--color-line); }

.hero { position: relative; overflow: clip; isolation: isolate; display: flex; flex-direction: column; justify-content: center; max-width: none; padding-inline: 0; min-height: calc(100svh - 5.5rem); padding-block: var(--space-12) var(--space-16); }
.hero-inner { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-12); width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: var(--gutter); }
/* The echo: one hairline ring leaves the dot as it lights and fades across the hero, behind everything. */
.hero::before { content: ""; position: absolute; left: var(--echo-x, 50%); top: var(--echo-y, 50%); width: 0; height: 0; border-radius: 50%; border: 1px solid var(--color-indicator-echo); transform: translate(-50%, -50%); opacity: 0; pointer-events: none; z-index: -1; }
.hero.echo::before { animation: echo 4.2s cubic-bezier(0.25, 0.4, 0.5, 1) forwards; }
@keyframes echo { 0% { width: 0; height: 0; opacity: 1; } 55% { opacity: 0.6; } 100% { width: 130vmax; height: 130vmax; opacity: 0; } }
.hero h1 { font-size: clamp(2.4rem, 1.4rem + 4.2vw, 4.75rem); line-height: 1.05; }
.hero h1 .l1, .hero h1 .l2 { display: inline-block; }
@media (min-width: 1100px) { .hero h1 .l1, .hero h1 .l2 { white-space: nowrap; } }
.hero h1 .l2 { color: var(--color-text-muted); }
.hero-actions { display: flex; flex-direction: column; gap: var(--space-4); align-items: flex-start; }
.actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.hero-more { font-family: var(--font-display); font-size: var(--text-sm); color: var(--color-text-muted); text-decoration: none; padding: var(--space-2) 0; }
.hero-more:hover { color: var(--color-text); }
.scroll-hint { position: absolute; left: 50%; bottom: var(--space-6); transform: translateX(-50%); color: var(--color-text-muted); opacity: 0; padding: var(--space-2); border-radius: 50%; }
.scroll-hint svg { display: block; animation: bob 2.2s ease-in-out infinite; }
.scroll-hint.show { animation: fade-in 0.6s ease-out forwards; }
.scroll-hint.gone { display: none; }
@keyframes fade-in { to { opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* The signal line: an event on the left becomes a notification on the right. */
.signal { position: relative; border-top: 1px solid var(--color-line); border-bottom: 1px solid var(--color-line); padding: var(--space-12) 0 var(--space-8); }
.stage { position: relative; min-height: 9rem; }
.scene { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(8rem, 0.6fr) minmax(0, 1fr); grid-template-rows: auto auto; align-items: center; align-content: center; gap: var(--space-3) var(--space-6); opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
.scene.active { opacity: 1; pointer-events: auto; }
.scene.leaving { opacity: 0; }
.sig-in, .sig-out { display: contents; }
.sig-label { font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); grid-row: 1; align-self: end; }
.sig-in .sig-label { grid-column: 1; }
.sig-out .sig-label { grid-column: 3; }
.sig-line { grid-column: 1; grid-row: 2; margin: 0; min-width: 0; font-family: var(--font-display); font-size: clamp(0.95rem, 0.45rem + 1.2vw, 1.4rem); line-height: 1.5; color: var(--color-text-muted); white-space: pre-wrap; overflow-wrap: anywhere; clip-path: inset(0 100% 0 0); }
.scene.active .sig-line { animation: type 1.1s steps(38, end) 0.2s forwards; }
.sig-line .ev { color: var(--color-text); }
.sig-wire { grid-column: 2; grid-row: 2; position: relative; height: 1px; background: repeating-linear-gradient(90deg, var(--color-line) 0 6px, transparent 6px 12px); }
.sig-pulse { position: absolute; top: 50%; left: 0; width: 2.5rem; height: 2px; transform: translate(-100%, -50%); background: linear-gradient(90deg, transparent, var(--color-indicator)); opacity: 0; }
.scene.active .sig-pulse { animation: travel 0.7s ease-in 1.3s forwards; }
.sig-dot { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; background: var(--color-canvas); border: 1px solid var(--color-line); }
.sig-dot::before { content: ""; position: absolute; inset: -6rem; border-radius: 50%; background: var(--glow-indicator); opacity: 0; pointer-events: none; }
.scene.active .sig-dot::before { animation: lamp 0.6s ease-out 1.9s forwards; }
.sig-dot .indicator { width: 0.85rem; height: 0.85rem; position: relative; opacity: 0.3; }
.scene.active .sig-dot .indicator { animation: light 0.3s ease-out 1.9s forwards; }
.sig-dot .indicator::after { content: ""; position: absolute; inset: -0.7rem; border-radius: 50%; border: 2px solid var(--color-indicator); opacity: 0; }
.scene.active .sig-dot .indicator::after { animation: ping 1.4s ease-out 2s 2; }
.sig-out .toast { grid-column: 3; grid-row: 2; opacity: 0; }
.scene.active .toast { animation: slide 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 2.2s forwards; }
.scene-dots { list-style: none; margin: var(--space-8) 0 0; padding: 0; display: flex; gap: var(--space-2); justify-content: center; }
.scene-dots li { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--color-line); }
.scene-dots li.on { background: var(--color-indicator); }
@keyframes type { to { clip-path: inset(0 -2% 0 0); } }
@keyframes travel { 0% { opacity: 1; left: 0; } 100% { opacity: 0; left: 50%; } }
@keyframes lamp { to { opacity: 1; } }
@keyframes light { to { opacity: 1; } }
@keyframes slide { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

.toast { width: 100%; max-width: 24rem; display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); align-items: start; padding: var(--space-3) var(--space-4); background: var(--color-surface-raised); border: 1px solid var(--color-line); border-radius: var(--radius-float); box-shadow: var(--shadow-float); font-family: var(--font-body); font-size: var(--text-sm); line-height: 1.35; }
.toast-icon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: var(--radius); background: var(--color-canvas); }
.toast-icon .indicator { width: 0.7rem; height: 0.7rem; }
.toast-text { display: flex; flex-direction: column; gap: var(--space-1); }
.toast-text b { font-weight: 600; }
.toast-text span, .toast-text small { color: var(--color-text-muted); }
.toast-text small { font-size: var(--text-xs); }

.flow-section { display: flex; flex-direction: column; gap: var(--space-8); }
.lede { color: var(--color-text-muted); font-size: var(--text-lg); max-width: 60ch; }
.flow { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-4); }
.node { position: relative; padding: var(--space-4); border: 1px solid var(--color-text-muted); border-radius: var(--radius); display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.node.dashed { border-style: dashed; }
.node b { font-family: var(--font-display); font-weight: 500; font-size: var(--text-sm); overflow-wrap: anywhere; }
.node span { font-size: var(--text-xs); color: var(--color-text-muted); }
.node + .node::before { content: "→"; position: absolute; left: calc(-1 * var(--space-4)); top: 50%; width: var(--space-4); text-align: center; transform: translate(0, -50%); color: var(--color-text-muted); font-family: var(--font-display); }
.flow-note { color: var(--color-text-muted); max-width: var(--measure); }

.steps { display: flex; flex-direction: column; gap: var(--space-12); }
.step { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--space-8); align-items: start; }
.step-text { display: flex; flex-direction: column; gap: var(--space-3); }
.step-text p:not(.eyebrow) { color: var(--color-text-muted); }

.role { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-8); border: 1px solid var(--color-line); border-radius: var(--radius); }
.role p:not(.eyebrow) { color: var(--color-text-muted); max-width: var(--measure); }

@keyframes rise { from { opacity: 0.001; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    main > section:not(.hero), .step, .role { animation: rise 0.6s ease-out both; animation-timeline: view(); animation-range: entry 0% entry 35%; }
  }
}

/* ---- Code blocks */
.code { position: relative; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius); overflow-x: auto; min-width: 0; }
.code[data-lang]::before { content: attr(data-lang); position: sticky; left: 0; display: block; padding: var(--space-1) var(--space-3); border-bottom: 1px solid var(--color-line); font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.code pre { margin: 0; padding: var(--space-3) var(--space-4); font-size: var(--text-sm); line-height: 1.6; }
.code .chroma { background: transparent; }
.content :not(pre) > code { padding: 0.1em 0.35em; background: var(--color-surface); border-radius: var(--radius); overflow-wrap: anywhere; }

/* ---- Docs */
.docs { display: grid; grid-template-columns: 240px minmax(0, 1fr) 200px; gap: var(--space-12); padding: var(--space-8) var(--gutter); max-width: 1280px; margin-inline: auto; align-items: start; }
.sidebar { display: flex; flex-direction: column; gap: var(--space-4); font-size: var(--text-sm); }
.sidebar ul, .toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.sidebar li a { display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius); text-decoration: none; color: var(--color-text-muted); }
.sidebar li a:hover { color: var(--color-text); }
.sidebar li a[aria-current="page"] { color: var(--color-text); background: var(--color-surface); }
.sidebar-menu { display: none; }
.sidebar-foot { font-family: var(--font-display); font-size: var(--text-xs); color: var(--color-text-muted); padding: 0 var(--space-3); }

.content { min-width: 0; max-width: var(--measure); display: flex; flex-direction: column; gap: var(--space-4); }
.content h1 { margin-bottom: var(--space-2); }
.content h2 { margin-top: var(--space-8); padding-top: var(--space-6); border-top: 1px solid var(--color-line); }
.content h3 { margin-top: var(--space-4); }
.content ul, .content ol { display: flex; flex-direction: column; gap: var(--space-1); }
.content table { border-collapse: collapse; font-size: var(--text-sm); display: block; overflow-x: auto; }
.content th, .content td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-line); vertical-align: top; }
.content th { font-family: var(--font-display); font-weight: 500; font-size: var(--text-xs); letter-spacing: 0.05em; text-transform: uppercase; color: var(--color-text-muted); }
.content blockquote { margin: 0; padding-left: var(--space-4); border-left: 2px solid var(--color-line); color: var(--color-text-muted); }

.toc { font-size: var(--text-sm); }
.toc-title { font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: var(--space-3); }
.toc a { text-decoration: none; color: var(--color-text-muted); display: block; padding: var(--space-1) 0; }
.toc a:hover { color: var(--color-text); }
.toc .level-3 { padding-left: var(--space-4); }
.toc-rail { position: sticky; top: var(--space-8); }
.toc-inline { display: none; }
.toc-inline summary, .sidebar-menu summary { cursor: pointer; font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-line); border-radius: var(--radius); }
.toc-inline ul { padding: var(--space-3) var(--space-4) 0; }

.pager { display: flex; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-8); padding-top: var(--space-6); border-top: 1px solid var(--color-line); }
.pager a { text-decoration: none; display: flex; flex-direction: column; gap: var(--space-1); font-family: var(--font-display); font-size: var(--text-sm); }
.pager a[rel="next"] { text-align: right; margin-left: auto; }
.pager small { font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }

/* ---- Narrow screens */
@media (max-width: 900px) {
  .step { grid-template-columns: 1fr; }
  .hero { min-height: 0; }
  .scroll-hint { display: none; }
  .scene { grid-template-columns: 1fr; grid-template-rows: none; gap: var(--space-4); }
  .sig-in, .sig-out { display: block; min-width: 0; }
  .sig-label, .sig-line, .sig-wire, .sig-out .toast { grid-column: auto; grid-row: auto; }
  .sig-label { display: block; margin-bottom: var(--space-3); }
  .sig-line, .scene.active .sig-line { clip-path: none; animation: none; }
  .sig-wire { height: 3.5rem; width: 1px; justify-self: start; margin-left: 1.5rem; background: repeating-linear-gradient(180deg, var(--color-line) 0 6px, transparent 6px 12px); }
  .sig-pulse { display: none; }
  .sig-dot::before { inset: -3rem; }
  .flow { grid-template-columns: 1fr; }
  .node + .node::before { content: "↓"; left: var(--space-4); top: calc(-1 * var(--space-4)); width: auto; transform: translate(0, -50%); }
  .docs { grid-template-columns: 1fr; gap: var(--space-6); }
  .sidebar .sidebar-list { display: none; }
  .sidebar-menu { display: block; }
  .sidebar-menu ul { padding-top: var(--space-3); }
  .toc-rail { display: none; }
  .toc-inline { display: block; }
}
@media (max-width: 600px) {
  .nav nav a:not(:first-child), .install { display: none; }
  .actions, .actions .button { width: 100%; text-align: center; }
}
