/* Atlas Experiences docs — Chakra-style documentation theme.
   No build step; docs.js injects the shared chrome around each page's <article>. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Atlas app palette: system-blue accent (AccentColor.colorset), iOS
     neutral surfaces, the icon's deep navy for the brand mark. */
  --bg: #ffffff;
  --bg-subtle: #f7f7f9;
  --bg-muted: #f2f2f7;
  --fg: #111114;
  --fg-muted: #55555e;
  --fg-subtle: #8e8e93;
  --border: #e5e5ea;
  --border-strong: #d1d1d6;
  --accent: #007aff;
  --accent-strong: #0062cc;
  --accent-bg: rgba(0, 122, 255, 0.08);
  --accent-contrast: #ffffff;
  --brand-navy: #071434;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.1), 0 16px 48px rgba(0,0,0,.18);

  --code-bg: #0d1117;
  --code-header-bg: #161b22;
  --code-border: #26262b;
  --code-fg: #e6edf3;

  --callout-info-bg: rgba(0, 122, 255, 0.07);
  --callout-info-border: rgba(0, 122, 255, 0.35);
  --callout-warn-bg: rgba(217, 119, 6, 0.08);
  --callout-warn-border: rgba(217, 119, 6, 0.4);
  --callout-warn-fg: #b45309;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-subtle: #0e0e10;
  --bg-muted: #1c1c1e;
  --fg: #f2f2f7;
  --fg-muted: #aeaeb2;
  --fg-subtle: #8e8e93;
  --border: rgba(255,255,255,0.1);
  --border-strong: rgba(255,255,255,0.18);
  --accent: #0a84ff;
  --accent-strong: #409cff;
  --accent-bg: rgba(10, 132, 255, 0.14);
  --accent-contrast: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.5), 0 24px 64px rgba(0,0,0,.5);
  --code-bg: #0d1117;
  --code-header-bg: #161b22;
  --code-border: rgba(255,255,255,0.09);
  --callout-warn-fg: #fbbf24;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-subtle: #0e0e10;
    --bg-muted: #1c1c1e;
    --fg: #f2f2f7;
    --fg-muted: #aeaeb2;
    --fg-subtle: #8e8e93;
    --border: rgba(255,255,255,0.1);
    --border-strong: rgba(255,255,255,0.18);
    --accent: #0a84ff;
    --accent-strong: #409cff;
    --accent-bg: rgba(10, 132, 255, 0.14);
    --accent-contrast: #ffffff;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.5), 0 24px 64px rgba(0,0,0,.5);
    --code-bg: #0d1117;
    --code-header-bg: #161b22;
    --code-border: rgba(255,255,255,0.09);
    --callout-warn-fg: #fbbf24;
  }
}

html { scroll-padding-top: 88px; background: var(--bg); }

/* Smooth cross-page navigation (Chrome 126+/Safari 18.2+): pages crossfade
   instead of hard-cutting. Non-supporting browsers fall back to instant
   navigation — the inline critical style in each page's <head> guarantees
   the right background paints first, so there is never a white flash.
   The fade is deliberately FAST (90ms, outgoing page drops immediately):
   paired with hover prerendering in docs.js, navigation reads as instant. */
@view-transition { navigation: auto; }

::view-transition-old(root) { animation: none; opacity: 0; }
::view-transition-new(root) {
  animation-duration: 90ms;
  animation-timing-function: ease-out;
}

/* The header and sidebar are identical from page to page — pull each into
   its own transition group with animations off, so they hold perfectly
   still while only the content crossfades. */
.site-header { view-transition-name: site-header; }
.sidebar { view-transition-name: site-sidebar; }
::view-transition-group(site-header),
::view-transition-old(site-header),
::view-transition-new(site-header),
::view-transition-group(site-sidebar),
::view-transition-old(site-sidebar),
::view-transition-new(site-sidebar) { animation: none; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

.brand-logo {
  display: block;
  width: 26px;
  height: 26px;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.brand svg { display: block; }
.brand .brand-sub { color: var(--fg-subtle); font-weight: 500; }

.version-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.header-spacer { flex: 1; }

.search-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  height: 36px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--fg-subtle);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.search-button:hover { border-color: var(--border-strong); }
.search-button .kbd-group { margin-left: auto; display: flex; gap: 3px; }

kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-subtle);
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  line-height: 1.5;
}

