/*
   Markdown Viewer
*/

:root {
    /*
     * The site header (#top) is sticky, so anything reached by an in-page anchor
     * has to be held clear of it or the header covers what you jumped to. Every
     * anchor target on these pages offsets by this one value - change it here if
     * the header height ever changes.
     */
    --anchor-offset: 85px;

    /*
     * Width of the course outline's caret column. Each nested level indents by
     * exactly this much, so a row's caret sits directly under its parent's label
     * rather than hanging to the left of it.
     */
    --outline-indent: 1.1rem;
}

.markdown-viewer-wrapper {
    background: #fff;
    min-height: 100vh;
}

/* Top Navigation Bar */
.markdown-nav-top {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.nav-back {
    color: #8e6f3e;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-back:hover {
    color: #6d5530;
}

/* Main Content Layout */
.markdown-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

.markdown-sidebar {
    margin-bottom: 2rem;
}

/* Table of Contents Sidebar */
.toc-sidebar {
    margin-top: 1.5rem;
    border-top: 1px solid #e9ecef;
    padding-top: 1rem;
}

.toc-header {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

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

.toc-item {
    margin: 0 0 0.1rem;
    line-height: 1.35;
}

.toc-link {
    display: block;
    padding: 0.3rem 0.5rem;
    font-size: 0.82rem;
    color: #555;
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 3px 3px 0;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    /* Wrap long module/resource names instead of truncating them — the sidebar
       column is narrow and titles were being cut off mid-word. */
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

.toc-link:hover {
    color: #1ea3b7;
    border-left-color: rgba(30, 163, 183, 0.4);
    background: rgba(30, 163, 183, 0.05);
    text-decoration: none;
}

.toc-link.active {
    color: #1ea3b7;
    border-left-color: #1ea3b7;
    background: rgba(30, 163, 183, 0.08);
    font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Course outline — two-level tree of modules and the contents of each module.
   Everything is expanded permanently: no accordion, no "show contents" step, so
   any item in the course is a single click from anywhere else in it. Length is
   handled by sticking the panel and scrolling it, which costs no clicks.
----------------------------------------------------------------------------- */
.toc-sidebar--outline {
    position: sticky;
    top: 1rem;
}

.toc-sidebar--outline .toc-nav {
    max-height: calc(100vh - 11rem);
    overflow-y: auto;
}

/* Where the page has a sidebar panel of its own, the outline gives way: it does
   not pin itself, and it keeps to a height that leaves that panel in view. */
.toc-sidebar--outline.toc-sidebar--compact {
    position: static;
}

.toc-sidebar--outline.toc-sidebar--compact .toc-nav {
    max-height: 21rem;
}

/*
 * Jumping to a unit from the outline lands on the card's anchor. Without the
 * offset the sticky header sits over the card heading and the jump appears to
 * land a row low, on the contents.
 */
.outline-anchor {
    scroll-margin-top: var(--anchor-offset);
}

/* A caret and a link side by side: the caret expands, the link navigates */
.outline-row {
    display: flex;
    align-items: flex-start;
}

.outline-row > .toc-link {
    flex: 1 1 auto;
    min-width: 0;
}

.outline-toggle {
    flex: 0 0 auto;
    width: var(--outline-indent);
    padding: 0.3rem 0 0 0;
    margin: 0;
    border: 0;
    background: none;
    color: #9a9a9a;
    font-size: 0.75rem;
    line-height: 1.35;
    /* Centred, not left-aligned: the caret rotates about its own centre, and
       flush against the column edge the rotated glyph spills past it and is
       clipped by the scrolling nav. */
    text-align: center;
    cursor: pointer;
}

.outline-toggle:hover,
.outline-toggle:focus {
    color: #1ea3b7;
}

.outline-toggle .fa {
    transition: transform 0.15s ease;
}

.outline-toggle[aria-expanded="true"] .fa {
    transform: rotate(90deg);
}

/* Keeps childless rows aligned with rows that do have a caret */
.outline-toggle--empty {
    cursor: default;
}

/* Nesting supplies the indentation, at whatever depth a course happens to use */
.outline-children {
    list-style: none;
    margin: 0 0 0.25rem;
    padding-left: var(--outline-indent);
}

.outline-module > .outline-row > .toc-link {
    font-weight: 600;
    color: #3a3a3a;
}

/* Titled groupings of materials that sit between a module and its items */
.outline-section > .outline-row > .toc-link {
    font-weight: 500;
    color: #4f4f4f;
    font-size: 0.79rem;
}

/* Leaf rows have no caret, so pad by the caret column to line up with the
   labels of sibling rows that do */
.outline-asset > .toc-link {
    padding-left: var(--outline-indent);
    font-size: 0.78rem;
    color: #6a6a6a;
}

.outline-icon {
    width: 1em;
    margin-right: 0.4rem;
    opacity: 0.65;
}

.outline-locked > .toc-link {
    color: #a0a0a0;
    font-style: italic;
    cursor: default;
}

/* Indentation per heading level */
.toc-level-1 .toc-link { padding-left: 0.5rem; }
.toc-level-2 .toc-link { padding-left: 0.5rem; }
.toc-level-3 .toc-link { padding-left: 1.25rem; font-size: 0.8rem; }
.toc-level-4 .toc-link { padding-left: 2rem;    font-size: 0.78rem; color: #777; }
.toc-level-5 .toc-link { padding-left: 2.75rem; font-size: 0.75rem; color: #888; }
.toc-level-6 .toc-link { padding-left: 3.25rem; font-size: 0.73rem; color: #999; }


.markdown-content-wrapper {
    padding: 0 30px;
}

/* Header Section */
.markdown-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e9ecef;
}

.markdown-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    color: #1a1a1a;
    line-height: 1.2;
}

.markdown-header .badge {
    display: inline-block;
    margin-left: 1rem;
}

/* Metadata Info */
.metadata-info {
    display: flex;
    gap: 2rem;
    margin-top: 0.75rem;
    color: #666;
    font-size: 0.95rem;
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metadata-item .fa {
    color: #8e6f3e;
    font-weight: 600;
}

/* Callout Cards Grid (Questions & Objectives) */
.callouts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

/* Individual Callout Card */
.callout-card {
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

.callout-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.callout-card-header {
    padding: 1rem 1.5rem;
    border-bottom: 3px solid #cfb991;
}

.callout-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: #8e6f3e;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.callout-card-title .fa {
    font-size: 1.25rem;
}

.callout-list {
    list-style: none;
    padding: 1.5rem;
    margin: 0;
}

.callout-list li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    line-height: 1.6;
}

.callout-list li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #cfb991;
    font-weight: bold;
}

.callout-list li:last-child {
    margin-bottom: 0;
}

/* Card Type Specific Styling */
.callout-questions-card {
    background: linear-gradient(135deg, rgba(30, 163, 183, 0.08) 0%, rgba(88, 151, 251, 0.08) 100%);
}

.callout-questions-card .callout-card-header {
    background: rgba(30, 163, 183, 0.1);
    border-color: rgba(30, 163, 183, 0.5);
}

.callout-questions-card .callout-card-title {
    color: rgba(30, 163, 183, 1);
}

.callout-questions-card .callout-list li:before {
    color: rgba(30, 163, 183, 1);
}

.callout-objectives-card {
    background: linear-gradient(135deg, rgba(88, 151, 251, 0.08) 0%, rgba(90, 184, 255, 0.08) 100%);
}

.callout-objectives-card .callout-card-header {
    background: rgba(88, 151, 251, 0.1);
    border-color: rgba(88, 151, 251, 0.5);
}

.callout-objectives-card .callout-card-title {
    color: rgba(88, 151, 251, 1);
}

.callout-objectives-card .callout-list li:before {
    color: rgba(88, 151, 251, 1);
}

/* PDF Viewer */

.pdf-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 2px solid #e9ecef;
    gap: 1rem;
}

.pdf-nav-top {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    margin-bottom: 0;
}

.pdf-nav-bottom {
    border-bottom: none;
    border-top: 2px solid #e9ecef;
    margin-bottom: 1.5rem;
}

.pdf-nav-pages {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pdf-nav-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: #495057;
}

.pdf-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    color: #495057;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.pdf-nav-btn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.pdf-nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.pdf-page-input {
    width: 3.5rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: center;
    font-size: 0.875rem;
    color: #495057;
}

.pdf-total {
    color: #6c757d;
}

.pdf-zoom-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pdf-zoom-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    color: #495057;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.pdf-zoom-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.pdf-zoom-label {
    font-size: 0.85rem;
    color: #495057;
    min-width: 3.5rem;
    text-align: center;
}

.pdf-canvas-area {
    background: #f0f0f0;
    padding: 1.5rem 1rem;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-x: auto;
    min-height: 400px;
}

.pdf-status {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #6c757d;
    font-size: 0.95rem;
    width: 100%;
}

#pdf-canvas {
    display: block;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
}

