/* The landing: design/tokens.css and nothing else (DESIGN.md — never a colour
   outside the token file; the design-token test scans this file too). Light,
   generous, one clay action per view, the awning rule between sections. */

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  font-size: 1.0625rem;
}

img {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-hover);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.container {
  width: min(1200px, 100% - 2 * var(--space-5));
  margin-inline: auto;
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.skip:focus {
  top: var(--space-4);
}

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: 600 1rem/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.button--accent {
  background: var(--accent);
  color: var(--on-accent);
}

.button--accent:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.button--quiet {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.button--quiet:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.linklike {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

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

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg-page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.top__inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: var(--header-h);
}

.brandmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.brandmark__name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-tight);
  color: var(--brand); /* the wordmark: brand text, large — DESIGN.md's named exception */
}

.top__nav {
  display: flex;
  gap: var(--space-5);
  margin-left: auto;
}

.top__nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-sm);
  text-decoration: none;
}

.top__nav a:hover {
  color: var(--text);
}

.top__github {
  min-height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
}

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

.hero {
  position: relative;
  padding: var(--space-9) 0 var(--space-8);
}

.hero__rule {
  position: absolute;
  inset: 0 0 auto;
  border-radius: 0;
}

.hero__grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: var(--space-8);
  align-items: center;
}

.hero__title {
  margin: var(--space-4) 0 var(--space-5);
  font-size: clamp(2.75rem, 5.2vw, var(--text-4xl));
  line-height: 1.02;
}

.hero__lede {
  margin: 0;
  font-size: var(--text-lg);
  line-height: var(--leading-body);
  color: var(--text-muted);
}

.hero__lede strong {
  color: var(--text);
  font-weight: 600;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.hero__note {
  margin: var(--space-4) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.hero__film {
  margin: 0;
}

.film-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-page);
  box-shadow: var(--shadow-pop);
}

.film-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.film-frame__expand {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text);
  font-size: var(--text-lg);
  cursor: pointer;
}

.hero__film figcaption {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---------- sections ---------- */

.section {
  padding: var(--space-9) 0;
}

.section--tight {
  padding: var(--space-8) 0;
}

.section--raised {
  background: var(--bg-raised);
  border-block: 1px solid var(--border);
}

.section__title {
  margin: var(--space-3) 0 var(--space-4);
  font-size: clamp(2rem, 3.6vw, var(--text-3xl));
  max-width: 24ch;
}

.section__lede {
  max-width: 68ch;
  margin: 0 0 var(--space-7);
  font-size: var(--text-lg);
  color: var(--text-muted);
}

.grid {
  display: grid;
  gap: var(--space-5);
}

.grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.card {
  position: relative;
  padding: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card h3 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-tight);
}

.card p {
  margin: 0;
  color: var(--text-muted);
}

.card__index {
  margin: 0 0 var(--space-4) !important;
  font-size: var(--text-sm);
  color: var(--accent) !important;
}

.card--plain {
  background: transparent;
  border-color: var(--border);
}

.door {
  display: flex;
  flex-direction: column;
}

.door .eyebrow {
  margin: 0 0 var(--space-2);
}

.door .tag {
  margin-top: auto;
  padding-top: 0;
}

.door p:not(.eyebrow):not(.tag) {
  margin-bottom: var(--space-5);
}

.tag {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  margin: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--bg-raised);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted) !important;
  white-space: nowrap;
}

.tag--positive {
  background: var(--olive-50);
  border-color: color-mix(in srgb, var(--positive) 35%, var(--bg-surface));
  color: var(--positive) !important;
}

.tag--warning {
  background: var(--amber-50);
  border-color: color-mix(in srgb, var(--warning) 35%, var(--bg-surface));
  color: var(--warning) !important;
}

/* ---------- run it ---------- */

.run {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-7);
  align-items: center;
}

.run .section__lede {
  margin-bottom: 0;
}

.code {
  margin: 0;
  padding: var(--space-6);
  overflow-x: auto;
  background: var(--ink-900);
  color: var(--stone-100);
  border-radius: var(--radius-lg);
  font: 0.95rem/1.8 var(--font-mono);
}

.code__muted {
  color: var(--ink-400);
}

/* ---------- differentiators ---------- */

.diffs {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.diff {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: var(--space-5);
  align-items: start;
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border);
}

.diff__index {
  font-size: var(--text-xl);
  color: var(--accent);
}

.diff h3 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-lg);
}

.diff p {
  margin: 0;
  color: var(--text-muted);
  max-width: 70ch;
}

/* ---------- measured ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin: 0;
}

.stat {
  padding: var(--space-5) var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat dt {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.stat dd {
  margin: var(--space-2) 0 0;
  font-size: var(--text-2xl);
  color: var(--text);
}

.stat__line {
  display: block;
}

.stat dd small {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.footnote {
  margin: var(--space-5) 0 0;
  max-width: 80ch;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---------- roadmap ---------- */

