/*
 * Documentation site theme.
 *
 * The palette is lifted from the product's own landing page (frontend/app/
 * globals.css) so the docs and the platform read as one thing: navy for
 * structure, gold for the single action that matters on a screen, and a blue
 * that is only ever used for links and accents.
 *
 * Kept separate from the application stylesheet on purpose — this site ships
 * from a different build and must not be able to affect the product's CSS.
 */

:root {
  --navy: #0050b0;
  --navy-deep: #06336e;
  --gold: #f2bd42;
  --gold-hi: #ffd267;
  --ink: #15233b;
  --muted: #66758c;
  --blue: #0064e1;
  --page: #f7f9fc;
  --card: #fff;
  --line: #dfe6ef;
  --code-bg: #f1f4f9;
  --shadow: 0 8px 24px rgb(15 35 63 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8edf6;
    --muted: #9aa8bd;
    --blue: #6ea8ff;
    --page: #0d1522;
    --card: #141e30;
    --line: #22314a;
    --code-bg: #0a121e;
    --shadow: 0 8px 24px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 100;
  background: var(--gold);
  color: #17243a;
  padding: 10px 16px;
  border-radius: 8px;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */

.topbar {
  height: 72px;
  padding: 0 max(20px, calc((100vw - 1320px) / 2));
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgb(255 255 255 / 11%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.mark {
  display: grid;
  place-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--gold);
  color: #17243a;
  font-size: 13px;
  font-weight: 900;
}
.topnav { display: flex; gap: 26px; margin-inline-start: 10px; }
.topnav a { font-size: 14px; color: rgb(247 248 251 / 78%); }
.topnav a:hover { color: var(--gold); text-decoration: none; }
.topactions { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
.ghost {
  padding: 9px 15px;
  border: 1px solid rgb(255 255 255 / 26%);
  border-radius: 9px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.ghost:hover { border-color: #fff; background: rgb(255 255 255 / 6%); text-decoration: none; }
.gold {
  padding: 10px 17px;
  border-radius: 9px;
  background: var(--gold);
  color: #17243a;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 8px 22px rgb(242 189 66 / 18%);
}
.gold:hover { background: var(--gold-hi); text-decoration: none; }

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

.layout {
  max-width: 1320px;
  margin: auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 216px;
  gap: 40px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  padding: 32px 0 40px;
  font-size: 14px;
}
.nav-group { margin-top: 26px; }
.nav-group h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-group ul { margin: 0; padding: 0; list-style: none; }
.nav-group li { margin: 2px 0; }
.nav-group a {
  display: block;
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--ink);
  border-inline-start: 2px solid transparent;
}
.nav-group a:hover { background: var(--card); text-decoration: none; }
.nav-group a.active {
  background: var(--card);
  border-inline-start-color: var(--gold);
  font-weight: 700;
  color: var(--navy);
}
@media (prefers-color-scheme: dark) {
  .nav-group a.active { color: var(--gold); }
}

main {
  min-width: 0;
  padding: 34px 0 80px;
}

.toc {
  position: sticky;
  top: 100px;
  padding: 36px 0;
  font-size: 13px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.toc h4 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ul { margin: 0; padding: 0; list-style: none; border-inline-start: 1px solid var(--line); }
.toc li a { display: block; padding: 4px 0 4px 12px; color: var(--muted); }
.toc li.d3 a { padding-inline-start: 24px; font-size: 12px; }
.toc li a:hover { color: var(--blue); text-decoration: none; }

/* ── Document body ────────────────────────────────────────────────────────── */

main h1 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.04em;
  margin: 0 0 18px;
}
main h2 {
  font-size: 26px;
  letter-spacing: -0.03em;
  margin: 48px 0 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
main h3 { font-size: 19px; margin: 30px 0 10px; letter-spacing: -0.02em; }
main h4 { font-size: 16px; margin: 24px 0 8px; }
main p { color: var(--ink); }
main li { margin: 5px 0; }

.anchor { float: inline-start; margin-inline-start: -0.7em; width: 0.7em; opacity: 0; }
.anchor::before { content: "#"; color: var(--muted); }
h2:hover .anchor, h3:hover .anchor { opacity: 1; text-decoration: none; }

main img { max-width: 100%; height: auto; vertical-align: middle; }

hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }

blockquote {
  margin: 22px 0;
  padding: 14px 20px;
  border-inline-start: 3px solid var(--gold);
  background: var(--card);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: 13px; }

.table-scroll { overflow-x: auto; margin: 20px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td {
  border: 1px solid var(--line);
  padding: 9px 13px;
  text-align: start;
  vertical-align: top;
}
th { background: var(--card); font-weight: 800; }

.lang-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 16px;
  margin-bottom: 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
}
.lang-row img { border-radius: 3px; vertical-align: -3px; }
.lang-row b { color: var(--ink); }

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

.sitefoot {
  border-top: 1px solid var(--line);
  padding: 26px max(20px, calc((100vw - 1320px) / 2));
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  background: var(--card);
}

/* ── Narrow screens ───────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .topnav { display: none; }
  .layout { grid-template-columns: 1fr; gap: 0; }
  .sidebar {
    position: static;
    max-height: none;
    padding: 20px 0 0;
    border-bottom: 1px solid var(--line);
  }
}
