/* Chrome: top bar, sidebar, masthead, search palette, popups, and pager. */

/* Icons are inline SVG drawn in currentColor. */

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--muted);
    background: none;
    border: 0;
    cursor: pointer;
    transition: color 120ms, background-color 120ms;
}

.icon-button:hover,
.icon-button:not(#sidebar-toggle)[aria-expanded="true"] {
    color: var(--fg-strong);
    background-color: var(--bg-hl);
}

.icon-button:focus-visible,
.topbar a:focus-visible,
.sidebar a:focus-visible,
.pager a:focus-visible {
    outline: 1px solid var(--blue);
    outline-offset: -1px;
}

.topbar svg,
.search-palette svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: square;
}

.topbar svg .fill {
    fill: currentColor;
    stroke: none;
}

/* Top bar. book.js writes an inline `top` meant for a scrolling bar; pin it. */

.topbar {
    position: fixed;
    top: 0 !important;
    left: 0;
    right: 0;
    z-index: 50;
    height: var(--menu-bar-height);
    background-color: var(--topbar-bg);
    border-bottom: 1px solid var(--rule);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding-inline: var(--gutter);
    font-size: 13px;
}

.brand {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    margin-inline-start: -4px;
}

.brand-mark {
    width: 17px;
    height: 20px;
    shape-rendering: crispEdges;
}

.topbar .brand-mark .pixel-face { fill: var(--fg-strong); }
.topbar .brand-mark .pixel-shadow { fill: var(--blue-shade); }
.topbar .brand:hover .pixel-face { fill: var(--blue); }

.menu-title {
    margin-inline-end: 10px;
    font-weight: 600;
    color: var(--fg-strong);
    white-space: nowrap;
    cursor: pointer;
}

.topnav {
    display: flex;
    gap: 2px;
}

.topnav a {
    padding: 3px 10px;
    color: var(--muted);
    text-decoration: none;
    transition: color 120ms, background-color 120ms;
}

.topnav a:hover { color: var(--fg-strong); }

.topnav a[aria-current] {
    color: var(--fg-strong);
    background-color: var(--bg-hl);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-inline-start: auto;
}

.search-button {
    width: auto;
    gap: 10px;
    padding: 0 6px 0 10px;
    margin-inline-end: 4px;
    font: inherit;
    border: 1px solid var(--rule-strong);
}

.search-button .search-hint {
    min-width: 96px;
    text-align: start;
    color: var(--faint);
}

.search-button kbd {
    font-size: 11px;
    border-bottom-width: 1px;
}

.cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    margin-inline-start: 8px;
    padding: 0 12px;
    font-weight: 600;
    color: var(--button-fg);
    background-color: var(--button-bg);
    text-decoration: none;
    transition: background-color 120ms;
}

.cta:hover { background-color: var(--blue); }

.cta svg { width: 15px; height: 15px; }

/* Theme picker. book.js shows and hides #theme-list with an inline display. */

.theme-menu { position: relative; }

.theme-popup {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 60;
    min-width: 200px;
    margin: 0;
    padding: 4px;
    list-style: none;
    background-color: var(--bg-dark);
    border: 1px solid var(--rule-strong);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.theme-popup::before {
    content: "Theme";
    display: block;
    padding: 6px 10px 4px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}

.theme-popup .theme {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 10px;
    font: inherit;
    font-size: 13px;
    text-align: start;
    color: var(--fg);
    background: none;
    border: 0;
    cursor: pointer;
}

.theme-popup .theme::before {
    content: "";
    flex: none;
    width: 30px;
    height: 12px;
    border: 1px solid var(--rule-strong);
}

#tokyo-night::before { background: var(--swatch-night); }
#tokyo-night-storm::before { background: var(--swatch-storm); }
#tokyo-night-day::before { background: var(--swatch-day); }

.theme-popup .theme:hover,
.theme-popup .theme:focus-visible {
    color: var(--fg-strong);
    background-color: var(--bg-hl);
    outline: 0;
}

.theme-popup .theme-selected { color: var(--fg-strong); }

.theme-popup .theme-selected::after {
    content: "■";
    margin-inline-start: auto;
    font-size: 9px;
    color: var(--blue);
}

/* Sidebar. Wide screens pin it inside the centred frame; narrow ones slide it in as a drawer. */

.sidebar {
    position: fixed;
    top: var(--menu-bar-height);
    bottom: 0;
    left: var(--gutter);
    z-index: 30;
    width: var(--sidebar-width);
    box-sizing: border-box;
    font-size: 12.5px;
    line-height: 1.5;
    background-color: var(--bg);
    border-inline-end: 1px solid var(--rule);
    transition: transform 0.25s ease;
}

.sidebar-scrollbox {
    display: block;
    height: 100%;
    box-sizing: border-box;
    padding: 28px 16px 48px 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--rule-strong) transparent;
}

