/* AERPAW User Manual (Wagtail) — uses the portal palette from common.css:
   blue #213e97, green #4C8508 */

.manual-layout {
    max-width: 1400px;
    margin: 0 auto;
}

/* ---------- Sidebar ---------- */

.manual-sidebar {
    font-size: 0.875rem;
}

@media (min-width: 992px) {
    /* Fixed-width column instead of col-lg-3 (25%), so wide screens give the space to the article */
    .manual-layout > .manual-aside {
        width: 15.5rem;
    }

    /* Sticky wrapper holds the border and the arrow; the nav inside scrolls on its own.
       Keeping overflow off the wrapper stops the arrow being clipped on the border line. */
    .manual-sidebar-shell {
        position: sticky;
        top: 1rem;
        border-right: 1px solid #dee2e6;
        padding-right: 0.75rem;
        min-height: 2.5rem;
    }

    .manual-sidebar {
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        padding-right: 0.5rem;
    }
}

.manual-sidebar-home {
    display: block;
    font-weight: 800;
    color: #213e97;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.manual-nav ul {
    padding-left: 0.85rem;
    border-left: 1px solid #e9ecef;
    margin-left: 0.4rem;
}

.manual-nav-link {
    display: block;
    color: #343a40;
    text-decoration: none;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    line-height: 1.3;
}

.manual-nav-link:hover,
.manual-sidebar-home:hover {
    background-color: #f1f4fb;
    color: #213e97;
}

.manual-nav-link.active,
.manual-sidebar-home.active {
    background-color: #213e97;
    color: #fff;
}

/* <details>/<summary> disclosure. display:flex drops the native marker, so draw
   a chevron: clicking it expands/collapses, clicking the link navigates. */
.manual-nav summary {
    display: flex;
    align-items: baseline;
    cursor: pointer;
    list-style: none;
}

.manual-nav summary::-webkit-details-marker {
    display: none;
}

.manual-nav summary::before {
    content: '';
    flex: 0 0 auto;
    width: 0.4rem;
    height: 0.4rem;
    margin: 0 0.35rem 0 0.1rem;
    border-right: 1.5px solid #6c757d;
    border-bottom: 1.5px solid #6c757d;
    transform: rotate(-45deg);
    transition: transform 0.15s;
}

.manual-nav details[open] > summary::before {
    transform: rotate(45deg);
}

.manual-nav summary .manual-nav-link {
    flex: 1;
}

/* Leaf links line up with the text of expandable siblings */
.manual-nav li > .manual-nav-link {
    margin-left: 0.85rem;
}

/* ---------- Article ---------- */

.manual-article {
    min-width: 0; /* lets wide code blocks scroll instead of stretching the column */
}

.manual-breadcrumbs {
    font-size: 0.85rem;
}

/* ---------- Sidebar hide/show (desktop) ---------- */

/* Round arrow sitting on the sidebar's right border: "<" hides, ">" shows */
.manual-sidebar-toggle {
    position: absolute;
    top: 0.15rem;
    right: -0.8rem;
    z-index: 2;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #213e97;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.manual-sidebar-toggle:hover,
.manual-sidebar-toggle:focus-visible {
    color: #fff;
    background: #213e97;
    border-color: #213e97;
}

/* One chevron-left icon, flipped to ">" when hidden. Rotating (instead of swapping
   classes) also works after FontAwesome's JS has replaced the <i> with an <svg>. */
.manual-sidebar-toggle svg,
.manual-sidebar-toggle i {
    transition: transform 0.2s;
}

@media (min-width: 992px) {
    /* Collapsed: the column shrinks to a thin rail that keeps only the ">" arrow */
    .manual-layout.manual-sidebar-hidden > .manual-aside {
        width: 2.25rem;
    }

    .manual-layout.manual-sidebar-hidden .manual-sidebar-shell {
        padding-right: 0;
    }

    /* !important to beat Bootstrap's d-lg-block on the same element */
    .manual-layout.manual-sidebar-hidden #manual-sidebar-collapse {
        display: none !important;
    }

    .manual-layout.manual-sidebar-hidden .manual-sidebar-toggle svg,
    .manual-layout.manual-sidebar-hidden .manual-sidebar-toggle i {
        transform: rotate(180deg);
    }
}

