/* --- style.css --- */

/* --- CSS Variables --- */
:root {
    /* Default to NEW Light Theme Variables (Sky Blue Theme) */
    --bg-color: #EDF6FF;
    --text-color: #0D47A1;
    --container-bg: #FFFFFF;
    --heading-color: #0D47A1;
    --heading-h1-color: #1565C0;
    --heading-h4-color: #1E88E5;
    --link-color: #1976D2;
    --link-hover-color: #0D47A1;
    --nav-bg: #BBDEFB; /* Variable for potential top nav */
    --nav-text: #0D47A1;
    --nav-link-hover-bg: #90CAF9;
    --nav-link-hover-text: #0D47A1;
    --border-color: #BBDEFB;
    --subtle-border-color: var(--border-color);
    --figure-bg: #E3F2FD; /* Figure background */
    --figure-border: var(--border-color); /* Figure border */
    --caption-color: #1565C0;
    --code-bg: #E3F2FD;
    --code-text: #0D47A1;
    --code-border-accent: #1976D2;
    --inline-code-bg: #E3F2FD;
    --inline-code-text: #0D47A1;
    --shadow-color: rgba(66, 165, 245, 0.2);
    --footer-text: #1565C0;
    --button-bg: #1976D2;
    --button-text: #FFFFFF;
    --button-hover-bg: #1565C0;

    /* Sidebar Variables (Light Theme) */
    --sidebar-bg: #FFFFFF;
    --sidebar-text: #0D47A1;
    --sidebar-link-hover-bg: #E3F2FD;
    --sidebar-link-active-bg: #1976D2;
    --sidebar-link-active-text: #FFFFFF;
    --sidebar-border: #BBDEFB;
}

/* Basic Logo Styling (for header logo) */
.logo {
    display: block;
    margin: 0 auto 20px auto;
    max-height: 250px; /* Increased size */
}

/* Header layout */
header {
    text-align: center;
    padding: 1em 0;
    margin-bottom: 2em;
}

body.dark-theme {
    /* Dark Theme Variable Overrides (Dark Grey Base, Blue Accents) */
    --bg-color: #1a1a1a;
    --text-color: #EAEAEA;
    --container-bg: #2a2a2a;
    --heading-color: #EAEAEA;
    --heading-h1-color: #FFFFFF;
    --heading-h4-color: #cccccc;
    --link-color: #4FC3F7;
    --link-hover-color: #29B6F6;
    --nav-bg: #111111;
    --nav-text: #EAEAEA;
    --nav-link-hover-bg: #4FC3F7;
    --nav-link-hover-text: #000000;
    --border-color: #444;
    --subtle-border-color: var(--border-color);
    --figure-bg: #2f2f2f; /* Figure background */
    --figure-border: var(--border-color); /* Figure border */
    --caption-color: #bbbbbb;
    --code-bg: #111;
    --code-text: #d0d0d0;
    --code-border-accent: #4FC3F7;
    --inline-code-bg: #333;
    --inline-code-text: #81D4FA;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --footer-text: #888;
    --button-bg: #4FC3F7;
    --button-text: #000000;
    --button-hover-bg: #29B6F6;

    /* Sidebar Variables (Dark Theme) */
    --sidebar-bg: #2c2c2c;
    --sidebar-text: #d0d0d0;
    --sidebar-link-hover-bg: #444;
    --sidebar-link-active-bg: #4FC3F7;
    --sidebar-link-active-text: #000000;
    --sidebar-border: #444;
}

/* --- Global Styles & Resets --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.7;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 0;
    font-size: 16px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* === Sidebar Navigation Styles === */
#sidebar-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    padding: 20px;
    overflow-y: auto;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Styles for Back-to-Top Link containing the logo */
#sidebar-nav .back-to-top-button {
    display: block;
    margin-bottom: 20px;
    padding: 0;
    background: none;
    border: none;
    text-align: center;
    cursor: pointer;
    line-height: 0;
}

/* Styles for Sidebar Logo Image itself */
#sidebar-nav .sidebar-logo {
    max-width: 75%;
    height: auto;
    display: inline-block;
    vertical-align: middle;
    transition: opacity 0.2s ease;
}

#sidebar-nav .back-to-top-button:hover .sidebar-logo {
    opacity: 0.8;
}

/* Styles specifically for the navigation list */
#sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto; /* Removed flex-grow */
}

#sidebar-nav li {
    margin-bottom: 5px;
}

/* Styles for links INSIDE the UL list */
#sidebar-nav ul a {
    display: block;
    padding: 8px 15px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.95em;
}

#sidebar-nav ul a:hover {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--text-color);
}

/* Style for the active link within the list */
#sidebar-nav ul a.active {
    background-color: var(--sidebar-link-active-bg);
    color: var(--sidebar-link-active-text);
    font-weight: bold;
}
/* ==================================== */


/* === Main Content Area Styles === */
.main-content-area {
    margin-left: 270px; /* Sidebar width (240px) + Space (30px) */
    padding: 1px 0 0 0;
}
/* ==================================== */


