/*
 * Layout for the Hugo theme.
 *
 * The counterpart of theme/mkdocs/fox-layout.css: everything about colour,
 * typography, admonitions, the action menu, the sidebar chrome and the page
 * furniture is in theme/shared/fox-wiki.css and is used unchanged, because this
 * theme emits Material's class names on purpose. What is left is the geometry
 * Material would otherwise have supplied - and, unlike Material's, it is a
 * two-column grid with nothing above it, because there is no top bar.
 */

/*
 * The variables Material would have defined.
 *
 * theme/shared/fox-wiki.css sets --md-text-font and --md-code-font from the fox
 * families, and then leans on `body { font-family: var(--md-text-font-family) }`
 * - but the *-family variables are derived inside Material's own stylesheet,
 * which this engine does not load. Without these two lines that var() is
 * undefined, the declaration is invalid, and every page falls back to the
 * browser's default serif. Deriving them the same way Material does keeps the
 * shared file working unchanged, font toggle included.
 */
:root {
    --md-text-font-family: var(--md-text-font), -apple-system, BlinkMacSystemFont,
        "Segoe UI", system-ui, sans-serif;
    --md-code-font-family: var(--md-code-font), SFMono-Regular, Consolas, monospace;
}

/*
 * Admonitions are a Material construct, so Material draws the box and
 * theme/shared/fox-wiki.css only assigns the register colour to it. Here the box
 * has to be drawn too - the shared file's `border-color` and the title tint have
 * nothing to sit on otherwise, which shows up as coloured bars with no card
 * around them.
 */
.md-typeset .admonition,
.md-typeset details:not(.wiki-menu) {
    margin: 1rem 0;
    padding: 0;
    border: 1px solid var(--hairline);
    border-left-width: 4px;
    border-radius: var(--radius-card);
    font-size: 0.75rem;
    overflow: hidden;
}

.md-typeset .admonition > .admonition-title,
.md-typeset details:not(.wiki-menu) > summary {
    margin: 0;
    padding: 0.4rem 0.8rem;
    font-weight: 700;
}

.md-typeset .admonition > :not(.admonition-title),
.md-typeset details:not(.wiki-menu) > :not(summary) {
    margin: 0.5rem 0.8rem;
}

/*
 * List indentation is a Material construct too: the shared fox.css resets
 * every element's margin and padding to zero, and Material's own stylesheet
 * (which this engine does not load) is what normally re-adds the padding
 * that indents a list under its marker. Without this, a nested <ul> still
 * nests in the HTML but sits flush with its parent - the sub-item's marker
 * still changes (browser default disc/circle/square), only the indent is
 * gone. Each level's own padding-left compounds on nesting, so one rule
 * covers every depth.
 */
.md-typeset ul,
.md-typeset ol {
    padding-left: 1.6rem;
    margin: 0.8rem 0;
}

.md-typeset li {
    margin-bottom: 0.3rem;
}

.md-container {
    background: var(--dusk);
    min-height: 100vh;
}

.md-main__inner {
    display: grid;
    max-width: 76rem;
    margin: 0 auto;
    gap: 1.2rem;
    grid-template-columns: 14rem minmax(0, 1fr);
    padding: 0 1rem 3rem;
}

.md-sidebar--primary {
    position: sticky;
    top: 0;
    max-height: 100vh;
    padding-top: 0.8rem;
    overflow-y: auto;
}

.md-nav--primary > .md-nav__title {
    display: block;
    padding: 0 0.6rem 0.4rem;
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 700;
}

.md-nav--primary > .md-nav__title .md-logo {
    display: inline-block;
    width: 1.3rem;
    height: 1.3rem;
    margin-right: 0.35rem;
    vertical-align: -0.25rem;
}

.md-nav--primary > .md-nav__title .md-logo svg {
    width: 100%;
    height: 100%;
}

.md-nav__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Nesting is drawn by indenting the nested list, not the item, so a section
   header lines up with its siblings the way Material's does. */
.md-nav .md-nav {
    margin-left: 0.6rem;
}

.md-nav__link {
    display: block;
    padding: 0.2rem 0.6rem;
    border-left: 2px solid transparent;
    color: var(--ink-soft);
    font-size: 0.7rem;
    text-decoration: none;
}

.md-nav__container > .md-nav__link {
    padding: 0;
    border: 0;
}

.md-nav__container {
    padding: 0.3rem 0.6rem 0.1rem;
    color: var(--ink);
    font-size: 0.72rem;
    font-weight: 700;
}

.md-nav__link:hover {
    color: var(--ink);
}

/* Weight plus an inset rule, not colour alone: links on this site are already
   ink, so a colour-only active marker would be invisible. Same reasoning as the
   Material rule in theme/shared/fox-wiki.css. */
.md-nav__link--active {
    border-left-color: var(--ink);
    color: var(--ink);
    font-weight: 700;
}

.md-content__inner {
    background: var(--snow);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    margin-top: 0.8rem;
    padding: 0.8rem 1.2rem 1.2rem;
}

/* The permalink anchors render-heading.html emits, revealed on hover the way
   Material reveals its own. */
.md-typeset .headerlink {
    margin-left: 0.3rem;
    color: var(--hairline);
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.md-typeset :hover > .headerlink,
.md-typeset .headerlink:focus {
    opacity: 1;
}

/* ------------------------------------------------------------- drawer
 *
 * Below the breakpoint the sidebar becomes a drawer driven by a checkbox, the
 * same shape Material uses - and for the same reason: it works with no
 * JavaScript at all, which matters because Gotenberg renders these pages.
 */
.wiki-drawer,
.wiki-drawer__toggle {
    display: none;
}

@media screen and (max-width: 76.1875em) {
    .md-main__inner {
        grid-template-columns: minmax(0, 1fr);
        padding-top: 2.6rem;
    }

    .md-sidebar--primary {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 6;
        width: 14rem;
        height: 100vh;
        padding: 0.8rem 0 1rem;
        background: var(--snow);
        border-right: 1px solid var(--hairline);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .wiki-drawer__toggle:checked ~ .md-container .md-sidebar--primary {
        transform: translateX(0);
    }

    .wiki-drawer {
        position: fixed;
        top: 0.6rem;
        left: 0.6rem;
        z-index: 7;
        display: flex;
        width: 1.9rem;
        height: 1.9rem;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--hairline);
        border-radius: var(--radius-ui);
        background: var(--snow);
        color: var(--ink);
        cursor: pointer;
        font-size: 0.9rem;
        box-shadow: 0 2px 6px rgba(var(--shadow-ink), 0.12);
    }

    .wiki-drawer__toggle:checked ~ .wiki-drawer {
        display: none;
    }
}

@media print {
    .md-main__inner {
        display: block;
        max-width: none;
        padding: 0;
    }

    .md-content__inner {
        border: 0;
        border-radius: 0;
        margin: 0;
        padding: 0;
    }
}
