/* Layout + performance-first styles for the static docs site */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --link: #0f66d3;
  --header-bg: #ffffff;
  --sidebar-bg: #fafafa;
  --active-bg: #eff6ff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --fg: #f3f4f6;
    --muted: #9ca3af;
    --border: #333333;
    --link: #60a5fa;
    --header-bg: #171717;
    --sidebar-bg: #141414;
    --active-bg: #1e293b;
  }
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
}

a {
  color: var(--link);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
}

.site-brand-logo {
  display: block;
  height: 24px;
  width: auto;
  flex-shrink: 0;
  margin-right: 2px;
  transform: translateY(-2px);
}

@media (prefers-color-scheme: dark) {
  .site-brand-logo {
    filter: brightness(0) invert(1);
  }
}

.site-brand-text {
  font-size: 0.95rem;
  line-height: 1;
}

.site-tabs {
  display: flex;
  gap: 0.25rem;
}

.site-tab {
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.875rem;
}

.site-tab.active,
.site-tab:hover {
  color: var(--link);
  background: var(--active-bg);
}

.site-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-search-btn,
.site-github {
  font-size: 0.875rem;
}

.site-search-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 0.375rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.site-github {
  color: var(--muted);
  text-decoration: none;
}

.site-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 53px);
}

html.page-api,
body.page-api {
  height: 100%;
  overflow: hidden;
}

body.page-api {
  height: 100vh;
}

body.page-api .site-layout {
  height: calc(100vh - 53px);
  min-height: 0;
  max-height: calc(100vh - 53px);
  overflow: hidden;
}

body.page-api .site-sidebar {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.page-api .site-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

body.page-api .api-reference-root {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: clip;
}

body.page-api .api-reference-root > div,
body.page-api .api-reference-root .scalar-app {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
}

/* Scalar modern layout: keep the tag sidebar fixed; scroll only the main pane */
body.page-api .api-reference-root .scalar-app.references-layout {
  display: flex !important;
  flex-direction: row !important;
  overflow: hidden !important;
}

body.page-api .api-reference-root .t-doc__sidebar {
  position: relative !important;
  top: auto !important;
  height: 100% !important;
  max-height: 100% !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
}

body.page-api .api-reference-root .references-rendered {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
}

.site-sidebar {
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.site-sidebar-link {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 0.375rem;
  text-decoration: none;
  color: var(--fg);
  font-size: 0.875rem;
}

.site-sidebar-link.active,
.site-sidebar-link:hover {
  background: var(--active-bg);
  color: var(--link);
}

.site-main {
  min-width: 0;
}

.guide-content {
  max-width: 820px;
  padding: 2rem 1.5rem 3rem;
}

.guide-content h1,
.guide-content h2,
.guide-content h3 {
  line-height: 1.25;
}

.guide-content pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
}

.guide-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.api-module-list {
  columns: 2;
  gap: 2rem;
  padding-left: 1.25rem;
}

#search-dialog {
  border: none;
  border-radius: 0.75rem;
  padding: 0;
  width: min(640px, calc(100vw - 2rem));
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

#search-dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.search-panel {
  padding: 1rem;
}

.search-panel input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--fg);
  font-size: 1rem;
}

.search-results {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  max-height: 360px;
  overflow-y: auto;
}

.search-results li {
  margin: 0;
}

.search-results a {
  display: block;
  padding: 0.5rem 0.25rem;
  text-decoration: none;
}

.search-results a:hover {
  background: var(--active-bg);
}

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

@media (max-width: 900px) {
  .site-layout {
    grid-template-columns: 1fr;
  }

  .site-sidebar {
    display: none;
  }

  .api-module-list {
    columns: 1;
  }
}