#sidebar-toggle-anchor:not(:checked) ~ .sidebar {
    transform: translateX(calc(-100% - var(--gutter) - 1px));
}

.sidebar-iframe-outer {
    width: 100%;
    height: 100%;
    border: 0;
}

.sidebar-iframe-inner {
    margin: 0;
    padding: 16px;
    font-size: 12.5px;
    background-color: var(--bg);
}

.sidebar ol.chapter,
.sidebar-iframe-inner ol.chapter {
    margin: 0;
    padding: 0;
    list-style: none;
}

.chapter li.chapter-item {
    margin: 1px 0;
}

.chapter li a {
    display: block;
    padding: 3px 10px;
    color: var(--fg);
    text-decoration: none;
    border-inline-start: 2px solid transparent;
    transition: color 120ms, background-color 120ms;
}

.chapter li a:hover {
    color: var(--fg-strong);
    background-color: color-mix(in srgb, var(--bg-hl) 55%, transparent);
}

.chapter li a.active {
    color: var(--fg-strong);
    background-color: var(--bg-hl);
    border-inline-start-color: var(--blue);
}

.chapter li.part-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 24px 0 8px;
    padding-inline-start: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.chapter li.part-title::before {
    content: "";
    width: 6px;
    height: 6px;
    background-color: var(--magenta);
}

.chapter li.part-title[data-part="Guide"]::before { background-color: var(--blue); }

.chapter li.spacer {
    height: 1px;
    margin: 12px 0;
    background-color: var(--rule);
}

.chapter .section {
    margin: 0;
    padding-inline-start: 14px;
    list-style: none;
}

.chapter li.chapter-item:not(.expanded) + li > ol { display: none; }

.chapter a.toggle { display: none; }

.sidebar-resize-handle { display: none !important; }

.sidebar-scrim { display: none; }

/* Page offset: the content column sits right of the sidebar inside the frame. */

@media only screen and (min-width: 1080px) {
    #sidebar-toggle-anchor:checked ~ .page-wrapper {
        margin-inline-start: calc(var(--gutter) + var(--sidebar-width));
    }

    #sidebar-toggle-anchor:checked ~ .page-wrapper .page {
        padding-inline: 56px var(--page-padding);
    }

    #sidebar-toggle-anchor:checked ~ .page-wrapper :is(.masthead, main, .pager) {
        margin-inline-start: 0;
    }

    html:not(.sidebar-resizing) .page-wrapper {
        transition: margin-left 0.25s ease;
    }
}

@media only screen and (max-width: 1079px) {
    .sidebar {
        left: 0;
        width: min(300px, 84vw);
        padding-inline-start: 12px;
        background-color: var(--bg-dark);
        border-inline-end-color: var(--rule-strong);
        box-shadow: 16px 0 40px rgba(0, 0, 0, 0.3);
    }

    #sidebar-toggle-anchor:not(:checked) ~ .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar-scrim {
        display: block;
        position: fixed;
        inset: var(--menu-bar-height) 0 0 0;
        z-index: 25;
        background-color: var(--overlay);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    #sidebar-toggle-anchor:checked ~ .sidebar-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    .menu-title { display: none; }
}

@media only screen and (max-width: 760px) {
    .topnav,
    .search-button .search-hint,
    .search-button kbd,
    .print-button { display: none; }

    .search-button {
        width: 32px;
        padding: 0;
        margin: 0;
        border: 0;
    }

    .cta { margin-inline-start: 4px; padding: 0 10px; }
}

/* Masthead: the pixel wordmark over every page, after the Omarchy manual. */

.masthead {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: var(--content-max-width);
    margin: 44px auto 36px;
    user-select: none;
}

.wordmark {
    width: min(232px, 60vw);
    height: auto;
    overflow: visible;
    shape-rendering: crispEdges;
}

