/* ==========================================================================
   1. GLOBAL & BASE LAYOUT CONFIGURATIONS
   ========================================================================== */
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%; /* Allows body to reference the full viewport height */
}

body {
    margin: 0;
    padding: 0;
    background-color: #ffffff;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* FIX 1: Anchors the footer to viewport bottom boundary on short pages */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Fluid responsive modifier rule for global graphics components */
img.responsive {
    width: 100%;
    max-width: 100%;
    display: block;
    height: auto;
}

/* ==========================================================================
   2. NAVIGATION BAR
   ========================================================================== */
.topnav-container-row {
    width: 100%;
    background-color: #333333;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 10;
}

.topnav {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #333333;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    position: relative; /* Anchor positioning for mobile burger button */
}

.topnav a {
    display: block;
    color: #f2f2f2;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 17px;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.topnav a:hover,
.topnav a.active {
    background-color: #ff6600;
    color: #ffffff;
}

.topnav .icon {
    display: none;
}

/* ==========================================================================
   3. HORIZONTAL TOP CATEGORIES GRID BAR
   ========================================================================== */
.top-grid-override {
    width: 100%;
    box-sizing: border-box;
}

.top-categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
    gap: 20px;
    box-sizing: border-box;
}

.category-block {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.category-block:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.category-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #444444;
    font-weight: bold;
    border-bottom: 2px solid #ff6600;
    padding-bottom: 6px;
    margin-bottom: 10px;
}

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

.category-links li {
    margin-bottom: 6px;
}

.category-links a {
    color: #0066cc;
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
}

.category-links a:hover {
    text-decoration: underline;
    color: #004499;
}

.nested-promo {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    padding: 10px;
    margin-top: auto;
    text-align: center;
}

.nested-promo h5 {
    margin: 0 0 6px 0;
    color: #856404;
    font-size: 13px;
}

.promo-btn-sm {
    display: inline-block;
    background-color: #ff6600;
    color: #ffffff;
    padding: 6px 10px;
    text-decoration: none;
    font-weight: bold;
    border-radius: 3px;
    font-size: 12px;
}

/* ==========================================================================
   4. MAIN READING BLOCK LAYOUT FRAMEWORK
   ========================================================================== */
.main-content-row {
    display: flex;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 25px;
    box-sizing: border-box;
    flex-grow: 1; /* FIX 2: Extends layout block to force sticky footer downward */
}

.main {
    flex: 1;
    max-width: 850px;
    text-align: left;
    box-sizing: border-box;
    padding-right: 30px;
}

/* Sidebar Styling Setup */
.sidebar {
    width: 250px;
    box-sizing: border-box;
    flex-shrink: 0; /* FIX 3: Prevents wide layout columns from compressing sidebar */
}

.main p {
    font-size: 16px;
    line-height: 1.65;
    margin-bottom: 20px;
}

.main h2 {
    font-size: 28px;
    margin-top: 10px;
    margin-bottom: 15px;
    color: #222222;
}

.back-arrow-btn {
    display: inline-flex;
    align-items: center;
    color: #0066cc;
    text-decoration: none;
    font-size: 15px;
    font-weight: bold;
    margin-top: 10px;
    margin-bottom: 30px;
    transition: color 0.15s ease-in-out;
}

/* ==========================================================================
   5. RESPONSIVENESS OVERRIDES
   ========================================================================== */

/* Tablet & Smaller Devices (< 768px) */
@media screen and (max-width: 767px) {
    .top-categories-grid {
        grid-template-columns: repeat(2, 1fr); 
    }

    /* FIX 4: Corrected structural nesting to safely stack layouts on mobile */
    .main-content-row {
        flex-direction: column;
        padding: 0 15px;
    }

    .main {
        padding: 0;
        max-width: 100%;
    }

    /* Hide sidebar on small screens across all general subpages */
    .sidebar {
        display: none;
    }

    /* Explicit override: keeps sidebar visible ONLY on the homepage */
    .index-page .sidebar {
        display: block;
        width: 100%;
        margin-top: 30px;
    }
}

/* Smartphones (< 576px) */
@media screen and (max-width: 576px) {
    .topnav a:not(:first-child) { 
        display: none; 
    }
    
    /* FIX 5: Locks menu toggle safely to top right corner */
    .topnav a.icon {
        position: absolute;
        right: 20px;
        top: 0;
        display: block;
    }
    
    .topnav.responsive {
        flex-direction: column;
        align-items: flex-start;
        padding: 0;
    }
    
    .topnav.responsive a {
        display: block;
        width: 100%;
        text-align: left;
        box-sizing: border-box;
    }
    
    /* FIX 6: Clean separation for the icon button when open */
    .topnav.responsive a.icon {
        position: absolute; 
        width: auto;
        top: 0;
        right: 20px;
    }

    .top-categories-grid {
        grid-template-columns: 1fr; 
    }
}