/* ======================================================= */
/* [Section 1: Root Variables and Basic Setup] */
/* ======================================================= */
:root {
    --primary-font: 'Poppins', sans-serif;
    /* Refined Color Palette */
    --bg-color: #f8f9fa;
    --card-bg-color: #ffffff;
    --primary-text-color: #212529;
    --secondary-text-color: #6c757d;
    --accent-color: #007bff;
    --accent-text-color: #ffffff;
    --shadow-color: rgba(108, 117, 125, 0.1);
    --border-color: #dee2e6;
    --before-exam-color: #fd7e14;
    --after-exam-color: #20c997;
    /* Consistent Sizing */
    --border-radius: 16px;
    --main-padding: 1.5em;
}

html { scroll-behavior: smooth; }

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

.container { max-width: 1200px; margin: 0 auto; }

/* ======================================================= */
/* [Section 2: Typography] */
/* ======================================================= */
h1 { font-size: 2.25em; font-weight: 700; color: var(--primary-text-color); margin-bottom: 0.25em; }
h2 { font-size: 1.5em; font-weight: 600; color: var(--primary-text-color); }
.exam-date-display { font-size: 1.1em; color: var(--secondary-text-color); margin-bottom: 2em; }

/* ======================================================= */
/* [Section 3: Header and Navigation] */
/* ======================================================= */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5em;
    transition: all 0.3s ease;
}

.site-name { font-size: 1.5em; font-weight: 600; color: var(--primary-text-color); }
.header-controls { display: flex; align-items: center; gap: 1.5em; }

/* Mobile Menu Icon */
.menu-icon { cursor: pointer; display: flex; flex-direction: column; gap: 5px; }
.menu-icon .bar { width: 25px; height: 3px; background-color: var(--primary-text-color); border-radius: 3px; }

/* Mobile Side Navigation Panel */
/* Find this rule in styles.css */
nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 280px;
    background-color: var(--card-bg-color);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1000;
    overflow-y: auto; /* ADD THIS LINE */
}
nav.active { transform: translateX(0); }
.close-btn { position: absolute; top: 1.5em; right: 1.5em; font-size: 2em; background: none; border: none; color: var(--primary-text-color); cursor: pointer; }
nav ul { list-style: none; padding: 0; margin-top: 6em; text-align: center; }
nav ul li a { display: block; padding: 1em 2em; font-size: 1.2em; font-weight: 500; text-decoration: none; color: var(--primary-text-color); transition: background-color 0.2s; }
nav ul li a:hover { background-color: var(--bg-color); }

/* ======================================================= */
/* [Section 4: Components] */
/* ======================================================= */

/* Countdown Timer */
.countdown { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; margin: 2em 0; }
.countdown div {
    background: var(--card-bg-color);
    border-radius: var(--border-radius);
    padding: 1.25em;
    box-shadow: 0 4px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
.countdown span { font-size: 2.5em; font-weight: 600; color: var(--accent-color); display: block; line-height: 1.2; }
.countdown .label { font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.5px; color: var(--secondary-text-color); font-weight: 600; }

/* Filter Buttons */
.holiday-controls { margin: 2em 0 1.5em; }
.holiday-controls button {
    font-family: var(--primary-font); font-size: 1em; padding: 0.8em 1.5em;
    border-radius: 25px; border: 1px solid var(--border-color); cursor: pointer;
    background-color: var(--card-bg-color); color: var(--secondary-text-color); margin: 0.25em;
    transition: all 0.3s ease; font-weight: 500;
}
.holiday-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.holiday-controls button.active {
    background-color: var(--accent-color);
    color: var(--accent-text-color);
    border-color: var(--accent-color);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}

/* Holiday and Task Cards */
#tasks-container, .holiday {
    background: var(--card-bg-color);
    padding: 1.5em;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    text-align: left;
}
.holiday:hover { transform: translateY(-5px); box-shadow: 0 8px 25px var(--shadow-color); }

.holidays { display: grid; grid-template-columns: 1fr; gap: 1.5em; }
.holiday { position: relative; overflow: hidden; }
.holiday .name { font-weight: 600; font-size: 1.2em; color: var(--primary-text-color); }
.holiday .date { margin: 0.5em 0; color: var(--secondary-text-color); font-weight: 400; }
.holiday .days-left { font-size: 0.9em; color: var(--secondary-text-color); }
.holiday .label {
    position: absolute; top: 1.5em; right: -1px; padding: 0.3em 1em; font-size: 0.8em;
    font-weight: 700; color: #fff; border-radius: 15px 0 0 15px;
}
.holiday .label.before-exam { background-color: var(--before-exam-color); }
.holiday .label.after-exam { background-color: var(--after-exam-color); }

