/*
 Physics II Interactive Course
 Lead creator & developer: Asadbek Jumaboyev Shokirjon o'g'li
 Academic co-author / scientific reviewer:
 Xolboyev Yunusali Xasan o'g'li
 Published under Turin Prepnik
 Pilot Beta v0.9
*/

:root {
    /* Color Palette */
    --bg-color: #121a23;
    --card-bg: #1c2734;
    --text-primary: #e0e0e0;
    --text-secondary: #94a3b8;
    /* Merged from index.html */
    --accent-color: #3498db;
    --accent-hover: #5dade2;
    --border-color: #2c3e50;
    --success-color: #2ecc71;
    --warning-color: #f1c40f;
    --shadow-glow: rgba(52, 152, 219, 0.2);
}

/* Global Reset & Typography */
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.8;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-color);
}

/* Typography */
h1 {
    font-size: 3rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    color: white;
}

h2 {
    color: var(--accent-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 4rem;
    font-size: 1.5rem;
    font-weight: 700;
}

h3 {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 2rem;
    font-size: 1.4rem;
}

p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Highlight Box */
.highlight-box {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(46, 204, 113, 0.05));
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.highlight-box h3 {
    margin-top: 0;
    color: var(--accent-color);
}

/* Key Points List */
.key-points {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
}

.key-points li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.8rem;
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.key-points li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: bold;
}

/* Layout: Header */
.header-bar {
    background-color: rgba(18, 26, 35, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 0 5%;
    width: 100%;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    max-width: 1400px;
    margin: 0 auto;
}

header .home-link {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 1.2rem;
}

header .center-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

header .author-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

header .author-link:hover {
    color: var(--accent-color);
}

@media (max-width: 768px) {
    header .center-title {
        display: none;
    }
}

/* Layout: Main Container */
.container {
    width: 90%;
    max-width: 960px;
    /* Default for content pages */
    margin: 0 auto;
    padding: 2rem 0;
    flex: 1;
}

/* For index page specifically, maybe allow wider? Classes for width control */
.container.wide {
    max-width: 1400px;
}

/* Navigation / Breadcrumb */
.nav-container {
    width: min(100%, 1200px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.55rem 20px 0.7rem;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    min-height: 100%;
    gap: 1rem;
}

.breadcrumb {
    min-width: 0;
    width: 100%;
    flex: 0 0 auto;
    font-size: 0.86rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.28rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: rgba(52, 152, 219, 0.5) transparent;
}

.breadcrumb a,
.breadcrumb span {
    flex: 0 0 auto;
    min-width: max-content;
    overflow: visible;
    text-overflow: clip;
}

.breadcrumb a {
    color: var(--accent-color);
    font-weight: 500;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-secondary);
    opacity: 0.45;
    flex: 0 0 auto;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 650;
}

.breadcrumb-muted,
.breadcrumb-optional {
    color: var(--text-secondary);
}

.course-search-shell {
    margin-left: 0;
    position: relative;
    width: min(420px, 100%);
    flex: 0 0 auto;
    justify-self: end;
}







.course-search-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.36rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.2;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.course-search-bar:focus-within,
.course-search-bar:hover {
    color: white;
    border-color: var(--accent-color);
    background: rgba(52, 152, 219, 0.14);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.12);
}

.course-search-inline-input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
}

.course-search-inline-input::placeholder {
    color: var(--text-secondary);
}

.course-search-dropdown {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(620px, calc(100vw - 2rem));
    max-height: min(520px, 72vh);
    overflow-y: auto;
    z-index: 1200;
    display: grid;
    gap: 0.45rem;
    padding: 0.55rem;
    background: rgba(14, 25, 36, 0.98);
    border: 1px solid rgba(52, 152, 219, 0.42);
    border-radius: 14px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.48);
}

.course-search-dropdown[hidden] {
    display: none;
}

/* Lesson navigation */
.lesson-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 4rem 0 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.lesson-navigation-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    max-width: 48%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.lesson-navigation-link:hover,
.lesson-navigation-link:focus-visible {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(52, 152, 219, 0.1);
    outline: none;
}

