/* ama4devs documentation site. One stylesheet for every page.

   The world: each page is a deep printer-body ground; what the mocks do prints on
   cool thermal paper with torn edges; controls are card-machine keypad keys.
   A page picks its ground with <body data-tool="whatsapp|asaas|generator|sms"> (none = home). */

:root {
  /* Grounds: one per page. */
  --ground: #1d1838;
  --ground-raise: #2a2450;
  --ground-line: #3d3570;
  --on-ground: #ece9f7;
  --on-ground-soft: #b9b2d9;

  /* Thermal paper and its print. */
  --paper: #f3f5f1;
  --paper-band: #e6e9e2;
  --paper-rule: #c9cdc4;
  --ink: #23212b;
  --ink-soft: #4b4857;
  --fade: #5f5880;
  --print-red: #b8262f;

  /* Keypad. */
  --key-confirm: #17804a;
  --key-confirm-deep: #0f5f35;
  --key-correct: #f2c232;
  --key-correct-deep: #c99b14;
  --key-cancel: #cf3a3c;
  --key-face: #f7f7f4;

  --display: 'Doto', 'Martian Mono', ui-monospace, monospace;
  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Martian Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --measure: 66ch;
  --page: 1240px;
  --gutter: clamp(16px, 4vw, 44px);
  --tooth: 14px;
  --feed: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

body[data-tool='whatsapp'] {
  --ground: #0e3a2f;
  --ground-raise: #15503f;
  --ground-line: #23674f;
  --on-ground: #e6f4ee;
  --on-ground-soft: #a6cfbf;
}

body[data-tool='asaas'] {
  --ground: #0f2160;
  --ground-raise: #18307e;
  --ground-line: #2a44a0;
  --on-ground: #e8ecfb;
  --on-ground-soft: #aebbec;
}

body[data-tool='generator'] {
  --ground: #3d1a12;
  --ground-raise: #55251a;
  --ground-line: #7a3a2a;
  --on-ground: #faece8;
  --on-ground-soft: #d8aba0;
}

body[data-tool='sms'] {
  --ground: #1b1b4b;
  --ground-raise: #26266a;
  --ground-line: #3d3d94;
  --on-ground: #ececfb;
  --on-ground-soft: #b3b3e6;
}

@media (prefers-color-scheme: dark) {
  /* The page is already a dark ground; the paper only dims to stop the glare. */
  :root {
    --paper: #e9ece6;
    --paper-band: #dadfd6;
    --paper-rule: #bcc1b6;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 96px;
  scrollbar-color: var(--ground-line) var(--ground);
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--on-ground);
  font: 400 17px/1.6 var(--sans);
  font-variation-settings: 'wdth' 100;
  overflow-x: hidden;
}

::selection { background: var(--key-correct); color: var(--ink); }

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--key-correct); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 16px; z-index: 20; background: var(--key-correct); color: var(--ink); padding: 8px 12px; }

code, pre, kbd, samp { font-family: var(--mono); font-variation-settings: 'wdth' 87.5; }

/* ───────── Header ───────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ground-line);
}

.site-header .bar {
  max-width: var(--page);
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  gap: 28px;
}

.wordmark {
  font: 800 24px/1 var(--display);
  letter-spacing: 0.02em;
  text-decoration: none;
  margin-right: auto;
  color: var(--on-ground);
}

.site-nav { display: flex; gap: 22px; align-items: center; font-size: 15px; }
.site-nav a { color: var(--on-ground-soft); text-decoration: none; padding: 4px 0; }
.site-nav a:hover { color: var(--on-ground); }
.site-nav a[aria-current='page'] { color: var(--on-ground); box-shadow: inset 0 -2px 0 var(--key-correct); }

.lang { display: flex; gap: 6px; }
.lang a, .lang span {
  font: 600 12px/1 var(--mono);
  padding: 7px 9px 6px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--on-ground-soft);
  box-shadow: inset 0 0 0 1px var(--ground-line);
}
.lang [aria-current='true'] { background: var(--key-face); color: var(--ink); box-shadow: 0 2px 0 #00000055; }

@media (max-width: 720px) {
  .site-header .bar { flex-wrap: wrap; gap: 8px 16px; }
  .site-nav { order: 3; width: 100%; gap: 18px; overflow-x: auto; scrollbar-width: none; }
  .site-nav a { flex: none; }
}

/* Section tabs of a mock: Overview, Quick start, API, Docs. */

