/* 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: none; }

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

/* ── Top bar (slim, docs-style; ported from klang-api-docs/Topbar.astro) ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  /* Height + padding chosen so the long logo lands at the same (16, 16) viewport */
  /* coordinates as the LogoDropdownMenu in l2s-frontend (8px wrapper + 8px button). */
  height: 57px; padding: 0 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar__brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 17px; letter-spacing: -0.01em;
  color: var(--text-primary);
  flex: 0 0 auto;
  /* 260px sidebar − 16px topbar padding = 244px so brand ends at the sidebar's right edge. */
  min-width: 244px;
  text-decoration: none;
}
.topbar__brand:hover { text-decoration: none; }
.topbar__logo { height: 24px; width: auto; display: block; }
.topbar__brand .badge {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  height: 20px;
  padding: 0 7px;
  font-size: 10px; font-weight: 600;
  background: var(--klang-blue); color: #fff;
  border-radius: 4px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.topbar__spacer { flex: 1; }
.topbar__nav {
  display: flex;
  gap: 2px;
}
.topbar__nav-link {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.topbar__nav-link:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}
.topbar__nav-link.is-active {
  color: var(--klang-blue);
}

.topbar__search {
  flex: 0 0 320px; max-width: 320px;
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.topbar__search:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--border-subtle);
}
.topbar__search-label {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__cta {
  display: flex; gap: 6px; align-items: center;
}
.topbar__icon {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  text-decoration: none;
}
.topbar__icon:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  text-decoration: none;
}
.topbar__icon .msr { font-size: 18px; }
.topbar__cta .k-btn { padding: 6px 14px; font-size: 13px; height: 32px; }

/* Hamburger — hidden on desktop. */
.topbar__hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: transparent; border: 0;
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--dur-fast) ease;
}
.topbar__hamburger:hover { background: rgba(0, 0, 0, 0.05); }
.topbar__hamburger .msr { font-size: 22px; }

/* Mobile menu drop-down. */
.topbar__mobile-menu {
  position: fixed;
  top: 57px; left: 0; right: 0;
  max-height: calc(100vh - 57px);
  z-index: 49;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 12px 16px 20px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  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],
.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) ease;
}
.topbar__mobile-menu a:hover { background: rgba(0, 0, 0, 0.05); text-decoration: none; }
.topbar__mobile-menu a.active,
.topbar__mobile-menu a.is-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__search,
  .topbar__nav { display: none; }
  .topbar__cta { margin-left: auto; }
  .topbar__cta .k-btn--outline-light,
  .topbar__icon { display: none; }
  .topbar__hamburger { display: inline-flex; }
  .topbar__brand { min-width: auto; }
}
@media (min-width: 921px) {
  .topbar__mobile-menu { display: none; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 16px; gap: 8px; }
  .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;
}

/* ── Docs shell (grid layout) — ported from klang-api-docs/DocsLayout.astro
   so docs/help pages share the same geometry. */
.docs-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 57px);
}
.docs-main {
  background: var(--klang-white);
  min-width: 0;
}
.docs-main__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 48px 56px 120px;
  max-width: 1380px;
}
.docs-content {
  min-width: 0;
  max-width: 760px;
}
/* Anchor jumps land below the sticky 57px topbar with breathing room. */
.docs-content :where(h1, h2, h3, h4, h5, h6) {
  scroll-margin-top: 80px;
}
/* Optional right-side TOC. Activated by adding `docs-shell--with-toc` to the shell. */
.docs-shell--with-toc .docs-main__inner {
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 48px;
  max-width: 1280px;
}
.docs-toc {
  position: relative;
  min-width: 0;
  font-size: 12.5px;
}
.docs-toc__sticky {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-bottom: 24px;
}
.docs-toc__heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 4px 8px;
}
.docs-toc a {
  display: block;
  padding: 4px 8px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.docs-toc a:hover { color: var(--text-primary); text-decoration: none; }
.docs-toc a.is-active {
  color: var(--klang-blue);
  border-left-color: var(--klang-blue);
}
.docs-toc a.l2 { padding-left: 20px; }

@media (max-width: 1180px) {
  .docs-shell--with-toc .docs-main__inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }
  .docs-toc { display: none; }
}
@media (max-width: 1040px) {
  .docs-shell { grid-template-columns: 240px 1fr; }
  .docs-main__inner { padding: 40px 32px 100px; }
}
@media (max-width: 920px) {
  .docs-shell { grid-template-columns: 1fr; }
  .docs-main__inner { padding: 32px 24px 80px; }
}

/* ── Sidebar (.docs-side) primitives ────────────────────────────────────
   Ported from klang-api-docs/src/components/Sidebar.astro so klang-help
   can consume the same chrome from shared.css. Should stay in sync with
   the api-docs version. */
.docs-side {
  background: var(--klang-warm-gray-light);
  border-right: 1px solid var(--border-subtle);
  height: calc(100vh - 57px);
  position: sticky;
  top: 57px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 13.5px;
}
.docs-side::-webkit-scrollbar { width: 6px; }
.docs-side::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
.docs-side::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }
.docs-side__inner {
  padding: 24px 0 80px;
}
.docs-side__group {
  padding: 0 12px 18px;
}
.docs-side__group + .docs-side__group {
  padding-top: 4px;
}
.docs-side__heading {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 10px 12px 6px;
}
.docs-side__heading .msr {
  font-size: 14px;
  color: var(--text-secondary);
  opacity: 0.7;
}
.docs-side__link {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  line-height: 22px;
  text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative;
}
.docs-side__link:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text-primary);
  text-decoration: none;
}
.docs-side__link[target="_blank"]::after {
  content: 'open_in_new';
  font-family: 'Material Symbols Rounded';
  font-size: 14px;
  line-height: 1;
  margin-left: auto;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.docs-side__link[target="_blank"]:hover::after,
.docs-side__link[target="_blank"]:focus-visible::after {
  opacity: 0.7;
}
.docs-side__link.is-active {
  background: rgba(33,43,250,0.08);
  color: var(--klang-blue);
  font-weight: 500;
}
.docs-side__link--op .method {
  min-width: 38px;
  font-size: 9.5px;
  padding: 2px 5px;
  flex-shrink: 0;
}
.docs-side__link-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.docs-side__status-dot {
  margin-left: auto;
  width: 7px; height: 7px;
  background: var(--mui-success);
  border-radius: 50%;
  flex-shrink: 0;
}
@media (max-width: 920px) {
  .docs-side { display: none; }
}

/* ── klang-help only: sidebar collapsible-group extensions ───────────────
   The api-docs sidebar uses flat groups; klang-help wraps each group in a
   collapsible toggle button + animated list. Keep additive so the
   .docs-side primitives stay in sync between repos. */
.docs-side__heading--toggle {
  width: 100%;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.docs-side__heading--toggle:hover { color: var(--text-primary); }
.docs-side__heading-label {
  flex: 1;
  text-align: left;
}
.docs-side__chev {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  transition: transform var(--dur-fast) var(--ease-standard);
}
.docs-side__chev.is-open { transform: rotate(90deg); }
.docs-side__group-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  transition: max-height var(--dur-base) var(--ease-standard),
              opacity var(--dur-base) var(--ease-standard);
}
.docs-side__sub { margin-top: 6px; }
.docs-side__subheading {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-disabled);
}
.docs-side__subheading .msr {
  font-size: 13px;
  opacity: 0.7;
}