.lesson-navigation-next {
    margin-left: auto;
}

.lesson-navigation-finish {
    border-color: rgba(46, 204, 113, 0.65);
    background: rgba(46, 204, 113, 0.1);
}

.lesson-navigation-finish .lesson-navigation-icon {
    color: #6ee7a0;
}

.lesson-navigation-finish:hover,
.lesson-navigation-finish:focus-visible {
    border-color: #6ee7a0;
    color: #b8f5ce;
    background: rgba(46, 204, 113, 0.16);
}

.lesson-navigation-icon {
    flex: 0 0 auto;
    color: var(--accent-color);
    font-size: 1.05rem;
    line-height: 1;
}

.lesson-completion-opinion {
    flex: 1 1 420px;
    max-width: 560px;
    margin-left: auto;
    padding: 1rem;
    border: 1px solid rgba(52, 152, 219, 0.45);
    border-radius: 8px;
    background: rgba(52, 152, 219, 0.06);
}

.lesson-completion-opinion h2 {
    margin: 0 0 0.35rem;
    padding: 0;
    border: 0;
    font-size: 1.1rem;
}

.lesson-completion-opinion p {
    margin: 0 0 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
}

.course-completion-feedback {
    max-width: none;
    margin: 0;
}

.course-completion-feedback summary {
    margin: 0;
    color: var(--accent-color);
    font-weight: 600;
}

/* COMPONENTS */

/* Topics Grid (Index Page) */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.topic-card {
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    min-height: 280px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.card-link {
    display: block;
}

.card-link:hover .topic-card {
    transform: translateY(-8px);
    border-color: var(--accent-color);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4), 0 0 15px var(--shadow-glow);
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.02), transparent);
}

.card-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    border: none;
    padding: 0;
    margin-top: 0;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

.card-link:hover .card-header h2 {
    color: var(--accent-color);
}

.card-body {
    padding: 1rem 1.5rem 1.5rem;
    flex-grow: 1;
}

.topic-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.topic-card ul li a {
    display: block;
    color: var(--text-secondary);
    padding: 10px 12px;
    margin: 4px -12px;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.topic-card ul li a:hover {
    color: white;
    background-color: rgba(52, 152, 219, 0.15);
    border-left-color: var(--accent-color);
    padding-left: 20px;
}

.placeholder {
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px dashed var(--border-color);
    background-color: transparent;
    opacity: 0.6;
}

.placeholder:hover {
    opacity: 1;
    border-color: var(--text-secondary);
}

.placeholder h2 {
    color: var(--text-secondary);
    border: none;
    margin: 0;
}

.placeholder p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 10px;
}


/* Math Blocks */
.math-block {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-color);
}

/* Variable Definitions List */
.def-list {
    display: grid;
    gap: 15px;
    margin: 2rem 0;
    background: rgba(0, 0, 0, 0.2);
    padding: 2rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
}

.def-item {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: baseline;
}

.def-symbol {
    font-weight: 700;
    color: var(--accent-color);
    font-family: 'Times New Roman', serif;
    font-size: 1.3rem;
}

.def-text {
    color: var(--text-secondary);
}


