/* Developer documentation (/docs, templates/docs.html). Builds on the theme
   variables in dashboard.css and the site nav in landing.css. */

.docs-page { padding-bottom: 1rem; }
.docs-layout {
  position: relative; z-index: 1;
  max-width: 1240px; margin: 0 auto; padding: 2rem 1.5rem 3rem;
  display: grid; grid-template-columns: 230px minmax(0, 1fr) 200px; gap: 2.5rem;
  align-items: start;
}
.docs-layout:not(:has(.docs-toc)) { grid-template-columns: 230px minmax(0, 1fr); }

/* Sidebar */
.docs-sidebar { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.docs-sidebar-toggle { display: none; }
.docs-sidebar ul, .docs-toc ul { list-style: none; margin: 0 0 1rem; padding: 0; }
.docs-group {
  margin: 1.1rem 0 0.35rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.docs-sidebar a, .docs-toc a {
  display: block; padding: 0.35rem 0.6rem; border-radius: 6px; border-left: 2px solid transparent;
  color: var(--text); text-decoration: none; font-size: 0.9rem; line-height: 1.35;
}
.docs-sidebar a:hover, .docs-toc a:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.docs-sidebar a[aria-current="page"] {
  color: var(--accent); font-weight: 600; border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.docs-home-link { font-weight: 600; }
.docs-toc { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.docs-toc a { font-size: 0.82rem; color: var(--muted); padding: 0.25rem 0.5rem; }

/* Article */
.docs-article { max-width: 780px; min-width: 0; }
.docs-article h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 1rem; }
.docs-article h2 {
  font-size: 1.3rem; margin: 2.4rem 0 0.75rem; padding-top: 0.4rem;
  border-top: 1px solid var(--border); scroll-margin-top: 80px;
}
.docs-article h1 + p, .docs-lead { font-size: 1.05rem; }
.docs-article h3 { font-size: 1.05rem; margin: 1.6rem 0 0.5rem; scroll-margin-top: 80px; }
.docs-article p, .docs-article li { line-height: 1.65; color: var(--text); }
.docs-article ul, .docs-article ol { padding-left: 1.3rem; }
.docs-article li + li { margin-top: 0.3rem; }
.docs-article a { color: var(--accent); }
.docs-article :not(pre) > code {
  font-size: 0.86em; padding: 0.1em 0.35em; border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel)); overflow-wrap: anywhere;
}
.docs-callout {
  margin: 1.25rem 0; padding: 0.8rem 1rem; border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-left-width: 4px; background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}
.docs-callout p { margin: 0; }

/* Tables */
.docs-table-wrap { overflow-x: auto; margin: 1rem 0 1.25rem; border: 1px solid var(--border); border-radius: 8px; -webkit-overflow-scrolling: touch; }
.docs-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.docs-table th, .docs-table td { text-align: left; vertical-align: top; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); }
.docs-table th { background: var(--panel); font-weight: 600; white-space: nowrap; }
.docs-table tr:last-child td { border-bottom: 0; }
.docs-table td:first-child { white-space: nowrap; }

/* Code */
.docs-code { margin: 1rem 0 1.4rem; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--panel); }
.docs-code figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.4rem 0.5rem 0.4rem 0.85rem; font-size: 0.8rem; color: var(--muted);
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 60%, var(--panel));
}
.docs-code pre { margin: 0; padding: 0.85rem 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.docs-code code { font-size: 0.84rem; line-height: 1.55; white-space: pre; }
.docs-copy {
  flex: none; font-size: 0.75rem; padding: 0.25rem 0.6rem; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.docs-copy:hover { border-color: var(--accent); color: var(--accent); }

/* Origin lock picker */
.docs-snippets select { max-width: 100%; margin: 0.5rem 0 0.25rem; padding: 0.45rem 0.6rem; font-size: 0.95rem; }
.docs-snippets .docs-where { color: var(--muted); font-size: 0.9rem; }

/* Docs home */
.docs-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem; margin: 0.75rem 0 1rem; }
.docs-card {
  display: flex; flex-direction: column; gap: 0.35rem; padding: 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel); text-decoration: none; color: var(--text);
}
.docs-card:hover { border-color: var(--accent); }
.docs-card strong { color: var(--accent); }
.docs-card span { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.docs-article .docs-card { color: var(--text); }

/* Previous / next */
.docs-pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; max-width: 780px; }
.docs-pager a {
  display: flex; flex-direction: column; gap: 0.2rem; padding: 0.75rem 1rem; border-radius: 8px;
  border: 1px solid var(--border); text-decoration: none; color: var(--accent); font-weight: 600; max-width: 48%;
}
.docs-pager a span { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.docs-pager-next { margin-left: auto; text-align: right; }
.docs-pager a:hover { border-color: var(--accent); }

/* Laptop: no "On this page" column */
@media (max-width: 1100px) {
  .docs-layout, .docs-layout:not(:has(.docs-toc)) { grid-template-columns: 210px minmax(0, 1fr); gap: 2rem; }
  .docs-toc { display: none; }
}

/* Phone and small tablet: the sidebar folds into a menu above the page */
@media (max-width: 820px) {
  .docs-layout, .docs-layout:not(:has(.docs-toc)) { display: block; padding: 0.75rem 1rem 2rem; }
  .docs-sidebar { position: sticky; top: 58px; z-index: 50; max-height: none; overflow: visible; margin: 0 -1rem 1.25rem; }
  .docs-sidebar-toggle {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 0.5rem;
    padding: 0.7rem 1rem; min-height: 44px; font-size: 0.95rem; font-weight: 600; text-align: left; cursor: pointer;
    color: var(--text); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
    border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  }
  .docs-sidebar-toggle svg { transition: transform 0.15s ease; }
  .docs-sidebar-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .docs-sidebar-nav {
    display: none; padding: 0.25rem 1rem 0.75rem; background: var(--bg); border-bottom: 1px solid var(--border);
    max-height: calc(100dvh - 120px); overflow-y: auto;
  }
  .docs-sidebar.is-open .docs-sidebar-nav { display: block; }
  .docs-sidebar a { padding: 0.6rem 0.6rem; }
  .docs-article h1 { font-size: 1.6rem; }
  .docs-article h2 { font-size: 1.15rem; scroll-margin-top: 112px; }
  .docs-article h3 { scroll-margin-top: 112px; }
  .docs-table { font-size: 0.85rem; }
  .docs-table td:first-child { white-space: normal; }
  .docs-code code { font-size: 0.8rem; }
  .docs-pager { flex-direction: column; }
  .docs-pager a { max-width: none; }
}

/* Code inside tables never breaks mid-word; a wide table scrolls sideways instead. */
.docs-table code { white-space: nowrap; overflow-wrap: normal; }
