/* ===================================
   RESET AND BASE STYLES
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* ===================================
   CSS VARIABLES
   =================================== */
:root {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --bg-highlight: #fff9e6;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border-color: #f0f0f0;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --maroon: #8C1D40;
    --maroon-dark: #6b1632;
    --gold: #FFC627;
    --gold-dark: #e6b022;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2a2a2a;
    --bg-highlight: #3d3520;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #3a3a3a;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
}

/* ===================================
   TYPOGRAPHY & BODY
   =================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* ===================================
   LAYOUT CONTAINERS
   =================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Content sections need scroll offset for fixed navbar */
.content-section {
    scroll-margin-top: 100px;
}

/* ===================================
   NAVIGATION BAR
   =================================== */
.navbar {
    background: var(--bg-secondary);
    box-shadow: 0 2px 10px var(--shadow-light);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-logo h2 {
    color: var(--maroon);
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
}

.nav-menu {
    display: flex;
    gap: 30px;
    flex: 1;
    justify-content: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--maroon);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--maroon);
}

/* ===================================
   HAMBURGER MENU (MOBILE)
   =================================== */
.hamburger {
    display: none;
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-size: 24px;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
}

.hamburger:hover {
    background: var(--bg-tertiary);
    color: var(--maroon);
}

.hamburger ion-icon {
    display: block;
    transition: transform 0.3s ease;
}

.hamburger.active ion-icon {
    transform: rotate(90deg);
}

/* ===================================
   THEME SWITCHER
   =================================== */
.theme-switcher {
    display: flex;
    align-items: center;
}

.theme-toggle {
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--maroon);
}

.theme-toggle ion-icon {
    display: block;
    transition: opacity 0.15s ease;
}

.theme-toggle.rotating ion-icon {
    animation: smoothRotate 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes smoothRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.theme-toggle ion-icon.fading {
    opacity: 0;
}

/* ===================================
   SIDEBAR NAVIGATION
   =================================== */
.sidebar-nav {
    position: fixed;
    left: 20px;
    top: 150px;
    width: 220px;
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 25px 20px;
    box-shadow: 0 5px 20px var(--shadow-light);
    border: 1px solid var(--border-color);
    z-index: 100;
    transition: all 0.3s ease;
}

.sidebar-nav h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 12px;
}

.sidebar-nav a {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--bg-tertiary);
    color: var(--maroon);
    border-left-color: var(--maroon);
    transform: translateX(5px);
}

.sidebar-nav a.active {
    background: var(--bg-highlight);
    color: var(--maroon);
    border-left-color: var(--maroon);
    font-weight: 600;
}

/* ===================================
   HERO SECTION
   =================================== */
.hero {
    margin-top: 70px;
    padding: 80px 0;
    background: linear-gradient(135deg, var(--maroon) 0%, #000000 100%);
    color: white;
    min-height: 600px;
    display: flex;
    align-items: center;
}

.hero-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 60px;
    align-items: center;
}

.hero-image {
    position: relative;
}

.hero-image img {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.hero-text h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
}

.subtitle {
    font-size: 1.3rem;
    margin-bottom: 30px;
    opacity: 0.9;
    font-weight: 300;
}

.author-info h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--gold);
}

.course-info {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 40px;
    color: var(--gold);
}

.cta-button {
    display: inline-block;
    background: var(--gold);
    color: #000000;
    padding: 15px 30px;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(255, 198, 39, 0.4);
}

.cta-button:hover {
    background: var(--gold-dark);
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(255, 198, 39, 0.6);
}

figcaption {
    margin-top: 15px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

figcaption a {
    color: var(--gold);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

figcaption a:hover {
    color: var(--gold-dark);
    text-decoration: underline;
}

figcaption ion-icon {
    font-size: 0.85rem;
    vertical-align: middle;
}

/* ===================================
   QUICK NAVIGATION CARDS
   =================================== */
.quick-nav {
    padding: 80px 0;
    background: var(--bg-secondary);
}

.quick-nav h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 50px;
    color: var(--text-primary);
}

.nav-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

.nav-card {
    background: var(--bg-secondary);
    padding: 40px 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow-light);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nav-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px var(--shadow-medium);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-card h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    min-height: 3em;
}

