/* Oscyl's two book themes, oscyl-light and oscyl-dark: the website's world
   ("Ulm Hi-Fi", see DESIGN.md), grey enamel, 1 px rules, the plate for the
   page you are on, Albert Sans for headings. mdBook's own stylesheets stay;
   under the Oscyl themes this file maps their variables onto the site's
   tokens (site/index.html) and restyles what they draw. mdBook's themes
   (Light, Rust, Coal, Navy, Ayu) stay as mdBook draws them. */

@font-face {
    font-family: "Albert Sans";
    font-weight: 700;
    font-display: swap;
    src: url("AlbertSans-Bold.ttf") format("truetype");
}

html.oscyl-light {
    --ground: #e7e6e2; --sidebar: #dedcd7; --raised: #f6f5f2; --plate: #2a2b2c; --on-plate: #ecebe7;
    --rule: #cbc9c3; --rule-strong: #8a8882; --ink: #1d1e1f; --legend: #62615c; --act: #a54c08;
    --shadow: rgb(29 30 31 / 14%); --hover: rgb(29 30 31 / 6%);
    /* Code, in the API reference's hues (docs/theme/rustdoc/oscyl.css). */
    --kind-type: #93306c; --kind-trait: #5a42a6; --kind-fn: #7e5410; --kind-macro: #1d6762;
    --kind-mod: #265d8e; --code-string: #3d6b1f;
    --color-scheme: light;
}
html.oscyl-dark {
    --ground: #202122; --sidebar: #1a1b1c; --raised: #2b2c2d; --plate: #d9d8d3; --on-plate: #202122;
    --rule: #353637; --rule-strong: #6b6c6d; --ink: #ecebe7; --legend: #9d9c97; --act: #f08a24;
    --shadow: rgb(0 0 0 / 40%); --hover: rgb(236 235 231 / 6%);
    --kind-type: #e48fc4; --kind-trait: #b4a3f2; --kind-fn: #deae66; --kind-macro: #7fcfc6;
    --kind-mod: #86b6e6; --code-string: #a9cf86;
    --color-scheme: dark;
}
@media (prefers-contrast: more) {
    html.oscyl-light, html.oscyl-dark { --rule: var(--rule-strong); --legend: var(--ink); }
}

html.oscyl-light, html.oscyl-dark {
    --ease: cubic-bezier(.2, .8, .2, 1);
    --plate-fill: linear-gradient(to bottom, color-mix(in srgb, var(--plate) 94%, white), color-mix(in srgb, var(--plate) 95%, black));
    --ui-font: system-ui, sans-serif;
    --display-font: "Albert Sans", system-ui, sans-serif;

    --sidebar-target-width: 290px;
    --page-padding: 24px;
    --content-max-width: 70rem;
    --menu-bar-height: 56px;
    --mono-font: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "DejaVu Sans Mono", monospace;
    --code-font-size: 0.875em;

    --bg: var(--ground);
    --fg: var(--ink);
    --sidebar-bg: var(--sidebar);
    --sidebar-fg: var(--ink);
    --sidebar-non-existant: var(--legend);
    --sidebar-active: var(--ink);
    --sidebar-spacer: var(--rule);
    --sidebar-header-border-color: var(--rule-strong);
    --scrollbar: var(--rule-strong);
    --icons: var(--legend);
    --icons-hover: var(--ink);
    --links: var(--ink);
    --inline-code-color: var(--ink);
    --theme-popup-bg: var(--raised);
    --theme-popup-border: var(--rule);
    --theme-hover: var(--hover);
    --quote-bg: transparent;
    --quote-border: var(--rule);
    --warning-border: var(--act);
    --table-border-color: var(--rule);
    --table-header-bg: transparent;
    --table-alternate-bg: transparent;
    --searchbar-border-color: var(--rule-strong);
    --searchbar-bg: var(--raised);
    --searchbar-fg: var(--ink);
    --searchbar-shadow-color: transparent;
    --searchresults-header-fg: var(--legend);
    --searchresults-border-color: var(--rule);
    --searchresults-li-bg: var(--hover);
    --search-mark-bg: color-mix(in srgb, var(--ink) 16%, transparent);
    --footnote-highlight: var(--rule-strong);
    --overlay-bg: rgb(0 0 0 / 30%);
    --blockquote-note-color: var(--legend);
    --blockquote-tip-color: var(--legend);
    --blockquote-important-color: var(--ink);
    --blockquote-warning-color: var(--act);
    --blockquote-caution-color: var(--act);
}