.tabs {
  max-width: var(--page);
  margin: 0 auto;
  padding: 18px var(--gutter) 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs a {
  flex: none;
  font: 600 14px/1 var(--sans);
  text-decoration: none;
  color: var(--on-ground-soft);
  padding: 11px 16px 10px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--ground-line);
}
.tabs a:hover { color: var(--on-ground); background: var(--ground-raise); }
.tabs a[aria-current='page'] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 #00000040; }

/* ───────── Keys: the card machine's keypad ───────── */

.key {
  --face: var(--key-face);
  --deep: #b9bab3;
  --label: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 700 15px/1 var(--sans);
  letter-spacing: 0.01em;
  color: var(--label);
  background: var(--face);
  border: 0;
  border-radius: 10px;
  padding: 14px 18px 13px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--deep), 0 8px 18px -6px #00000080;
  transition: transform 90ms steps(2), box-shadow 90ms steps(2);
}
.key:hover { text-decoration: none; filter: brightness(1.04); }
.key:active, .key.is-pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--deep), 0 3px 8px -4px #00000080; }
.key[disabled] { cursor: default; opacity: 0.45; transform: translateY(3px); box-shadow: 0 1px 0 var(--deep); }
.key.confirm { --face: var(--key-confirm); --deep: var(--key-confirm-deep); --label: #fff; }
.key.correct { --face: var(--key-correct); --deep: var(--key-correct-deep); --label: var(--ink); }
.key.small { font-size: 13px; padding: 10px 13px 9px; border-radius: 8px; }
.key svg { width: 18px; height: 18px; flex: none; }

.actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 28px; }

/* ───────── Layout ───────── */

main { display: block; }

.wrap { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter); }

h1, h2, h3 { margin: 0; text-wrap: balance; }

h1 {
  font: 800 clamp(40px, 6.2vw, 84px)/0.98 var(--sans);
  font-variation-settings: 'wdth' 75;
  letter-spacing: -0.02em;
  max-width: 13ch;
}

.lead {
  font-size: clamp(18px, 1.7vw, 21px);
  line-height: 1.55;
  color: var(--on-ground-soft);
  max-width: 54ch;
  margin: 24px 0 0;
}
.lead strong { color: var(--on-ground); font-weight: 650; }

/* Hero: copy on the ground, the printer on the right. */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: clamp(32px, 4vw, 64px);
  align-items: start;
  padding-top: clamp(40px, 6vw, 80px);
  padding-bottom: clamp(48px, 6vw, 88px);
}
.hero-copy { align-self: center; }
@media (max-width: 960px) {
  .hero { grid-template-columns: minmax(0, 1fr); align-items: start; }
}

/* A command on the ground: the one line to type. */

.cmd {
  margin-top: 32px;
  max-width: 620px;
  background: var(--ground-raise);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: inset 0 0 0 1px var(--ground-line);
}

.cmd pre { margin: 0; flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.7; color: var(--on-ground); }
.lead code, .intro code { font-size: 0.82em; background: var(--ground-raise); padding: 2px 6px; border-radius: 4px; }
.cmd pre .c { color: var(--on-ground-soft); }
.cmd .key { flex: none; }

/* ───────── The printer ───────── */

.printer { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 470px; justify-self: center; }

