/*
 * The public manual (App\Ui\Manual\ManualExporter) — Bootstrap 5.3 dressed as the MDC shell: the same
 * root scale, the same surface and text tokens light and dark, the same top bar (Zone A) and the same
 * sidebar stack (Zone B) as assets/styles/app.css. Copied as values, not imported: the manual is a
 * separate site and must not load the application's stylesheet — when the shell's tokens change, this
 * block follows by hand.
 *
 * The content column is the one thing the shell does not have: a reading measure (48rem, about an A4
 * text column), centred in the space beside the sidebar.
 */
html {
    font-size: 93.75%;
}

:root,
[data-bs-theme="light"] {
    --mdc-sidebar-width: 16rem;
    --mdc-navbar-search-width: 14rem;
    --mdc-navbar-search-width-lg: 19rem;
    --mdc-shell-bg: #f1f5f9;
    --mdc-page-bg: #f8fafc;
    --mdc-surface-bg: #fff;
    --mdc-nav-hover-bg: #f1f5f9;
    --mdc-nav-active-bg: #e2e8f0;
    --bs-body-color: #0f172a;
    --bs-body-color-rgb: 15, 23, 42;
    --bs-secondary-color: #475569;
    --bs-secondary-color-rgb: 71, 85, 105;
    --bs-tertiary-color: #64748b;
    --bs-tertiary-color-rgb: 100, 116, 139;
    --bs-secondary: #64748b;
    --bs-secondary-rgb: 100, 116, 139;
    --bs-secondary-bg: #e2e8f0;
    --bs-secondary-bg-rgb: 226, 232, 240;
    --bs-tertiary-bg: #f1f5f9;
    --bs-tertiary-bg-rgb: 241, 245, 249;
    --bs-border-color: #e2e8f0;
    --bs-link-color: #0a58ca;
    --bs-link-color-rgb: 10, 88, 202;
    --bs-link-hover-color: #084298;
    --bs-link-hover-color-rgb: 8, 66, 152;
}

[data-bs-theme="dark"] {
    --mdc-shell-bg: #0b1120;
    --mdc-page-bg: #0f172a;
    --mdc-surface-bg: #1e293b;
    --mdc-nav-hover-bg: #1e293b;
    --mdc-nav-active-bg: #334155;
    --bs-body-bg: var(--mdc-surface-bg);
    --bs-body-bg-rgb: 30, 41, 59;
    --bs-body-color: #e2e8f0;
    --bs-body-color-rgb: 226, 232, 240;
    --bs-secondary-color: #94a3b8;
    --bs-secondary-color-rgb: 148, 163, 184;
    --bs-tertiary-color: #64748b;
    --bs-tertiary-color-rgb: 100, 116, 139;
    --bs-secondary: #64748b;
    --bs-secondary-rgb: 100, 116, 139;
    --bs-secondary-bg: #334155;
    --bs-secondary-bg-rgb: 51, 65, 85;
    --bs-tertiary-bg: #0b1120;
    --bs-tertiary-bg-rgb: 11, 17, 32;
    --bs-border-color: #334155;
    --bs-link-color: #6ea8fe;
    --bs-link-color-rgb: 110, 168, 254;
    --bs-link-hover-color: #8bb9fe;
    --bs-link-hover-color-rgb: 139, 185, 254;
}

body {
    background: var(--mdc-page-bg);
}

.mdc-layout {
    min-height: 100dvh;
}

/* Zone A — the top bar, full width, on the shell tone. */
.mdc-topbar {
    background-color: var(--mdc-shell-bg);
}

/*
 * "Handbuch" stands on the baseline of the letters M, D, C. An image's baseline is its bottom edge, but the
 * letters of the mark and the wordmark end at y 176 of 200 — 24 units above it. The negative margin moves
 * the image down by those 24/200 of its 22px height, so the letters' foot is the baseline the label sits on.
 * `vertical-align: baseline` undoes Reboot's `middle` for images, which would centre the image instead.
 */
.mdc-manual-brand img {
    vertical-align: baseline;
    margin-bottom: calc(22px * -24 / 200);
}

.mdc-manual-brand-label {
    color: var(--bs-secondary-color);
    font-weight: 600;
}

/* The search field: one width token, as in the shell, and its result list hung below it. */
.mdc-navbar-search {
    width: var(--mdc-navbar-search-width);
}

