/*
 * sdk.factadte.com — the developer portal's whole stylesheet.
 *
 * WHY ONE FILE. The site is static HTML served under a CSP of
 * `script-src 'self'` with no CDN, so there is no framework, no utility
 * generator and no build step for styles. One file also means the implementer
 * can diff it: when a rule here disagrees with a board, the board is the
 * drawing and this is the contract.
 *
 * SIBLING OF `/api/`. The tokens below are the same values as
 * `apps/web/public/api/docs.css` and `apps/web/src/styles/tokens.css`
 * (Fintech clara, Torogoz). They are copied, not imported — a page outside the
 * Vite bundle cannot import them, and `/api/` already pays the same price.
 * Anything token-shaped that is NOT in `/api/` is marked «portal» below and is
 * new because a multi-page site needs measures a single page does not: a
 * sidebar width, an outline width, a drawer shadow.
 *
 * LIGHT AND DARK FOLLOW THE SYSTEM. There is no theme switch: the portal has
 * no account to store a preference in, and a switch that forgets is worse than
 * no switch. Same decision as `/api/`.
 *
 * NO SYNTAX HIGHLIGHTING, on purpose. Colouring code needs either a client
 * parser (a megabyte of somebody else's JavaScript under a CSP that forbids
 * `eval`) or per-token markup in the generator. Monochrome code on a tinted
 * surface is what `/api/` already does, and consistency with the sibling was
 * the requirement. If it is wanted later, emit `<span class="tok-str">` and
 * friends and add the rules in ONE place, at the end of §10.
 */

/* ══ 1. Tokens ═══════════════════════════════════════════════════════════ */

:root {
  /* Surfaces and ink — identical to /api/ */
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-alt: oklch(0.97 0.005 235);
  --ink: oklch(0.28 0.02 230);
  --muted: oklch(0.55 0.02 230);
  --faint: oklch(0.65 0.015 230);
  --accent: oklch(0.55 0.13 225);
  --accent-soft: oklch(0.94 0.03 225);
  --border: #e2e7ec;
  --border-soft: #eef1f5;
  --ok-bg: oklch(0.95 0.03 155);
  --ok-text: oklch(0.42 0.1 155);
  --warn-bg: oklch(0.96 0.04 85);
  --warn-text: oklch(0.45 0.11 75);
  --err-bg: oklch(0.95 0.03 25);
  --err-text: oklch(0.47 0.13 25);

  /* portal: the code surface is a shade below the page so a block reads as a
     recess and not as a card. `--surface-alt` alone was too close to white. */
  --code-bg: oklch(0.975 0.006 235);
  --code-ink: oklch(0.26 0.02 230);
  /* portal: a scrim dark enough to mute a whole page of text behind a drawer */
  --scrim: oklch(0.28 0.02 230 / 0.44);
  /* portal: the accent used as a fill needs ink that survives on it */
  --on-accent: #ffffff;
  /* portal: the neutral chip (scopes, «requerido», keyboard hints) */
  --chip-bg: var(--surface-alt);
  --chip-ink: var(--muted);

  /* Type — identical to /api/ */
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --body: "Schibsted Grotesk", system-ui, sans-serif;

  /* Shape */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --radius-pill: 999px;

  /* portal: the measures a multi-page shell needs */
  --top-h: 56px;
  --sidebar-w: 268px;
  --outline-w: 216px;
  --shell-max: 1480px;
  --gutter: 16px;
  --tap: 44px; /* the touch-target floor; never shrink this on a phone */

  --shadow-pop: 0 10px 30px oklch(0.28 0.02 230 / 0.14), 0 2px 6px oklch(0.28 0.02 230 / 0.08);
  --shadow-drawer: 0 0 0 100vmax var(--scrim);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.19 0.015 230);
    --surface: oklch(0.23 0.015 230);
    --surface-alt: oklch(0.26 0.015 230);
    --ink: oklch(0.93 0.01 230);
    --muted: oklch(0.68 0.015 230);
    --faint: oklch(0.58 0.015 230);
    --accent: oklch(0.72 0.12 225);
    --accent-soft: oklch(0.3 0.05 230);
    --border: oklch(0.31 0.015 230);
    --border-soft: oklch(0.27 0.015 230);
    --ok-bg: oklch(0.3 0.06 155);
    --ok-text: oklch(0.85 0.11 155);
    --warn-bg: oklch(0.32 0.06 85);
    --warn-text: oklch(0.87 0.11 85);
    --err-bg: oklch(0.32 0.07 25);
    --err-text: oklch(0.85 0.1 25);

    --code-bg: oklch(0.165 0.015 235);
    --code-ink: oklch(0.9 0.012 230);
    --scrim: oklch(0.12 0.01 230 / 0.62);
    /* In dark the accent is light, so ink ON it has to be dark, not white. */
    --on-accent: oklch(0.17 0.02 230);
    --chip-bg: oklch(0.29 0.015 230);
    --chip-ink: oklch(0.76 0.015 230);
    --shadow-pop: 0 10px 34px oklch(0.08 0.01 230 / 0.6), 0 2px 8px oklch(0.08 0.01 230 / 0.4);
  }
}