/* Iframes / Simulators */
.iframe-container {
    width: 100%;
    margin: 3rem 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background-color: #000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

iframe {
    width: 100%;
    border: none;
    display: block;
}

/* Helper classes for iframe heights */
.sim-frame {
    height: 600px;
}

.diagram-frame {
    height: 650px;
}

.iframe-container iframe {
    height: 600px;
}

.course-responsive-embed {
    height: clamp(620px, 72vh, 780px);
    min-height: 560px;
}

.course-fullscreenable-embed {
    position: relative;
}

.course-responsive-frame {
    height: 100% !important;
    min-height: 0;
}

.course-fullscreen-button {
    position: absolute;
    right: 0.75rem;
    top: 0.75rem;
    z-index: 20;
    min-height: 34px;
    padding: 0.42rem 0.72rem;
    border: 1px solid rgba(148, 163, 184, 0.48);
    border-radius: 999px;
    background: rgba(7, 12, 20, 0.72);
    color: #eaf6ff;
    font: 600 0.78rem/1.1 'Inter', sans-serif;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
    backdrop-filter: blur(10px);
}

.course-fullscreenable-embed:hover .course-fullscreen-button,
.course-fullscreenable-embed:focus-within .course-fullscreen-button,
.course-fullscreen-button:focus-visible {
    opacity: 1;
    transform: translateY(0);
}

.course-fullscreen-button:hover,
.course-fullscreen-button:focus-visible {
    background: rgba(37, 99, 235, 0.88);
    border-color: rgba(147, 197, 253, 0.9);
    outline: none;
}

.course-fullscreen-active {
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #000 !important;
}

.course-fullscreen-active .course-responsive-frame,
.course-fullscreen-active iframe {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
}

.course-fullscreen-active .course-fullscreen-button {
    opacity: 1;
    transform: none;
    right: 1rem;
    top: 1rem;
}

.course-fullscreen-modal-open {
    overflow: hidden;
}

.course-fullscreen-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #020617;
}

.course-fullscreen-modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.96);
    color: #e2e8f0;
    font-weight: 700;
}

.course-fullscreen-close {
    min-height: 36px;
    padding: 0.42rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.48);
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.85);
    color: white;
    cursor: pointer;
    font-weight: 700;
}

.course-fullscreen-modal-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

@media (hover: none), (max-width: 700px) {
    .course-fullscreen-button {
        opacity: 1;
        transform: none;
        min-height: 38px;
    }
}

.course-potential-embed,
.course-continuous-embed {
    height: clamp(680px, 74vh, 800px) !important;
}

.course-conductor-lab-embed {
    height: clamp(720px, 76vh, 840px) !important;
}

.course-conductor-2d-embed {
    height: clamp(620px, 70vh, 760px) !important;
}

.course-capacitor-embed {
    height: clamp(680px, 74vh, 800px) !important;
}

.course-lorentz-bfv-embed {
    height: clamp(660px, 74vh, 820px) !important;
}

/* Default fallback */

@media (max-width: 900px) {
    .diagram-frame,
    .sim-frame,
    .iframe-container iframe {
        height: clamp(780px, 118svh, 1040px);
        min-height: 720px;
    }

    .course-responsive-embed {
        height: clamp(780px, 118svh, 1040px);
        min-height: 720px;
    }

    .course-responsive-embed .course-responsive-frame {
        height: 100% !important;
        min-height: 0;
    }

    .course-potential-embed .course-responsive-frame,
    .course-continuous-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-conductor-lab-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-conductor-2d-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-capacitor-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-potential-embed,
    .course-continuous-embed,
    .course-conductor-lab-embed,
    .course-conductor-2d-embed,
    .course-capacitor-embed,
    .course-lorentz-bfv-embed {
        height: clamp(780px, 118svh, 1040px) !important;
        min-height: 720px;
    }
}

@media (max-width: 560px) {
    .diagram-frame,
    .sim-frame,
    .iframe-container iframe {
        height: clamp(860px, 138svh, 1180px);
        min-height: 800px;
    }

    .course-responsive-embed {
        width: 100%;
        height: clamp(860px, 138svh, 1180px);
        min-height: 800px;
    }

    .course-responsive-embed .course-responsive-frame {
        height: 100% !important;
        min-height: 0;
    }

    .course-potential-embed .course-responsive-frame,
    .course-continuous-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-conductor-lab-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-conductor-2d-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-capacitor-embed .course-responsive-frame {
        height: 100% !important;
    }

    .course-potential-embed,
    .course-continuous-embed,
    .course-conductor-lab-embed,
    .course-conductor-2d-embed,
    .course-capacitor-embed,
    .course-lorentz-bfv-embed {
        height: clamp(860px, 138svh, 1180px) !important;
        min-height: 800px;
    }
}


