/* Evercam API Gateway — survey-plan aesthetic.
   Paper, ink and one signal red (the Evercam mark). Archivo for display,
   IBM Plex for text and code. Every asset is self-hosted (strict CSP). */

@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-wdth.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/plex-sans-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/plex-sans-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/plex-sans-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/plex-mono-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/plex-mono-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --paper: #f3f0e8;
  --paper-raised: #fbfaf6;
  --ink: #15171a;
  --ink-soft: #3b3f45;
  --muted: #6c6a63;
  --rule: #d6d1c4;
  --grid-fine: rgba(21, 23, 26, 0.045);
  --grid-bold: rgba(21, 23, 26, 0.085);
  --red: #c3141c;
  --red-ink: #a50f16;
  --red-wash: rgba(195, 20, 28, 0.08);
  --ok: #1f7a4d;
  --warn: #b26a00;
  --code-bg: #15171a;
  --code-ink: #ece8df;
  --code-dim: #8b8a84;
  --shadow: 0 1px 0 rgba(21, 23, 26, 0.06), 0 12px 32px -18px rgba(21, 23, 26, 0.35);
  --display: "Archivo", "Arial Narrow", sans-serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --measure: 72ch;
  --radius: 3px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111315;
    --paper-raised: #181b1e;
    --ink: #ece8df;
    --ink-soft: #c9c5bb;
    --muted: #8f8d86;
    --rule: #2c3034;
    --grid-fine: rgba(236, 232, 223, 0.035);
    --grid-bold: rgba(236, 232, 223, 0.07);
    --red: #ff4d56;
    --red-ink: #ff6d74;
    --red-wash: rgba(255, 77, 86, 0.12);
    --ok: #4fc58a;
    --warn: #f0a63c;
    --code-bg: #0a0b0c;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 16px 36px -20px rgba(0, 0, 0, 0.9);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  /* Engineering paper: a fine 8px grid under a bold 64px one. */
  background-image:
    linear-gradient(var(--grid-bold) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-bold) 1px, transparent 1px),
    linear-gradient(var(--grid-fine) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-fine) 1px, transparent 1px);
  background-size:
    64px 64px,
    64px 64px,
    8px 8px,
    8px 8px;
  background-position: -1px -1px;
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
}

a {
  color: inherit;
  text-decoration-color: var(--red);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--red-ink);
}
:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

code,
pre,
.mono {
  font-family: var(--mono);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.75rem;
  z-index: 10;
}
.skip-link:focus {
  left: 0.5rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}
.brand img {
  width: 26px;
  height: 26px;
}
.brand__name {
  font: 800 1rem/1 var(--display);
  font-stretch: 112%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.brand__host {
  font: 500 0.78rem/1 var(--mono);
  color: var(--muted);
  border-left: 1px solid var(--rule);
  padding-left: 0.65rem;
}
.site-nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font: 500 0.82rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--red);
}