/* ══ 2. Reset and base ═══════════════════════════════════════════════════ */

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

html {
  scroll-behavior: smooth;
  /* Anchors land below the sticky bar. On a phone the nav row is sticky too,
     so the padding is deeper; see §5. */
  scroll-padding-top: calc(var(--top-h) + 60px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15.5px;
  line-height: 1.62;
  /* `overflow-x: hidden` would paper over a real overflow bug and make it
     impossible to find. It is deliberately NOT here: if something overflows at
     390 px, the page must show it so it gets fixed. */
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, samp { font-family: var(--mono); font-size: 0.88em; }
p code, li code, td code, th code, dd code, dt code, figcaption code,
summary code, .callout code {
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 0.5px 4px;
  /* A long identifier inside a sentence is allowed to break rather than push
     the column wider. This is the single most common cause of the 390 px
     horizontal scroll. */
  overflow-wrap: anywhere;
}

img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

/* ══ 3. Skip link and focus ══════════════════════════════════════════════ */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 60;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent);
}

/* One focus ring for the whole site. `:focus-visible` so a mouse click does
   not leave a ring behind, and an offset so the ring never sits on the glyphs. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Screen-reader-only text that is still focusable if it ever needs to be. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Controls that only make sense with JavaScript. `portal.js` removes `no-js`
   from <html> as its first statement, so these are hidden for the one frame
   before the deferred script runs and then appear. A dead button is worse. */
.no-js [data-js-only] { display: none !important; }