.header-nav { display: flex; align-items: center; gap: 4px; }
.header-nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-muted);
  padding: 6px 10px;
  border-radius: 6px;
  transition: color .15s ease;
}
.header-nav a:hover { color: var(--fg); }
.header-nav a.active { color: var(--accent); }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}
.icon-button:hover { background: var(--bg-muted); color: var(--fg); }

.menu-button { display: none; }

/* ---------- Layout ---------- */

.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 224px;
  gap: 0;
  padding: 0 24px;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 28px 24px 48px 4px;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}

.sidebar-group { margin-bottom: 26px; }
.sidebar-group-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--fg);
  margin-bottom: 8px;
  padding-left: 12px;
  letter-spacing: -0.006em;
}
.sidebar a {
  display: block;
  font-size: 14px;
  color: var(--fg-muted);
  padding: 5px 12px;
  border-radius: 6px;
  transition: color .12s ease, background .12s ease;
}
.sidebar a:hover { color: var(--fg); background: var(--bg-muted); }
.sidebar a.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 550;
}

/* ---------- Main / article ---------- */

.main {
  min-width: 0;
  padding: 40px 56px 96px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-subtle);
  margin-bottom: 14px;
}
.breadcrumb .sep { opacity: .55; }
.breadcrumb .current { color: var(--fg-muted); font-weight: 500; }

article h1 {
  font-size: 36px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 10px;
}

.lede {
  font-size: 17px;
  color: var(--fg-muted);
  margin-bottom: 32px;
  max-width: 62ch;
}

article h2 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 48px 0 14px;
  scroll-margin-top: 88px;
}
article h3 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.014em;
  margin: 32px 0 10px;
  scroll-margin-top: 88px;
}
article h4 {
  font-size: 15.5px;
  font-weight: 650;
  margin: 24px 0 8px;
}

.anchor-link {
  margin-left: 8px;
  color: var(--accent);
  opacity: 0;
  font-weight: 500;
  transition: opacity .12s ease;
}
h2:hover .anchor-link, h3:hover .anchor-link { opacity: 1; }

article p { margin: 0 0 16px; max-width: 72ch; }
article ul, article ol:not(.steps) { margin: 0 0 16px 24px; max-width: 70ch; }
article li { margin-bottom: 6px; }
article li > ul { margin-top: 6px; }

article a:not(.card):not(.pager-link):not(.anchor-link) {
  color: var(--accent);
  font-weight: 500;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color .12s ease;
}
article a:not(.card):not(.pager-link):not(.anchor-link):hover {
  border-bottom-color: var(--accent);
}

article strong { font-weight: 650; }

article code {
  font-family: var(--font-mono);
  font-size: 0.855em;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1.5px 5px;
  white-space: nowrap;
}
article h1 code, article h2 code, article h3 code { font-size: 0.9em; white-space: normal; }

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

/* ---------- Code blocks ---------- */