main {
  display: block;
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---------- Survey labels ---------- */

.label {
  font: 500 0.72rem/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.label--red {
  color: var(--red);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding: 4.5rem 0 3.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}
/* Ruler ticks down the left edge, like a site drawing's scale bar. */
.hero::before {
  content: "";
  position: absolute;
  left: -1.5rem;
  top: 4.5rem;
  bottom: 3.5rem;
  width: 10px;
  background:
    repeating-linear-gradient(to bottom, var(--ink) 0 1px, transparent 1px 8px) left / 6px 100% no-repeat,
    repeating-linear-gradient(to bottom, var(--ink) 0 1px, transparent 1px 40px) left / 10px 100% no-repeat;
  opacity: 0.35;
}
.hero__title {
  margin: 1rem 0 1.25rem;
  font: 850 clamp(2.6rem, 6.4vw, 5.2rem) / 0.9 var(--display);
  font-stretch: 125%;
  letter-spacing: -0.015em;
  text-transform: uppercase;
}
.hero__title em {
  font-style: normal;
  color: var(--red);
}
.hero__lede {
  max-width: 46ch;
  font-size: 1.12rem;
  color: var(--ink-soft);
  margin: 0 0 2rem;
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  font: 500 0.85rem/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  background: var(--paper-raised);
  box-shadow: 3px 3px 0 var(--ink);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.button:hover {
  color: var(--ink);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}
.button--primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 3px 3px 0 var(--ink);
}
.button--primary:hover {
  color: #fff;
}

/* Routing diagram: one host, a trunk, a branch per API. */
.routes {
  position: relative;
  margin: 0;
  padding: 1.4rem 1.4rem 1.2rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--mono);
}
.routes__host {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 500;
  font-size: 1rem;
}
.routes__host::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid var(--red);
  border-radius: 50%;
  background: var(--paper-raised);
}
.routes ol {
  list-style: none;
  margin: 0.4rem 0 0 5px;
  padding: 0 0 0 1.4rem;
  border-left: 2px solid var(--ink);
}
.routes li {
  position: relative;
  display: grid;
  grid-template-columns: 6.6rem 1fr;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.38rem 0;
  font-size: 0.86rem;
  opacity: 0;
  animation: branch-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: calc(0.15s + var(--i, 0) * 0.07s);
}
.routes li::before {
  content: "";
  position: absolute;
  left: -1.4rem;
  top: 50%;
  width: 1.05rem;
  border-top: 2px solid var(--ink);
}
.routes li::after {
  content: "";
  position: absolute;
  left: -0.42rem;
  top: calc(50% - 4px);
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
}
.routes__slug {
  font-weight: 500;
  color: var(--ink);
}
.routes__slug a {
  text-decoration: none;
}
.routes__upstream {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.routes__upstream::before {
  content: "→ ";
  color: var(--red);
}
.routes__caption {
  margin: 1rem 0 0;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--rule);
  font-size: 0.74rem;
  color: var(--muted);
}

@keyframes branch-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Sections ---------- */

.section {
  padding: 3.5rem 0;
  border-top: 1px solid var(--rule);
}
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.section__title {
  margin: 0.4rem 0 0;
  font: 800 clamp(1.6rem, 3vw, 2.2rem) / 1 var(--display);
  font-stretch: 118%;
  text-transform: uppercase;
  letter-spacing: -0.005em;
}

/* Quick start */
.steps {
  counter-reset: step;
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
/* Each step is a row: what and why on the left, the command on the right. */
.steps > li {
  counter-increment: step;
  min-width: 0;
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--rule);
}
.steps > li:last-child {
  border-bottom: 0;
}
.steps h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.6rem;
  font: 600 1rem/1.3 var(--sans);
}
.steps h3::before {
  content: counter(step, decimal-leading-zero);
  font: 500 0.75rem/1 var(--mono);
  color: #fff;
  background: var(--red);
  padding: 0.3rem 0.4rem;
  border-radius: 2px;
}
.steps p {
  margin: 0 0 0.75rem;
  color: var(--ink-soft);
  font-size: 0.93rem;
}

.code {
  position: relative;
  margin: 0;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.6;
}
.code pre {
  margin: 0;
  padding: 1rem 5.5rem 1rem 1.1rem; /* keep text clear of the copy button */
  overflow-x: auto;
}
.code .dim {
  color: var(--code-dim);
}
.code .hl {
  color: #ff8a90;
}
.copy {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid #3a3d42;
  border-radius: 2px;
  background: #1f2226;
  color: var(--code-ink);
  font: 500 0.68rem/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.copy:hover {
  border-color: var(--red);
}
.copy[data-copied] {
  color: #7fe0a8;
  border-color: #2f6b4b;
}

/* API cards — station markers */
.group {
  margin-bottom: 2.5rem;
}
.group__title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.group__title::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--rule);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.15rem 1.15rem 1rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}
.card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}
/* Corner register marks */
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: var(--red);
  border-style: solid;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.card::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}