/*
 * The ⌘K / Ctrl K hint, drawn as app.css draws it, over the empty and unfocused field. From sm rather than
 * the app's lg: the manual's bar carries only the search and the language, so the field has room for
 * placeholder and hint at 14rem; below sm a phone has no key to name.
 */
.mdc-navbar-search-hint {
    display: none;
    position: absolute;
    top: 50%;
    right: .5rem;
    transform: translateY(-50%);
    pointer-events: none;
    padding: .05rem .35rem;
    font-size: .75em;
    color: var(--bs-secondary-color);
    background-color: var(--bs-secondary-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
}

@media (min-width: 992px) {
    .mdc-navbar-search {
        width: var(--mdc-navbar-search-width-lg);
    }
}

@media (min-width: 576px) {
    .mdc-navbar-search:placeholder-shown:not(:focus) {
        padding-right: 3.25rem;
    }

    .mdc-navbar-search:placeholder-shown:not(:focus) + .mdc-navbar-search-hint {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .mdc-navbar-search-form {
        flex: 1 1 auto;
        min-width: 0;
    }

    .mdc-navbar-search {
        width: 100%;
    }
}

.mdc-search-results {
    width: max(100%, 24rem);
    max-width: calc(100vw - 2rem);
    max-height: 70vh;
    overflow-y: auto;
}

.mdc-search-results .dropdown-item {
    white-space: normal;
}

.mdc-search-results .dropdown-item small {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    color: var(--bs-secondary-color);
}

.mdc-search-results .dropdown-item.active small,
.mdc-search-results .dropdown-item:active small {
    color: inherit;
}

/* Zone B — the sidebar: a column on the page tone from md, an off-canvas panel below. */
.mdc-sidebar {
    width: var(--mdc-sidebar-width);
}

@media (min-width: 768px) {
    .mdc-sidebar {
        background-color: var(--mdc-page-bg) !important;
        position: sticky;
        top: 0;
        align-self: flex-start;
        max-height: 100dvh;
        overflow-y: auto;
    }
}

.mdc-nav-stack {
    --bs-nav-link-font-size: .875rem;
    --bs-nav-link-font-weight: 400;
    --bs-nav-link-padding-y: .375rem;
    --bs-nav-link-padding-x: .5rem;
    --bs-nav-pills-link-active-bg: var(--mdc-nav-active-bg);
    --bs-nav-pills-link-active-color: var(--bs-primary-text-emphasis);
    row-gap: .125rem;
    flex-wrap: nowrap;
}

.mdc-nav-stack .nav-link.active {
    font-weight: 600;
}

.mdc-nav-stack .nav-link:not(.active):hover,
.mdc-nav-stack .nav-link:not(.active):focus-visible {
    background-color: var(--mdc-nav-hover-bg);
}

/* A chapter's sections, indented under it; one step quieter than the chapters. */
.mdc-nav-stack .mdc-nav-stack {
    margin: .125rem 0 .25rem .75rem;
    padding-left: .5rem;
    border-left: 1px solid var(--bs-border-color);
    --bs-nav-link-font-size: .8125rem;
}

.mdc-nav-stack .mdc-nav-section-label {
    font-size: .75rem;
    letter-spacing: .02em;
}

/* Zone C — the content: a reading column centred beside the sidebar. */
.mdc-content {
    flex: 1 1 auto;
    min-width: 0;
}

.mdc-manual-column {
    max-width: 48rem;
    margin: 0 auto;
}

.mdc-manual-list > li {
    padding: .75rem 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.mdc-manual-terms dt {
    margin-top: .75rem;
}

.mdc-manual-terms dd {
    margin-bottom: 0;
}

/* A chapter's long text: tables scroll on a narrow screen instead of widening the page. */
.mdc-manual-article table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

.mdc-manual-article h2 {
    font-size: 1.25rem;
    margin-top: 2rem;
}

.mdc-manual-article h3 {
    font-size: 1.05rem;
    margin-top: 1.5rem;
}

.mdc-manual-article pre {
    padding: .75rem;
    background: var(--mdc-surface-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.mdc-manual-more {
    padding: .75rem 1rem;
    background: var(--mdc-surface-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.mdc-manual-foot {
    color: var(--bs-secondary-color);
}