/* Deep Dive Buttons */
.dive-wrapper {
    display: flex;
    justify-content: center;
    margin: 2rem 0 3rem;
}

.dive-btn,
.deep-dive-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(52, 152, 219, 0.08);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(52, 152, 219, 0.45);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background-color 0.2s;
    width: fit-content;
    max-width: 100%;
}

.dive-btn:hover,
.deep-dive-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.22);
    background: rgba(52, 152, 219, 0.18);
    border-color: var(--accent-color);
    color: white;
}

.deep-dive-link span[aria-hidden="true"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    background: rgba(52, 152, 219, 0.18);
    color: var(--accent-hover);
    flex: 0 0 auto;
}

.deep-dive-return {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    justify-content: center;
    margin: 0;
    color: var(--text-primary);
    background: rgba(52, 152, 219, 0.1);
    border: 1px solid rgba(52, 152, 219, 0.45);
    border-radius: 999px;
    padding: 0.75rem 1.15rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
}

.deep-dive-return::before {
    content: "<";
}

.deep-dive-return:hover {
    color: white;
    border-color: var(--accent-color);
    background: rgba(52, 152, 219, 0.18);
    text-decoration: none;
}

.deep-dive-return-wrap {
    display: flex;
    justify-content: center;
    margin: 3rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

footer:empty,
footer[hidden] {
    display: none !important;
}

.course-attribution-footer {
    display: grid;
    gap: 0.25rem;
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.82rem;
    background-color: var(--bg-color);
    margin-top: auto;
}

.notation-toggle {
    margin: -1rem 0 1.25rem;
    border: 1px solid rgba(52, 152, 219, 0.45);
    background: rgba(52, 152, 219, 0.08);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 0.42rem 0.8rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.notation-toggle:hover {
    border-color: var(--accent-color);
    color: white;
    background: rgba(52, 152, 219, 0.18);
}

.notation-panel {
    margin: -0.75rem 0 1.75rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.notation-panel h3 {
    margin: 0 0 0.75rem;
    color: var(--accent-color);
    font-size: 1rem;
}

.notation-row {
    display: grid;
    grid-template-columns: minmax(90px, 0.35fr) 1fr auto;
    gap: 0.75rem;
    align-items: baseline;
    padding: 0.45rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.notation-row:first-of-type {
    border-top: 0;
}

.notation-row strong {
    color: var(--accent-color);
    font-family: "Times New Roman", serif;
    font-size: 1.1rem;
}

.notation-row a {
    color: var(--accent-color);
    font-size: 0.85rem;
    white-space: nowrap;
}

.search-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin: 1.5rem 0 2rem;
}

.search-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-primary);
    padding: 0.9rem 1rem;
    font: inherit;
    font-size: 1.05rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.search-results {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.search-result {
    display: block;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
}

.search-result:hover {
    border-color: var(--accent-color);
    background: rgba(52, 152, 219, 0.08);
}

.search-result-title {
    color: white;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.search-result-meta {
    color: var(--accent-color);
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.search-result-snippet {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.search-open {
    overflow: hidden;
}

.course-search-overlay[hidden] {
    display: none;
}

.course-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: start center;
    padding: 8vh 1rem 1rem;
}

.course-search-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 12, 0.72);
    backdrop-filter: blur(8px);
}

.course-search-modal {
    position: relative;
    width: min(760px, calc(100vw - 2rem));
    max-height: min(760px, 84vh);
    display: flex;
    flex-direction: column;
    background: rgba(14, 25, 36, 0.98);
    border: 1px solid rgba(52, 152, 219, 0.42);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.course-search-input-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--accent-color);
}

.course-search-input-wrap input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 1.05rem;
}

.course-search-input-wrap button {
    width: 2rem;
    height: 2rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
}

.course-search-input-wrap button:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.course-search-modal-results {
    display: grid;
    gap: 0.5rem;
    padding: 0.65rem;
    overflow-y: auto;
}

.course-search-empty {
    color: var(--text-secondary);
    padding: 1.4rem 1rem;
}

.course-search-result {
    display: grid;
    gap: 0.28rem;
    padding: 0.85rem 0.95rem;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--text-secondary);
    text-decoration: none;
}