.card::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
}
.card:hover::before,
.card:hover::after {
  opacity: 1;
}
.card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card__slug {
  margin: 0;
  font: 500 1.45rem/1.1 var(--mono);
  letter-spacing: -0.01em;
}
.card__slug span {
  color: var(--red);
}
.card__name {
  margin: -0.25rem 0 0;
  font: 600 0.95rem/1.3 var(--sans);
}
.card__summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  flex: 1;
}
.card__base {
  margin: 0;
  padding: 0.45rem 0.55rem;
  font: 400 0.76rem/1.3 var(--mono);
  background: var(--paper);
  border: 1px dashed var(--rule);
  border-radius: 2px;
  overflow-wrap: anywhere;
}
.card__links {
  display: flex;
  gap: 1rem;
  font: 500 0.78rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chip {
  font: 500 0.66rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.28rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip--admin {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-wash);
}

/* Guides list */
.guides {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.guide-link {
  display: block;
  padding: 1rem 1.1rem;
  text-decoration: none;
  border-top: 3px solid var(--ink);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}
.guide-link strong {
  display: block;
  font: 700 1.05rem/1.2 var(--display);
  font-stretch: 110%;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}
.guide-link span {
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.guide-link:hover {
  border-top-color: var(--red);
  color: var(--ink);
}

/* ---------- Prose (guides) ---------- */

.doc {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 3rem;
  padding: 3rem 0 5rem;
}
.doc__nav {
  position: sticky;
  top: 4.5rem;
  align-self: start;
  font: 500 0.82rem/1 var(--mono);
}
.doc__nav ul {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  border-left: 1px solid var(--rule);
}
.doc__nav a {
  display: block;
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  color: var(--ink-soft);
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.doc__nav a[aria-current="page"] {
  color: var(--ink);
  border-left-color: var(--red);
}
.prose {
  max-width: var(--measure);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 3rem 3rem;
}
.prose h1 {
  margin: 0 0 1rem;
  font: 850 clamp(2rem, 4vw, 2.8rem) / 1 var(--display);
  font-stretch: 122%;
  text-transform: uppercase;
}
.prose h2 {
  margin: 2.4rem 0 0.8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font: 750 1.35rem/1.2 var(--display);
  font-stretch: 112%;
  text-transform: uppercase;
}
.prose h3 {
  margin: 1.8rem 0 0.5rem;
  font: 500 1rem/1.3 var(--mono);
}
.prose h3 code {
  color: var(--red);
}
.prose :target {
  scroll-margin-top: 5rem;
  background: var(--red-wash);
}
.prose p,
.prose li {
  color: var(--ink-soft);
}
.prose strong {
  color: var(--ink);
}
.prose :not(pre) > code {
  font-size: 0.86em;
  padding: 0.1em 0.35em;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.prose pre {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.6;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88rem;
}
.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
}
.prose th {
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--red);
  background: var(--red-wash);
}
.prose blockquote p {
  margin: 0;
}

/* ---------- Status ---------- */

.status-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  margin: 2.5rem 0 1.5rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-left: 6px solid var(--ok);
  box-shadow: var(--shadow);
  font: 600 1.05rem/1.3 var(--sans);
}
.status-summary[data-state="degraded"] {
  border-left-color: var(--warn);
}
.status-summary[data-state="down"] {
  border-left-color: var(--red);
}
.status-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  margin-bottom: 4rem;
}
.status-table th,
.status-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.status-table th {
  font: 500 0.7rem/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.status-table td.num,
.status-table td.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
}
.dot {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: 500 0.78rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dot::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.dot--up::before {
  background: var(--ok);
}
.dot--degraded::before {
  background: var(--warn);
}
.dot--down::before {
  background: var(--red);
}

/* ---------- Reference (Scalar) ---------- */

.reference-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-raised);
  font: 500 0.78rem/1 var(--mono);
}
.reference-bar a {
  padding: 0.45rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 2px;
  text-decoration: none;
  white-space: nowrap;
  color: var(--ink-soft);
}
.reference-bar a[aria-current="page"] {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--paper);
}
.reference-bar__spacer {
  flex: 1;
}
#reference {
  min-height: calc(100vh - 7rem);
  background: var(--paper);
}
.noscript {
  max-width: 60ch;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 0 3rem;
  font: 400 0.8rem/1.6 var(--mono);
  color: var(--muted);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
}
.site-footer nav {
  display: flex;
  gap: 1.25rem;
}

/* ---------- Responsive & motion ---------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 3rem;
  }
  .hero::before {
    display: none;
  }
  .steps > li,
  .guides {
    grid-template-columns: 1fr;
  }
  .doc {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .doc__nav {
    position: static;
  }
  .prose {
    padding: 1.5rem 1.25rem 2rem;
  }
  .brand__host {
    display: none;
  }
  .site-nav {
    gap: 0.9rem;
  }
}
@media (max-width: 520px) {
  .routes li {
    grid-template-columns: 5rem 1fr;
  }
  .site-nav a:nth-child(n + 3) {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .routes li {
    opacity: 1;
  }
}