/* ══ 4. Top bar ══════════════════════════════════════════════════════════ */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--top-h);
  padding: 8px var(--gutter);
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand .word { display: inline-flex; align-items: baseline; gap: 2px; }
/* The «punto de sello» of the brand kit: the dot IS the seal of the symbol. */
.brand .dot { width: 5px; height: 5px; border-radius: 50%; background: #007faa; }
.brand-tag {
  font-family: var(--body);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  padding-left: 9px;
  margin-left: 1px;
  border-left: 1px solid var(--border);
}

.chip-version {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  white-space: nowrap;
}

.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-height: 36px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.search-btn:hover { color: var(--accent); border-color: var(--accent); }
.search-btn svg { flex-shrink: 0; }
.search-btn kbd {
  font-size: 11px;
  color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  line-height: 1.5;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.top-links a { color: var(--muted); }
.top-links a:hover { color: var(--accent); }
.top-cta {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink) !important;
  white-space: nowrap;
}
.top-cta:hover { border-color: var(--accent); color: var(--accent) !important; text-decoration: none; }

/*
 * The bar has to survive 390 px, so below the breakpoints it sheds what is
 * duplicated elsewhere rather than wrapping onto a second line: the two
 * contract links live in the menu's footer, and the version chip is on the
 * status page. What never goes away is the brand, the search and the way back
 * to the app.
 */
@media (max-width: 1023px) {
  .top-links a:not(.top-cta) { display: none; }
}
@media (max-width: 767px) {
  .brand-tag { display: none; }
  .chip-version { display: none; }
  /* Icon only — and a full 44 px target, not a shrunken button. */
  .search-btn span, .search-btn kbd { display: none; }
  .search-btn {
    min-width: var(--tap);
    min-height: var(--tap);
    padding: 0;
    justify-content: center;
  }
  .top-cta { min-height: var(--tap); }
}

/* ══ 5. Layout ═══════════════════════════════════════════════════════════ */

.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

main {
  min-width: 0; /* without this a <pre> inside a grid track can widen the track */
  padding: 8px var(--gutter) 56px;
}
.page { max-width: 820px; }

/* Prose measure is applied to the TEXT, not to the block: a table or a code
   block inside an article is not prose, and 68ch would make it scroll inside a
   column that had room to spare. Same reasoning as /api/. */
.prose > p,
.prose > ul,
.prose > ol,
.prose > dl { max-width: 68ch; }

section { scroll-margin-top: calc(var(--top-h) + 60px); }
h2, h3, h4 { scroll-margin-top: calc(var(--top-h) + 60px); }

/* ══ 6. Sidebar, and the drawer it becomes on a phone ════════════════════ */

/*
 * ONE nav in the document, not two.
 *
 * It is a <details open> for a reason that is easy to get wrong: a CLOSED
 * <details> cannot be reopened from CSS —the browser gives its content
 * `content-visibility: hidden`— so a wide screen would get an empty sidebar.
 * So the markup ships open and `portal.js` closes it on a phone. Without
 * JavaScript a phone shows the nav expanded, capped in height, with its own
 * summary to fold it by hand: worse, never broken.
 *
 * <summary> carries `aria-expanded` from the user agent, so the drawer's state
 * is announced without any author ARIA.
 */
.nav {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: var(--top-h);
  z-index: 20;
}

.nav-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 var(--gutter);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  list-style: none;
}
.nav-toggle::-webkit-details-marker { display: none; }
.nav-toggle-here {
  margin-left: auto;
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-toggle .bars { flex-shrink: 0; color: var(--muted); }
.nav[open] .bars .bar-top { transform: translateY(5px) rotate(45deg); }
.nav[open] .bars .bar-mid { opacity: 0; }
.nav[open] .bars .bar-bot { transform: translateY(-5px) rotate(-45deg); }
.bars rect { transform-origin: center; transition: transform 0.16s ease, opacity 0.12s ease; }

.nav-panel {
  padding: 4px var(--gutter) 20px;
  /* On a phone the open nav is a menu: it covers what is under it on purpose,
     and it scrolls on its own instead of pushing the page down. */
  max-height: calc(100vh - var(--top-h) - var(--tap));
  max-height: calc(100dvh - var(--top-h) - var(--tap));
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* When JavaScript is present the open drawer also dims the page behind it.
   The shadow hangs off `.nav` and not off `.nav-panel`, so it dims the page
   and NOT the drawer's own toggle row — which is part of the drawer. */
.nav[open][data-drawer] { box-shadow: var(--shadow-drawer); }

.nav-group + .nav-group { margin-top: 18px; }
.nav-group-title {
  margin: 0 0 6px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  /* 44 px on a phone. §9 of the spec, and the reason the desktop rule below
     overrides the height rather than the other way round. */
  min-height: var(--tap);
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  color: var(--ink);
  font-size: 14px;
}
.nav-list a:hover { background: var(--surface-alt); text-decoration: none; }
.nav-list a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.nav-list .method { flex-shrink: 0; }
.nav-list .nav-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-foot {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: grid;
  gap: 2px;
  font-size: 13px;
}
.nav-foot a { color: var(--muted); display: flex; align-items: center; min-height: 32px; padding: 0 8px; }
.nav-foot a:hover { color: var(--accent); }

/* ══ 7. Outline — «En esta página» ═══════════════════════════════════════ */

.outline { display: none; }

/* ══ 8. Prose ════════════════════════════════════════════════════════════ */

h1 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 6vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 22px 0 10px;
}
h2 {
  font-family: var(--display);
  font-size: 1.32rem;
  line-height: 1.2;
  letter-spacing: -0.012em;
  margin: 46px 0 10px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
h2.plain { border-top: 0; padding-top: 0; margin-top: 34px; }
h3 {
  font-family: var(--display);
  font-size: 1.08rem;
  font-weight: 500;
  margin: 28px 0 6px;
}
h4 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  font-weight: 500;
  margin: 22px 0 8px;
}
p { margin: 0 0 12px; }
.lead {
  max-width: 62ch;
  font-size: 1.06rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 18px;
}
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 1.15rem; }
.prose li { margin-bottom: 7px; }
.prose ul li::marker { color: var(--accent); }
.prose ol li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
strong { font-weight: 700; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

/* ══ 9. Cards, the base-URL strip, the status strip ══════════════════════ */

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  margin: 0 0 8px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* A card that is entirely a link keeps the whole rectangle clickable without
   nesting interactive elements. */
a.card { color: var(--ink); }
a.card:hover { border-color: var(--accent); text-decoration: none; }
a.card:hover .card-title { color: var(--accent); }
/* A pill is a label, not a banner: in a column flex box it would stretch to
   the full width unless it is told to keep its own size. */
.card > .pill { align-self: flex-start; }
.card-title { font-family: var(--display); font-size: 1.05rem; font-weight: 500; margin: 0; }
.card p { margin: 0; font-size: 14px; color: var(--muted); }
.card-more { margin-top: auto; padding-top: 6px; font-size: 13.5px; font-weight: 500; color: var(--accent); }

.server {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin: 18px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.server-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.server code { font-size: 12.5px; overflow-wrap: anywhere; }
.server .copy { margin-left: auto; }

/* The publication strip: three facts, flat, no card per fact. */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding: 14px 16px;
  margin: 18px 0;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.fact { display: grid; gap: 1px; min-width: 0; }
.fact dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.fact dd { margin: 0; font-size: 13.5px; font-weight: 500; }
.fact dd .note-inline { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }

/* ══ 10. Code: blocks, tabs, copy ════════════════════════════════════════ */

.code {
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden; /* keeps the rounded corner over the scrolling <pre> */
}
.code > figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 4px 8px 4px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}
.code-lang {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.code-note { color: var(--faint); font-size: 12px; }
.code > figcaption .copy { margin-left: auto; }

pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--code-ink);
  /* A code sample is never re-wrapped: a wrapped curl line is a line that does
     not run when it is pasted. It scrolls inside its own box instead. */
  white-space: pre;
  -webkit-overflow-scrolling: touch;
  /* Only the block scrolls, never the page behind it. */
  overscroll-behavior-x: contain;
}
pre code { font-family: var(--mono); background: none; border: 0; padding: 0; }
/* A bare <pre> outside a <figure> (an inline shell line, a tree) still gets a
   box, otherwise it would float on the page background. */