.course-search-result:hover,
.course-search-result:focus-visible {
    border-color: rgba(52, 152, 219, 0.45);
    background: rgba(52, 152, 219, 0.1);
    outline: none;
}

.course-search-result strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.course-search-result span:last-child {
    line-height: 1.45;
}

.course-search-result-type {
    color: var(--accent-color);
    font-size: 0.78rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.course-search-result mark,
.course-find-highlight {
    background: rgba(250, 204, 21, 0.28);
    color: #fff7cc;
    border-radius: 0.2em;
    padding: 0.02em 0.15em;
}

@media (max-width: 700px) {
    .math-block {
        overflow-x: auto;
        overflow-y: hidden;
    }

    mjx-container[jax="CHTML"] {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 0.12rem;
    }

    .nav-container {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 0.45rem;
        padding: 0.5rem 14px 0.65rem;
    }

    .course-search-shell {
        width: 100%;
        flex-basis: auto;
    }





    .lesson-navigation {
        margin-top: 2.5rem;
    }

    .lesson-navigation-link {
        max-width: 50%;
        padding: 0.6rem 0.7rem;
        font-size: 0.82rem;
    }

    .lesson-completion-opinion {
        flex-basis: 100%;
        max-width: none;
        width: 100%;
        margin-left: 0;
        order: 3;
    }

    .course-search-dropdown {
        position: fixed;
        top: 5.8rem;
        right: 0.75rem;
        left: 0.75rem;
        transform: none;
        width: auto;
    }

    .notation-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}


/* Ordered Properties Lists */
ol.properties-list {
    counter-reset: item;
    list-style-type: none;
    padding: 0;
    margin-bottom: 2rem;
}

ol.properties-list li {
    position: relative;
    padding-left: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

ol.properties-list li strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

ol.properties-list li::before {
    content: counter(item);
    counter-increment: item;
    position: absolute;
    left: 0;
    top: 0;
    width: 2.5rem;
    height: 2.5rem;
    background-color: var(--card-bg);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    border-radius: 50%;
    text-align: center;
    line-height: 2.5rem;
    font-weight: bold;
    font-family: 'Inter', sans-serif;
}

/* Footer */
footer {
    text-align: center;
    padding: 4rem 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    background-color: var(--bg-color);
    margin-top: auto;
}

footer.course-attribution-footer {
    padding: 1.5rem 1rem 2rem;
    font-size: 0.82rem;
}

body.diagram-mode {
    background-color: #000;
    overflow: hidden;
    padding: 0;
    margin: 0;
    display: block;
    /* Override flex column */
}

/* --- CHAPTER INDEX PAGE STYLES --- */

.main-title {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 1rem;
    display: inline-block;
}

.intro-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 3rem;
}

.intro-text strong {
    color: var(--text-primary);
    font-weight: 500;
}

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.topic-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--card-bg);
    padding: 18px 25px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.topic-row:hover {
    transform: translateY(-3px);
    background-color: #2c3e50;
    border-color: var(--accent-color);
}

.topic-row .text-content h2 {
    margin: 0 0 4px 0;
    font-size: 1.3em;
    font-weight: 500;
    color: var(--text-primary);
    border: none;
    /* Reset from global h2 */
    padding: 0;
}

.topic-row .text-content p {
    margin: 0;
    font-size: 0.9em;
    color: var(--text-secondary);
    font-style: italic;
}

.topic-row .arrow-icon {
    font-size: 1.5em;
    color: var(--border-color);
    transition: transform 0.2s ease, color 0.2s ease;
}

