:root {
    --heading-font: 'Lora', serif;
    --body-font: 'Nunito Sans', sans-serif;
    /* Light Theme */
    --bg-main: #fdfdfa;
    --bg-header: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #555;
    --accent-primary: #d95d39;
    --accent-light: #fdeee8;
    --border-color: #eee;
    --img-shadow: rgba(0, 0, 0, 0.1);
}

/* --- Dark Mode Variables --- */
body.dark-mode {
    --bg-main: #121212;
    --bg-header: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --accent-primary: #e87957; /* Slightly brighter accent for dark bg */
    --accent-light: #3a2e29;
    --border-color: #2e2e2e;
    --img-shadow: rgba(0, 0, 0, 0.4);
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--body-font);
    background: var(--bg-main);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
}

*, *::before, *::after {
    box-sizing: inherit;
}

header {
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    min-height: 64px;
    transition: background-color 0.3s, border-color 0.3s;
}

.header-right-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    font-family: var(--heading-font);
    font-weight: bold;
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: var(--accent-primary);
    text-decoration: none;
}

nav {
    display: flex;
    gap: 1.5rem; /* This adds space between the nav links */
}

    nav a {
        color: var(--text-secondary);
        text-decoration: none;
        font-weight: 500;
        transition: color 0.2s;
    }

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

#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

    #theme-toggle:hover {
        color: var(--accent-primary);
        background-color: var(--accent-light);
    }

    #theme-toggle svg {
        width: 22px;
        height: 22px;
    }

/* CORRECTED ICON LOGIC: Show the icon for the theme you will switch TO. */
.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

body.dark-mode .sun-icon {
    display: block;
}

body.dark-mode .moon-icon {
    display: none;
}


.container {
    display: flex;
    max-width: 1200px;
    width: 100%;
    margin: 2.5rem auto;
    gap: 3.5rem;
    padding: 0 1rem;
    align-items: flex-start;
}

.main-content {
    flex: 3;
    min-width: 0;
    overflow-wrap: break-word;
}

.aside-toc {
    flex: 1;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.toc-title {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 2px solid var(--border-color);
}

    .toc-list a {
        display: block;
        padding: 0.5rem 1rem;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 0.95rem;
        transition: all 0.2s ease-in-out;
        border-left: 2px solid transparent;
        margin-left: -2px;
    }

        .toc-list a:hover {
            background-color: var(--accent-light);
            color: var(--accent-primary);
        }

        .toc-list a.active {
            color: var(--accent-primary);
            font-weight: 700;
            border-left-color: var(--accent-primary);
            background-color: var(--accent-light);
        }

    .toc-list .toc-h3 a {
        padding-left: 2rem;
    }

.breadcrumbs {
    font-size: 0.98rem;
    color: var(--text-secondary);
    margin-bottom: 0.7rem;
}

    .breadcrumbs a {
        color: var(--accent-primary);
        text-decoration: none;
    }

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

h1, h2, h3 {
    font-family: var(--heading-font);
    color: var(--text-primary);
}

h1 {
    font-size: 2.8rem;
    margin: 0 0 0.7rem 0;
}

h2 {
    font-size: 2rem;
    margin: 3rem 0 1.5rem 0;
    padding-top: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem 0;
}

.meta {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    max-width: 65ch;
    line-height: 1.6;
}

p {
    font-size: 1.1rem;
    line-height: 1.7;
    margin: 0 0 1.5em 0;
    max-width: 65ch;
}

/* --- General Link Styles for Main Content --- */
.main-content p a,
.main-content ol a,
.main-content ul a {
    color: var(--accent-primary);
    text-decoration: underline;
    transition: color 0.2s;
}

    .main-content p a:hover,
    .main-content ol a:hover,
    .main-content ul a:hover {
        text-decoration-thickness: 2px;
    }


img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2em auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--img-shadow);
}

.callout {
    display: flex;
    align-items: flex-start;
    background: #f5faff;
    border-left: 4px solid #2196F3;
    border-radius: 12px;
    padding: 1.2em 1em;
    margin: 1.5em 0;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.08);
    font-size: 1rem;
}

.callout-icon {
    margin-right: 1em;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.callout-content {
    font-family: inherit;
    font-size: 1.15em;
    color: #234;
}

/* --- Add this code right after your existing .callout styles --- */

/* Callout styles for Dark Mode */
body.dark-mode .callout {
    background: #1e293b; /* A dark blue-gray */
    border-left-color: #38bdf8; /* A brighter, sky-blue for the border */
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.1);
}

body.dark-mode .callout-content {
    color: #e2e8f0; /* A light, soft off-white text color */
}

/* Override the hardcoded SVG colors specifically for dark mode */
body.dark-mode .callout-icon svg circle {
    fill: #0f172a; /* A very dark blue for the icon's circle background */
    stroke: #38bdf8; /* Match the brighter border color */
}

body.dark-mode .callout-icon svg rect {
    fill: #38bdf8; /* Match the brighter border color for the 'i' parts */
}