pre:not(.code pre) {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
}
.copy:hover { color: var(--accent); border-color: var(--accent); }
/* The «Copiado» state. Held for 1.4 s by portal.js; it changes colour AND the
   word, because colour alone is not a message. */
.copy.is-done { color: var(--ok-text); border-color: var(--ok-text); background: var(--ok-bg); }
.copy.is-failed { color: var(--err-text); border-color: var(--err-text); background: var(--err-bg); }

/* Language tabs. Without JavaScript every panel is visible, each under its own
   heading; with JavaScript the tablist appears and the headings go away. */
.tabs { margin: 0 0 18px; }
.tablist {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--border);
}
.tablist::-webkit-scrollbar { display: none; }
.tablist [role="tab"] {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tablist [role="tab"]:hover { color: var(--ink); }
.tablist [role="tab"][aria-selected="true"] {
  color: var(--accent);
  font-weight: 500;
  border-bottom-color: var(--accent);
}
.tabs [role="tabpanel"] { padding-top: 14px; }
.tabs [role="tabpanel"]:focus-visible { outline-offset: -2px; }
.tab-fallback-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  font-weight: 500;
  margin: 18px 0 6px;
}
/* With JavaScript on, the per-panel heading is redundant with the tab. */
:root:not(.no-js) .tab-fallback-label { display: none; }
/* Reserved for a future generator that emits token spans. Unused today. */
.tok-str, .tok-num, .tok-key, .tok-com, .tok-kw { color: inherit; }

/* ══ 11. Tables ══════════════════════════════════════════════════════════ */

/*
 * Every table lives inside `.table-wrap`, which scrolls locally. A table that
 * widens the page is the classic 390 px overflow, and a table squeezed into
 * 358 px is unreadable — so it keeps a sensible `min-width` and the READER
 * scrolls the table, not the document.
 */