.tape-window {
  width: 100%;
  height: clamp(360px, 54vh, 540px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 14px;
  filter: drop-shadow(0 14px 18px #00000059);
  /* Paper fades into the dark above, as if it kept going. */
  -webkit-mask: linear-gradient(to bottom, #0000, #000 64px);
  mask: linear-gradient(to bottom, #0000, #000 64px);
}

.tape {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  padding: 26px 22px 18px;
  font: 400 12.5px/1.65 var(--mono);
  font-variation-settings: 'wdth' 87.5;
  -webkit-mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--tooth) 51% repeat-x,
    linear-gradient(#000 0 0) bottom / 100% 50% no-repeat;
  mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--tooth) 51% repeat-x,
    linear-gradient(#000 0 0) bottom / 100% 50% no-repeat;
}

.tape-head { text-align: center; padding-bottom: 12px; margin-bottom: 10px; border-bottom: 1px dashed var(--paper-rule); }
.tape-head .brand { font: 800 26px/1 var(--display); letter-spacing: 0.04em; }
.tape-head .sub { color: var(--fade); margin-top: 6px; }
.swapline { display: block; text-align: left; overflow-wrap: anywhere; }
.swapline.from { color: var(--fade); text-decoration: line-through; text-decoration-color: var(--print-red); }
.swapline.to { font-weight: 700; }
.swapline::before { display: inline-block; width: 2ch; }
.swapline.from::before { content: '-'; color: var(--print-red); }
.swapline.to::before { content: '+'; }
.tape-head .swaps { margin-top: 12px; display: grid; gap: 2px; }

.lines { list-style: none; margin: 0; padding: 0; }
.ln { display: grid; grid-template-columns: 6.6ch minmax(0, 1fr); column-gap: 1.2ch; padding: 1px 0; }
.ln time { color: var(--fade); }
.ln .ev { overflow-wrap: anywhere; }
.ln .ev b { font-weight: 700; }
.ln .ok { font-weight: 700; }
.ln .bad { color: var(--print-red); font-weight: 700; }
.ln.day { grid-template-columns: 1fr; text-align: center; margin: 10px 0 6px; font: 800 17px/1.2 var(--display); letter-spacing: 0.06em; }
.ln.day::before, .ln.day::after { content: none; }
.ln.hook .ev { padding-left: 2ch; }
.ln.hook .ev i { font-style: normal; color: var(--fade); }
.ln.total { border-top: 1px dashed var(--paper-rule); margin-top: 8px; padding-top: 8px; font-weight: 700; }

.tape-foot { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--paper-rule); color: var(--fade); text-align: center; font-size: 11px; }

/* Printing: a line is swept onto the paper by the head, the paper jerks up. */
.is-printing .ln[hidden] { display: none; }
.ln.printed { animation: sweep 260ms steps(16) both; }
.tape.fed { animation: feed 140ms steps(3); }
@keyframes sweep { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes feed { from { transform: translateY(14px); } to { transform: translateY(0); } }

/* The machine under the paper. */
.machine {
  width: 100%;
  background: linear-gradient(#2b2b33, #1c1c22);
  border-radius: 18px 18px 26px 26px;
  padding: 10px 18px 18px;
  box-shadow: 0 1px 0 #ffffff1f inset, 0 24px 40px -18px #000000a6;
}
.slot { height: 9px; border-radius: 6px; background: #0b0b0e; box-shadow: inset 0 2px 3px #000; margin: 0 6px 14px; }
.keypad { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.keypad .key.confirm { justify-content: center; }
.progress { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.progress i { width: 7px; height: 7px; border-radius: 50%; background: #45454f; }
.progress i.on { background: var(--key-confirm); }
.machine-note { font-size: 13px; color: var(--on-ground-soft); text-align: center; margin-top: 14px; max-width: 42ch; }

/* ───────── Sections on the ground ───────── */

.band { padding: clamp(56px, 7vw, 104px) 0; border-top: 1px solid var(--ground-line); }
.band h2 {
  font: 800 clamp(30px, 3.6vw, 48px)/1.05 var(--sans);
  font-variation-settings: 'wdth' 80;
  letter-spacing: -0.015em;
  max-width: 22ch;
}
.band .intro { color: var(--on-ground-soft); max-width: 60ch; margin: 18px 0 0; font-size: 18px; }

/* Home: the two mocks as two receipt copies ("vias"). */
.vias { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(24px, 4vw, 56px); margin-top: 48px; align-items: start; }
@media (max-width: 900px) { .vias { grid-template-columns: minmax(0, 1fr); } }

.via { color: var(--ink); filter: drop-shadow(0 18px 22px #00000059); }
.via .sheet { padding-top: 34px; }
.via .sheet h3 { font: 800 34px/1 var(--display); letter-spacing: 0.03em; margin: 0 0 12px; }
.via .what { color: var(--ink-soft); margin: 0 0 18px; }
.via figure { margin: 0 0 20px; }
.via figure img { border-radius: 6px; box-shadow: 0 0 0 1px var(--paper-rule); }
.via .sheet ul { list-style: none; padding: 0; margin: 0 0 20px; }
.via .sheet li { margin: 0; padding: 8px 0; border-bottom: 1px dotted var(--paper-rule); }
.via .sheet li:last-child { border-bottom: 0; }
.via .links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* The mocks still to come: blank paper slots, not printed yet. */
.planned { margin-top: clamp(48px, 6vw, 80px); }
.planned h3 { font: 800 clamp(22px, 2.4vw, 30px)/1.1 var(--display); letter-spacing: 0.03em; margin: 0 0 20px; }
.planned p { color: var(--on-ground-soft); max-width: 62ch; margin: 20px 0 0; }
.stubs { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.stubs li {
  min-height: 96px;
  display: flex;
  align-items: flex-end;
  padding: 14px 16px;
  font: 700 16px/1.2 var(--mono);
  font-variation-settings: 'wdth' 87.5;
  color: var(--on-ground-soft);
  border: 2px dashed var(--ground-line);
  border-radius: 4px;
}

/* ───────── Paper: the reading surface ───────── */

.sheet {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  padding: clamp(32px, 4vw, 56px) clamp(20px, 4vw, 56px);
  -webkit-mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--tooth) 51% repeat-x,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--tooth) 51% repeat-x;
  mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--tooth) 51% repeat-x,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--tooth) 51% repeat-x;
}
.paper-shadow { filter: drop-shadow(0 18px 24px #00000059); }

.sheet a { color: var(--ink); text-decoration-color: var(--fade); }
.sheet a:hover { text-decoration-color: var(--ink); }
.sheet :focus-visible { outline-color: var(--ink); }
.sheet ::selection { background: var(--key-correct); }

.sheet h2 {
  font: 800 clamp(26px, 3vw, 38px)/1.1 var(--display);
  letter-spacing: 0.02em;
  margin: 0 0 18px;
}
.sheet h3 { font: 700 21px/1.25 var(--sans); font-variation-settings: 'wdth' 90; margin: 38px 0 10px; }
.sheet p, .sheet ul, .sheet ol { max-width: var(--measure); }
.sheet p { margin: 0 0 16px; }
.sheet ul, .sheet ol { padding-left: 22px; margin: 0 0 18px; }
.sheet li { margin-bottom: 8px; }
.sheet li::marker { color: var(--fade); }
.sheet strong { font-weight: 650; }
.sheet .muted { color: var(--ink-soft); }

/* Sections on paper are torn apart by a perforation. */
.sheet > section + section,
.sheet article > section + section {
  margin-top: 56px;
  padding-top: 52px;
  background: radial-gradient(circle, var(--paper-rule) 1.6px, #0000 2px) top left / 12px 4px repeat-x;
}

.sheet code { font-size: 0.86em; background: var(--paper-band); padding: 1px 5px; border-radius: 3px; overflow-wrap: anywhere; }

/* A printed code block. */
.code {
  position: relative;
  margin: 0 0 24px;
  background: var(--paper-band);
  border-radius: 6px;
}
.code pre {
  margin: 0;
  padding: 18px 20px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  scrollbar-width: thin;
  scrollbar-color: var(--paper-rule) transparent;
}
.code pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: inherit; }
.code .c { color: var(--fade); }
.code .add { color: var(--key-confirm-deep); font-weight: 700; }
.code .del { color: var(--print-red); }
.code .copy { position: absolute; top: 9px; right: 9px; }
.code:has(.copy) pre { padding-right: 84px; }
.sheet.narrow { max-width: 920px; }

/* Tables printed on the receipt. */
.table-wrap { overflow-x: auto; margin: 8px 0 28px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px 10px 0; border-bottom: 1px dotted var(--paper-rule); }
thead th { font-weight: 700; border-bottom: 1px solid var(--ink); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
td code { white-space: nowrap; }

/* Screenshots: pasted onto the paper. */
.shot { margin: 0 0 28px; }
.shot img { border-radius: 6px; box-shadow: 0 0 0 1px var(--paper-rule), 0 10px 24px -14px #23212b80; background: #fff; }
.shot figcaption { font-size: 15px; color: var(--ink-soft); margin-top: 12px; max-width: var(--measure); }
.shot figcaption strong { color: var(--ink); }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 28px; margin: 28px 0 32px; }
.gallery .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .gallery { grid-template-columns: minmax(0, 1fr); } }

.note { background: var(--paper-band); border-radius: 6px; padding: 14px 18px; color: var(--ink-soft); max-width: var(--measure); margin: 0 0 24px; }
.note strong { color: var(--ink); }

/* ───────── Doc pages: index on the ground, paper beside it ───────── */

.doc {
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 48px) var(--gutter) clamp(64px, 8vw, 112px);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}
@media (max-width: 1000px) {
  .doc { grid-template-columns: minmax(0, 1fr); }
  .doc > .toc { display: none; }
}

.doc-title { padding-bottom: 8px; }
.doc-title h1 { font-size: clamp(36px, 5vw, 64px); max-width: 18ch; }
.doc-title .lead { margin-top: 18px; }

.doc > .toc { align-self: stretch; }
.toc nav { position: sticky; top: 96px; font-size: 14px; }
.toc p { font: 700 13px/1 var(--mono); color: var(--on-ground-soft); margin: 0 0 12px; }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--on-ground-soft); text-decoration: none; }
.toc a:hover { color: var(--on-ground); background: var(--ground-raise); }
.toc a.active { color: var(--ink); background: var(--paper); font-weight: 600; }

/* Ways to run, one per perforated section of a sheet: when to pick it, the commands
   per mock under the mock's name, and the address each opens. */
.sheet .way h3 { font: 800 clamp(24px, 2.6vw, 32px)/1.1 var(--display); letter-spacing: 0.02em; margin: 0 0 8px; }
.way-why { color: var(--ink-soft); margin: 0 0 22px; }
.way-label { font: 700 13px/1 var(--mono); color: var(--fade); margin: 22px 0 10px; }
.way-why + .way-label { margin-top: 0; }
.way-out { font-size: 15px; color: var(--ink-soft); margin: -12px 0 0; }

/* Steps of a quick start: a real sequence, so they are numbered. */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; max-width: none; }
.steps > li { counter-increment: step; position: relative; padding-left: 64px; margin: 0 0 40px; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -6px;
  font: 800 40px/1 var(--display);
  color: var(--fade);
}
.steps > li > h3 { margin-top: 0; }
@media (max-width: 640px) {
  .steps > li { padding-left: 0; padding-top: 44px; }
  .steps > li::before { top: 0; font-size: 32px; }
  .code:has(.copy) pre { padding-right: 20px; padding-top: 52px; }
}

/* Use cases: a printed scenario per case. */
.case { margin: 0 0 8px; }
.case + .case { margin-top: 48px; }
.case h3 { margin-top: 0; }
.case .proves { color: var(--ink-soft); }

/* API reference rendered from data. */
.api-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 24px; }
.api-tools input[type='search'] {
  flex: 1 1 260px;
  font: 400 15px/1 var(--sans);
  padding: 12px 14px;
  border: 1px solid var(--paper-rule);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.api-tools input[type='search']::placeholder { color: var(--ink-soft); }
.api-tools input[type='search']:focus-visible { outline: 3px solid var(--key-correct); outline-offset: 1px; }
.api-tools label { display: inline-flex; gap: 8px; align-items: center; font-size: 15px; cursor: pointer; }
.api-tools input[type='checkbox'] { accent-color: var(--key-confirm); width: 18px; height: 18px; }
.api-count { font: 400 13px/1.4 var(--mono); color: var(--ink-soft); margin: 0 0 18px; }

.api-group { margin: 0 0 36px; }
.api-group h3 { margin: 0 0 8px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.api-group h3 small { font: 400 13px/1 var(--mono); color: var(--ink-soft); }
.op { display: grid; grid-template-columns: 7ch minmax(0, 1fr) auto; gap: 4px 14px; padding: 9px 0; border-bottom: 1px dotted var(--paper-rule); align-items: baseline; }
.op .m { font: 700 12px/1.4 var(--mono); }
.op .p { font: 400 13px/1.5 var(--mono); overflow-wrap: anywhere; }
.op .s { grid-column: 2 / 3; font-size: 14px; color: var(--ink-soft); }
.op .b { grid-row: 1; grid-column: 3; font: 700 11px/1 var(--mono); padding: 5px 7px 4px; border-radius: 4px; white-space: nowrap; }
.op .b.live { background: var(--key-confirm); color: #fff; }
.op .b.spec { background: var(--paper-band); color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--paper-rule); }
.api-empty { color: var(--ink-soft); }

/* A row opens like an OpenAPI operation: parameters, body, examples, responses. */
.op-row > summary { list-style: none; cursor: pointer; position: relative; padding-left: 22px; }
.op-row > summary::-webkit-details-marker { display: none; }
.op-row > summary::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 15px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--fade);
  border-bottom: 2px solid var(--fade);
  transform: rotate(-45deg);
  transition: transform 90ms steps(2);
}
.op-row[open] > summary::before { transform: rotate(45deg); top: 12px; }
.op-row > summary:hover .p { text-decoration: underline; text-decoration-color: var(--fade); }
.op-row[open] > summary { border-bottom-style: solid; border-bottom-color: var(--ink); }
.op-body { padding: 14px 0 28px 22px; border-bottom: 1px solid var(--ink); }
.op-body h4 { font: 700 15px/1.3 var(--sans); margin: 22px 0 10px; }
.op-body h4:first-child { margin-top: 4px; }
.op-body h4 small { font: 400 12px/1 var(--mono); color: var(--ink-soft); margin-left: 6px; }
.op-desc { color: var(--ink-soft); font-size: 15px; margin: 0 0 12px; max-width: var(--measure); }
.op-body table { font-size: 14px; }
.op-body td:first-child { white-space: normal; }
.op-body .code pre { max-height: 420px; overflow: auto; }
.req { font: 600 11px/1 var(--mono); color: var(--print-red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip {
  font: 600 12px/1 var(--mono);
  padding: 8px 10px 7px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper-band);
  box-shadow: inset 0 0 0 1px var(--paper-rule);
}
.chip.ok { color: var(--key-confirm-deep); }
.chip.err { color: var(--print-red); }
.chip[aria-pressed='true'] { background: var(--ink); color: var(--paper); box-shadow: none; }
@media (max-width: 560px) {
  .op { grid-template-columns: 6ch minmax(0, 1fr); }
  .op .b { grid-row: auto; grid-column: 2; justify-self: start; }
  /* Field tables become stacked cards of name, type and description. */
  .op-body thead { display: none; }
  .op-body table, .op-body tbody, .op-body tr, .op-body td { display: block; }
  .op-body tr { padding: 10px 0; border-bottom: 1px dotted var(--paper-rule); }
  .op-body td { border: 0; padding: 2px 0; }
  .op-body { padding-left: 0; }
}

/* Next page links at the bottom of a sheet. */
.next { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 40px; }

/* ───────── Video modal ───────── */

.video-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  margin-left: 8px;
  font-size: 24px;
  line-height: 1;
  text-decoration: none;
  transition: transform 0.15s var(--feed), filter 0.15s ease;
  user-select: none;
}
.video-btn:hover {
  transform: scale(1.22);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}
.video-btn:active {
  transform: scale(0.95);
}

.video-modal {
  border: 1px solid var(--ground-line);
  border-radius: 12px;
  background: var(--ground);
  color: var(--on-ground);
  padding: 0;
  max-width: 960px;
  width: min(92vw, 960px);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}
.video-modal::backdrop {
  background: rgba(10, 8, 20, 0.8);
  backdrop-filter: blur(6px);
}
.video-modal-box {
  display: flex;
  flex-direction: column;
}
.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--ground-raise);
  border-bottom: 1px solid var(--ground-line);
}
.video-modal-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: var(--on-ground);
}
.video-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--ground-line);
  border-radius: 6px;
  background: var(--ground);
  color: var(--on-ground-soft);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.video-modal-close:hover {
  background: var(--ground-line);
  color: var(--on-ground);
}
.video-modal-player {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 ratio */
  background: #000;
}
.video-modal-player iframe,
.video-modal-player video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  outline: none;
}