.wordmark .stop-1 { stop-color: var(--fg-strong); }
.wordmark .stop-2 { stop-color: var(--blue); }
.wordmark .stop-3 { stop-color: var(--magenta); }
.wordmark .pixel-shadow { fill: var(--bg-hl); }

.masthead-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.32em;
    text-indent: 0.32em;
    text-transform: uppercase;
    color: var(--muted);
}

.masthead-tagline {
    display: none;
    margin: 10px 0 0;
    font-family: var(--sans-font);
    font-size: 17px;
    font-weight: 500;
    color: var(--fg-strong);
}

/* The home page gets the big wordmark over a scattered pixel field. */

.masthead-home {
    margin-top: 32px;
    margin-bottom: 48px;
    padding: 72px 0 56px;
}

.masthead-home .wordmark { width: min(440px, 80vw); }

.masthead-home .masthead-tagline { display: block; }

.masthead-home::before {
    content: "";
    position: absolute;
    inset: 0 -48px;
    z-index: -1;
    background-color: var(--dot);
    -webkit-mask: var(--pixel-field) 0 0 / 160px 160px, radial-gradient(closest-side, transparent 38%, #000 72%, transparent 100%);
    -webkit-mask-composite: source-in;
    mask: var(--pixel-field) 0 0 / 160px 160px, radial-gradient(closest-side, transparent 38%, #000 72%, transparent 100%);
    mask-composite: intersect;
}

@media only screen and (max-width: 760px) {
    .masthead { margin: 28px auto 24px; }
    .masthead-home { padding: 48px 0 40px; }
    .masthead-home::before { inset: 0 calc(0px - var(--page-padding)); }
}

/* Pager */

.pager {
    display: flex;
    gap: 16px;
    max-width: var(--content-max-width);
    margin: 64px auto 0;
    padding-top: 18px;
    border-top: 1px solid var(--rule);
}

.pager a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 48%;
    padding: 6px 0;
    text-decoration: none;
}

.pager .next {
    margin-inline-start: auto;
    align-items: flex-end;
    text-align: end;
}

.pager-dir {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.pager-name {
    color: var(--fg-strong);
    transition: color 120ms;
}

.pager a:hover .pager-name { color: var(--blue); }

/* Search: a launcher-style palette over the page. */

#search-wrapper {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 12vh 16px 16px;
    background-color: var(--overlay);
}

.search-palette {
    display: flex;
    flex-direction: column;
    width: min(640px, 100%);
    max-height: 72vh;
    background-color: var(--bg-dark);
    border: 1px solid var(--rule-strong);
    border-top: 2px solid var(--blue);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-bottom: 1px solid var(--rule);
}

.search-glyph { flex: none; color: var(--blue); }

#searchbar {
    flex: 1;
    min-width: 0;
    padding: 14px 0;
    font: inherit;
    font-size: 15px;
    color: var(--fg-strong);
    background: none;
    border: 0;
    outline: 0;
}

#searchbar::placeholder { color: var(--faint); }

#searchbar::-webkit-search-cancel-button { display: none; }

.search-esc { flex: none; font-size: 11px; color: var(--muted); }

.spinner-wrapper { display: none; color: var(--muted); }
#searchbar-outer.searching .spinner-wrapper { display: block; }

.searchresults-outer {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--rule-strong) transparent;
}

.searchresults-header {
    padding: 10px 16px 6px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

ul#searchresults {
    margin: 0;
    padding: 0 0 8px;
    list-style: none;
}

ul#searchresults li {
    padding: 8px 16px;
    border-inline-start: 2px solid transparent;
}

ul#searchresults li.focus,
ul#searchresults li:hover {
    background-color: var(--bg-hl);
    border-inline-start-color: var(--blue);
}

ul#searchresults a {
    color: var(--fg-strong);
    text-decoration: none;
}

ul#searchresults span.teaser {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

ul#searchresults span.teaser em {
    font-style: normal;
    color: var(--yellow);
}

/* Copy button on code blocks */

pre > .buttons {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.1s linear, opacity 0.1s linear;
}

pre:hover > .buttons,
pre > .buttons:focus-within {
    visibility: visible;
    opacity: 1;
}

pre > .buttons button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    color: var(--muted);
    background-color: var(--bg-hl);
    border: 1px solid var(--rule-strong);
    cursor: pointer;
}

pre > .buttons button:hover { color: var(--fg-strong); border-color: var(--blue); }

