/* Shared chrome for klang docs */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Hover-revealed anchor link beside h2/h3 inside <main>. Injected by
   BaseLayout's inline script. */
main h2, main h3 { position: relative; }
main h2 .anchor-link,
main h3 .anchor-link {
  margin-left: 8px;
  vertical-align: middle;
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 6px;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
  text-decoration: none;
}
main h2:hover .anchor-link,
main h3:hover .anchor-link,
main .anchor-link:focus-visible { opacity: 1; }
main .anchor-link:hover {
  background: rgba(0,0,0,0.05);
  color: var(--klang-blue);
  text-decoration: none;
}
main .anchor-link.is-copied { color: var(--mui-palette-success-main, #2E7D32); opacity: 1; }
main .anchor-link .msr { font-size: 16px; }

body {
  background: #fff;
  color: var(--text-primary);
}

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

code, pre, .mono {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* ── Top bar (used on docs pages) ─────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  height: 64px; padding: 0 24px;
  background: var(--klang-warm-gray);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar__brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 18px; letter-spacing: -0.01em;
  color: var(--text-primary);
}
.topbar__brand .badge {
  font-size: 11px; font-weight: 600;
  background: var(--klang-blue); color: #fff;
  padding: 3px 7px; border-radius: 4px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.topbar__nav { display: flex; gap: 4px; flex: 1; margin-left: 16px; }
.topbar__nav a {
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  padding: 8px 12px; border-radius: 6px;
}
.topbar__nav a:hover { color: var(--text-primary); background: rgba(0,0,0,0.04); text-decoration: none; }
.topbar__nav a.active { color: var(--klang-blue); }
.topbar__cta {
  display: flex; gap: 8px; align-items: center;
}
.topbar__cta .k-btn { padding: 8px 16px; font-size: 14px; }

/* Hamburger — hidden on desktop, shown alongside the mobile menu below. */
.topbar__hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: transparent; border: 0;
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  margin-left: 4px;
  transition: background var(--dur-fast, 0.12s) ease;
}
.topbar__hamburger:hover { background: rgba(0,0,0,0.05); }
.topbar__hamburger .msr { font-size: 24px; }

/* Mobile menu drop-down — full-width panel below the topbar. */
.topbar__mobile-menu {
  position: fixed;
  top: 64px; left: 0; right: 0;
  max-height: calc(100vh - 64px);
  z-index: 49;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 12px 16px 20px;
  background: var(--klang-warm-gray);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 12px 24px rgba(0,0,0,0.06);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.topbar__mobile-menu[hidden] { display: none; }
.topbar__mobile-menu a {
  display: flex; align-items: center;
  padding: 12px 14px; border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px; font-weight: 500;
  text-decoration: none;
  transition: background var(--dur-fast, 0.12s) ease;
}
.topbar__mobile-menu a:hover { background: rgba(0,0,0,0.05); text-decoration: none; }
.topbar__mobile-menu a.active { color: var(--klang-blue); }
.topbar__mobile-menu__divider {
  height: 1px; background: var(--border-subtle);
  margin: 8px 0;
}

/* Responsive collapse. */
@media (max-width: 920px) {
  .topbar__nav { display: none; }
  .topbar__cta { margin-left: auto; }
  .topbar__cta .k-btn--outline-light { display: none; }
  .topbar__hamburger { display: inline-flex; }
}
@media (min-width: 921px) {
  .topbar__mobile-menu { display: none; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 16px; }
  .topbar__brand .badge { display: none; }
}

/* shared utility */
.muted { color: var(--text-secondary); }
.mono-sm { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; }

/* Pills / chips */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: rgba(33,43,250,0.08); color: var(--klang-blue);
}
.pill--green { background: rgba(46,125,50,0.1); color: #2E7D32; }
.pill--orange { background: rgba(255,142,0,0.12); color: #B36300; }
.pill--gray { background: rgba(0,0,0,0.06); color: var(--text-secondary); }

/* HTTP method tags */
.method {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.02em;
  min-width: 52px;
}
.method--get { background: rgba(46,125,50,0.12); color: #2E7D32; }
.method--post { background: rgba(33,43,250,0.1); color: var(--klang-blue); }
.method--put { background: rgba(255,142,0,0.15); color: #B36300; }
.method--delete { background: rgba(211,47,47,0.1); color: #D32F2F; }

/* ── Shared docs page primitives ─────────────────────── */
/* Used by every documentation/article page (auth, errors, pagination, */
/* rate-limits, intro, webhook overview/events/signatures). Page-specific */
/* additions live in the page itself. */
.docs-page {
  max-width: 760px;
  min-width: 0;
}
.docs-page__eyebrow {
  color: var(--klang-blue);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.docs-page__h1 {
  font-weight: 300;
  font-size: 48px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
}
.docs-page__lead {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 60ch;
  margin: 0;
}
.docs-page__section {
  padding-top: 32px;
  scroll-margin-top: 56px;
}
.docs-page__section h2 {
  font-weight: 400;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.docs-page__section h3 {
  font-weight: 600;
  font-size: 18px;
  line-height: 24px;
  margin: 24px 0 8px;
}
.docs-page__section p {
  font-size: 15px;
  line-height: 1.6;
  max-width: 64ch;
  margin: 0;
}
.docs-page__section p + p { margin-top: 12px; }
.docs-page__section pre.codeblock {
  margin: 16px 0;
  padding: 14px 16px;
}

/* code block (light) */
.codeblock {
  background: var(--klang-warm-gray-light);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
/* Light syntax tokens — applied unless `.codeblock--dark` overrides them. */
.codeblock .tk-key  { color: #B3306F; }
.codeblock .tk-str  { color: var(--mui-success); }
.codeblock .tk-num  { color: var(--mui-success); }
.codeblock .tk-com  { color: var(--text-secondary); font-style: italic; }
.codeblock .tk-kw   { color: #B3306F; }
.codeblock .tk-meth { color: var(--klang-blue); font-weight: 600; }
.codeblock .tk-prop { color: var(--text-primary); }
.codeblock .tk-fn   { color: var(--mui-success); }

/* code block (dark) — uses official Klang theme tokens. */
.codeblock--dark {
  background: var(--klang-blue-dark);
  color: var(--klang-white);
  border: 0;
}
/* `tk-` token classes used in markup */
.codeblock--dark .tk-key  { color: var(--klang-blue-light); }
.codeblock--dark .tk-str  { color: var(--klang-orange-light); }
.codeblock--dark .tk-num  { color: var(--klang-orange-light); }
.codeblock--dark .tk-com  { color: rgba(255, 255, 255, 0.4); font-style: italic; }
.codeblock--dark .tk-kw   { color: var(--klang-blue-light); }
.codeblock--dark .tk-meth { color: var(--klang-blue-light); font-weight: 600; }
.codeblock--dark .tk-prop { color: var(--klang-white); }
.codeblock--dark .tk-fn   { color: var(--klang-orange-light); }
/* legacy `tok-` aliases */
.codeblock--dark .tok-key { color: var(--klang-blue-light); }
.codeblock--dark .tok-str { color: var(--klang-orange-light); }
.codeblock--dark .tok-num { color: var(--klang-orange-light); }
.codeblock--dark .tok-comment { color: rgba(255, 255, 255, 0.4); font-style: italic; }
.codeblock--dark .tok-meth { color: var(--klang-blue-light); font-weight: 600; }
.codeblock--dark .tok-prop { color: var(--klang-white); }
.codeblock--dark .tok-fn { color: var(--klang-orange-light); }

/* In-line code */
:not(pre) > code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.875em;
  padding: 1px 6px;
  background: var(--klang-warm-gray-light);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}
.codeblock--dark :not(pre) > code, .codeblock--dark code {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