figure.code-block {
  margin: 20px 0 24px;
  border: 1px solid var(--code-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg);
}
figure.code-block figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #8b949e;
  background: var(--code-header-bg);
  border-bottom: 1px solid var(--code-border);
}
figure.code-block .lang-tag {
  margin-left: auto;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6e7681;
}
figure.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--code-fg);
}
figure.code-block pre code { background: none; border: none; padding: 0; font-size: inherit; white-space: pre; }

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: #8b949e;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 550;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.copy-button:hover { background: rgba(255,255,255,.08); color: #e6edf3; }
.copy-button.copied { color: #7ee787; }

/* github-dark token palette */
.tk-comment { color: #8b949e; font-style: italic; }
.tk-string { color: #a5d6ff; }
.tk-key { color: #7ee787; }
.tk-keyword { color: #ff7b72; }
.tk-num { color: #79c0ff; }
.tk-fn { color: #d2a8ff; }
.tk-tag { color: #7ee787; }
.tk-attr { color: #79c0ff; }
.tk-template { color: #ffa657; }

/* ---------- Callouts ---------- */

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  margin: 20px 0 24px;
  font-size: 14.5px;
  border: 1px solid var(--callout-info-border);
  background: var(--callout-info-bg);
}
.callout p { margin: 0; }
.callout p + p { margin-top: 8px; }
.callout .callout-icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  margin-top: 2px;
  color: var(--accent);
}
.callout.warn { border-color: var(--callout-warn-border); background: var(--callout-warn-bg); }
.callout.warn .callout-icon { color: var(--callout-warn-fg); }

/* ---------- Steps ---------- */

ol.steps {
  list-style: none;
  margin: 28px 0 32px;
  counter-reset: step;
}
ol.steps > li.step {
  position: relative;
  padding: 0 0 30px 52px;
  counter-increment: step;
}
ol.steps > li.step::before {
  content: counter(step);
  position: absolute;
  left: 0; top: -2px;
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 650;
  color: var(--fg-muted);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
}
ol.steps > li.step::after {
  content: "";
  position: absolute;
  left: 17px; top: 38px; bottom: 6px;
  width: 1px;
  background: var(--border);
}
ol.steps > li.step:last-child { padding-bottom: 8px; }
ol.steps > li.step:last-child::after { display: none; }
ol.steps > li.step > h3 { margin-top: 0; margin-bottom: 8px; }

/* ---------- Tabs ---------- */

.tabs { margin: 20px 0 24px; }
.tab-list {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  color: var(--fg-subtle);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color .12s ease;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0 32px;
}
a.card {
  display: block;
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-subtle);
  transition: border-color .15s ease, transform .15s ease;
}
a.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-1px); }
a.card .card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 15px;
  margin-bottom: 6px;
}
a.card .card-title svg { color: var(--accent); flex-shrink: 0; }
a.card .card-body { font-size: 13.5px; color: var(--fg-muted); line-height: 1.55; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 20px 0 24px; border: 1px solid var(--border); border-radius: 10px; }
article table { border-collapse: collapse; width: 100%; font-size: 14px; }
article th {
  text-align: left;
  font-weight: 650;
  padding: 10px 14px;
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
article td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
article tr:last-child td { border-bottom: none; }
article td code, article th code { white-space: nowrap; }

/* ---------- Pager ---------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
}
.pager-link {
  display: block;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s ease;
}
.pager-link:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.pager-link .pager-label { font-size: 12px; color: var(--fg-subtle); margin-bottom: 3px; }
.pager-link .pager-title { font-size: 14.5px; font-weight: 600; color: var(--accent); }
.pager-link.next { text-align: right; grid-column: 2; }
.pager-link.prev { grid-column: 1; }

.doc-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg-subtle);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- TOC ---------- */

.toc {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 40px 8px 48px 8px;
  font-size: 13.5px;
  scrollbar-width: thin;
}
.toc-title {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--fg-subtle);
  margin-bottom: 10px;
}
.toc a {
  display: block;
  color: var(--fg-subtle);
  padding: 3.5px 0 3.5px 12px;
  border-left: 1.5px solid var(--border);
  line-height: 1.45;
  transition: color .12s ease, border-color .12s ease;
}
.toc a.depth-3 { padding-left: 26px; }
.toc a:hover { color: var(--fg); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 550; }

/* ---------- Search modal ---------- */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 0;
}
.search-overlay.open { display: flex; }
.search-panel {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-subtle);
}
.search-input-row input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 16px;
  color: var(--fg);
}
.search-results { max-height: 46vh; overflow-y: auto; padding: 8px; }
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
}
.search-result .sr-section { font-size: 11.5px; color: var(--fg-subtle); }
.search-result .sr-title { font-size: 14.5px; font-weight: 550; }
.search-result:hover, .search-result.selected { background: var(--accent-bg); }
.search-result.selected .sr-title { color: var(--accent); }
.search-empty { padding: 24px; text-align: center; color: var(--fg-subtle); font-size: 14px; }

/* ---------- File tree ---------- */

.file-tree {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.9;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 20px 0 24px;
  color: var(--fg-muted);
}
.file-tree .ft-dir { color: var(--fg); font-weight: 600; }
.file-tree .ft-note { color: var(--fg-subtle); font-family: var(--font-sans); font-size: 12.5px; }

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
  .layout { grid-template-columns: 256px minmax(0, 1fr); }
  .toc { display: none; }
  .main { padding: 36px 40px 80px; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 28px 4px 72px; }
  .search-button { width: auto; }
  .search-button .search-hint, .search-button .kbd-group { display: none; }
  .header-nav { display: none; }
  .menu-button { display: inline-flex; }
  .sidebar {
    display: none;
    position: fixed;
    top: 64px; left: 0;
    width: 300px;
    max-width: 85vw;
    height: calc(100vh - 64px);
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 24px 20px 48px;
    z-index: 60;
  }
  .sidebar.open { display: block; }
  .card-grid { grid-template-columns: 1fr; }
  article h1 { font-size: 30px; }
}
