/* Documentation portal stylesheet.
 *
 * Deliberately small and dependency-free: the portal must render correctly
 * with no network access and no build step, because it is also served from
 * networks that have neither.
 *
 * The green-forward palette matches the forest theme used by the Mermaid
 * diagrams committed in the repository.
 */

:root {
  --ink: #16181d;
  --dim: #6b7280;
  --line: #e3e6ea;
  --bg: #ffffff;
  --panel: #f7f9f7;
  --accent: #1f6f43;
  --accent-soft: #e8f2ec;
  --code-bg: #f4f6f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.tier {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.layout {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.sidebar {
  flex: 0 0 15rem;
  position: sticky;
  top: 4rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  font-size: 0.88rem;
}

.sidebar-title {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.sidebar details { margin-bottom: 0.5rem; }

.sidebar summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.2rem 0;
}

.sidebar ul { list-style: none; margin: 0.2rem 0 0.6rem; padding-left: 0.75rem; }
.sidebar li { margin: 0.15rem 0; }
.sidebar a { color: var(--ink); text-decoration: none; }
.sidebar a:hover { color: var(--accent); text-decoration: underline; }
.sidebar a[aria-current="page"] { color: var(--accent); font-weight: 700; }

main { flex: 1 1 auto; min-width: 0; max-width: 46rem; }

main h1 { font-size: 1.9rem; line-height: 1.25; margin-top: 0; }
main h2 { font-size: 1.35rem; margin-top: 2.2rem; padding-top: 0.4rem; }
main h3 { font-size: 1.1rem; margin-top: 1.6rem; }

main a { color: var(--accent); }

main table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

main th, main td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

main th { background: var(--panel); }

main code {
  background: var(--code-bg);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.88em;
}

main pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
}

main pre code { background: none; padding: 0; }

/* Diagrams are static SVG; let them scale to the reading column. */
main img { display: block; max-width: 100%; height: auto; margin: 1.2rem 0; }

/* A diagram whose renderer is not loaded shows its source rather than nothing,
 * which is why mermaid output is a styled pre element. */
main pre.mermaid {
  background: var(--panel);
  border-left: 3px solid var(--accent);
  color: var(--dim);
  font-size: 0.85rem;
}

main blockquote {
  margin: 1rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--accent-soft);
  color: var(--dim);
}

/* Search. The form is usable and the status line is honest with scripting
 * disabled; only the result list is filled in by static/search.js. */
#site-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.25rem 0;
}

#site-search label {
  flex: 1 0 100%;
  font-weight: 600;
  font-size: 0.92rem;
}

#site-search input {
  flex: 1 1 18rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

#site-search button {
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

#site-search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

#site-search-results li {
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 0;
}

#site-search-results a {
  font-weight: 600;
}

#site-search-results p {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--dim);
}

.dim { color: var(--dim); }

/* Product/docs relationship ------------------------------------------------ */

.skip {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 100;
  transform: translateY(-200%);
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.skip:focus { transform: none; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.brand span {
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.doc-label {
  color: var(--dim);
  font-size: 0.78rem;
  border-left: 1px solid var(--line);
  padding-left: 0.75rem;
}

.topbar-product {
  margin-left: auto;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}

.topbar-product + .topbar-product { margin-left: 0.9rem; }
.topbar-product:hover { color: var(--accent); text-decoration: underline; }

main pre {
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 820px) {
  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
  }

  .doc-label { display: none; }
  .topbar-product { margin-left: 0; }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 1rem 3rem;
  }

  /* Content first: a long sidebar above the article is the thing a phone
   * reader has to scroll past before reaching the page they asked for. The
   * navigation stays in the same document, below the article. */
  main { order: 1; max-width: 100%; }

  .sidebar {
    order: 2;
    position: static;
    flex: none;
    width: 100%;
    max-height: none;
    margin: 0;
    border-top: 1px solid var(--line);
    padding-top: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

#site-search-results .search-retry {
  margin-top: 0.5rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}

#site-search-results .search-retry:hover {
  background: var(--accent-soft);
}