pre > .buttons button.clip-button::before {
    content: "";
    width: 14px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask: var(--copy-icon) center / contain no-repeat;
    mask: var(--copy-icon) center / contain no-repeat;
}

:root {
    /* Scattered pixels for the home masthead, generated once from a fixed seed. */
    --pixel-field: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' shape-rendering='crispEdges'%3E%3Cpath fill-opacity='.35' d='M0 0h.7v.7h-.7zM1 0h.7v.7h-.7zM6 0h.7v.7h-.7zM9 0h.7v.7h-.7zM13 0h.7v.7h-.7zM15 0h.7v.7h-.7zM19 0h.7v.7h-.7zM0 1h.7v.7h-.7zM3 1h.7v.7h-.7zM4 1h.7v.7h-.7zM8 1h.7v.7h-.7zM15 1h.7v.7h-.7zM16 1h.7v.7h-.7zM17 1h.7v.7h-.7zM18 1h.7v.7h-.7zM1 2h.7v.7h-.7zM7 2h.7v.7h-.7zM15 2h.7v.7h-.7zM16 2h.7v.7h-.7zM19 2h.7v.7h-.7zM1 3h.7v.7h-.7zM3 3h.7v.7h-.7zM6 3h.7v.7h-.7zM11 3h.7v.7h-.7zM13 3h.7v.7h-.7zM14 3h.7v.7h-.7zM19 3h.7v.7h-.7zM5 4h.7v.7h-.7zM8 4h.7v.7h-.7zM11 4h.7v.7h-.7zM1 5h.7v.7h-.7zM2 5h.7v.7h-.7zM12 5h.7v.7h-.7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h-.7zM19 4h.7v.7h-.7zM8 5h.7v.7h-.7zM10 5h.7v.7h-.7zM11 5h.7v.7h-.7zM18 5h.7v.7h-.7zM19 5h.7v.7h-.7zM7 7h.7v.7h-.7zM8 8h.7v.7h-.7zM9 8h.7v.7h-.7zM12 8h.7v.7h-.7zM1 9h.7v.7h-.7zM3 9h.7v.7h-.7zM5 9h.7v.7h-.7zM13 9h.7v.7h-.7zM5 10h.7v.7h-.7zM10 10h.7v.7h-.7zM12 10h.7v.7h-.7zM13 10h.7v.7h-.7zM3 12h.7v.7h-.7zM5 12h.7v.7h-.7zM12 12h.7v.7h-.7zM0 13h.7v.7h-.7zM1 14h.7v.7h-.7zM4 14h.7v.7h-.7zM10 15h.7v.7h-.7zM0 16h.7v.7h-.7zM9 16h.7v.7h-.7zM12 16h.7v.7h-.7zM13 16h.7v.7h-.7zM9 17h.7v.7h-.7zM8 18h.7v.7h-.7z'/%3E%3Cpath fill-opacity='1' d='M12 0h.7v.7h-.7zM13 2h.7v.7h-.7zM12 4h.7v.7h-.7zM0 5h.7v.7h-.7zM18 8h.7v.7h-.7zM18 9h.7v.7h-.7zM14 11h.7v.7h-.7zM6 12h.7v.7h-.7zM4 13h.7v.7h-.7zM5 13h.7v.7h-.7zM13 13h.7v.7h-.7zM17 13h.7v.7h-.7zM19 15h.7v.7h-.7zM11 17h.7v.7h-.7zM0 18h.7v.7h-.7zM2 18h.7v.7h-.7zM10 19h.7v.7h-.7z'/%3E%3C/svg%3E");
    --copy-icon: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="black" stroke-width="1.4"><path d="M5.5 5.5h8v8h-8z"/><path d="M10.5 5.5v-3h-8v8h3"/></svg>');
}

/* Keyboard help (press ?). book.js sets the container's display to flex. */

#mdbook-help-container {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    background-color: var(--overlay);
}

#mdbook-help-popup {
    min-width: 280px;
    padding: 20px 24px;
    background-color: var(--bg-dark);
    border: 1px solid var(--rule-strong);
    border-top: 2px solid var(--magenta);
}

.mdbook-help-title {
    margin: 0 0 14px;
    font-size: 15px;
}

#mdbook-help-popup dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 20px;
    margin: 0;
    font-size: 13px;
}

#mdbook-help-popup dt { white-space: nowrap; }
#mdbook-help-popup dd { margin: 0; color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-scrim,
    .page-wrapper { transition: none !important; }
}