/* ───────── Lightbox modal ───────── */

.carousel-section {
  position: relative;
  margin-top: 36px;
}

.carousel-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.carousel-counter {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--on-ground);
  display: flex;
  align-items: center;
  gap: 6px;
}

.carousel-counter .curr {
  color: var(--key-correct);
  font-size: 22px;
}

.carousel-counter .sep {
  opacity: 0.4;
}

.carousel-counter .tot {
  color: var(--on-ground-soft);
}

.carousel-nav {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.carousel-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--ground-raise);
  border: 1px solid var(--ground-line);
  color: var(--on-ground);
  cursor: pointer;
  transition: transform 0.15s var(--feed), background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.carousel-arrow:hover {
  background: var(--ground-line);
  color: #fff;
  transform: translateY(-2px);
}

.carousel-arrow:active {
  transform: translateY(1px);
}

.carousel-arrow[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.carousel-track {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 6px 4px 24px;
  margin: 0 -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--ground-line) transparent;
}

.carousel-track::-webkit-scrollbar {
  height: 6px;
}
.carousel-track::-webkit-scrollbar-track {
  background: transparent;
}
.carousel-track::-webkit-scrollbar-thumb {
  background: var(--ground-line);
  border-radius: 4px;
}

.carousel-card {
  flex: 0 0 clamp(310px, 34vw, 420px);
  scroll-snap-align: start;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s var(--feed), box-shadow 0.2s ease;
  position: relative;
  cursor: pointer;
}