/* Image Viewer */

.image-viewer-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: #f0f0f0;
    padding: 1.5rem;
    border-radius: 6px;
    min-height: 300px;
    margin-bottom: 1.5rem;
}

.image-asset {
    max-width: 100%;
    height: auto;
    display: block;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.image-status {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #6c757d;
    font-size: 0.95rem;
    width: 100%;
}

/* Audio Viewer */

.audio-viewer-area {
    padding: 2rem 1.5rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    text-align: center;
}

.audio-player {
    width: 100%;
    max-width: 640px;
    display: block;
    margin: 0 auto 1rem;
}

.audio-meta {
    font-size: 0.875rem;
    margin: 0;
}

/* Video Viewer */

.video-container {
    margin-bottom: 1.5rem;
}


/* Footer Section */
.markdown-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    row-gap: 0.75rem;
    width: 100%;
}

.footer-content>.badges {
    left: 0;
    margin-right: auto;
}

.footer-content>.download-btn {
    right: 0;
    margin-left: auto;
}

.badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.875rem;
}

.badge-success {
    background: #d4edda;
    color: #155724;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    text-decoration: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .markdown-content-wrapper {
        padding: 0 15px;
    }

    .markdown-title {
        font-size: 1.75rem;
    }

    .callouts-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 576px) {
    .markdown-viewer-wrapper {
        background: #fff;
    }

    .markdown-content-wrapper {
        padding: 0 10px;
    }

    .markdown-sidebar {
        margin-bottom: 1.5rem;
    }

    .markdown-title {
        font-size: 1.5rem;
    }

    .callout-card-title {
        font-size: 1rem;
    }

    .callout-list {
        padding: 1rem;
    }

}

/* Download button (pdf/image/markdown/audio viewers share this footer) - icon
   only below 425px, same breakpoint as the PDF toolbar cutoff this pairs with.
   The accessible name comes from the button's own aria-label, not this text,
   so hiding it here doesn't affect screen readers. */
@media (max-width: 425px) {
    .download-btn-text {
        display: none;
    }
}
