/* AKD Pay developer docs. Mobile first; light and dark follow the system. */
:root {
  --navy: #0b1726;
  --accent: #c84920;
  --accent-strong: #a83a16;
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --surface: #ffffff;
  --text: #17212f;
  --muted: #566274;
  --border: #e2e7ee;
  --link: #b8421c;
  --code-bg: #0f1c2e;
  --code-text: #e3e9f2;
  --inline-code-bg: #eef1f6;
  --sandbox: #8a6200;
  --sandbox-bg: #fff6d8;
  --sandbox-border: #f0c94a;
  --live: #166b45;
  --live-bg: #e6f5ec;
  --live-border: #7fcca1;
  --note-bg: #eef3fb;
  --note-border: #9bb6e0;
  --warn-bg: #fdf0ea;
  --warn-border: #eaa585;
  --shadow: 0 1px 2px rgba(11, 23, 38, 0.06), 0 4px 16px rgba(11, 23, 38, 0.06);
  --radius: 10px;
  --topbar-h: 56px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1726;
    --bg-soft: #0f1d30;
    --surface: #112036;
    --text: #e4e9f1;
    --muted: #9aa7ba;
    --border: #22324a;
    --link: #f08a62;
    --accent-strong: #e0623a;
    --code-bg: #071120;
    --code-text: #e3e9f2;
    --inline-code-bg: #1a2a42;
    --sandbox: #f5c94a;
    --sandbox-bg: #2a2410;
    --sandbox-border: #6f5a17;
    --live: #74d3a2;
    --live-bg: #0f2a1f;
    --live-border: #2b6b4c;
    --note-bg: #13243c;
    --note-border: #33507a;
    --warn-bg: #2c1a14;
    --warn-border: #7a3d25;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-strong);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img {
  max-width: 100%;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
}