/* --- Container (Now inside main-content-area) --- */
.container {
    max-width: 900px;
    margin: 20px auto 40px auto;
    padding: 30px 40px;
    background-color: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 5px 15px var(--shadow-color);
    transition: background-color 0.3s ease;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 { color: var(--heading-color); margin-top: 1.5em; margin-bottom: 0.7em; line-height: 1.3; font-weight: 600; }
h1 { font-size: 2.6em; text-align: center; margin-bottom: 1em; padding-bottom: 0.3em; border-bottom: 3px solid var(--subtle-border-color); color: var(--heading-h1-color); display: block; }
h2 { font-size: 2em; border-bottom: 2px solid var(--border-color); padding-bottom: 0.3em; }
h3 { font-size: 1.6em; }
h4 { font-size: 1.2em; color: var(--heading-h4-color); }
p { margin-bottom: 1.2em; }

/* General Link Styles (in main content) */
.main-content-area a, footer a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease, opacity 0.3s ease;
}
.main-content-area a:hover, footer a:hover,
.main-content-area a:focus, footer a:focus {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* Lists */
/* General list styling */
ul, ol { margin-bottom: 1.2em; padding-left: 25px; }
/* Default list item marker */
li { margin-bottom: 0.6em; }
strong, b { font-weight: 700; color: var(--heading-h1-color); }

/* Remove bullets from the Problems/GIFs list */
ul.problems-list {
    list-style-type: none;
    padding-left: 0;
}
/* Optional: Adjust margin for list items if needed now that padding is gone */
ul.problems-list li {
     margin-bottom: 1.5em;
     /* Add any other specific styling for these list items */
     text-align: left; /* Ensure text aligns left */
}
ul.problems-list li figure { /* Ensure figure within this specific list item centers text */
    text-align: center;
}


/* --- Top Navigation (Keep if used, otherwise remove) --- */
/* Styles removed for brevity if not used */


/* --- Images & Figures --- */
img { max-width: 100%; height: auto; display: block; border-radius: 6px; }
/* General Figure Styles */
figure {
    margin: 2.5em auto;
    padding: 15px;
    border: 1px solid var(--figure-border);
    border-radius: 6px;
    background-color: var(--figure-bg);
    text-align: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    max-width: 95%;
}
figcaption {
    margin-top: 10px;
    font-size: 0.95em;
    color: var(--caption-color);
    text-align: center;
}

/* --- GIF Gallery Styles --- */
.gif-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Responsive columns */
    gap: 50px; /* Space between grid items */
    margin-top: 2em; /* Space above the gallery */
    margin-bottom: 2em; /* Space below the gallery */
}

.gallery-item {
    margin: 0;
    padding: 10px;
    border: 1px solid var(--figure-border);
    border-radius: 6px;
    background-color: var(--figure-bg);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.gallery-item img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    margin-bottom: 10px;
    /* === ADDED/CONFIRMED CENTERING RULES === */
    margin-left: auto;
    margin-right: auto;
    /* ======================================== */
}

.gallery-item figcaption {
    font-size: 0.9em;
    color: var(--caption-color);
    margin-top: auto; /* Helps push caption down */
}
/* ========================= */


/* === Styles for GIF Figures in Problems Section === */
.problem-gif {
    margin-top: 1em;
    margin-bottom: 0.5em;
    padding: 15px;
    border: 1px solid var(--figure-border);
    background-color: var(--figure-bg);
    border-radius: 6px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.problem-gif img {
    display: block;
    max-width: 90%;
    height: auto;
    margin: 0 auto; /* This centers the image */
    border-radius: 4px;
}

.problem-gif figcaption {
    display: block;
    font-size: 0.9em;
    margin-top: 0.5em;
    text-align: center;
    color: var(--caption-color);
}
/* =============================================== */


/* --- Code Blocks --- */
pre { background-color: var(--code-bg); border: 1px solid var(--border-color); border-left: 5px solid var(--code-border-accent); padding: 20px; margin: 1.5em 0; overflow-x: auto; border-radius: 5px; font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.9em; line-height: 1.6; color: var(--code-text); transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease; }
code { background-color: var(--inline-code-bg); color: var(--inline-code-text); padding: 0.2em 0.5em; border-radius: 3px; font-size: 90%; font-family: 'Consolas', 'Monaco', 'Courier New', monospace; transition: background-color 0.3s ease, color 0.3s ease; }
pre code { background-color: transparent; color: inherit; padding: 0; border-radius: 0; font-size: inherit; font-family: inherit; }


/* --- Header & Footer --- */
header { text-align: center; margin-bottom: 2em; padding: 1em 0; }
header p { color: var(--text-color); opacity: 0.8; font-size: 1.1em; }
footer { text-align: center; margin-top: 4em; padding-top: 1.5em; border-top: 1px solid var(--border-color); color: var(--footer-text); font-size: 0.9em; transition: border-color 0.3s ease, color 0.3s ease; }


/* === UPDATED Theme Toggle Button Style (to look like nav link) === */
#theme-toggle-button {
    /* Reset Button Defaults & Apply Link Look */
    background: none;
    border: none;
    font-family: inherit;
    font-weight: normal;
    text-align: left;
    cursor: pointer;

    /* Apply Link Dimensions & Colors */
    display: block;
    width: 100%;
    padding: 8px 15px;
    font-size: 0.95em;
    color: var(--sidebar-text);
    border-radius: 4px;
    margin-top: 25px;

    /* Keep transition */
    transition: background-color 0.2s ease, color 0.2s ease;
}

#theme-toggle-button:hover {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--text-color);
}
/* =============================================================== */


/* --- Responsiveness --- */
@media (max-width: 992px) {
     /* Sidebar adjustments */
    #sidebar-nav { width: 180px; }
    .main-content-area { margin-left: 210px; } /* Adjusted margin: 180px + 30px space */
     /* Container adjustments */
     .container { padding: 25px 20px; }
}

@media (max-width: 768px) {
    /* Hide sidebar completely */
    #sidebar-nav { display: none; }
    .main-content-area { margin-left: 0; }

    /* General adjustments */
    .container { padding: 20px 15px; margin: 10px auto 20px auto; }
    h1 { font-size: 2.1em; }
    h2 { font-size: 1.8em; }
    h3 { font-size: 1.4em; }

    /* Button position adjustment - Rule removed */
}