.table-wrapper {
    overflow-x: auto; /* This enables horizontal scrolling */
    width: 100%; /* Ensures the wrapper fits its parent container */
    border-radius: 14px; /* Applies rounded corners to the wrapper */
    box-shadow: 0 2px 16px rgba(60, 60, 60, 0.10); /* Applies box shadow to the wrapper */
    margin-bottom: 2rem; /* Moves the margin from the table to the wrapper */
    -webkit-overflow-scrolling: touch; /* Provides smoother scrolling on iOS devices */
    transition: box-shadow 0.3s;
}

/***************************/

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    color: #222;
    border-radius: 14px;
    overflow: hidden;
    /* The shadow is now on the wrapper, so we remove it from the table itself for consistency */
    /* box-shadow: 0 2px 16px rgba(60, 60, 60, 0.10); */
    margin-bottom: 0; /* Margin is on the wrapper now */
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

thead {
    background: #f4f6f8;
    transition: background-color 0.3s;
}

th,
td {
    padding: 1rem 1.5rem;
    text-align: left;
    vertical-align: middle;
}

th {
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-bottom: 2px solid #e0e3e7;
    transition: border-color 0.3s;
}

tbody tr {
    transition: background 0.2s;
}

    tbody tr:nth-child(even) {
        background: #f7fafd;
    }

    tbody tr:nth-child(odd) {
        background: #fff;
    }

    tbody tr:hover {
        background: #eaf4ff;
    }

td {
    border-bottom: 1px solid #f0f0f0;
    transition: border-color 0.3s;
}

/* --- Dark Mode Table Styles --- */
body.dark-mode .table-wrapper {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.dark-mode table {
    background: var(--bg-header);
    color: var(--text-primary);
}

body.dark-mode thead {
    background: #2a2a2a;
}

body.dark-mode th {
    border-bottom-color: #4a4a4a;
}

body.dark-mode tbody tr:nth-child(even) {
    background: var(--bg-main);
}

body.dark-mode tbody tr:nth-child(odd) {
    background: var(--bg-header);
}

body.dark-mode tbody tr:hover {
    background: var(--accent-light);
}

body.dark-mode td {
    border-bottom-color: var(--border-color);
}

/* --- Styles for Mobile Nav Toggle --- */
#mobile-menu-toggle {
    display: none; /* Hidden by default on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    color: var(--text-secondary);
    z-index: 1100; /* Ensure it's on top */
}

    #mobile-menu-toggle:hover {
        color: var(--accent-primary);
        background-color: var(--accent-light);
    }

    #mobile-menu-toggle .close-icon {
        display: none;
    }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
    justify-items: center; /* center the card horizontally */
}

.card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 2px 12px rgba(40, 40, 40, 0.06);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, background-color 0.3s;
    overflow: hidden;
    max-width: 340px; /* or whatever width you prefer */
    width: 100%;
}

    .card:hover {
        box-shadow: 0 6px 24px rgba(40, 40, 40, 0.13);
    }

.card-thumb {
    max-height: 200px; /* Adjust as needed */
    width: auto;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

.card-content {
    padding: 1.25rem;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.main-content .card-title {
    margin: 0 0 0.6rem 0;
    font-size: 1.15rem;
    font-weight: bold;
    color: #ce5523; /* matches your header color */
    transition: color 0.3s;
}

.main-content .card-desc {
    margin: 0;
    color: #444;
    font-size: 0.98rem;
    line-height: 1.5;
    transition: color 0.3s;
}

/* --- Dark Mode Card Styles --- */
body.dark-mode .card {
    background: var(--bg-header);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

    body.dark-mode .card:hover {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    }

body.dark-mode .main-content .card-title {
    color: var(--accent-primary);
}

body.dark-mode .main-content .card-desc {
    color: var(--text-secondary);
}


hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, #eee, #ccc, #eee);
    margin: 2em 0;
}

@media (max-width: 1024px) {
    .aside-toc {
        display: none;
    }
}

@media (max-width: 700px) {
    header {
        padding: 0 1rem;
    }

    /* Show the hamburger button */
    #mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide desktop nav and style mobile nav container */
    nav {
        display: none; /* Hide it by default */
        position: absolute;
        top: 63px; /* Position below header */
        left: 0;
        width: 100%;
        background: var(--bg-header);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        flex-direction: column;
        gap: 0;
    }

        /* Show the nav when it's active */
        nav.is-active {
            display: flex;
        }

        /* Style the links inside the mobile nav */
        nav a {
            display: block;
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--border-color);
            width: 100%;
            text-align: left;
        }

    /* Prevent body scrolling when menu is open */
    body.no-scroll {
        overflow: hidden;
    }

    .container {
        margin: 1rem 0;
        padding: 0 1rem;
    }

    h1 {
        font-size: 2.2rem;
    }

    p {
        font-size: 1rem;
    }

    .callout {
        flex-direction: column;
        padding: 1em 0.8em;
    }

    .callout-icon {
        margin-bottom: 0.5em;
        margin-right: 0;
    }
}

footer {
    width: 100%;
    background: var(--bg-header);
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: center;
    padding: 2rem 1rem 1.5rem 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

    footer a {
        color: var(--accent-primary);
        text-decoration: none;
        font-weight: 500;
        margin: 0 0.5rem;
        transition: color 0.2s;
    }

        footer a:hover {
            text-decoration: underline;
        }