.phases {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.phase span {
  flex: none;
  min-width: 2.2rem;
  font-weight: 500;
  color: var(--text-muted);
}

.phase--done {
  color: var(--text);
}

.phase--done span {
  color: var(--positive);
}

.phase--done span::after {
  content: ' ✓';
}

.phase--now {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.phase--now span {
  color: var(--accent);
}

/* ---------- call to action ---------- */

.cta {
  text-align: center;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.cta__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cta__title {
  margin: var(--space-5) 0 var(--space-3);
  font-size: clamp(2rem, 4vw, var(--text-3xl));
}

.cta .section__lede {
  margin-bottom: 0;
}

.cta__actions {
  justify-content: center;
}

/* ---------- what the film says ---------- */

.prose {
  max-width: var(--container-prose);
}

details summary {
  cursor: pointer;
  list-style-position: outside;
}

.details__title {
  display: inline;
  font-size: var(--text-xl);
}

.film-text {
  margin: var(--space-5) 0 0;
  padding-left: var(--space-5);
  color: var(--text-muted);
}

.film-text li + li {
  margin-top: var(--space-3);
}

.film-text strong {
  color: var(--text);
}

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

.footer__inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-4) var(--space-6);
  align-items: center;
  padding: var(--space-7) 0;
}

.footer__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.footer__brand p {
  margin: 0;
  color: var(--text-muted);
}

.footer__brand strong {
  color: var(--text);
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-5);
}

.footer__links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
}

.footer__links a:hover {
  color: var(--text);
}

.footer__note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---------- the film, with sound ---------- */

.film-dialog {
  width: min(1280px, 100vw - 2 * var(--space-5));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-pop);
}

.film-dialog::backdrop {
  background: color-mix(in srgb, var(--ink-900) 72%, transparent);
}

.film-dialog__bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.film-dialog__title {
  margin: 0 auto 0 0;
  font-weight: 600;
}

.film-dialog__bar .button {
  min-height: 36px;
  font-size: var(--text-sm);
}

.film-dialog__video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-page);
}

/* ---------- architecture: C4 levels 1 and 2, one drawing ---------- */

.arch__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.arch__zoom {
  display: inline-flex;
  padding: var(--space-1);
  gap: var(--space-1);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.arch__zoom-button {
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  font: 600 var(--text-sm) var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
}

.arch__zoom-button[aria-pressed='true'] {
  background: var(--ink-900);
  color: var(--stone-100);
}

.arch__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.arch__legend li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.arch__key {
  display: inline-block;
  width: 28px;
  border-top: 2px solid var(--border-strong);
}

.arch__key--agent {
  border-top-color: var(--brand);
}

.arch__key--optional {
  border-top-style: dashed;
}

.arch__canvas {
  position: relative;
}

.arch__wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.wire {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.5;
  marker-end: url(#arch-arrow);
}

.wire--agent {
  stroke: var(--brand);
  stroke-width: 2;
}

.wire--optional {
  stroke-dasharray: 6 5;
}

.arch__arrow {
  fill: context-stroke;
}

/* The wires are drawn above the boxes' background but ignore the pointer —
   except their invisible hit stroke, which carries the relation's title. */
.wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  pointer-events: stroke;
  cursor: help;
}

.wire-group:hover .wire {
  stroke: var(--text);
  stroke-width: 2.5;
}

.wire-group:hover .wire--agent {
  stroke: var(--accent-hover);
}

/* The actors span the system, not the providers beside it, so each one stands
   above the box it uses. */
.arch__actors {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-4);
  margin-right: calc(250px + var(--space-8));
}

.arch__middle {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: var(--space-8);
  align-items: center;
  margin-top: var(--space-8);
}

.node {
  position: relative;
  z-index: 2;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
}

.node__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-md);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

.node__text {
  margin: var(--space-1) 0 0;
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  color: var(--text-muted);
}

.node--agent {
  background: var(--accent-tint);
  border-color: var(--clay-100);
}

.node--agent .node__name {
  color: var(--accent);
}

.node--planned,
.node--optional {
  border-style: dashed;
}

.node--store {
  border-bottom-width: 3px;
}

.node--external {
  background: var(--bg-raised);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: var(--space-2) 0 0;
}

.mini {
  padding: 1px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  font: 500 var(--text-3xs) var(--font-mono);
  color: var(--text);
}

.mini--agent {
  background: var(--accent-tint);
  border-color: var(--clay-100);
  color: var(--accent);
}

.mini--quiet {
  color: var(--text-muted);
}

/* The system: Tendero's boundary, with the awning along its top edge. */
/* Three layers: this box's background (no z-index, so no stacking context of
   its own), the wires above it (1), and every box above the wires (2) — so the
   wires run inside the system and disappear under the boxes they connect. */
.arch__system {
  position: relative;
  padding: var(--space-6);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.arch__system::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: repeating-linear-gradient(90deg, var(--clay-500) 0 14px, var(--clay-100) 14px 28px);
}

.arch__summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-5);
  align-items: center;
}

.arch__system-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-tight);
  color: var(--brand); /* the wordmark, large */
}