/* Task List (Home Page) */
#tasks-container { margin-bottom: 2em; }
#tasks-container h2 { margin-top: 0; padding-bottom: 0.5em; border-bottom: 1px solid var(--border-color); }
#task-list { list-style: none; padding-left: 0; margin: 0; }
#task-list li { padding: 0.8em 0.2em; border-bottom: 1px solid #f1f3f5; }
#task-list li:last-child { border-bottom: none; }
#task-list .task-date { font-weight: 600; color: var(--primary-text-color); display: block; margin-bottom: 0.25em; }

/* ======================================================= */
/* [Section 5: Page-Specific Styles (Lessons, Calendar)] */
/* ======================================================= */

/* Lesson Page */
.page-title { text-align: center; margin-bottom: 1.5em; }
.subjects-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5em; text-align: left; }
.subject-card { background: var(--card-bg-color); border-radius: var(--border-radius); padding: 1.5em; box-shadow: 0 4px 15px var(--shadow-color); border: 1px solid var(--border-color); transition: all 0.3s; }
.subject-title { font-size: 1.5em; font-weight: 600; margin-bottom: 1em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5em; color: var(--primary-text-color); }
.chapter-list { list-style: none; padding-left: 0; margin: 0; }
.chapter-item { display: flex; align-items: center; font-size: 1.1em; padding: 0.8em 0; border-bottom: 1px solid var(--border-color); }
.chapter-item:last-child { border-bottom: none; }
.chapter-item label { cursor: pointer; flex-grow: 1; color: var(--secondary-text-color); transition: color 0.3s; }
.chapter-item input[type="checkbox"] { margin-right: 1em; width: 20px; height: 20px; cursor: pointer; accent-color: var(--accent-color); }
.chapter-item input:checked + label { text-decoration: line-through; color: var(--primary-text-color); }

/* Calendar Page */
#calendar-container { background: var(--card-bg-color); padding: 1.5em; border-radius: var(--border-radius); box-shadow: 0 4px 15px var(--shadow-color); border: 1px solid var(--border-color); transition: all 0.3s; overflow: hidden; }
#calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5em; }
#calendar-header h1 { margin: 0; font-size: 1.8em; }
#calendar-header button { background: none; border: none; font-size: 2em; cursor: pointer; color: var(--primary-text-color); padding: 0 0.5em; }
#weekdays { display: grid; grid-template-columns: repeat(7, 1fr); font-weight: 600; color: var(--secondary-text-color); padding-bottom: 1em; border-bottom: 1px solid var(--border-color); margin-bottom: 1em; }
#calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5em; }
.day { padding: 0.8em 0.2em; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-height: 80px; font-size: 1em; color: var(--primary-text-color); position: relative; cursor: pointer; border-radius: 8px; transition: background-color 0.2s; }
.day:hover { background-color: var(--bg-color); }
.day.padding { color: var(--secondary-text-color); opacity: 0.5; cursor: default; }
.day.padding:hover { background: none; }
.day-number { margin-bottom: 8px; }
.day.today .day-number { background-color: var(--accent-color); color: var(--accent-text-color); border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; }
.event-dot-container { display: flex; }
.event-dot { width: 6px; height: 6px; border-radius: 50%; background-color: var(--before-exam-color); }
.event-dot.task-dot { background-color: var(--accent-color); margin-left: 4px; }