/* In every theme: the parts index.hbs adds. */
.menu-title a { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; vertical-align: top; }
.menu-title img { width: 26px; height: 26px; }
.theme-popup .theme-separator { margin: 4px 0; border-top: 1px solid var(--theme-popup-border); }
.nav-label { display: none; }

html:is(.oscyl-light, .oscyl-dark) {
    /* Base */
    & {
        font-family: var(--ui-font);
        scrollbar-color: var(--rule-strong) var(--ground);
        -webkit-font-smoothing: antialiased;
    }
    body { font-size: 1.7rem; }
    ::selection { background: var(--plate); color: var(--on-plate); }
    :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
    .page-wrapper { background: var(--ground); }

    /* Menu bar: the site's header bar, the name set as on the site. */
    #mdbook-menu-bar { align-items: center; }
    #mdbook-menu-bar.bordered { border-block-end-color: var(--rule); }
    .left-buttons, .right-buttons { display: flex; align-items: center; gap: 2px; margin: 0 12px; }
    #mdbook-menu-bar .icon-button, #mdbook-menu-bar .right-buttons a {
        display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
        border-radius: 6px; line-height: 1; color: var(--legend);
        transition: background .16s var(--ease), color .16s var(--ease);
    }
    #mdbook-menu-bar .right-buttons a .fa-svg, #mdbook-menu-bar .icon-button .fa-svg { padding: 0; line-height: 1; }
    #mdbook-menu-bar .icon-button:hover, #mdbook-menu-bar .right-buttons a:hover { background: var(--hover); color: var(--ink); }
    .menu-title {
        font: 700 2rem/var(--menu-bar-height) var(--display-font);
        letter-spacing: -.01em; color: var(--ink);
    }
    .menu-title a { height: var(--menu-bar-height); }

    /* Theme menu: a popover. */
    .theme-popup {
        top: calc(var(--menu-bar-height) - 6px); padding: 4px; border-radius: 10px; font-size: 1.4rem;
        box-shadow: 0 0 0 1px var(--rule), 0 4px 12px var(--shadow); border: 0;
    }
    .theme-popup .theme { padding: 6px 14px 6px 28px; line-height: 1.5; border-radius: 6px; }
    .theme-selected::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-inline-start: -16px; margin-inline-end: 10px; vertical-align: middle; }

    /* Search */
    #mdbook-searchbar { border-radius: 6px; border: 0; box-shadow: inset 0 0 0 1px var(--rule-strong); padding: 11px 16px; font: inherit; }
    #mdbook-searchbar:focus, #mdbook-searchbar.active { box-shadow: inset 0 0 0 1px var(--rule-strong); outline: 2px solid var(--ink); outline-offset: 2px; }
    .searchresults-header { font-weight: 600; color: var(--legend); }
    .searchresults-outer { border-block-end: 1px solid var(--rule); }
    ul#mdbook-searchresults { padding: 0; }
    ul#mdbook-searchresults li { margin: 0; padding: 12px 14px; border-radius: 6px; border-bottom: 1px solid var(--rule); }
    ul#mdbook-searchresults li:last-child { border-bottom: 0; }
    ul#mdbook-searchresults li > a { font-weight: 600; color: var(--ink); }
    ul#mdbook-searchresults span.teaser { margin: 4px 0 0; font-size: .88em; color: var(--legend); }
    ul#mdbook-searchresults span.teaser em { color: var(--ink); }
    mark { color: inherit; }

    /* Sidebar: the sources column. The page you are on is the plate. */
    .sidebar { font-size: 1.5rem; border-inline-end: 1px solid var(--rule); }
    .sidebar .sidebar-scrollbox { padding: 18px 14px 32px; }
    .chapter { line-height: 1.4; }
    .chapter li.chapter-item { margin-block-start: 1px; line-height: 1.4; }
    .chapter li a {
        display: block; flex: 1; padding: 6px 10px; border-radius: 6px; color: var(--ink);
        transition: background .16s var(--ease);
    }
    .chapter li a:hover { background: var(--hover); color: var(--ink); }
    .chapter li a.active, .chapter li a.active:hover {
        background: var(--plate-fill); color: var(--on-plate); font-weight: 600;
        box-shadow: 0 1px 3px var(--shadow);
    }
    .chapter li.part-title {
        margin: 22px 10px 6px; color: var(--legend); font-weight: 500;
        font-size: 1.25rem; letter-spacing: .08em; text-transform: uppercase;
    }
    .chapter-fold-toggle { display: grid; place-items: center; padding: 0 8px; border-radius: 6px; color: var(--legend); opacity: 1; }
    .chapter-fold-toggle:hover { background: var(--hover); color: var(--ink); }
    .chapter-fold-toggle div { transition: transform .2s var(--ease); }
    .section { padding-inline-start: 14px; line-height: 1.4; }
    .on-this-page { margin: 4px 0 10px 18px; padding-left: 2px; border-inline-start: 1px solid var(--rule-strong); }
    .chapter li.header-item { margin-block-end: 0; line-height: 1.35; }
    .on-this-page a { padding: 4px 10px; font-size: 1.4rem; color: var(--legend); }
    .chapter a.current-header { color: var(--ink); font-weight: 600; }
    .sidebar-resize-handle .sidebar-resize-indicator::before, .sidebar-resize-handle .sidebar-resize-indicator::after { color: var(--rule-strong); }

    /* Reading: the site's measure, rules and type. */
    .content { padding-bottom: 72px; }
    .content main { line-height: 1.6; }
    .content p, .content ol, .content ul { line-height: 1.6; }
    .content li + li { margin-top: .3em; }
    .content main > h1:first-of-type, .content main > .header:first-child h1 { margin-top: 1.3em; }
    .content h1, .content h2 {
        font-family: var(--display-font); font-weight: 700; letter-spacing: -.02em;
        text-wrap: balance;
    }
    .content h1 { font-size: clamp(3.2rem, 2.4rem + 2.2vw, 4.6rem); line-height: 1.06; margin: 1.3em 0 .55em; }
    .content h2 { font-size: 2.7rem; line-height: 1.15; margin: 2em 0 .6em; padding-top: .9em; border-top: 1px solid var(--rule); }
    .content h3 { font-size: 2rem; font-weight: 600; line-height: 1.3; margin: 1.8em 0 .5em; }
    .content h4, .content h5 { font-size: 1.7rem; font-weight: 600; margin: 1.6em 0 .4em; }
    .content h1 + h2 { border-top: 0; padding-top: 0; }
    .content .header:link, .content .header:visited { color: var(--ink); }
    .content h1:target::before, .content h2:target::before, .content h3:target::before,
    .content h4:target::before, .content h5:target::before, .content h6:target::before { color: var(--legend); }
    :target { scroll-margin-top: calc(var(--menu-bar-height) + 1em); }

    /* Links: ink, underlined, so they never rely on colour. */
    .content a:not(.header) { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
    .content a:not(.header):hover { text-decoration-color: var(--ink); }
    .content strong { font-weight: 600; }
    .content hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }

    /* Code */
    code { font-variant-ligatures: none; }
    :not(pre) > code {
        padding: .1em .35em; border-radius: 4px; color: var(--ink);
        background: var(--sidebar); box-shadow: inset 0 0 0 1px var(--rule);
    }
    .content a > code { background: none; box-shadow: none; padding: 0; }
    pre { margin: 1.4em 0; border-radius: 10px; background: var(--sidebar); box-shadow: inset 0 0 0 1px var(--rule); }
    pre > code, pre > code.hljs { padding: 16px 20px; background: transparent; color: var(--ink); line-height: 1.65; font-size: 1.4rem; }
    pre > .buttons { top: 8px; right: 8px; }
    pre > .buttons button { border-radius: 6px; color: var(--legend); background: var(--raised); border: 0; box-shadow: inset 0 0 0 1px var(--rule-strong); }
    pre > .buttons button:hover { color: var(--ink); }
    /* Syntax: the API reference's hues, each at least 4.5:1 on the code panel. */
    .hljs { background: transparent; color: var(--ink); }
    .hljs-comment, .hljs-quote { color: var(--legend); font-style: italic; }
    .hljs-keyword, .hljs-selector-tag { color: var(--kind-trait); font-weight: 600; }
    .hljs-string, .hljs-number, .hljs-symbol, .hljs-bullet, .hljs-regexp { color: var(--code-string); }
    .hljs-title, .hljs-section, .hljs-function .hljs-title { color: var(--kind-fn); }
    .hljs-type, .hljs-built_in, .hljs-literal, .hljs-class .hljs-title { color: var(--kind-type); }
    .hljs-meta { color: var(--legend); }
    .hljs-attr, .hljs-attribute { color: var(--kind-mod); }
    .hljs-name, .hljs-tag, .hljs-selector-class, .hljs-selector-id, .hljs-link { color: var(--kind-mod); }
    .hljs-variable, .hljs-template-variable, .hljs-params { color: var(--ink); }
    .hljs-macro { color: var(--kind-macro); }
    .hljs-addition { color: var(--ink); background: var(--hover); }
    .hljs-deletion { color: var(--legend); text-decoration: line-through; }
    .boring { opacity: .55; }

    /* Tables: ruled, as on the site. */
    .content table { margin: 1.6em 0; width: 100%; font-size: .94em; font-variant-numeric: tabular-nums; }
    .content table thead { background: none; }
    .content table thead tr { border: 0; }
    .content table th {
        padding: 0 16px 8px 0; text-align: start; vertical-align: bottom; border-bottom: 1px solid var(--rule-strong);
        font-weight: 600; color: var(--ink);
    }
    .content table td { padding: 10px 16px 10px 0; border: 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
    .content table th:last-child, .content table td:last-child { padding-right: 0; }

    /* Asides: a framed panel with the site's enamel sweep. */
    blockquote {
        margin: 1.6em 0; padding: 4px 22px; border: 1px solid var(--rule); border-radius: 10px;
        background: linear-gradient(to bottom, color-mix(in srgb, var(--ink) 3%, transparent), transparent 45%);
    }
    .blockquote-tag { padding: 4px 22px; border: 1px solid var(--rule); }
    .blockquote-tag-warning, .blockquote-tag-caution { border-color: var(--act); }
    .blockquote-tag-title { font-size: 1.25rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin: 14px 0 6px; }
    kbd { font: 500 .85em var(--mono-font); padding: 2px 6px; border-radius: 4px; background: var(--raised); border: 0; box-shadow: inset 0 0 0 1px var(--rule-strong), 0 1px 0 var(--rule-strong); }

    /* Previous and next: the wide side arrows give way to two outlined buttons
       at the page's foot that name the chapter (index.hbs). */
    .nav-wide-wrapper { display: none; }
    .nav-wrapper { display: flex; gap: 12px; max-width: var(--content-max-width); margin: 64px auto 0; padding-top: 24px; border-top: 1px solid var(--rule); }
    .nav-wrapper::after { content: none; }
    .mobile-nav-chapters {
        float: none; flex: 1 1 0; width: auto; min-width: 0; display: flex; flex-direction: column; gap: 2px;
        padding: 12px 16px; border-radius: 6px; background: none; box-shadow: inset 0 0 0 1px var(--rule-strong);
        font-size: 1.6rem; text-align: start; text-decoration: none; color: var(--ink);
        transition: background .16s var(--ease);
    }
    .mobile-nav-chapters.next { text-align: end; margin-inline-start: auto; }
    .mobile-nav-chapters:hover { background: var(--hover); text-decoration: none; }
    .mobile-nav-chapters .fa-svg { display: none; }
    .nav-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
    .mobile-nav-chapters small { font-size: 1.25rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--legend); }
    .mobile-nav-chapters b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    @media (max-width: 620px) {
        & { --page-padding: 16px; }
        .content h2 { font-size: 2.4rem; }
        .left-buttons, .right-buttons { margin: 0 4px; gap: 0; }
        .nav-wrapper { flex-direction: column; }
        .mobile-nav-chapters.next { margin-inline-start: 0; }
    }
    @media (prefers-reduced-motion: reduce) {
        &, .page-wrapper, .sidebar, .chapter li a, .chapter-fold-toggle div, .mobile-nav-chapters, #mdbook-menu-bar .icon-button { transition: none !important; scroll-behavior: auto; }
    }
}
