/*
 * BitPays documentation design layer.
 *
 * Every docs page keeps its own inline stylesheet (they are static pages and
 * some are generated). This file loads LAST and re-points their shared design
 * tokens at the BitPays identity — Inter, deep navy, electric blue, cool
 * greys — and styles the shared top bar, sidebar and search injected by
 * scripts/finalize-docs.mjs. Selectors use `html:root` so they outrank the
 * pages' own `:root` / `:root[data-theme]` rules regardless of source order.
 */

html:root,
html:root[data-theme="light"] {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #e4e8ef;
  --border-strong: #cfd6e2;
  --text: #0f1729;
  --text-dim: #4d586b;
  --text-faint: #7b8597;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-soft: #eef3ff;
  --green: #15803d; --green-soft: #e7f6ed;
  --amber: #a15c07; --amber-soft: #fdf3e2;
  --red: #c02636; --red-soft: #fdecee;
  --violet: #5b4bd1; --violet-soft: #efedfc;
  --code-bg: #0b1220;
  --code-bar: #111a2c;
  --code-text: #d6deec;
  --code-dim: #6b7a95;
  --code-str: #9be2b5;
  --code-key: #8fb5ff;
  --code-border: #1c2740;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05);
  --radius: 10px;
  --bpd-navy: #0b1220;
  --bpd-top: 60px;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"]) {
    --bg: #070b14; --surface: #0c1220; --surface-2: #111a2c; --border: #1d273b; --border-strong: #2a3651;
    --text: #e8edf6; --text-dim: #a1acbf; --text-faint: #6d7a91;
    --accent: #5b8cff; --accent-ink: #8cb0ff; --accent-soft: #14213d;
    --green: #4ccf8f; --green-soft: #0f261b; --amber: #e3a948; --amber-soft: #2a2010;
    --red: #f26b7e; --red-soft: #2c131a; --violet: #a596f5; --violet-soft: #1d1933;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
html:root[data-theme="dark"] {
  --bg: #070b14; --surface: #0c1220; --surface-2: #111a2c; --border: #1d273b; --border-strong: #2a3651;
  --text: #e8edf6; --text-dim: #a1acbf; --text-faint: #6d7a91;
  --accent: #5b8cff; --accent-ink: #8cb0ff; --accent-soft: #14213d;
  --green: #4ccf8f; --green-soft: #0f261b; --amber: #e3a948; --amber-soft: #2a2010;
  --red: #f26b7e; --red-soft: #2c131a; --violet: #a596f5; --violet-soft: #1d1933;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

html body {
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
}
html body h1, html body h2, html body h3 { letter-spacing: -0.02em; }
html body code, html body pre { font-family: var(--font-mono); }
html { scroll-padding-top: calc(var(--bpd-top) + 16px); }
:target { scroll-margin-top: calc(var(--bpd-top) + 16px); }

/* Logos on legacy layouts become the navy BitPays mark. */
html body .logo { background: var(--bpd-navy); color: #3b82f6; }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.bpd-top {
  position: sticky; top: 0; z-index: 60; height: var(--bpd-top);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.bpd-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -0.02em; text-decoration: none !important; flex: none; }
.bpd-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--bpd-navy); display: grid; place-items: center; }
html[data-theme="dark"] .bpd-mark { background: #fff; }
.bpd-brand small { font-weight: 500; color: var(--text-faint); font-size: 13px; padding-left: 10px; border-left: 1px solid var(--border); }
.bpd-search {
  flex: 1; max-width: 420px; margin-left: 12px; display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text-faint); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left;
}
.bpd-search:hover { border-color: var(--border-strong); }
.bpd-search span { flex: 1; }
.bpd-kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--surface); color: var(--text-faint); }
.bpd-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.bpd-links a, .bpd-iconbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 7px;
  color: var(--text-dim); font-size: 13.5px; font-weight: 500; text-decoration: none !important; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.bpd-links a:hover, .bpd-iconbtn:hover { background: var(--surface-2); color: var(--text); }