.skip:focus {
  top: 8px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand:hover {
  color: #fff;
}

.brand b {
  color: #f3a283;
  font-weight: 600;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch,
.dash-link,
.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.lang-switch:hover,
.menu-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.dash-link {
  background: var(--accent);
  border-color: var(--accent);
}

.dash-link:hover {
  color: #fff;
  background: #b23f1a;
}

.lang-long {
  display: none;
}

.menu-btn {
  padding: 0 10px;
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.menu-icon {
  position: relative;
}

.menu-icon::before,
.menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-icon::before {
  top: -5px;
}

.menu-icon::after {
  top: 5px;
}

.menu-text {
  display: none;
}

.env-banner {
  padding: 8px 16px;
  background: var(--sandbox-bg);
  color: var(--text);
  border-bottom: 1px solid var(--sandbox-border);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- layout ---------- */
.layout {
  display: flex;
  flex-direction: column;
  max-width: 1440px;
  margin: 0 auto;
}

.content {
  min-width: 0;
  padding: 24px 16px 48px;
  order: 1;
}

.content:focus {
  outline: none;
}

/* Without JavaScript the sidebar sits below the content on phones (the
   "Menu" link jumps to it); with JavaScript it becomes a drawer. */
.sidebar {
  order: 2;
  padding: 24px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 15px;
}

.js .sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  z-index: 35;
  width: min(320px, 86vw);
  overflow-y: auto;
  border-top: 0;
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.2s ease;
  visibility: hidden;
}

.js.nav-open .sidebar {
  transform: none;
  visibility: visible;
}

.scrim {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  z-index: 30;
  background: rgba(6, 12, 20, 0.45);
}

.nav-group + .nav-group {
  margin-top: 20px;
}

.nav-group-title {
  margin: 0 0 6px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar li a {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
}

.sidebar li a:hover {
  background: var(--border);
  color: var(--text);
}

.sidebar li a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--link);
  font-weight: 600;
}

.search {
  display: none;
  margin-bottom: 20px;
  position: relative;
}

.js .search {
  display: block;
}

.search input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.search-results {
  margin-top: 8px !important;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
}

.search-results li a {
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}

.search-results li:last-child a {
  border-bottom: 0;
}

.search-results small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.search-results .empty {
  padding: 8px 10px;
  color: var(--muted);
}

.toc {
  display: none;
  order: 3;
}

/* ---------- article ---------- */
.doc {
  max-width: 760px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.doc h1 {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.lead {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 18px;
}

.doc h2 {
  margin: 44px 0 12px;
  padding-top: 8px;
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.doc h3 {
  margin: 32px 0 8px;
  font-size: 19px;
  line-height: 1.35;
}

.doc h4 {
  margin: 24px 0 8px;
  font-size: 16px;
}

.doc h2 .anchor,
.doc h3 .anchor {
  margin-left: 8px;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
}

.doc h2:hover .anchor,
.doc h3:hover .anchor,
.doc .anchor:focus {
  opacity: 1;
}

.secnum {
  display: inline-block;
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.75em;
  font-weight: 500;
  vertical-align: 0.1em;
}

.doc p,
.doc ul,
.doc ol {
  margin: 0 0 16px;
}

.doc ul,
.doc ol {
  padding-left: 24px;
}

.doc li + li {
  margin-top: 4px;
}

.doc li.task {
  list-style: none;
  margin-left: -24px;
  padding-left: 28px;
  position: relative;
}

.doc li.task input {
  position: absolute;
  left: 2px;
  top: 6px;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.doc code {
  font-family: var(--mono);
  font-size: 0.875em;
}

.doc :not(pre) > code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--inline-code-bg);
  overflow-wrap: anywhere;
}

.doc td code,
.doc th code {
  overflow-wrap: normal;
}

.doc hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.code {
  position: relative;
  margin: 0 0 18px;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
}

.code pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 4;
}

.code[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 6px;
  right: 12px;
  color: #8796ab;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: lowercase;
  pointer-events: none;
}

.js .code[data-lang]::before {
  right: 72px;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  min-height: 28px;
  padding: 2px 10px;
  border: 1px solid #2c3d57;
  border-radius: 6px;
  background: #16263d;
  color: #d3dbe7;
  font: 500 12px var(--font);
  cursor: pointer;
}

.copy-btn:hover {
  background: #1e3250;
}

.code:has(.copy-btn) pre {
  padding-top: 36px;
}

.table-wrap {
  margin: 0 0 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.5;
}

th,
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--bg-soft);
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

/* ---------- tabs ---------- */
.tabs {
  margin: 0 0 20px;
}

.tab-label {
  margin: 0 0 6px !important;
  font-weight: 600;
  font-size: 14px;
}

.tab-list {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.tab-list button {
  flex: none;
  min-height: 38px;
  padding: 6px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: 500 14px var(--font);
  cursor: pointer;
}

.tab-list button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.js .tabs .tab-label {
  display: none;
}

.js .tabs .tab-panel + .tab-panel {
  display: none;
}

.js .tabs.ready .tab-panel {
  display: none;
}

.js .tabs.ready .tab-panel.active {
  display: block;
}

/* ---------- callouts and badges ---------- */
.callout {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid var(--note-border);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--note-bg);
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout-title {
  margin: 0 0 6px !important;
  font-weight: 600;
}

.callout-kind {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.callout-sandbox {
  background: var(--sandbox-bg);
  border-color: var(--sandbox-border);
}

.callout-live {
  background: var(--live-bg);
  border-color: var(--live-border);
}

.callout-warning {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.callout-untranslated {
  background: var(--bg-soft);
  border-color: var(--border);
  border-left-color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.02em;
  vertical-align: 0.1em;
  white-space: nowrap;
}

.badge-sandbox {
  background: var(--sandbox-bg);
  color: var(--sandbox);
  border: 1px solid var(--sandbox-border);
}

.badge-live {
  background: var(--live-bg);
  color: var(--live);
  border: 1px solid var(--live-border);
}

.badge-soon {
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px dashed var(--muted);
}

.badge-merchant,
.badge-akd {
  border: 1px solid transparent;
}

.badge-merchant {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--link);
}

.badge-akd {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
}

/* ---------- home ---------- */
.hero {
  margin: 0 -16px 32px;
  padding: 32px 16px;
  background: var(--navy);
  color: #e8edf4;
  border-radius: 0;
}

.hero h1 {
  color: #fff;
  font-size: 32px !important;
}

.hero p {
  max-width: 640px;
  color: #c8d2df;
  font-size: 17px;
}

.hero .eyebrow {
  color: #f3a283;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 9px;
  font-weight: 600;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #b23f1a;
  color: #fff;
}

.btn-secondary {
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0 0 28px;
  padding: 0 !important;
  list-style: none;
}

.cards li {
  margin: 0 !important;
}

.cards a {
  display: block;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.cards a:hover {
  border-color: var(--accent);
}

.cards strong {
  display: block;
  margin-bottom: 4px;
  color: var(--link);
}

.cards span {
  color: var(--muted);
  font-size: 15px;
}

/* ---------- onboarding flow ---------- */
.flow {
  counter-reset: step;
  display: grid;
  gap: 0;
  margin: 8px 0 28px;
  padding: 0 !important;
  list-style: none;
}

.flow li {
  position: relative;
  margin: 0 !important;
  padding: 0 0 22px 52px;
}

.flow li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  border: 2px solid var(--accent);
}

.flow li::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 38px;
  bottom: 2px;
  width: 2px;
  background: var(--border);
}

.flow li:last-child::after {
  display: none;
}

.flow .step {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flow .step-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 650;
}

.flow .step p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.flow .step-akd .step {
  background: var(--bg-soft);
}

.flow .step-live .step {
  border-color: var(--live-border);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- pager and footer ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 760px;
  margin: 48px auto 0;
}

.pager a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.4;
}

.pager a:hover {
  border-color: var(--accent);
}

.pager span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.pager-next {
  grid-column: 2;
  text-align: right;
}

.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 14px;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.footer p {
  margin: 0 0 8px;
}

.compliance {
  color: var(--text);
}

/* ---------- 404 ---------- */
.notfound {
  max-width: 560px;
  margin: 12vh auto;
  padding: 0 16px;
  text-align: center;
}

/* ---------- wider screens ---------- */
@media (min-width: 560px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }

  .lang-long {
    display: inline;
  }

  .lang-short {
    display: none;
  }

  .menu-text {
    display: inline;
  }

  .hero {
    margin: 0 0 32px;
    padding: 36px 32px;
    border-radius: 16px;
  }
}

@media (min-width: 960px) {
  .menu-btn,
  .scrim {
    display: none !important;
  }

  .topbar {
    padding: 0 24px;
  }

  .layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .sidebar,
  .js .sidebar {
    order: 0;
    position: sticky;
    top: var(--topbar-h);
    flex: 0 0 272px;
    width: 272px;
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 24px 16px 40px;
    border-top: 0;
    border-right: 1px solid var(--border);
    transform: none;
    visibility: visible;
    transition: none;
  }

  .content {
    flex: 1 1 auto;
    padding: 36px 40px 64px;
  }

  .doc h1 {
    font-size: 36px;
  }
}

@media (min-width: 1240px) {
  .toc {
    display: block;
    position: sticky;
    top: calc(var(--topbar-h) + 32px);
    flex: 0 0 232px;
    max-height: calc(100vh - var(--topbar-h) - 48px);
    overflow-y: auto;
    padding: 0 20px 24px 0;
    font-size: 14px;
  }

  .toc-title {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--border);
  }

  .toc a {
    display: block;
    margin-left: -1px;
    padding: 4px 0 4px 12px;
    border-left: 2px solid transparent;
    color: var(--muted);
    text-decoration: none;
    line-height: 1.4;
  }

  .toc .toc-l3 a {
    padding-left: 24px;
    font-size: 13px;
  }

  .toc a:hover,
  .toc a.active {
    color: var(--text);
  }

  .toc a.active {
    border-left-color: var(--accent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .sidebar {
    transition: none;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toc,
  .pager,
  .copy-btn,
  .env-banner {
    display: none !important;
  }

  .js .tabs .tab-panel,
  .js .tabs .tab-label {
    display: block !important;
  }
}