.topic-row:hover .arrow-icon {
    transform: translateX(5px);
    color: var(--accent-color);
}
/* Compact learning chrome and inline, context-specific feedback. */
html:has(body.course-page) { overscroll-behavior-y: none; }
body.course-page {
    margin: 0;
    overflow-x: clip;
    overflow-y: visible;
    overscroll-behavior-y: none;
}
body.course-page .header-bar { padding: 0; margin-bottom: 1rem; }
body.course-page .nav-container {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem; align-items: center; padding: 0.5rem 20px;
}
body.course-page .header-bar header { padding-top: 1rem; padding-bottom: 1rem; }
.course-home-title { margin: 0; font-size: 1.5rem; line-height: 1.3; letter-spacing: 0; }
.course-search-shell, .course-search-bar, .course-search-dropdown { box-sizing: border-box; }
.course-search-dropdown { left: auto; right: 0; transform: none; }
body.course-page .header-bar header { box-sizing: border-box; height: auto; min-height: 60px; }
footer.course-attribution-footer {
    padding: 1rem; font-size: 0.75rem; line-height: 1.6; gap: 0;
    border: 0; background: transparent;
}
.course-attribution-footer a { color: var(--text-secondary); text-decoration: underline; }
.course-footer-identity { margin-bottom: 0.45rem; }
.course-footer-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.25rem; }
.opinion-feedback { max-width: 440px; margin: 0.25rem auto; text-align: left; font-size: 0.82rem; }
.opinion-feedback summary { color: var(--text-secondary); cursor: pointer; padding: 0.35rem 0; width: fit-content; margin: auto; }
.opinion-form { display: grid; gap: 0.7rem; padding: 0.75rem 0; }
.opinion-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.opinion-form legend { color: var(--text-primary); font-size: 0.95rem; margin-bottom: 0.4rem; }
.opinion-options { display: flex; flex-wrap: wrap; gap: 1rem; }
.opinion-options label { display: flex; align-items: center; gap: 0.3rem; min-height: 36px; cursor: pointer; }
.opinion-form > label { display: grid; gap: 0.35rem; }
.opinion-form textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; padding: 0.5rem; color: var(--text-primary); background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 4px; }
.opinion-form small { line-height: 1.5; color: var(--text-secondary); }
.opinion-form button { justify-self: start; min-height: 36px; font: inherit; padding: 0.35rem 1rem; border: 1px solid var(--border-color); border-radius: 4px; background: var(--card-bg); color: var(--text-primary); cursor: pointer; }
.opinion-form :focus-visible, .opinion-feedback summary:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 3px; }
.opinion-form [role="status"] { margin: 0; font-size: 0.82rem; }
.opinion-form [role="status"]:empty { display: none; }
.credits h2 { font-size: 1.1rem; }
.credits h1 { font-size: 1.75rem; line-height: 1.3; }
.credits section { margin-bottom: 1.5rem; }
@media (max-width: 700px) {
    body.course-page .nav-container { grid-template-columns: minmax(0, 1fr); gap: 0.35rem; padding: 0.5rem 14px; }
    body.course-page .header-bar header { gap: 0.75rem; padding: 1rem; flex-direction: column; align-items: stretch; }
    .course-home-title { font-size: 1.35rem; }
    .opinion-options label, .opinion-form button { min-height: 44px; }
    .course-page .katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
    .course-search-shell { width: 100%; }
    .course-search-dropdown { position: absolute; top: calc(100% + 0.35rem); left: 0; right: 0; width: 100%; }
}
body.course-page .header-bar header { flex-direction: column; align-items: stretch; gap: 0.6rem; }
body.course-page .header-bar header .course-search-shell { align-self: flex-end; }
.course-release-notice {
    box-sizing: border-box; width: 100%; max-width: 1400px; margin: -0.5rem auto 1rem;
    padding: 0.35rem 2rem; display: flex; align-items: center; gap: 0.65rem;
    color: var(--text-secondary); font-size: 0.8rem; line-height: 1.4;
}
.course-release-notice a { color: var(--accent-color); text-decoration: underline; }
.course-release-notice button {
    margin-left: auto; padding: 0 0.3rem; border: 0; background: none;
    color: var(--text-secondary); font-size: 1.2rem; cursor: pointer;
}
.course-release-notice :focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
@media (max-width: 700px) { .course-release-notice { padding: 0.35rem 1rem; } }