.carousel-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 36px -10px rgba(0, 0, 0, 0.6);
}

.carousel-card .card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9.6;
  background: #000;
  overflow: hidden;
}

.carousel-card .card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s ease;
  display: block;
}

.carousel-card:hover .card-media img {
  transform: scale(1.05);
}

.card-zoom-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(15, 12, 30, 0.78);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.carousel-card:hover .card-zoom-badge {
  opacity: 1;
  transform: scale(1.05);
  background: rgba(15, 12, 30, 0.92);
}

.carousel-card .card-body {
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.carousel-card .card-tag {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--paper-band);
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.carousel-card .card-title {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 8px;
  color: var(--ink);
}

.carousel-card .card-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
  flex: 1;
}

/* ───────── Lightbox modal with zoom & glide ───────── */

.lightbox-modal {
  border: 1px solid var(--ground-line);
  border-radius: 16px;
  background: var(--ground);
  color: var(--on-ground);
  padding: 0;
  max-width: min(1200px, 94vw);
  width: 94vw;
  max-height: 94vh;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.lightbox-modal::backdrop {
  background: rgba(8, 6, 18, 0.88);
  backdrop-filter: blur(12px);
}

.lightbox-modal[open] {
  animation: lightboxPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lightboxPop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.lightbox-box {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--ground-raise);
  border-bottom: 1px solid var(--ground-line);
  gap: 16px;
}

.lightbox-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.lightbox-tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--ground-line);
  color: var(--key-correct);
  white-space: nowrap;
}