.nav-card p {
    color: var(--text-primary);
    margin-bottom: 25px;
    line-height: 1.6;
    flex-grow: 1;
}

.card-link {
    color: var(--maroon);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: color 0.3s ease;
    margin-top: auto;
}

.card-link:hover {
    color: var(--maroon-dark);
}

/* ===================================
   PAGE CONTENT SECTIONS
   =================================== */
.page-content {
    margin-top: 70px;
    padding: 80px 0;
    min-height: calc(100vh - 140px);
}

.page-header {
    text-align: center;
    margin-bottom: 60px;
}

.page-header h1 {
    font-size: 3rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    font-weight: 700;
}

.page-subtitle {
    font-size: 1.3rem;
    color: var(--maroon);
    font-weight: 300;
}

.content-section {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 5px 20px var(--shadow-light);
    margin-bottom: 40px;
}

.content-section h2 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 25px;
    border-bottom: 3px solid var(--maroon);
    padding-bottom: 10px;
}

.content-section h3 {
    font-size: 1.5rem;
    color: var(--maroon);
    margin: 30px 0 15px 0;
}

.content-section h4 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 20px 0 10px 0;
}

.content-section p {
    margin-bottom: 20px;
    line-height: 1.8;
    color: var(--text-primary);
}

/* ===================================
   LISTS
   =================================== */
.content-section ul,
.content-section ol {
    margin: 20px 0;
    padding-left: 40px;
}

.content-section ul li,
.content-section ol li {
    margin-bottom: 12px;
    line-height: 1.8;
    color: var(--text-primary);
}

.content-section ul {
    list-style-type: disc;
}

.content-section ol {
    list-style-type: decimal;
}

.content-section ul ul,
.content-section ol ul {
    margin: 10px 0;
    padding-left: 30px;
}

.content-section ul ul {
    list-style-type: circle;
}

.content-section > p a,
.content-section > ul a,
.content-section > ol a {
    color: var(--maroon);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.content-section > p a:hover,
.content-section > ul a:hover,
.content-section > ol a:hover {
    color: var(--maroon-dark);
    text-decoration: underline;
}

.content-section > p a ion-icon,
.content-section > ul a ion-icon,
.content-section > ol a ion-icon {
    font-size: 0.85rem;
    vertical-align: middle;
}

/* ===================================
   HIGHLIGHT BOXES
   =================================== */
.highlight-box {
    background: var(--bg-highlight);
    padding: 30px;
    border-radius: 10px;
    margin: 30px 0;
    border-left: 4px solid var(--gold);
}

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

/* ===================================
   MEDIA CONTAINERS
   =================================== */
.media-container {
    margin: 40px 0;
}

.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 20px auto;
    padding-bottom: 45%;
    overflow: hidden;
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow-light);
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 15px;
}

.media-description {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-top: 15px;
}

/* ===================================
   SPECIAL ELEMENTS
   =================================== */
.takeaway-list {
    background: var(--bg-tertiary);
    border-radius: 10px;
    margin: 25px 0;
    list-style-type: none !important;
    padding: 25px 25px 25px 0;
}

.takeaway-list li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
    list-style-type: none;
}

.takeaway-list li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--maroon);
    font-weight: bold;
}

.solution-number {
    display: inline-block;
    background: var(--maroon);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    text-align: center;
    line-height: 50px;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
}

/* ===================================
   NAVIGATION BUTTONS
   =================================== */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 50px 0 20px 0;
    gap: 20px;
}

.nav-button {
    display: inline-block;
    padding: 15px 25px;
    background: var(--maroon);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 200px;
    width: auto;
}