.arch__summary .node__text {
  font-size: var(--text-sm);
  max-width: 52ch;
}

.arch__inside {
  display: none;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-7) var(--space-4);
  align-items: start;
}

.arch[data-level='2'] .arch__summary {
  display: none;
}

.arch[data-level='2'] .arch__inside {
  display: grid;
}

.arch__inside-label {
  grid-area: 5 / 1 / 6 / 13;
  margin: calc(-1 * var(--space-4)) 0 0;
}

/* Laid out so every wire runs through an empty gutter: the agents come down the
   aisle between the storefront and the backoffice, the API sits against the
   system's right edge so the external providers are a straight line away, and
   everything the API and the workers write to shares the bottom row. */
.arch__inside [data-c4='tendero.storefront'] { grid-area: 2 / 1 / 3 / 5; }
.arch__inside [data-c4='tendero.backoffice'] { grid-area: 2 / 10 / 3 / 13; }
.arch__inside [data-c4='tendero.workers'] { grid-area: 3 / 1 / 4 / 5; }
.arch__inside [data-c4='tendero.api'] { grid-area: 3 / 5 / 4 / 13; }
.arch__inside [data-c4='tendero.postgres'] { grid-area: 4 / 1 / 5 / 4; }
.arch__inside [data-c4='tendero.elasticsearch'] { grid-area: 4 / 4 / 5 / 7; }
.arch__inside [data-group='ai'] { grid-area: 4 / 7 / 5 / 10; }
.arch__inside [data-c4='tendero.observability'] { grid-area: 4 / 10 / 5 / 13; }

.arch__group {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3) var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
}

.arch__group-label {
  position: absolute;
  top: calc(-1 * var(--space-3));
  left: var(--space-3);
  margin: 0;
  padding: 0 var(--space-2);
  background: var(--bg-surface);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted);
}

.arch__externals {
  display: grid;
  gap: var(--space-6);
}

/* Each box's connections, written out by site.js from the model's relations.
   Read aloud everywhere; shown on a phone, where they replace the wires. */
.node__links {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.link {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-2);
  padding: var(--space-1) 0 var(--space-1) var(--space-3);
  border-left: 2px solid var(--border-strong);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

.link__to {
  font-weight: 600;
  color: var(--text);
}

.link__what {
  color: var(--text-muted);
}

.link--agent {
  border-left-color: var(--brand);
}

.link--agent .link__to {
  color: var(--accent);
}

.link--optional {
  border-left-style: dashed;
}

/* ---------- smaller screens ---------- */

@media (max-width: 960px) {
  .arch__actors {
    grid-template-columns: repeat(3, 1fr);
  }

  .arch__actors {
    margin-right: 0;
  }

  .arch__middle {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .arch__externals {
    grid-template-columns: 1fr 1fr;
  }

  .hero__grid,
  .run {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: var(--space-8);
  }

  .grid--3,
  .phases {
    grid-template-columns: 1fr 1fr;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  /* The menu is never hidden: on a narrow screen it becomes a second row under
     the header, always visible, scrolling sideways when it does not fit. */
  html {
    scroll-padding-top: calc(var(--header-h) + 44px + var(--space-4));
  }

  .top__inner {
    flex-wrap: wrap;
    height: auto;
    padding-top: var(--space-3);
    row-gap: 0;
  }

  .top__github {
    margin-left: auto;
  }

  .top__nav {
    order: 3;
    flex: 1 0 100%;
    margin: 0;
    gap: var(--space-5);
    overflow-x: auto;
    padding: var(--space-3) 0;
    scrollbar-width: none;
  }

  .top__nav a {
    white-space: nowrap;
  }
}

@media (max-width: 620px) {
  /* Stacked, lines would only cross text: each box says where it connects
     instead, and an arrow runs between the groups. */
  .arch__wires {
    display: none;
  }

  .node__links {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    display: grid;
    gap: var(--space-1);
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
  }

  .arch__middle,
  .arch__externals {
    position: relative;
  }

  .arch__middle {
    margin-top: var(--space-8);
  }

  .arch__middle::before,
  .arch__externals::before {
    content: '↓';
    position: absolute;
    left: 50%;
    top: calc(-1 * var(--space-7));
    transform: translateX(-50%);
    font-size: var(--text-xl);
    line-height: 1;
    color: var(--text-muted);
  }

  .arch__externals::before {
    top: calc(-1 * var(--space-6) + var(--space-1));
  }

  .arch__actors,
  .arch__externals {
    grid-template-columns: 1fr;
  }

  .arch__inside {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .arch__inside > * {
    grid-area: auto !important;
  }

  .arch__summary {
    grid-template-columns: 1fr;
  }

  .grid--3,
  .phases,
  .stats {
    grid-template-columns: 1fr;
  }

  .diff {
    grid-template-columns: 2rem 1fr;
  }

  .diff .tag {
    grid-column: 2;
  }

  .footer__inner {
    grid-template-columns: 1fr;
  }

  .footer__links {
    justify-content: flex-start;
  }
}