.manual-section-heading {
    font-weight: 800;
    color: #213e97;
    font-size: 1.4rem;
    margin-top: 2rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid #4C8508;
}

.manual-subheading {
    font-weight: 700;
    color: #213e97;
    margin-top: 1.5rem;
}

/* Keep sub-headings smaller than the 1.4rem section headings */
h3.manual-subheading {
    font-size: 1.2rem;
}

h4.manual-subheading {
    font-size: 1.05rem;
}

/* Headings typed inside rich text (imported pages, the editor's heading buttons):
   same sizes as Heading blocks, which carry their own classes */
.manual-richtext h2,
.manual-body > h2:not([class]) {
    font-size: 1.3rem;
    font-weight: 700;
    color: #213e97;
    margin-top: 1.5rem;
}

.manual-richtext h3,
.manual-body > h3:not([class]) {
    font-size: 1.15rem;
    font-weight: 700;
    color: #213e97;
    margin-top: 1.25rem;
}

.manual-richtext h4,
.manual-body > h4:not([class]) {
    font-size: 1rem;
    font-weight: 700;
    margin-top: 1rem;
}

.manual-section-heading,
.manual-subheading,
[id^="fig-"] {
    scroll-margin-top: 1rem;
}

.manual-anchor {
    margin-left: 0.4rem;
    color: #adb5bd;
    text-decoration: none;
    opacity: 0;
    font-weight: 400;
}

.manual-section-heading:hover .manual-anchor,
.manual-subheading:hover .manual-anchor,
.manual-anchor:focus {
    opacity: 1;
}

.manual-richtext a,
.manual-body a:not(.btn):not(.manual-download) {
    color: #4C8508;
}

.manual-onpage {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.875rem;
}

.manual-onpage a {
    color: #4C8508;
}

/* ---------- Figures ---------- */

.manual-figure {
    display: block;
    margin: 1rem 0 1.5rem;
}

.manual-figure-half {
    max-width: 50%;
}

.manual-figure-third {
    max-width: 33%;
}

@media (max-width: 767.98px) {
    .manual-figure-half,
    .manual-figure-third {
        max-width: 100%;
    }
}

.manual-gallery .manual-figure {
    margin: 0;
}

/* ---------- Code ---------- */

.manual-code {
    margin: 1rem 0 1.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
}

.manual-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f1f3f5;
    border-bottom: 1px solid #dee2e6;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    color: #495057;
    font-family: var(--bs-font-monospace);
}

.manual-copy-btn {
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    color: #495057;
}

.manual-code pre {
    margin: 0;
    background: #f8f9fa;
}

.manual-code pre code {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    white-space: pre;
    overflow-x: auto;
}

.manual-code pre code.hljs {
    background: #f8f9fa;
}

/* ---------- Tables ---------- */

.manual-body table:not(.manual-table) {
    /* TableBlock output has no Bootstrap classes */
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.manual-body table:not(.manual-table) th,
.manual-body table:not(.manual-table) td {
    border: 1px solid #dee2e6;
    padding: 0.35rem 0.6rem;
    vertical-align: top;
}

.manual-body table:not(.manual-table) thead th {
    background: #f8f9fa;
}

.manual-table caption {
    color: #213e97;
}

/* ---------- Steps ---------- */

.manual-steps {
    counter-reset: step;
    list-style: none;
    padding-left: 0;
}

.manual-step {
    counter-increment: step;
    position: relative;
    padding-left: 2.75rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-left: 2px solid #dee2e6;
    margin-left: 0.9rem;
}

.manual-step::before {
    content: counter(step);
    position: absolute;
    left: -0.95rem;
    top: 0;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: #213e97;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.manual-step:last-child {
    border-left-color: transparent;
}

/* ---------- Video ---------- */

/* oEmbed iframes come with fixed width/height attributes; fill the 16:9 box instead */
.manual-video .ratio iframe {
    width: 100%;
    height: 100%;
}

/* ---------- Misc ---------- */

.manual-chapter-card {
    transition: border-color 0.15s, box-shadow 0.15s;
}

.manual-chapter-card:hover {
    border-color: #213e97;
    box-shadow: 0 2px 6px rgba(33, 62, 151, 0.15);
}

.manual-download:hover {
    background-color: #f1f4fb;
}

@media (max-width: 991.98px) {
    .manual-sidebar {
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 0.75rem;
    }
}