.table-wrap {
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  background: var(--surface);
  /*
   * The shadow that says «esto se desplaza».
   *
   * Two opaque covers scroll WITH the content (`local`) and two soft shadows
   * stay fixed to the box (`scroll`), so a shadow only shows on the side where
   * there is still something to see. No JavaScript, no scroll listener — and
   * it is what keeps a table that scrolls from looking like a table that is
   * simply cut off.
   */
  background-image:
    linear-gradient(to right, var(--surface) 30%, transparent),
    linear-gradient(to left, var(--surface) 30%, transparent),
    linear-gradient(to right, oklch(0.28 0.02 230 / 0.13), transparent 14px),
    linear-gradient(to left, oklch(0.28 0.02 230 / 0.13), transparent 14px);
  background-position: 0 0, 100% 0, 0 0, 100% 0;
  background-repeat: no-repeat;
  background-size: 26px 100%, 26px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  background: var(--surface);
}
table caption {
  text-align: left;
  padding: 11px 14px 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td p { margin: 0 0 6px; }
td p:last-child { margin: 0; }
td ul { margin: 4px 0 0; padding-left: 1rem; }

.t-fields { min-width: 540px; }
.t-fields td:first-child > code { white-space: nowrap; }
.t-errors { min-width: 720px; }
.t-errors td:first-child { white-space: nowrap; }
/* Two columns fit a phone without scrolling; three do not. */
.t-compact { min-width: 0; font-size: 13px; }
.t-compact th, .t-compact td { padding: 9px 12px; }
/* An identifier broken across two lines stops being an identifier. It is safe
   to keep it whole because the wrapper scrolls on its own. */
.t-compact td:first-child > code { white-space: nowrap; }
.t-status { min-width: 620px; }

/*
 * `.t-stack` — a THREE-column field table (name · type · what it is) becomes a
 * list of blocks on a narrow screen.
 *
 * Only that shape. A comparison grid —the error table, «qué exige cada tipo»—
 * loses its meaning when its columns are stacked, so those keep scrolling
 * sideways: in a grid the columns ARE the information.
 *
 * The <thead> goes away because the order name → type → description reads on
 * its own; no label is invented for a cell that has lost its header.
 */
@media (max-width: 560px) {
  .t-stack { min-width: 0; }
  .t-stack thead { display: none; }
  .t-stack tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
  .t-stack tr:last-child { border-bottom: 0; }
  .t-stack td { display: block; border: 0; padding: 0; }
  .t-stack td:first-child { font-weight: 500; margin-bottom: 2px; }
  .t-stack td:nth-child(2) { margin-bottom: 6px; }
  .t-stack td:nth-child(2):empty { margin-bottom: 0; }
  .t-stack caption { padding-bottom: 8px; }
}

.type { color: var(--muted); white-space: nowrap; font-size: 12.5px; }

/* ══ 12. Chips and badges ════════════════════════════════════════════════ */

.method {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.7;
  border-radius: 5px;
  padding: 1px 6px;
  min-width: 38px;
  text-align: center;
  color: var(--on-accent);
}
.method.get { background: oklch(0.55 0.13 225); }
.method.post { background: oklch(0.5 0.12 155); }
.method.delete { background: oklch(0.5 0.13 25); }
@media (prefers-color-scheme: dark) {
  .method.get { background: oklch(0.72 0.12 225); }
  .method.post { background: oklch(0.7 0.13 155); }
  .method.delete { background: oklch(0.68 0.14 25); }
}

.status {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 5px;
  padding: 2px 8px;
  white-space: nowrap;
}
.status.ok { background: var(--ok-bg); color: var(--ok-text); }
.status.warn { background: var(--warn-bg); color: var(--warn-text); }
.status.err { background: var(--err-bg); color: var(--err-text); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  background: var(--chip-bg);
  color: var(--chip-ink);
  white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); }
.pill.mono { font-family: var(--mono); font-size: 11px; }

.req {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: 1.5px;
  white-space: nowrap;
}
.req.on { color: var(--accent); border-color: var(--accent); }

/* ══ 13. Callouts ════════════════════════════════════════════════════════ */

/*
 * Three levels, and the level is in the WORD as well as the colour: a person
 * who cannot tell the amber from the red still reads «Atención» and «Peligro».
 */