.bpd-links a.bpd-cta { background: var(--accent); color: #fff; }
.bpd-links a.bpd-cta:hover { background: var(--accent-ink); color: #fff; }
.bpd-menu-btn { display: none; }

/* Sub-navigation: the shared documentation map */
.bpd-sub {
  position: sticky; top: var(--bpd-top); z-index: 55; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.bpd-sub::-webkit-scrollbar { display: none; }
.bpd-sub a {
  flex: none; padding: 10px 10px; font-size: 13px; font-weight: 500; color: var(--text-dim);
  border-bottom: 2px solid transparent; text-decoration: none !important; white-space: nowrap;
}
.bpd-sub a:hover { color: var(--text); }
.bpd-sub a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* Legacy layouts sit below both bars */
html body .side { top: calc(var(--bpd-top) + 41px); height: calc(100vh - var(--bpd-top) - 41px); padding-top: 18px; }
html body .side > .brand { display: none; }
html body .side .theme-btn { display: none; }
html body main > .topbar { display: none !important; }

/* ── Sidebar layout for country / guide pages ────────────────────────── */
.bpd-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 40px; max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.bpd-side {
  position: sticky; top: calc(var(--bpd-top) + 41px); align-self: start; height: calc(100vh - var(--bpd-top) - 41px);
  overflow-y: auto; padding: 22px 0 40px;
}
.bpd-side .grp { text-transform: uppercase; font-size: 10.5px; letter-spacing: .09em; color: var(--text-faint); font-weight: 700; margin: 18px 0 6px; padding: 0 10px; }
.bpd-side .grp:first-child { margin-top: 0; }
.bpd-side a {
  display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13.5px; padding: 5px 10px; border-radius: 7px; text-decoration: none !important;
}
.bpd-side a:hover { background: var(--surface-2); color: var(--text); }
.bpd-side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.bpd-side .bpd-flag { width: 18px; height: 12px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.bpd-layout > main { min-width: 0; }

/* Pages placed in the shared layout: auto margins would shrink a grid item to
   its content width (overflowing on phones), and the multi-country page's
   main.wrap reuses the two-column .wrap grid. Both become plain blocks here. */
html body .bpd-layout > main { margin-left: 0; margin-right: 0; width: auto; max-width: 900px; justify-self: stretch; }
html body .bpd-layout > main.wrap { display: block; padding: 0; }

/* The country tab bar bleeds to the full viewport on its own; inside the shared
   layout it stays in the content column and sticks below the docs bars. */
html body .bpd-layout .bp-tabs {
  top: calc(var(--bpd-top) + 41px); margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;
  border-radius: 0;
}

/* Long identifiers and URLs must wrap rather than widen the page. */
html body :not(pre) > code { overflow-wrap: anywhere; }
html body pre { max-width: 100%; overflow-x: auto; }
.bpd-ep > header code { overflow-wrap: anywhere; }

/* ── Drawer (mobile) ─────────────────────────────────────────────────── */
.bpd-drawer { position: fixed; inset: 0; z-index: 90; display: none; }
.bpd-drawer.open { display: block; }
.bpd-drawer .bpd-scrim { position: absolute; inset: 0; background: rgba(5, 9, 18, .5); }
.bpd-drawer .bpd-panel {
  position: absolute; left: 0; top: 0; bottom: 0; width: min(320px, 86vw); background: var(--bg); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 14px 32px; animation: bpd-in .16s ease-out;
}
.bpd-drawer .bpd-panel .grp { text-transform: uppercase; font-size: 10.5px; letter-spacing: .09em; color: var(--text-faint); font-weight: 700; margin: 18px 0 6px; padding: 0 8px; }
.bpd-drawer .bpd-panel a { display: block; padding: 8px; border-radius: 7px; color: var(--text-dim); font-size: 14px; text-decoration: none !important; }
.bpd-drawer .bpd-panel a:hover { background: var(--surface-2); color: var(--text); }
@keyframes bpd-in { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Search ──────────────────────────────────────────────────────────── */
.bpd-modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.bpd-modal.open { display: flex; }
.bpd-modal .bpd-scrim { position: absolute; inset: 0; background: rgba(5, 9, 18, .55); }
.bpd-box { position: relative; width: 100%; max-width: 640px; max-height: 72vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.45); overflow: hidden; }
.bpd-box input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 16px 18px; font: inherit; font-size: 16px; background: transparent; color: var(--text); outline: none; }
.bpd-results { overflow-y: auto; padding: 6px; }
.bpd-results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none !important; }
.bpd-results a .t { font-weight: 600; font-size: 14px; }
.bpd-results a .p { display: block; font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.bpd-results a .s { display: block; font-size: 13px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.bpd-results a[aria-selected="true"], .bpd-results a:hover { background: var(--accent-soft); }
.bpd-results mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.bpd-empty { padding: 26px; text-align: center; color: var(--text-faint); font-size: 14px; }
.bpd-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); }

/* ── Copy buttons added to bare <pre> blocks ─────────────────────────── */
.bpd-pre { position: relative; }
.bpd-copy {
  position: absolute; top: 8px; right: 8px; font: 500 11.5px var(--font-sans); padding: 3px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--code-border); background: var(--code-bar); color: var(--code-dim);
}
.bpd-copy:hover { color: var(--code-text); }
.bpd-copy.ok { color: var(--code-str); }

/* ── Docs home hero + API reference ─────────────────────────────────── */
.bpd-hero { padding: 28px 0 8px; }
.bpd-hero .eyebrow { color: var(--accent); font-weight: 600; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin: 0; }
.bpd-hero h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.1; margin: 10px 0 12px; font-weight: 700; }
.bpd-hero p.lede { font-size: 17px; color: var(--text-dim); max-width: 640px; margin: 0; }
.bpd-hero .bpd-search { max-width: 520px; margin: 22px 0 0; height: 44px; font-size: 14.5px; background: var(--surface); }
.bpd-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 22px 0 6px; }
.bpd-card { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text) !important; text-decoration: none !important; transition: border-color .15s, transform .15s; }
.bpd-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-1px); }
.bpd-card b { display: block; font-size: 14px; }
.bpd-card span { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.bpd-card .m { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }

.bpd-ep { border: 1px solid var(--border); border-radius: 12px; margin: 18px 0 26px; overflow: hidden; background: var(--surface); }
.bpd-ep > header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.bpd-ep > header h3 { margin: 0; font-size: 16px; }
.bpd-ep > header code { font-size: 13.5px; background: none; padding: 0; }
.bpd-ep > header .auth { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.bpd-ep .body { padding: 6px 16px 16px; }
.bpd-ep h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 18px 0 8px; }
.bpd-m { display: inline-block; font: 700 11px var(--font-mono); padding: 3px 7px; border-radius: 5px; letter-spacing: .04em; }
.bpd-m.get { background: var(--green-soft); color: var(--green); }
.bpd-m.post { background: var(--accent-soft); color: var(--accent); }
.bpd-confirm { display: inline-block; font-size: 11px; font-weight: 600; color: var(--amber); background: var(--amber-soft); border-radius: 5px; padding: 1px 6px; margin-left: 4px; }
.bpd-langtabs { display: flex; gap: 2px; padding: 6px 8px 0; background: var(--code-bar); border: 1px solid var(--code-border); border-bottom: 0; border-radius: 10px 10px 0 0; margin-top: 12px; }
.bpd-langtabs button { font: 500 12px var(--font-sans); color: var(--code-dim); background: none; border: 0; padding: 7px 10px; border-radius: 6px 6px 0 0; cursor: pointer; }
.bpd-langtabs button[aria-selected="true"] { color: var(--code-text); background: var(--code-bg); }
.bpd-langtabs + .bpd-pre pre { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.bpd-code pre, pre.bpd-code {
  background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-border); border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; font-size: 12.5px; line-height: 1.65; margin: 0;
}
.bpd-staging { border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--border)); background: var(--amber-soft); border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 14px; }
.bpd-staging b { color: var(--amber); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .bpd-search { display: none; }
  .bpd-hero .bpd-search { display: flex; }
  .bpd-links a:not(.bpd-cta) { display: none; }
  .bpd-menu-btn { display: inline-flex; }
  .bpd-layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px; gap: 0; }
  .bpd-side { display: none; }
  html body .wrap { grid-template-columns: minmax(0, 1fr) !important; padding: 0 16px !important; gap: 0 !important; }
  html body .side { display: none !important; }
  .bpd-brand small { display: none; }
}
@media (max-width: 520px) {
  .bpd-top { padding: 0 12px; gap: 8px; }
  .bpd-links a.bpd-cta { padding: 0 9px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .bpd-drawer .bpd-panel { animation: none; }
  .bpd-card { transition: none; }
}