.nav-button:hover {
    background: var(--maroon-dark);
    transform: translateY(-2px);
}

.nav-button.prev {
    background: #000000;
}

.nav-button.prev:hover {
    background: #333333;
}

/* ===================================
   REFERENCES PAGE
   =================================== */
.references-content {
    margin-bottom: 40px;
}

.reference-section {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 5px 20px var(--shadow-light);
}

.reference-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.reference-item {
    padding-left: 0;
    border-left: none;
}

.reference-item p {
    margin: 0;
    line-height: 1.8;
    color: var(--text-primary);
    text-indent: -40px;
    padding-left: 40px;
}

.reference-item em {
    font-style: italic;
}

.reference-item a {
    color: var(--maroon);
    text-decoration: none;
    word-break: break-all;
    transition: color 0.3s ease;
}

.reference-item a:hover {
    color: var(--maroon-dark);
    text-decoration: underline;
}

/* ===================================
   FOOTER
   =================================== */
.footer {
    background: #000000;
    color: white;
    padding: 40px 0;
    text-align: center;
    margin-top: auto;
}

.footer p {
    margin: 0;
    opacity: 0.8;
}

/* ===================================
   BACK TO TOP & SCROLL PROGRESS
   =================================== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--maroon);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(140, 29, 64, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--maroon-dark);
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(140, 29, 64, 0.4);
}

.back-to-top ion-icon {
    font-size: 28px;
}

.scroll-progress {
    position: fixed;
    top: 70px;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--maroon), var(--gold));
    z-index: 999;
    transition: width 0.3s ease;
}

/* ===================================
   UTILITY CLASSES
   =================================== */
.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Large screens with sidebar */
@media (min-width: 1201px) {
    /* Only apply sidebar spacing when sidebar exists */
    .sidebar-nav ~ .page-content,
    body:has(.sidebar-nav) .page-content {
        display: flex;
        justify-content: center;
        padding-left: 260px; /* Space for sidebar */
    }

    .sidebar-nav ~ .page-content .container,
    body:has(.sidebar-nav) .page-content .container {
        max-width: 1400px;
        flex: 1;
        padding: 0 40px;
    }
}

/* Hide sidebar on smaller screens */
@media (max-width: 1200px) {
    .sidebar-nav {
        display: none;
    }

    .page-content .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
    }
}

/* Tablet and smaller */
@media (max-width: 1024px) {
    .nav-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .nav-logo h2 {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .theme-switcher {
        margin-left: auto;
        margin-right: 0;
    }

    .nav-logo h2 {
        font-size: 0.95rem;
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        flex-direction: column;
        background-color: var(--bg-secondary);
        width: 100%;
        text-align: center;
        box-shadow: 0 10px 27px var(--shadow-light);
        padding: 0;
        gap: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.4s ease;
    }

    .nav-menu.active {
        max-height: 400px;
        opacity: 1;
        padding: 20px 0;
    }

    .nav-link.active::after {
        display: none;
    }

    .nav-link {
        padding: 12px 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 40px;
    }

    .hero-text h1 {
        font-size: 2.2rem;
    }

    .page-header h1 {
        font-size: 2.2rem;
    }

    .content-section {
        padding: 25px;
    }

    .navigation-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .nav-button {
        max-width: none;
    }

    .video-wrapper {
        max-width: 100%;
        padding-bottom: 56.25%;
    }
}

@media (max-width: 480px) {
    .nav-logo h2 {
        font-size: 1rem;
    }

    .hero {
        padding: 40px 0;
    }

    .hero-text h1 {
        font-size: 1.8rem;
    }

    .quick-nav {
        padding: 40px 0;
    }

    .nav-cards {
        grid-template-columns: 1fr;
    }

    .nav-card {
        padding: 25px 20px;
    }

    .page-content {
        padding: 40px 0;
    }

    .container {
        padding: 0 15px;
    }
}