.callout {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 13px 15px;
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 72ch;
}
.callout > svg { grid-row: 1; margin-top: 2px; }
.callout-title {
  grid-column: 2;
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.callout-body { grid-column: 2; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-body p, .callout-body ul { font-size: 14px; }

.callout.note { border-left-color: var(--accent); background: color-mix(in oklab, var(--accent-soft) 45%, var(--surface)); }
.callout.note .callout-title, .callout.note > svg { color: var(--accent); }
.callout.warn { border-left-color: var(--warn-text); background: color-mix(in oklab, var(--warn-bg) 45%, var(--surface)); }
.callout.warn .callout-title, .callout.warn > svg { color: var(--warn-text); }
.callout.danger { border-left-color: var(--err-text); background: color-mix(in oklab, var(--err-bg) 45%, var(--surface)); }
.callout.danger .callout-title, .callout.danger > svg { color: var(--err-text); }

/* ══ 14. Operation pages ═════════════════════════════════════════════════ */

.op-head { margin: 22px 0 14px; }
.op-route {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 14px;
}
.op-route .path {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.op-route .copy { margin-left: auto; }
.op-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }

.responses { display: grid; gap: 10px; margin: 0 0 18px; }
.response {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface-alt);
}
.response-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.response-head .name { font-size: 13.5px; font-weight: 500; }
.response-body { max-width: 64ch; }
.response-body p, .response-body ul { font-size: 13.5px; margin-bottom: 8px; }
.response-body > :last-child { margin-bottom: 0; }

/* ══ 15. Steps — «Empezar» ═══════════════════════════════════════════════ */

.steps { list-style: none; margin: 24px 0 0; padding: 0; counter-reset: step; }
.step {
  counter-increment: step;
  position: relative;
  padding: 0 0 26px 44px;
  /* The rail that joins one step to the next. */
  border-left: 1px solid var(--border);
  margin-left: 15px;
}
.step:last-child { border-left-color: transparent; padding-bottom: 8px; }
.step::before {
  content: counter(step);
  position: absolute;
  left: -16px;
  top: 0;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}
.step-title { font-family: var(--display); font-size: 1.06rem; font-weight: 500; margin: 3px 0 6px; }
.step > :last-child { margin-bottom: 0; }

/* ══ 16. Search dialog ═══════════════════════════════════════════════════ */

dialog.search {
  width: min(680px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  padding: 0;
  margin-top: 8vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
dialog.search::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.search-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.search-head svg { color: var(--faint); flex-shrink: 0; }
.search-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  /* 16 px exactly: anything smaller makes iOS zoom the page on focus. */
  font-size: 16px;
}
.search-input:focus { outline: none; }
.search-close {
  min-height: 32px;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.search-results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; max-height: calc(70vh - 60px); }
.search-results li + li { margin-top: 2px; }
.search-results a {
  display: block;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  min-height: var(--tap);
}
.search-results a:hover,
.search-results a[aria-selected="true"] { background: var(--accent-soft); text-decoration: none; }
.search-results a[aria-selected="true"] .r-heading { color: var(--accent); }
.r-where { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.r-heading { font-size: 14px; font-weight: 500; margin: 1px 0; }
.r-text {
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.r-text mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-empty { padding: 26px 16px 30px; text-align: center; color: var(--muted); font-size: 14px; }
.search-empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.search-foot {
  display: flex;
  gap: 14px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--faint);
}
.search-foot kbd {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 11px;
}

/* ══ 17. Pager and footer ════════════════════════════════════════════════ */

.pager {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  margin: 44px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.pager a {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a:hover .pager-title { color: var(--accent); }
.pager .pager-dir { font-size: 11.5px; color: var(--faint); }
.pager .pager-title { font-size: 14.5px; font-weight: 500; }
.pager .next { text-align: right; }

.foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px var(--gutter) 40px;
}
.foot-inner { max-width: var(--shell-max); margin: 0 auto; display: grid; gap: 8px; }
.foot p { margin: 0; font-size: 12.5px; color: var(--muted); max-width: 72ch; }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }

/* ══ 18. The 404 ═════════════════════════════════════════════════════════ */

.notfound { padding: 40px 0 20px; max-width: 620px; }
.notfound .code-big {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.1em;
}

/* ══ 19. The states board (estados.html) ═════════════════════════════════ */

.spec { margin: 0 0 40px; }
.spec-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 4px; }
.spec-head h2 { margin: 0; padding: 0; border: 0; font-size: 1.16rem; }
.spec-note { font-size: 13px; color: var(--muted); margin: 0 0 14px; max-width: 72ch; }
.spec-frame {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg);
}
.spec-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spec-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
/* A frozen copy of the drawer/dialog so the board can show them without JS. */
.static-dialog {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  max-width: 680px;
}
.static-drawer {
  position: relative;
  max-width: 340px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
/*
 * The frozen drawer keeps PHONE metrics even though the board is being read on
 * a wide screen: that is the whole point of showing it. Without these the
 * desktop rules would hide its toggle row and shrink its rows to 30 px, and
 * the board would be drawing something nobody ever sees.
 */
.static-drawer .nav-toggle { display: flex; }
.static-drawer .nav-panel { display: block; max-height: 430px; padding: 4px 16px 16px; overflow-y: auto; }
.static-drawer .nav-list a { min-height: var(--tap); font-size: 14px; padding: 6px 8px; }
.static-drawer .nav-foot a { min-height: 32px; }
/* In the frozen dialog the field is a <span>, so it needs the single-line
   behaviour an <input> has for free. */
.static-dialog .search-input { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-demo {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 13px;
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ══ 20. Breakpoints ═════════════════════════════════════════════════════ */

/*
 * 768 px — a tablet in portrait, or a phone turned sideways. The nav is still
 * a drawer (a 268 px rail would leave 460 px of content, which is worse than
 * a full-width column), but the page breathes: wider gutters, two-up cards.
 */
@media (min-width: 768px) {
  :root { --gutter: 24px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
  .pager { grid-template-columns: 1fr 1fr; }
  .spec-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .facts { gap: 10px 34px; }
  body { font-size: 15px; }
}

/*
 * 1024 px — the sidebar docks. From here the nav is not a disclosure at all,
 * so the summary goes away and the panel is forced visible: a <details> that
 * JavaScript closed on a narrow screen must not stay closed when the window
 * grows, and CSS cannot open it.
 */
@media (min-width: 1024px) {
  :root { --gutter: 32px; }
  html { scroll-padding-top: calc(var(--top-h) + 24px); }
  section, h2, h3, h4 { scroll-margin-top: calc(var(--top-h) + 24px); }

  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); gap: 36px; align-items: start; padding-right: var(--gutter); }
  main { padding-left: 0; padding-right: 0; }

  .nav {
    position: sticky;
    top: var(--top-h);
    max-height: calc(100vh - var(--top-h));
    overflow: hidden;
    border-bottom: 0;
    background: none;
    padding-left: var(--gutter);
    box-shadow: none !important; /* the drawer scrim never applies here */
  }
  .nav-toggle { display: none; }
  .nav-panel {
    display: block !important; /* beats the UA rule for a closed <details> */
    padding: 24px 6px 32px 0;
    max-height: calc(100vh - var(--top-h));
    overflow-y: auto;
  }
  .nav-list a { min-height: 30px; font-size: 13.5px; padding: 4px 8px; }
  .nav-foot a { min-height: 26px; }
  .search-btn { min-width: 210px; }
}

/*
 * 1200 px — the outline appears. It is the first thing to go because it is the
 * only column that repeats information already on the page.
 */
@media (min-width: 1200px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--outline-w); }
  .outline {
    display: block;
    position: sticky;
    top: calc(var(--top-h) + 24px);
    max-height: calc(100vh - var(--top-h) - 40px);
    overflow-y: auto;
    padding: 24px 0 32px;
  }
  .outline h2 {
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    font-family: var(--body);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--faint);
  }
  .outline ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
  .outline li a {
    display: block;
    padding: 5px 0 5px 12px;
    margin-left: -1px;
    border-left: 2px solid transparent;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
  }
  .outline li a:hover { color: var(--ink); text-decoration: none; }
  .outline li a[aria-current="true"] { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
  .outline .sub a { padding-left: 24px; font-size: 12.5px; }
}

/* The content column stops growing before the lines get too long to track. */
@media (min-width: 1440px) {
  .page { max-width: 880px; }
}

/* ══ 21. Motion and print ════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .top, .nav, .outline, .pager, .search-btn, .copy { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; font-size: 11pt; }
  pre, .table-wrap { break-inside: avoid; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #444; }
}