.lightbox-title {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 700;
  color: var(--on-ground);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lightbox-counter {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 800;
  color: var(--on-ground-soft);
}

.lightbox-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ground-line);
  border-radius: 8px;
  background: var(--ground);
  color: var(--on-ground-soft);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.lightbox-close:hover {
  background: var(--ground-line);
  color: #fff;
}

.lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 320px;
  max-height: calc(82vh - 120px);
  padding: 12px;
}

.lightbox-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img-wrap img {
  max-width: 100%;
  max-height: calc(82vh - 130px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  transition: opacity 0.15s ease;
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(15, 12, 30, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.lightbox-nav-btn:hover {
  background: rgba(15, 12, 30, 0.95);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-nav-btn.prev {
  left: 16px;
}

.lightbox-nav-btn.next {
  right: 16px;
}

.lightbox-footer {
  padding: 14px 22px;
  background: var(--ground-raise);
  border-top: 1px solid var(--ground-line);
}

.lightbox-desc {
  font-size: 14px;
  color: var(--on-ground-soft);
  margin: 0;
  line-height: 1.5;
}

/* ───────── Footer ───────── */

.site-footer { border-top: 1px solid var(--ground-line); }
.site-footer .bar {
  max-width: var(--page);
  margin: 0 auto;
  padding: 36px var(--gutter) 56px;
  font-size: 14px;
  color: var(--on-ground-soft);
  display: grid;
  gap: 8px;
}
.site-footer p { margin: 0; max-width: 90ch; }
.site-footer a { color: var(--on-ground); }
.site-footer .made { font: 800 18px/1 var(--display); color: var(--on-ground); margin-bottom: 6px; letter-spacing: 0.03em; }

@media (prefers-reduced-motion: reduce) {
  .ln.printed, .tape.fed { animation: none; }
  .key { transition: none; }
}
