/* 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: var(--docs-fill);
  color: var(--klang-blue);
  text-decoration: none;
}
main .anchor-link.is-copied { color: var(--mui-palette-success-main); opacity: 1; }
main .anchor-link.is-copy-failed { color: var(--mui-palette-error-main); opacity: 1; }
main .anchor-link .material-symbols-rounded { font-size: 16px; }

body {
  background: var(--docs-canvas);
  color: var(--text-primary);
}

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

code, pre, .mono {
  font-family: var(--font-mono);
}

/* ── Top bar (used on docs pages) ─────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  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: var(--text-on-primary);
  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: var(--mui-palette-action-hover); text-decoration: none; }
.topbar__nav a.active { color: var(--klang-blue); }
.topbar__cta {
  display: flex; gap: 8px; align-items: center;
}

/* Mobile menu drop-down — full-width panel below the topbar. */
.topbar__mobile-menu {
  position: fixed;
  left: 0; right: 0;
  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: var(--docs-fill); 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; }
}
@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: var(--font-mono); 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(var(--mui-palette-primary-mainChannel) / 0.08); color: var(--klang-blue);
}
.pill--green { background: rgba(var(--mui-palette-success-mainChannel) / 0.1); color: var(--mui-palette-success-main); }
.pill--orange { background: rgba(var(--mui-palette-secondary-mainChannel) / 0.12); color: var(--klang-orange-dark); }
.pill--gray { background: var(--docs-fill); color: var(--text-secondary); }

/* HTTP method tags */
.method {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.02em;
  min-width: 52px;
}
.method--get { background: rgba(var(--mui-palette-success-mainChannel) / 0.12); color: var(--mui-palette-success-main); }
.method--post { background: rgba(var(--mui-palette-primary-mainChannel) / 0.1); color: var(--klang-blue); }
.method--put { background: rgba(var(--mui-palette-secondary-mainChannel) / 0.15); color: var(--klang-orange-dark); }
.method--delete { background: rgba(var(--mui-palette-error-mainChannel) / 0.1); color: var(--mui-palette-error-main); }

/* ── 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: var(--topbar-height);
}
main :is(h2, h3)[id] {
  scroll-margin-top: calc(var(--topbar-height) + 16px);
}
.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 */
.codeblock {
  background: var(--klang-warm-gray-light);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
.codeblock .tk-key  { color: var(--code-keyword); }
.codeblock .tk-str  { color: var(--code-string); }
.codeblock .tk-num  { color: var(--code-string); }
.codeblock .tk-com  { color: var(--code-comment); font-style: italic; }
.codeblock .tk-kw   { color: var(--code-keyword); }
.codeblock .tk-meth { color: var(--code-method); font-weight: 600; }
.codeblock .tk-prop { color: var(--text-primary); }
.codeblock .tk-fn   { color: var(--code-string); }

/* In-line code */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 1px 6px;
  background: var(--klang-warm-gray-light);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

/* ── Shared docs primitives ─────────────────────────────
   Reused across getting-started, the MCP section, errors, pagination, and
   rate-limits. Kept here (not per-page) so every page that uses the class
   actually gets the styling — Astro only bundles a page's own <style> block,
   so a class defined inline on one page renders unstyled on the others. */

/* Definition-style list with hairline separators. */
.docs-page__list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.docs-page__list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
}
.docs-page__list li:last-child { border-bottom: 0; }

/* Numbered procedure list. */
.docs-page__steps {
  margin: 12px 0 16px;
  padding: 0 0 0 20px;
  list-style: decimal;
}
.docs-page__steps li {
  padding: 6px 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Code card with optional tabs, filename, and copy button. */
.codecard {
  background: var(--klang-warm-gray-light);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  margin: 20px 0;
  min-width: 0;
  max-width: 100%;
}
.codecard--terminal {
  background: var(--docs-terminal-bg);
  color: var(--docs-terminal-fg);
}
.codecard--terminal .codecard__body { color: inherit; }
.codecard__head {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--docs-raised);
  min-width: 0;
}
.codecard__tab {
  padding: 10px 18px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary);
  background: transparent; border: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}
.codecard__tab:hover { color: var(--text-primary); }
.codecard__tab.active { color: var(--klang-blue); border-bottom-color: var(--klang-blue); }
.codecard__filename {
  margin-left: auto;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 0 16px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.codecard__copy {
  background: transparent; border: 0;
  color: var(--text-secondary);
  padding: 8px 14px;
  cursor: pointer;
  border-left: 1px solid var(--border-subtle);
  transition: color var(--dur-fast) var(--ease-standard);
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: 12px;
}
.codecard__copy:hover { color: var(--text-primary); }
.codecard__copy .copy-done { display: none; align-items: center; gap: 6px; }
.codecard__copy .copy-default { display: inline-flex; align-items: center; gap: 6px; }
.codecard__copy.is-copied .copy-default { display: none; }
.codecard__copy.is-copied .copy-done { display: inline-flex; }
.codecard__bodies { display: block; }
.codecard__body {
  padding: 18px 22px;
  font-family: var(--font-mono);
  font-size: 13.5px; line-height: 1.7;
  color: var(--text-primary);
  overflow-x: auto;
  white-space: pre;
  display: none;
}
.codecard__body.is-active { display: block; }
.codecard .tk-key  { color: var(--code-keyword); }
.codecard .tk-str  { color: var(--code-string); }
.codecard .tk-num  { color: var(--code-string); }
.codecard .tk-com  { color: var(--code-comment); font-style: italic; }
.codecard .tk-kw   { color: var(--code-keyword); }
.codecard .tk-meth { color: var(--code-method); font-weight: 600; }

/* Inline note / aside. */
.callout {
  display: flex; gap: 12px;
  padding: 14px 16px;
  background: rgba(var(--mui-palette-primary-mainChannel) / 0.06);
  border-left: 3px solid var(--klang-blue);
  border-radius: 4px;
  margin: 20px 0;
  font-size: 14px; line-height: 1.55;
}
.callout .material-symbols-rounded { font-size: 20px; color: var(--klang-blue); }
.callout strong { color: var(--text-primary); }

/* Linked card for "next step" navigation. */
.next-cards {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

@media (max-width: 1100px) {
  .codecard__tab { padding: 10px 14px; font-size: 12px; }
  .codecard__copy { padding: 8px 12px; font-size: 11.5px; }
}
@media (max-width: 900px) {
  .codecard__filename { display: none; }
}
@media (max-width: 600px) {
  .codecard__tab { padding: 8px 10px; font-size: 11.5px; }
  .codecard__copy { padding: 6px 10px; font-size: 11px; }
  .codecard__copy .copy-default span:not(.material-symbols-rounded),
  .codecard__copy .copy-done span:not(.material-symbols-rounded) { display: none; }
  .codecard__body { padding: 14px 16px; font-size: 12.5px; }
}

/* Plain data tables on docs pages (limits, error codes, field lists). */
.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.docs-table th,
.docs-table td {
  text-align: left;
  padding: 10px 16px 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  line-height: 1.5;
}
.docs-table th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.docs-table-wrap { overflow-x: auto; }
