/* Caravel Pay docs: three-column layout (nav, content, on-page TOC).
   Depends on base.css. Pages are generated by site/_build/docs.py. */

:root { --top-h: 64px; }
body.docs { background: var(--paper); }

/* ---------- top bar ---------- */
.docs-top {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--top-h);
  background: rgba(255, 253, 248, 0.9);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.docs-top-in {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.docs-top .brand { color: var(--ink); }
.docs-tag {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--cream);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  text-decoration: none;
}
.docs-tag:hover { color: var(--ink); border-color: rgba(20, 24, 33, 0.22); }
.docs-top-links {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
}
.docs-top-links a:not(.btn) {
  color: var(--ink-2);
  font-size: 14.5px;
  text-decoration: none;
}
.docs-top-links a:not(.btn):hover { color: var(--ink); }
.docs-menu-btn {
  display: none;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 14.5px;
  cursor: pointer;
}
.docs-menu-btn svg { width: 16px; height: 16px; }

/* ---------- shell ---------- */
.docs-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 232px;
  max-width: 1440px;
  margin: 0 auto;
}

/* ---------- left nav ---------- */
.docs-nav {
  position: sticky;
  top: var(--top-h);
  height: calc(100vh - var(--top-h));
  overflow-y: auto;
  padding: 30px 18px 40px var(--gutter);
  border-right: 1px solid var(--line-2);
  scrollbar-width: thin;
}
.docs-nav-group {
  margin: 26px 0 8px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.docs-nav-group:first-child { margin-top: 0; }
.docs-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.docs-nav a {
  display: block;
  padding: 7px 12px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.docs-nav a:hover { background: rgba(20, 24, 33, 0.04); color: var(--ink); }
.docs-nav a[aria-current="page"] {
  background: var(--cream-2);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--amber);
}

/* ---------- main column ---------- */
.docs-main {
  min-width: 0;
  padding: 48px clamp(24px, 4.5vw, 72px) 40px;
}
.prose { max-width: 760px; }
.prose > * + * { margin-top: 18px; }

.prose .kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber-ink);
}
.prose h1 {
  margin-top: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(34px, 3.6vw, 46px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.prose .intro {
  margin-top: 16px;
  font-size: 18.5px;
  line-height: 1.6;
  color: var(--ink-2);
  text-wrap: pretty;
}
.prose h2 {
  margin-top: 56px;
  padding-top: 30px;
  border-top: 1px solid var(--line-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.025em;
  scroll-margin-top: calc(var(--top-h) + 16px);
}
.prose h3 {
  margin-top: 34px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: -0.015em;
  scroll-margin-top: calc(var(--top-h) + 16px);
}
.prose h2 + *, .prose h3 + * { margin-top: 12px; }
.prose p, .prose li { font-size: 16px; line-height: 1.72; color: var(--ink-2); text-wrap: pretty; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { color: var(--ink); }
.prose a:not(.btn):not(.choice-card) {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(20, 24, 33, 0.3);
}
.prose a:not(.btn):not(.choice-card):hover { text-decoration-color: var(--ink); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 8px; }
.prose li::marker { color: var(--ink-3); }
.prose :not(pre) > code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--cream-2);
  font-size: 0.86em;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.prose code.wrap { word-break: break-all; }
.prose code.sig { background: var(--green-wash); color: var(--green); }

.anchor {
  margin-left: 10px;
  color: var(--ink-3);
  font-weight: 400;
  text-decoration: none !important;
  opacity: 0;
  transition: opacity 0.15s ease;
}
h2:hover > .anchor, h3:hover > .anchor, .anchor:focus-visible { opacity: 1; }

/* ---------- code blocks ---------- */
.prose .code { margin-top: 22px; }
.prose .code + .code { margin-top: 12px; }
.code-title:has(+ .code-tabs) {
  flex: 0 1 auto;
  min-width: 0;
  margin-right: 6px;
  padding-right: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---------- endpoint chip ---------- */
.endpoint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--cream);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink);
}
.endpoint code { background: none !important; padding: 0 !important; font-size: 14px !important; }
.method {
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--cream);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.method.get { background: var(--green-wash); color: var(--green); }

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  /* Wide tables scroll sideways on small screens. A soft shadow on the edge that has more to show
     is the only cue, so it is drawn with fixed and scrolling backgrounds: no script. */
  background:
    linear-gradient(to right, var(--paper) 40%, rgba(255, 253, 248, 0)) left center / 36px 100% no-repeat local,
    linear-gradient(to left, var(--paper) 40%, rgba(255, 253, 248, 0)) right center / 36px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(20, 24, 33, 0.18), rgba(20, 24, 33, 0)) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(20, 24, 33, 0.18), rgba(20, 24, 33, 0)) right center / 12px 100% no-repeat scroll,
    var(--paper);
}
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; }
.prose th, .prose td { padding: 12px 16px; text-align: left; vertical-align: top; line-height: 1.6; }
.prose thead th {
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
}
.prose tbody tr + tr > * { border-top: 1px solid var(--line-2); }
.prose td { color: var(--ink-2); }
.prose tbody th[scope="row"] {
  width: 1%;
  white-space: nowrap;
  background: var(--cream);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.params td:first-child { width: 1%; white-space: nowrap; }
.params td:first-child code { font-size: 13.5px; }
.params td:first-child > code:first-child:not(:last-child) { display: block; width: fit-content; }
.type, .req, .opt {
  display: inline-block;
  margin: 5px 8px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}
.req { color: var(--amber-ink); }
.ledger td { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.ledger tbody th[scope="row"] { width: auto; background: none; font-weight: 500; color: var(--ink-2); }
.ledger .total > *, .ledger tbody .total th[scope="row"] { font-weight: 700; color: var(--ink); }
.ledger .total td { color: var(--green); }
.prose td .status + .status { margin-left: 4px; }

/* ---------- callouts ---------- */
.callout {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--cream);
  border: 1px solid var(--line-2);
}
.callout > svg { width: 20px; height: 20px; flex: none; margin-top: 3px; color: var(--ink-2); }
.callout p { font-size: 15px; }
.callout.warn { background: #fbf3e2; border-color: rgba(138, 90, 6, 0.16); }
.callout.warn > svg { color: var(--amber-ink); }

/* ---------- numbered steps ---------- */
.prose ol.doc-steps { list-style: none; padding: 0; counter-reset: step; }
.doc-steps > li { position: relative; padding-left: 46px; counter-increment: step; }
.doc-steps > li + li { margin-top: 18px; }
.doc-steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
}
.doc-steps p + p { margin-top: 10px; }
.ui-path { font-weight: 600; color: var(--ink); }
.ui-path span { margin: 0 3px; font-weight: 400; color: var(--ink-3); }

/* ---------- quickstart choice cards ---------- */
.prose .choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 30px;
}
.choice-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.6;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.choice-card:hover { border-color: rgba(20, 24, 33, 0.26); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.choice-card strong { font-family: var(--font-display); font-size: 19px; letter-spacing: -0.02em; }
.choice-k {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.choice-go { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; font-weight: 600; color: var(--ink); }
.choice-go svg { width: 14px; height: 14px; transition: transform 0.18s ease; }
.choice-card:hover .choice-go svg { transform: translateX(3px); }

/* ---------- ASCII lifecycle diagram ---------- */
.prose .diagram {
  margin: 22px 0 0;
  padding: 22px 24px;
  border-radius: 16px;
  border: 1px solid var(--line-2);
  background: var(--cream);
}
.diagram pre {
  margin: 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}
.diagram figcaption { margin-top: 14px; font-size: 14px; line-height: 1.6; color: var(--ink-3); }

/* ---------- fee tiles ---------- */
.prose .fee-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fee {
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--cream);
  border: 1px solid var(--line-2);
  font-size: 14px;
  color: var(--ink-3);
}
.fee-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 6px;
}