/* Calendar Modal */
#modal-backdrop { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.5); z-index: 2000; display: flex; justify-content: center; align-items: center; }
#modal-backdrop.hidden { display: none; }
#task-modal { background: var(--card-bg-color); padding: 1.5em; border-radius: var(--border-radius); width: 90%; max-width: 500px; position: relative; }
#modal-date { margin-top: 0; margin-bottom: 1em; }
.modal-list { list-style: none; padding: 0; margin: 0; max-height: 150px; overflow-y: auto; }
.modal-list li { padding: 0.5em 0; color: var(--secondary-text-color); }
.modal-list li.holiday-item { font-weight: 600; }
.modal-list li.task-item { display: flex; justify-content: space-between; align-items: center; }
.task-item button { background: none; border: 1px solid #ff4545; color: #ff4545; cursor: pointer; border-radius: 5px; padding: 0.2em 0.5em; }
.add-task-form { display: flex; margin-top: 1em; gap: 0.5em; }
#task-input { flex-grow: 1; padding: 0.8em; border: 1px solid var(--border-color); border-radius: 8px; background-color: var(--bg-color); color: var(--primary-text-color); }
#add-task-btn { padding: 0.8em 1.2em; border: none; background-color: var(--accent-color); color: var(--accent-text-color); border-radius: 8px; cursor: pointer; }

/* ======================================================= */
/* [Section 6: Dark Mode & Theme Switcher] */
/* ======================================================= */
body.dark-mode {
    --bg-color: #121212;
    --card-bg-color: #1e1e1e;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #a0a0a0;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --border-color: #2c2c2c;
}
body.dark-mode #task-list li { border-color: #2c2c2c; }
body.dark-mode .chapter-item { border-color: #2c2c2c; }
body.dark-mode .holiday-controls button.active { box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3); }
body.dark-mode nav { box-shadow: -5px 0 15px rgba(0,0,0,0.3); }
body.dark-mode nav ul li a:hover { background-color: #2c2c2c; }

.theme-switcher-item { display: flex; justify-content: space-between; align-items: center; padding: 1em 2em; font-size: 1.2em; font-weight: 500; color: var(--primary-text-color); }
.theme-switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 28px; transition: all 0.3s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; border-radius: 50%; transition: all 0.3s; }
body.dark-mode .slider { background-color: #3a3a3c; }
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(22px); }

/* ======================================================= */
/* [Section 7: Desktop Layout & Media Queries] */
/* ======================================================= */
@media (min-width: 1024px) {
    body { padding: 2.5em 3em; }
    h1 { font-size: 2.75em; }
    .container { max-width: 1400px; }
    .main-content { display: grid; grid-template-columns: 420px 1fr; gap: 2.5em; align-items: flex-start; text-align: left; }
    .left-column { position: sticky; top: 2.5em; }
    .holidays { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
    .menu-icon, .close-btn { display: none; }
    nav { position: static; transform: none; height: auto; width: auto; background: none; box-shadow: none; }
    nav ul { display: flex; align-items: center; gap: 2em; margin: 0; }
    nav ul li a { padding: 0.5em 0; font-size: 1em; }
    nav ul li a:hover { background: none; color: var(--accent-color); }
    .theme-switcher-item { display: none; }
}

@media (max-width: 1023px) {
    h1 { text-align: center; }
    .left-column { text-align: center; }
    #tasks-container { text-align: left; }
    nav ul .theme-switcher-item { display: flex; }
}

/* ======================================================= */
/* [Section 8: Dropdown Menu Styles] */
/* ======================================================= */

/* The container for the dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Style for the main "Articles" button */
.dropdown .drop-btn {
    cursor: pointer;
}

/* The hidden dropdown content */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--card-bg-color);
    min-width: 250px;
    box-shadow: 0 8px 16px 0 var(--shadow-color);
    border-radius: var(--border-radius);
    z-index: 1;
    border: 1px solid var(--border-color);
    overflow: hidden; /* Ensures border-radius applies to children */
}

