/* ===== CSS VARIABLES FOR THEME SWITCHING ===== */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-accent: #21262d;
    --text-primary: #f0f6fc;
    --text-secondary: #7d8590;
    --text-accent: #58a6ff;
    --border-color: #484f58;
    --border-accent: #9f9f9f;
    --shadow: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-accent: #21262d;
    --text-primary: #f0f6fc;
    --text-secondary: #7d8590;
    --text-accent: #58a6ff;
    --border-color: #484f58;
    --border-accent: #9f9f9f;
    --shadow: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9f9f9;
    --bg-accent: #fff3cd;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-accent: #2196F3;
    --border-color: #dddddd;
    --border-accent: #6D6E71;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* ===== GENERAL STYLES ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Times New Roman', Times, serif;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 16px;
}

/* ===== LAYOUT CONTAINER ===== */
.container {
    margin: 0 auto;
    width: 65%;
    max-width: 1200px;
    min-height: 100vh;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    width: 100%;
    padding: 20px 30px;
}

/* ===== CONTENT WITH SIDEBAR ===== */
.content-with-sidebar {
    display: flex;
    gap: 30px;
    margin-top: 1rem;
}

/* ===== TABLE OF CONTENTS SIDEBAR ===== */
.toc-sidebar {
    width: 220px;
    background-color: transparent;
    border: none;
    padding: 1.5rem 0;
    height: fit-content;
    position: sticky;
    top: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-accent) var(--bg-secondary);
    align-self: flex-start;
    order: 2;
}

.toc-sidebar::-webkit-scrollbar {
    width: 6px;
}

.toc-sidebar::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-accent);
    border-radius: 3px;
}

.toc-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-accent);
}

.toc-sidebar h3 {
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    font-size: 1.5rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-accent);
    padding-bottom: 0.5rem;
    font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
}

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

.toc-list li {
    margin-bottom: 0.5rem;
}

.toc-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 0.6rem 0.8rem 0.6rem 0;
    border-radius: 4px;
    transition: all 0.3s ease;
    border-right: 2px solid transparent;
    font-weight: 400;
    font-size: 0.9rem;
    font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
}

.toc-link:hover {
    background-color: var(--bg-primary);
    color: var(--text-accent);
    border-right-color: var(--border-accent);
    transform: translateX(-3px);
}

.toc-link.active {
    color: var(--border-accent);
    border-right-color: var(--border-accent);
    font-weight: 500;
}

/* Add border below Task 3 navigation item */
.toc-list li:nth-child(3) {
    border-bottom: 1px solid var(--border-accent);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

/* ===== MAIN CONTENT AREA ===== */
.main-content-area {
    flex: 1;
    min-width: 0;
    order: 1;
}

.toc-sidebar h3 {
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    font-size: 1.5rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-accent);
    padding-bottom: 0.5rem;
    font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
}

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

.toc-list li {
    margin-bottom: 0.3rem;
}

.toc-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 0.8rem 1rem 0.8rem 0;
    transition: all 0.3s ease;
    font-weight: 400;
    font-size: 0.9rem;
    background-color: transparent;
    font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
}

.toc-link:hover {
    background-color: var(--bg-secondary);
    color: var(--text-accent);
}

.toc-link.active {
    color: var(--border-accent);
    font-weight: 500;
}

/* ===== HEADER STYLES ===== */
header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem 0 0.5rem 0;
    border-bottom: 1px solid var(--border-accent);
}

h1 {
    color: var(--text-primary);
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-family: 'Times New Roman', Times, serif;
    letter-spacing: 0.5px;
}

.course-info {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.course-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    font-family: 'Times New Roman', Times, serif;
}

.professor-name {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 0.5rem;
}

h2 {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-accent);
    padding-bottom: 0.5rem;
    margin: 1.5rem 0 1rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
}

/* ===== THEME TOGGLE TEXT ===== */
.theme-toggle-text {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.theme-toggle-link {
    color: var(--text-accent);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.3s ease;
}

.theme-toggle-link:hover {
    color: var(--border-accent);
}

/* ===== CONTENT SECTIONS ===== */
section {
    margin-bottom: 2rem;
    padding: 0 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

section:last-of-type {
    margin-bottom: 0;
}

.text-section {
    background-color: transparent;
    padding: 1rem 0;
    margin: 1rem 0;
    border-radius: 0;
    box-shadow: none;
    line-height: 1.6;
    font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
    color: var(--text-primary);
    font-size: 1rem;
}

/* ===== MEDIA STYLES ===== */
.media-container {
    text-align: center;
    margin: 2rem 0;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px var(--shadow);
}

.source {
    font-weight: 400;
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    margin-top: 1.5rem;
    text-align: left;
    font-style: normal;
    font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
}

.source a {
    color: var(--text-accent);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.3s ease;
}

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

/* ===== FOOTER STYLES ===== */
footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    font-style: italic;
    font-size: 0.9rem;
}

footer a {
    color: var(--text-accent);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.3s ease;
}

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

/* ===== HAMBURGER MENU ===== */
.hamburger-menu {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-secondary);
    border: 2px solid var(--border-accent);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
    width: 50px;
    height: 50px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.hamburger-menu:hover {
    background: var(--bg-accent);
    transform: scale(1.05);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
    border-radius: 1px;
}

.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Overlay */
.toc-sidebar.mobile-open {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 999;
    padding: 80px 2rem 2rem 2rem;
    overflow-y: auto;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .container {
        width: 80%;
    }
}

@media (max-width: 768px) {
    .container {
        width: 95%;
        margin: 0 auto;
    }

    .main-content {
        padding: 15px 20px;
    }

    .content-with-sidebar {
        flex-direction: column;
        gap: 20px;
    }

    .hamburger-menu {
        display: flex;
    }

    .toc-sidebar {
        display: none;
        width: 100%;
        position: static;
        top: auto;
        order: 2;
        align-self: auto;
    }

    .main-content-area {
        order: 1;
    }

    .toc-link {
        padding: 0.6rem 1rem;
        text-align: center;
    }

    h1 {
        font-size: 1.7rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    .course-title {
        font-size: 1.1rem;
    }

    .professor-name {
        font-size: 0.9rem;
    }

    .text-section {
        padding: 1rem;
    }

    .toc-sidebar h3 {
        text-align: center;
        margin-bottom: 2rem;
        font-size: 2rem;
        font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji");
        color: var(--text-primary);
    }

    .toc-list {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .toc-list li {
        margin-bottom: 0;
        width: 100%;
        max-width: 300px;
    }

    .toc-link {
        padding: 1rem;
        border-radius: 8px;
        border: 1px solid var(--border-color);
        text-align: center;
        white-space: nowrap;
        font-size: 1rem;
        display: block;
        width: 100%;
        background: var(--bg-secondary);
        transition: all 0.3s ease;
    }

    .toc-link:hover {
        transform: none;
        background: var(--bg-accent);
        border-color: var(--border-accent);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 10px 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .toc-list {
        flex-direction: column;
        align-items: center;
    }

    .toc-link {
        width: 100%;
        max-width: 280px;
    }

    body {
        font-size: 15px;
    }
}