.link-list a { font-weight: 600; }

/* ---------- pager + footer ---------- */
.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 760px;
  margin-top: 64px;
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.pager a:hover { border-color: rgba(20, 24, 33, 0.26); background: var(--cream); }
.pager .k {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.pager svg { width: 13px; height: 13px; }
.pager-next { align-items: flex-end; text-align: right; }
.docs-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: 760px;
  margin-top: 48px;
  padding-top: 22px;
  border-top: 1px solid var(--line-2);
  font-size: 13.5px;
  color: var(--ink-3);
}
.docs-foot code { font-size: 12.5px; }

/* ---------- right TOC ---------- */
.toc {
  position: sticky;
  top: var(--top-h);
  height: calc(100vh - var(--top-h));
  overflow-y: auto;
  padding: 50px var(--gutter) 40px 8px;
  scrollbar-width: thin;
}
.toc-title {
  margin-bottom: 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 14px;
  border-left: 2px solid transparent;
  color: var(--ink-3);
  font-size: 13.5px;
  line-height: 1.45;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.toc .lvl3 a { padding-left: 26px; font-size: 13px; }
.toc a:hover { color: var(--ink); }
.toc a.is-active { color: var(--ink); border-left-color: var(--amber); }

/* ---------- responsive ---------- */
@media (max-width: 1279px) {
  .docs-shell { grid-template-columns: 248px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (min-width: 1024px) {
  .docs-nav[hidden] { display: block !important; }
}

@media (max-width: 1023px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .js .docs-menu-btn { display: inline-flex; }
  .docs-top-links a:not(.btn) { display: none; }
  .docs-nav {
    position: fixed;
    top: var(--top-h);
    left: 0;
    right: 0;
    z-index: 25;
    height: auto;
    max-height: calc(100vh - var(--top-h));
    padding: 18px var(--gutter) 28px;
    background: var(--paper);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 30px 50px -30px rgba(20, 24, 33, 0.35);
  }
  .js .docs-nav:not(.is-open) { display: none; }
  html:not(.js) .docs-nav { position: static; max-height: none; box-shadow: none; }
  .docs-main { padding-top: 36px; }
}

@media (max-width: 640px) {
  .docs-top-links { display: none; }
  .docs-menu-btn { margin-left: auto; }
  .docs-main { padding: 28px var(--gutter) 32px; }
  .prose .intro { font-size: 17px; }
  .prose h2 { margin-top: 44px; padding-top: 24px; font-size: 23px; }
  .prose .choice { grid-template-columns: minmax(0, 1fr); }
  .prose .fee-grid { gap: 8px; }
  .fee { padding: 14px; }
  .fee-num { font-size: 30px; }
  .code-title:has(+ .code-tabs) { display: none; }
  .code pre { font-size: 12.5px; padding: 16px; }
  .prose th, .prose td { padding: 10px 12px; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager-next { align-items: flex-start; text-align: left; }
  .doc-steps > li { padding-left: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .choice-card, .choice-go svg, .docs-nav a, .toc a { transition: none; }
}
