/* Preset: Match the editor */
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
       line-height: 1.5; color: #222; }
p  { margin: 1em 0; white-space: pre-wrap; }
h1 { font-size: 1.7em; }
h2 { font-size: 1.4em; }
h3 { font-size: 1.15em; }
ul, ol { margin: 1em 0 1em 1.5em; }
code, pre { font-family: Menlo, Consolas, monospace; }
pre { background: #f4f4f4; padding: .6em 1em; border-radius: 3px; overflow-x: auto; }
table { border-collapse: collapse; }
th, td { border: 1px solid #ccc; padding: .3rem .6rem; }
blockquote { border-left: 3px solid #888; padding-left: 1em; color: #555; }
a { color: #1976d2; }


/* ─── Responsive base (always included) ─── */
*, *::before, *::after { box-sizing: border-box; }
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
/* Wide tables scroll within their column instead of widening the page */
.site-content table { display: block; overflow-x: auto; max-width: 100%; }

/* ─── Publish-pipeline chrome (always included) ─── */

.site-nav, .page-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5em;
    padding: 0.7em 1em;
    margin: 0 0 1.8em 0;
    background: #fafafa;
    border-bottom: 1px solid #e4e4e4;
    font-size: 0.85em;
    color: #888;
}

/* Two-level document nav, below the banner: notebook row + page row. */
/* Prev / current / next row. Typography matches the breadcrumbs (sans-serif,
   small, muted), with the same ‹ › chevrons. */
.doc-nav { max-width: 1100px; margin: 0 auto; font-family: Helvetica, Arial, sans-serif; }
.docnav-row {
    display: flex;
    align-items: center;
    gap: 1em;
    padding: 0.45em 1.5em;
    font-size: 0.8rem;
    border-bottom: 1px solid #e9ebee;
}
.docnav-notebooks { background: #eef1f6; font-weight: 600; }
.docnav-pages { background: #fafbfc; }
.docnav-prev, .docnav-next {
    flex: 1 1 0; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.docnav-next { text-align: right; }
.docnav-cur {
    flex: 0 1 auto; text-align: center; max-width: 50%;
    color: #868e9a;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-nav a { color: #6b7280; text-decoration: none; }
.doc-nav a:hover { color: #2a6496; text-decoration: underline; }

.site-nav a, .page-nav a {
    color: #5a6c7d;
    text-decoration: none;
}
.site-nav a:hover, .page-nav a:hover {
    color: #1a2733;
    text-decoration: underline;
}

.site-nav-prev, .page-nav-prev,
.site-nav-next, .page-nav-next {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.site-nav-next, .page-nav-next { text-align: right; }

.site-nav-current, .page-nav-up {
    flex: 0 1 auto;
    text-align: center;
    color: #2a3540;
    font-weight: 600;
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Top-level publication index */
.publish-section { margin: 0 0 1.8em 0; }
.publish-section h2 {
    margin: 0.5em 0 0.4em 0;
    font-size: 1.15em;
    color: #4a5a6a;
    letter-spacing: 0.02em;
}
.publish-toc {
    list-style: none;
    padding-left: 0.5em;
    margin: 0;
}
.publish-toc li { padding: 0.2em 0; }
.publish-toc li a { color: #2a6496; text-decoration: none; }
.publish-toc li a:hover { text-decoration: underline; }

/* Collapsible per-notebook entries in the folder index (native <details>). */
.publish-notebook { margin: 0.2em 0; }
.publish-notebook > summary {
    cursor: pointer;
    padding: 0.35em 0;
    font-weight: 600;
    color: #2a3540;
    list-style-position: inside;
}
.publish-notebook > summary:hover { color: #2d6cdf; }
.publish-notebook[open] > summary { color: #2d6cdf; }
.publish-notebook > .publish-toc { padding-left: 1.5em; margin: 0 0 0.6em; }

/* Concat-with-divider boundary between pages */
.page-divider {
    border: 0;
    border-top: 1px dashed #d0d0d0;
    margin: 2em 0;
}

/* ─── Notebook site theme (page-per-file layout only) ─── */
/* Scoped to `body.site` (set by the orchestrator for page-per-file) so the
   full-bleed banner/sidebar layout never touches the concat layouts. */

body.site { margin: 0; }

.site-banner {
    background: #1f2a44;
    color: #fff;
    padding: 1.1em 1.5em;
}
.banner-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 0.9em; }
.site-logo { height: 40px; width: auto; display: block; flex: 0 0 auto; }
.banner-text { display: flex; flex-direction: column; gap: 0.1em; }
.site-tagline { font-size: 0.8em; font-weight: 400; opacity: 0.8; }
.site-banner .site-title {
    color: #fff;
    font-size: 1.25em;
    font-weight: 600;
    text-decoration: none;
}

.site-layout {
    display: flex;
    max-width: 1100px;
    margin: 0 auto;
    align-items: flex-start;
}

.notebook-nav {
    flex: 0 0 220px;
    background: #f6f7f9;
    border-right: 1px solid #e4e6ea;
    padding: 1.25em 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
}
/* Topic mode is 3-column: page-list ToC (left) · content · Related Topics
   (right). Give it a little more width, and put the topics rail's divider on
   its left edge since it sits on the right. */
body.topics .site-layout { max-width: 1240px; }
.notebook-nav.topics-rail {
    border-right: none;
    border-left: 1px solid #e4e6ea;
}
/* Both rails use the sans-serif heading face (body copy is serif), so the
   navigation reads as chrome, distinct from the reading column. */
.notebook-nav { font-family: Helvetica, Arial, sans-serif; }
/* A small uppercase section label atop the ToC rail, mirroring the topics
   rail's "Related Topics" head. Targets only the ToC rail (the topics rail's
   direct child is a div, not a ul) and only in topics mode. */
body.topics .notebook-nav > ul::before {
    content: "Contents";
    display: block;
    padding: 0 1.25em;
    margin-bottom: 0.6em;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a9099;
}
.notebook-nav ul { list-style: none; margin: 0; padding: 0; }
.notebook-nav li a {
    display: block;
    padding: 0.4em 1.25em;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.95em;
}
.notebook-nav li a:hover { background: #eceef1; color: #2b2f36; }
.notebook-nav li.active a {
    color: #374151;
    font-weight: 600;
}
/* One continuous grey bar down the active section (its whole subtree), drawn
   as an inset shadow so it neither shifts the text nor fragments into a
   per-item, per-indent staircase the way a border on each link did. */
.notebook-nav li.active { box-shadow: inset 3px 0 0 #b0b6bf; }
/* Outline tree: each nesting level indents one step further. */
.notebook-nav ul ul { padding-left: 0.9em; }
.notebook-nav ul ul li a { font-size: 0.9em; color: #868e9a; }
/* Collapsible sections (parents with children) — JS-free <details>. The
   default disclosure triangle is the expand/collapse affordance; the page
   title stays a normal link beside it. */
.notebook-nav summary {
    cursor: pointer;
    padding: 0.4em 1.25em;
    font-size: 0.95em;
    color: #6b7280;
}
.notebook-nav summary:hover { background: #eceef1; }
.notebook-nav summary a {
    display: inline;
    padding: 0;
    font-size: inherit;
}
.notebook-nav ul ul summary { font-size: 0.9em; }
.notebook-nav li.active > details > summary a { color: #374151; font-weight: 600; }

/* Contents-page table of contents, rendered as the same outline tree. */
.notebook-toc, .notebook-toc ul { list-style: none; }
.notebook-toc { padding-left: 0; margin: 0.5em 0; }
.notebook-toc ul { padding-left: 1.2em; }
.notebook-toc li { padding: 0.2em 0; }
.notebook-toc a { text-decoration: none; color: #2a6496; }
.notebook-toc a:hover { text-decoration: underline; }

.site-content {
    flex: 1 1 auto;
    padding: 1.75em 2em;
    max-width: 760px;
}
.site-content img { max-width: 100%; height: auto; }
.site-content h1:first-child, .site-content h2:first-child { margin-top: 0; }

/* ─── Collapsible table of contents (pure-CSS hamburger toggle) ─── */
/* The hidden #toc-toggle checkbox sits just before .site-layout; its
   <label class="toc-toggle-btn"> lives in the banner. Default state
   (unchecked) shows the sidebar on desktop; checking it collapses the
   sidebar so the content spans full width. The mobile breakpoint below
   flips the default (collapsed) and the checked state (expanded). */
.toc-toggle { display: none; }
.toc-toggle-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9em;
    height: 1.9em;
    margin-right: 0.1em;
    font-size: 1.15em;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    user-select: none;
}
.toc-toggle-btn:hover { background: rgba(255,255,255,0.14); }
.toc-toggle:checked ~ .site-layout .notebook-nav:not(.topics-rail) { display: none; }

.site-footer {
    border-top: 1px solid #e4e6ea;
    color: #666;
    font-size: 0.85em;
    text-align: center;
    padding: 1.5em;
}
.site-footer a { color: #2d6cdf; }

@media (max-width: 720px) {
    /* Topbar wraps: logo + title on the first line, the nav (search / Topics /
       Contents / Home) on a full-width second line, with the search box
       flexing to fill the row instead of overflowing the page. */
    .site-banner { padding: 0.9em 1em; }
    .banner-inner { flex-wrap: wrap; }
    .topbar-nav { margin-left: 0; width: 100%; margin-top: 0.6em; gap: 0.7em; }
    .topic-search { flex: 1 1 auto; }
    .topic-search input { width: 100%; max-width: none; }

    .site-layout { flex-direction: column; }
    .notebook-nav {
        flex-basis: auto;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e4e6ea;
        position: static;
    }
    /* Mode 1 (no topics): the page-list sidebar collapses behind the ☰ toggle
       on mobile — hidden by default, shown when toggled. */
    body:not(.topics) .notebook-nav { display: none; }
    body:not(.topics) .toc-toggle:checked ~ .site-layout .notebook-nav { display: block; }
    /* Mode 2: content first, then the Related-Topics rail, then the ToC — all
       stacked full-width and visible below the content (the ☰ toggle can still
       collapse the ToC via the global checked rule). */
    .notebook-nav.topics-rail { border-left: none; }
    body.topics .site-content { order: -2; }
    body.topics .notebook-nav.topics-rail { order: -1; }
    /* `.site-layout` uses align-items:flex-start for the desktop sidebar, which
       shrink-wraps items in the mobile column; force the main column full-width
       (this also neutralizes the no-rail `margin: 0 auto` centering). */
    .site-content { width: 100%; max-width: none; }

    .doc-nav .docnav-row { padding: 0.45em 1em; }
    .site-content { padding: 1.25em; }
}

/* ─── Landing / home page (page-per-file, when a Home config page exists) ─── */

.hero {
    position: relative;
    text-align: center;
    color: #fff;
    padding: 5rem 1.5rem 5.5rem;
    overflow: hidden;
    background: linear-gradient(135deg, #1f2a44, #2d6cdf);
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.hero-scrim { position: absolute; inset: 0; z-index: 1; }
.hero.has-image .hero-scrim {
    background: linear-gradient(135deg, rgba(31,42,68,0.82), rgba(31,42,68,0.5));
}
.hero-inner { position: relative; z-index: 2; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: 2.8rem; line-height: 1.1; margin: 0 0 0.7rem; letter-spacing: -0.5px; color: #fff; }
.hero-tagline { font-size: 1.2rem; opacity: 0.92; margin: 0 0 2rem; font-weight: 400; }
.hero-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.btn {
    display: inline-block; padding: 0.8rem 1.8rem; border-radius: 7px;
    font-size: 1.02rem; font-weight: 600; text-decoration: none;
}
.btn-primary { background: #fff; color: #1f2a44; }
.btn-secondary { border: 1.5px solid rgba(255,255,255,0.8); color: #fff; }

.intro { max-width: 720px; margin: 0 auto; padding: 3.5rem 1.5rem 1rem; text-align: center; }
.intro p { font-size: 1.18rem; color: #333; margin: 0; }

.contents { max-width: 1100px; margin: 0 auto; padding: 3rem 1.5rem 4rem; }
.contents h2 {
    font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: #666; font-weight: 600; margin: 0 0 1.5rem; text-align: center;
}
.contents-grid { display: grid; grid-template-columns: repeat(3, 1fr); column-gap: 2.5rem; row-gap: 1.6rem; }
.toc-item { border-top: 1px solid #e4e6ea; padding-top: 0.9rem; }
.toc-title {
    display: inline-block; font-size: 1.08rem; font-weight: 600;
    color: #2d6cdf; text-decoration: none; margin-bottom: 0.2rem;
}
.toc-title:hover { text-decoration: underline; }
.toc-desc { display: block; font-size: 0.92rem; color: #666; }

@media (max-width: 820px) {
    .contents-grid { grid-template-columns: repeat(2, 1fr); }
    .hero h1 { font-size: 2.1rem; }
}
@media (max-width: 560px) {
    .contents-grid { grid-template-columns: 1fr; }
}

/* ─── Topics (publish mode 2: "pages + topics") ─── */

/* Related Topics — the whole right rail in topics mode. */
.topics-panel { padding: 0 1.25em; }
.topics-panel-head {
    margin-bottom: 0.6em;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a9099;
}
.page-topics { list-style: none; margin: 0; padding: 0; }
.page-topics > li { padding: 0.3em 0; font-size: 0.92em; }
.page-topics a.page-topic { color: #6b7280; text-decoration: none; }
.page-topics a.page-topic:hover { color: #2a6496; text-decoration: underline; }
/* Each topic is a collapsed <details>; its occurrence links reveal on unfold.
   The row padding lives on the <li>, so keep the summary flush and quiet. The
   topic name stays a link to the topic page; a custom rotating triangle (the
   native marker is suppressed by the list's inherited list-style:none) is the
   expand affordance — click it to reveal the occurrences. */
.page-topics summary {
    padding: 0;
    font-size: inherit;
    color: inherit;
    cursor: pointer;
    list-style: none;
}
.page-topics summary::-webkit-details-marker { display: none; }
.page-topics summary::before {
    content: "▸";
    display: inline-block;
    width: 1em;
    margin-right: 0.15em;
    color: #9aa0aa;
    font-size: 0.8em;
    transition: transform 0.15s ease;
}
.page-topics details[open] > summary::before { transform: rotate(90deg); }
.page-topics summary:hover { background: none; }
.page-topics summary:hover::before { color: #2a6496; }
.topic-xrefs {
    display: block;
    margin: 0.1em 0 0 0.6em;
    line-height: 1.4;
}
.topic-xref {
    display: block;
    font-size: 0.82em;
    color: #9aa0aa;
    text-decoration: none;
}
/* Small muted bullet before each occurrence link (replaces the old arrow). */
.topic-xref::before { content: "•"; margin-right: 0.4em; color: #c2c7cf; }
.topic-xref:hover { color: #2a6496; text-decoration: underline; }

/* ─── Topbar nav (banner right side): Search · Contents · Home ─── */
.topbar-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.9em;
}
.topbar-link {
    color: #dbe3f0;
    text-decoration: none;
    font-size: 0.95em;
    white-space: nowrap;
}
.topbar-link:hover { color: #fff; text-decoration: underline; }
.topbar-home {
    display: inline-flex;
    align-items: center;
    color: #dbe3f0;
}
.topbar-home:hover { color: #fff; }

/* Topic-name search box on the topbar; results drop down over the page. */
.topic-search { position: relative; }
.topic-search input {
    width: 200px;
    max-width: 46vw;
    box-sizing: border-box;
    padding: 0.4em 0.6em;
    font-size: 0.9em;
    border: 1px solid transparent;
    border-radius: 5px;
    background: #fff;
    color: #1f2a44;
}
.topic-search input:focus { outline: none; border-color: #2d6cdf; }
.topic-search-results {
    list-style: none;
    margin: 0;
    padding: 0;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d6dbe2;
    border-radius: 5px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 20;
}
.topic-search-results:empty { display: none; }
.topic-search-results li a {
    display: block;
    padding: 0.4em 0.6em;
    color: #2a6496;
    text-decoration: none;
    font-size: 0.9em;
}
.topic-search-results li a:hover { background: #eceef1; }
.topic-search-results .topic-search-empty {
    padding: 0.4em 0.6em;
    color: #999;
    font-size: 0.85em;
    font-style: italic;
}

/* A–Z bar at the top of each index page's content (NOT the sidebar): only the
   letters that have topics, the current one highlighted. */
.topic-alpha-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em 0.4em;
    margin: 0 0 1.5em;
    padding-bottom: 0.9em;
    border-bottom: 1px solid #e4e6ea;
}
.topic-alpha-bar a {
    display: inline-block;
    min-width: 1.7em;
    text-align: center;
    padding: 0.2em 0.4em;
    font-weight: 600;
    color: #2a6496;
    text-decoration: none;
    border-radius: 4px;
}
.topic-alpha-bar a:hover { background: #eceef1; }
.topic-alpha-bar a.active { background: #2d6cdf; color: #fff; }

/* When a page has no rail (no Related Topics), the main column spans the
   layout; center it for readability. */
.site-layout > .site-content:only-child { margin: 0 auto; }

/* Topic pages + topic index reuse the banner/footer chrome. */
.topic-section { margin: 1.5em 0; }
.topic-section h2 {
    font-size: 1.1em;
    color: #4a5a6a;
    border-bottom: 1px solid #e4e6ea;
    padding-bottom: 0.25em;
}
.topic-section ul { margin: 0.5em 0; padding-left: 1.25em; }
.topic-related .rel-role { color: #888; font-size: 0.88em; }
.topic-references a, .topic-weblinks a { color: #2a6496; text-decoration: none; }
.topic-references a:hover, .topic-weblinks a:hover { text-decoration: underline; }
.topic-about { color: #333; }

/* Related Topics rail on a topic page (mirrors the notebook-page rail). */
.notebook-nav .topic-related { list-style: none; margin: 0.4em 0 0; padding: 0; }
.notebook-nav .topic-related li { padding: 0.25em 0; font-size: 0.92em; }
.notebook-nav .topic-related a { color: #2a6496; text-decoration: none; }
.notebook-nav .topic-related a:hover { text-decoration: underline; }

/* ─── Top-menu layout ("Top navigation menu" option): a horizontal level-1
   menu with a JS '⋯' overflow replaces the left sidebar; readers drill down
   via breadcrumbs + each section page's child list. ─── */
body.topmenu .site-layout { max-width: 1240px; }

.top-menu {
    display: flex;
    align-items: stretch;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 1em;
    background: #f6f7f9;
    border-bottom: 1px solid #e4e6ea;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 0.92rem;
}
.top-menu > a {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;          /* don't shrink — nav.js measures true widths to overflow */
    padding: 0.7em 0.9em;
    color: #6b7280;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}
.top-menu > a:hover { color: #2b2f36; background: #eceef1; }
.top-menu > a.active { color: #374151; font-weight: 600; border-bottom-color: #b0b6bf; }

/* Secondary bar: the current section's level-2 pages. Lighter and a touch
   smaller than the level-1 menu, so the hierarchy reads at a glance. */
.sub-menu {
    background: #fbfbfc;
    font-size: 0.85rem;
}
.sub-menu > a { padding: 0.55em 0.9em; }

/* Left "‹" control: appears when the menu has slid to reveal the active item;
   click jumps back to the start. */
.top-menu-back {
    flex: 0 0 auto;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0.55em 0.7em;
    color: #6b7280;
    font-size: 1.15em;
    line-height: 1;
    font-family: inherit;
}
.top-menu-back:hover { color: #2b2f36; background: #eceef1; }

.top-menu-more { position: relative; margin-left: auto; flex: 0 0 auto; }
.top-menu-more > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.7em 0.9em;
    color: #6b7280;
}
.top-menu-more > summary::-webkit-details-marker { display: none; }
.top-menu-more[open] > summary { color: #2b2f36; background: #eceef1; }
.top-menu-more-items {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 20;
    min-width: 180px;
    /* Cap the width to the viewport so a long title can't push the panel off
       the left edge; items wrap instead of overflowing. */
    max-width: min(280px, 90vw);
    background: #fff;
    border: 1px solid #e4e6ea;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    padding: 0.25em 0;
}
.top-menu-more-items > a {
    padding: 0.5em 1em;
    color: #6b7280;
    text-decoration: none;
    white-space: normal;      /* long titles wrap within the panel */
}
.top-menu-more-items > a:hover { background: #eceef1; color: #2b2f36; }
.top-menu-more-items > a.active { color: #374151; font-weight: 600; }

.breadcrumbs {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0.7em 1em 0;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 0.8rem;
    color: #868e9a;
}
.breadcrumbs a { color: #6b7280; text-decoration: none; }
.breadcrumbs a:hover { color: #2a6496; text-decoration: underline; }
.breadcrumbs .crumb-sep { color: #b0b6bf; margin: 0 0.15em; }

/* Lightbulb toggle: fold away the Related Topics rail (top-menu + topics). */
.topics-toggle { display: none; }
.topics-toggle-btn { cursor: pointer; font-size: 1.1em; padding: 0 0.4em; user-select: none; opacity: 0.7; }
.topics-toggle-btn:hover { opacity: 1; }
.topics-toggle:checked ~ .site-layout .topics-rail { display: none; }