/* The links inside the dropdown */
.dropdown-content a {
    color: var(--secondary-text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

/* Change color of dropdown links on hover */
.dropdown-content a:hover {
    background-color: var(--bg-color);
    color: var(--accent-color);
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
    display: block;
}

/* On mobile, we need to ensure the dropdown doesn't get cut off */
@media (max-width: 1023px) {
    .dropdown-content {
        position: static;
        box-shadow: none;
        border: none;
        background: none;
        min-width: 0;
    }
    .dropdown-content a {
        padding-left: 3em; /* Indent article links on mobile */
    }
}

/* ======================================================= */
/* [Section 9: Article & Blog Styles] */
/* ======================================================= */

.article-container {
    max-width: 800px; /* Optimal reading width */
    margin: 2em auto;
    background: var(--card-bg-color);
    padding: 2em 3em; /* More horizontal padding */
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px var(--shadow-color);
    text-align: left;
}

/* Article headings use the main site font */
.article-container h1, 
.article-container h2, 
.article-container h3 {
    font-family:var(--primary-font); /* New reading font */
    color: var(--primary-text-color);
    margin-top: 1.5em;
    margin-bottom: 0.6em;
}

.article-container h1 {
    font-size: 2.5em;
    line-height: 1.2;
}

.article-container h2 {
    font-size: 1.8em;
    border-bottom: 2px solid var(--border-color); /* Adds a nice separator */
    padding-bottom: 0.3em;
}

/* Article body text uses the new, readable serif font */
.article-container p,
.article-container li {
    font-family: 'Merriweather', serif; /* New reading font */
    font-size: 1.15rem; /* Larger font size for readability */
    line-height: 1.8; /* More spacing between lines */
    color: var(--secondary-text-color);
    margin-bottom: 1.2em;
}

.article-container a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.article-container a:hover {
    background-color: rgba(0, 123, 255, 0.05);
    border-bottom: 2px solid rgba(0, 123, 255, 0.2);
}

.article-container ul,
.article-container ol {
    padding-left: 2em;
    margin-bottom: 1.5em;
}

.article-container strong {
    font-weight: 600;
    color: var(--primary-text-color);
}
/* On mobile, use this class to show/hide the content on tap */
.dropdown.dropdown-active .dropdown-content {
    display: block;
}

/* ======================================================= */
/* [Section 10: Responsive Article Adjustments] */
/* ======================================================= */

@media (max-width: 768px) {
    .article-container {
        /* Reduce padding on smaller screens */
        padding: 1.5em; 
    }

    .article-container h1 {
        /* Reduce main title size */
        font-size: 2em; 
    }

    .article-container h2 {
        /* Reduce subtitle size */
        font-size: 1.5em; 
    }

    /* THIS IS THE KEY FIX FOR YOUR FONT SIZE ISSUE */
    .article-container p,
    .article-container li {
        /* Reduce body font size for better mobile reading */
        font-size: 1.05rem; 
        line-height: 1.7; /* Keep line height for good spacing */
    }
}

/* ======================================================= */
/* [Section 11: Focus Mode] */
/* ======================================================= */

/* Style for the new button */
.focus-mode-button {
    font-family: var(--primary-font);
    font-size: 1.1em;
    font-weight: 600;
    padding: 0.8em 1.5em;
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
    cursor: pointer;
    background-color: var(--card-bg-color);
    color: var(--accent-color);
    margin: 1.5em 0;
    width: 100%;
    transition: all 0.3s ease;
}

.focus-mode-button:hover {
    background-color: var(--accent-color);
    color: var(--accent-text-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-color);
}

/* --- LOGIC FOR HIDING/SHOWING ELEMENTS --- */

/* When body has the focus-mode-active class, hide these elements */
body.focus-mode-active .site-header,
body.focus-mode-active .right-column,
body.focus-mode-active .holiday-controls {
    display: none;
}

/* On desktop, when in focus mode, we should override the grid layout
   so the remaining column doesn't look empty */
@media (min-width: 1024px) {
    body.focus-mode-active .main-content {
        display: block; /* Turns off the grid */
    }

    body.focus-mode-active .left-column {
        max-width: 800px; /* Give it a max-width for readability */
        margin: 0 auto; /* Center it */
        position: static; /* Override the sticky position */
    }
}
/* ======================================================= */
/* [Section 8: Dropdown Menu Styles (Enhanced for Desktop)] */
/* ======================================================= */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown .drop-btn {
    cursor: pointer;
}

.dropdown-content {
    display: none; /* Initially hidden on mobile */
    position: absolute;
    background-color: var(--card-bg-color);
    min-width: 250px;
    border-radius: var(--border-radius);
    z-index: 1;
    border: 1px solid var(--border-color);
    overflow: hidden; 
}

.dropdown-content a {
    color: var(--secondary-text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    font-size: 0.9em;
    transition: background-color 0.2s, color 0.2s;
}

/* On mobile, keep the simple tap-to-open functionality */
@media (max-width: 1023px) {
    .dropdown-content {
        position: static;
        box-shadow: none;
        border: none;
        background: none;
        min-width: 0;
    }
    .dropdown-content a {
        padding-left: 3em;
    }
    .dropdown.dropdown-active .dropdown-content {
        display: block;
    }
}

/* ======================================================= */
/* [Section 12: Desktop Dropdown Enhancements] */
/* ======================================================= */

/* Apply these styles ONLY to desktop screens */
@media (min-width: 1024px) {
    /* Add a small arrow (caret) next to the Articles button */
    .drop-btn::after {
        content: '';
        display: inline-block;
        width: 0;
        height: 0;
        margin-left: 0.5em;
        vertical-align: middle;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 5px solid var(--secondary-text-color);
        transition: transform 0.2s ease;
    }

    /* Point the arrow up when the dropdown is open */
    .dropdown:hover .drop-btn::after {
        transform: rotate(180deg);
    }
    
    /* Prepare the dropdown for animation */
/* Find this rule inside the @media (min-width: 1024px) block */
.dropdown-content {
    display: block; 
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px); 
    transition: all 0.2s ease-in-out;
    margin-top: 0.5em; 
    box-shadow: 0 10px 25px rgba(108, 117, 125, 0.2);
    
    /* ADD THIS LINE to align the dropdown to the right */
    right: 0; 
}

    body.dark-mode .dropdown-content {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    }

    /* The hover state that triggers the animation */
    .dropdown:hover .dropdown-content {
        opacity: 1;
        visibility: visible;
        transform: translateY(0); /* Move back to original position */
    }

    /* Enhance the hover effect on the links inside */
    .dropdown-content a {
        transition: all 0.2s ease;
    }
    
    .dropdown-content a:hover {
        background-color: var(--bg-color);
        color: var(--accent-color);
        transform: translateX(5px); /* Add a subtle slide effect */
    }
}