:root {
    --bg-canvas: #fbfaf8;       /* Warm, soft off-white */
    --bg-card: #ffffff;         /* Card background */
    --primary-deep: #1e1b4b;    /* Deep night-sky indigo */
    --accent-lavender: #6366f1; /* Mystical lavender */
    --accent-gold: #d97706;     /* Warm spiritual gold */
    --text-main: #27272a;       /* Off-black for easy reading */
    --text-muted: #52525b;     /* Muted grey for metadata */
    --border-color: #e4e4e7;   /* Soft border line */
    
    --font-serif: "Georgia", "Times New Roman", serif;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --max-width: 1100px;
}

/* 2. CSS RESET & BASE STYLES */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-canvas);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--accent-lavender);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-deep);
}

/* 3. LAYOUT WRAPPERS */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* --- STICKY NAV SYSTEM (LIGHTWEIGHT VANILLA) --- */

.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--primary-deep);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 15px 0;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links a {
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 5px 0;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--accent-gold);
}

.lang-switch {
    color: var(--accent-gold) !important;
    font-weight: bold;
}

/* Inline Header Search Bar Capsule */
.header-search {
    display: flex;
    align-items: center;
    background-color: #ffffff !important; /* Clean white background */
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 50px !important; /* Smooth capsule shape */
    padding: 6px 16px !important; /* Balanced inner spacing */
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 38px !important; /* Fixed height for consistency */
    width: 220px !important; /* Comfortable width */
}

.header-search:focus-within {
    border-color: var(--accent-lavender) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

/* Input Field (Dark text to be visible on white capsule) */
.header-search input {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: #1e1b4b !important; /* Dark text for readability */
    font-size: 0.9rem !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
}

.header-search input::placeholder {
    color: #9ca3af !important; /* Soft grey placeholder text */
}

/* Search Button (Strips blocky background and borders) */
.header-search button {
    background: transparent !important; /* Forces no background */
    border: none !important; /* Strips borders */
    outline: none !important;
    color: #1e1b4b !important; /* Dark icon for high contrast on white */
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin-left: 8px !important;
    height: 100% !important;
    width: auto !important;
    transition: color 0.2s ease;
}

.header-search button:hover {
    color: var(--accent-lavender) !important; /* Lavender color shift on hover */
}

/* Mobile Hamburger Menu button */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1010;
}

.menu-toggle .bar {
    width: 100%;
    height: 2.5px;
    background-color: #ffffff;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* --- MOBILE RESPONSIVE LAYOUT (No Bootstrap Required) --- */
@media (max-width: 991px) {
    .menu-toggle {
        display: flex; /* Display toggle trigger on tablets/mobile */
    }

    .nav-menu {
        position: absolute;
        top: calc(100% + 15px); /* Position the menu directly beneath the navbar */
        right: 0;
        background-color: var(--primary-deep);
        width: 100%;
        max-width: 320px;
        flex-direction: column;
        gap: 20px;
        padding: 25px 20px;
        border-radius: 8px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.25);
        border: 1px solid rgba(255, 255, 255, 0.05);
        display: none; /* Collapsed by default */
        transform-origin: top right;
    }

    /* Target state triggered via JS class injection */
    .nav-menu.active {
        display: flex;
        animation: menuFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .nav-links {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 15px;
    }

    .nav-links a {
        width: 100%;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .header-search {
        width: 100%;
    }

    .header-search input {
        width: 100%;
    }

    /* Smooth Hamburger Transition Effects */
    .menu-toggle.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .menu-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
}

/* Dropdown Animation */
@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 4. MAIN CONTENT AREA */
main {
    flex-grow: 1;
    padding: 40px 0;
}

/* 5. HERO / SEARCH ZONE */
.hero-section {
    text-align: center;
    padding: 60px 20px;
    background-color: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 40px;
}

.hero-section h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    color: var(--primary-deep);
    margin-bottom: 10px;
}

.hero-section p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

/* --- MAIN SEARCH CONSOLE CAPSULE --- */
.search-form {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    overflow: hidden;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

/* Main Input Field */
.search-form .search-field {
    flex-grow: 1;
    min-width: 0; /* Critical: Tells flexbox to shrink the input instead of the button! */
    border: none;
    padding: 15px 25px;
    font-size: 1rem;
    outline: none;
    background: transparent;
    color: var(--text-main);
}

/* Main Submit Button (Stops any text cutting) */
.search-form button[type="submit"] {
    background-color: var(--primary-deep);
    color: #ffffff;
    border: none;
    padding: 0 30px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0; /* Critical: Forces the button to never shrink or cut text! */
    align-self: stretch; /* Spans the full height of the container */
    transition: background-color 0.2s ease;
}

.search-form button[type="submit"]:hover {
    background-color: var(--accent-lavender);
}

/* --- MOBILE RESPONSIVE ADAPTATION --- */
@media (max-width: 575px) {
    .search-form .search-field {
        padding: 12px 18px; /* Compact padding on small screens to save space */
        font-size: 0.9rem; /* Slightly smaller text for readability */
    }
    
    .search-form button[type="submit"] {
        padding: 0 20px; /* Reduced button padding on mobile so it fits screens down to 320px */
        font-size: 0.9rem;
    }
}

/* 6. GRID LAYOUT FOR RECENT/FEATURED & CARD HOVER ZOOM */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.01);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
    transform: translateY(-4px); /* Clean lift */
    box-shadow: 0 12px 24px rgba(0,0,0,0.06); /* Deeper shadow on hover */
}

/* Base style for card image transition */
.card img {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Triggers subtle zoom on card hover */
.card:hover img {
    transform: scale(1.06) !important; /* Elegant 6% scale zoom */
}

.card .tag {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: bold;
    color: var(--accent-gold);
    margin-bottom: 10px;
}

.card h3 {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    color: var(--primary-deep);
    margin-bottom: 10px;
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 15px;
}

/* 7. FOOTER STYLING */
/* --- PROFESSIONAL FOOTER STYLES --- */
.main-footer {
    background-color: #111827 !important; /* Deep charcoal background */
    color: #9ca3af !important; /* Muted text */
    padding: 60px 0 40px 0 !important;
    font-size: 0.95rem;
    border-top: 4px solid var(--accent-gold);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: 2fr 1fr 1.5fr; /* 3-column layout matching screenshot */
    }
}

.footer-col h3 {
    color: #ffffff;
    font-family: var(--font-serif);
    font-size: 1.2rem;
    text-transform: uppercase;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

/* Useful Links List */
.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-links li a {
    color: #d1d5db;
    transition: color 0.2s;
    font-weight: 500;
}

.footer-links li a:hover {
    color: var(--accent-gold);
}

/* Social Media Icons Wrapper */
.footer-socials {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.social-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

/* Brand Colors on Hover matching screenshot */
.social-circle.fb:hover { border-color: #1877f2; color: #1877f2; background: rgba(24,119,242,0.05); }
.social-circle.tw:hover { border-color: #1da1f2; color: #1da1f2; background: rgba(29,161,242,0.05); }
.social-circle.ig:hover { border-color: #e1306c; color: #e1306c; background: rgba(225,48,108,0.05); }
.social-circle.li:hover { border-color: #0077b5; color: #0077b5; background: rgba(0,119,181,0.05); }
.social-circle.yt:hover { border-color: #ff0000; color: #ff0000; background: rgba(255,0,0,0.05); }

/* Newsletter Form */
.footer-newsletter {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-newsletter input[type="email"] {
    background-color: #ffffff;
    border: none;
    padding: 14px 20px;
    border-radius: 4px;
    color: var(--text-main);
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}

.footer-newsletter button {
    background-color: #10b981; /* Emerald Green matching screenshot */
    color: #ffffff;
    border: none;
    padding: 14px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
    font-size: 0.95rem;
}

.footer-newsletter button:hover {
    background-color: #059669;
}

/* Footer Bottom Bar */
.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    gap: 15px;
}

@media (min-width: 768px) {
    .footer-bottom {
        flex-direction: row;
        gap: 0;
    }
}

/* --- ARTICLE SPECIFIC STYLES --- */

/* Breadcrumbs (UX and Search Crawlers love this) */
.breadcrumbs {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.breadcrumbs a {
    color: var(--text-muted);
}
.breadcrumbs span {
    margin: 0 8px;
    color: var(--border-color);
}

/* Two-Column Layout (Content + Sidebar) */
.article-layout {
    display: grid;
    grid-template-columns: 100%; /* Full width on mobile */
    gap: 40px;
}

@media (min-width: 768px) {
    .article-layout {
        /* minmax(0, ...) prevents columns from expanding beyond their allocated space */
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); 
    }
}

/* Base Wrapper constraint to prevent nested expansion */
.article-body {
    min-width: 0;
    width: 100%;
    overflow: hidden; /* Secondary safety guard */
}

/* Force long words, URLs, and text blocks to wrap cleanly */
.article-content {
    line-height: 1.8;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* --- RESPONSIVE IN-ARTICLE MEDIA CONSTRAINTS (Forces TinyMCE output to be responsive) --- */
.article-content img,
.article-content iframe,
.article-content video,
.article-content embed {
    max-width: 100% !important;
    height: auto !important; /* Preserves aspect ratio on mobile screens */
    border-radius: 6px;
}

/* Bulletproof Mobile Tables (Adds horizontal scrollbars ONLY to tables, preventing page breakage) */
.article-content table {
    width: 100% !important;
    border-collapse: collapse;
    margin: 20px 0;
    display: block; /* Enables horizontal scrolling capability */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.article-content table th,
.article-content table td {
    padding: 10px;
    border: 1px solid var(--border-color);
}

/* Featured Quick Answer Box (Targets Google's Featured Snippets) */
.snippet-box {
    background-color: rgba(99, 102, 241, 0.05); /* Light lavender tint */
    border-left: 4px solid var(--accent-lavender);
    padding: 20px;
    border-radius: 0 8px 8px 0;
    margin: 25px 0;
    overflow-wrap: break-word; /* Safety wrap inside snippet */
}
.snippet-box h3 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: var(--primary-deep);
    margin-bottom: 8px;
}
.snippet-box p {
    font-style: italic;
    font-size: 1.05rem;
}

/* Article Body Typography */
.article-body h2 {
    font-family: var(--font-serif);
    color: var(--primary-deep);
    font-size: 1.75rem;
    margin: 35px 0 15px 0;
}
.article-body p {
    margin-bottom: 20px;
    font-size: 1.05rem;
    color: var(--text-main);
}

/* Sidebar and Ad Containers (Prevents Cumulative Layout Shift - CLS) */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-width: 0; /* Prevents sidebar expansion */
}

.sidebar-widget {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    min-width: 0;
}

.sidebar-widget h3 {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--primary-deep);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
}

/* Ad Placeholders */
.ad-slot-sidebar {
    max-width: 100%;
    width: 300px;
    height: 250px;
    background-color: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.8rem;
    margin: 0 auto;
}

.ad-slot-in-content {
    width: 100%;
    min-height: 90px;
    background-color: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.8rem;
    margin: 30px 0;
}

/* --- Sidebar Thumbnail List & Hover Zoom --- */
.article-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

.article-list li a {
    display: flex;
    gap: 15px;
    align-items: center;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.article-list li a:hover h3 {
    color: var(--accent-lavender);
    text-decoration: underline;
}

/* Crop wrapper mask for sidebar thumbnail images */
.sidebar-img-wrapper {
    width: 80px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden; /* Mask that crops the zooming image */
    flex-shrink: 0; /* Prevents container from collapsing */
    background-color: var(--border-color);
}

.sidebar-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Triggers zoom inside sidebar thumbnail mask on list anchor hover */
.article-list li a:hover .sidebar-img-wrapper img {
    transform: scale(1.08) !important; /* Subtle 8% scale zoom */
}

.article-list .article-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.article-list .date {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 500;
}

.article-list h3 {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--primary-deep);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- BACK TO TOP FLOATING BUTTON --- */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 46px;
    height: 46px;
    background-color: var(--primary-deep); /* Midnight Indigo */
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    
    /* Smooth transition effects */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

/* Active State Triggered via JS Scroll Listener */
.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: var(--accent-lavender); /* Lavender shift */
    transform: translateY(-4px); /* Subtle hover lift */
    color: #ffffff;
}

.back-to-top:active {
    transform: translateY(-1px);
}

/* Ensure button stays above mobile search elements cleanly */
@media (max-width: 767px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
    }
}

/* --- LOGO HOVER PROTECTION --- */

/* Overrides the global hover color change to keep logo text white */
.logo, 
.logo:hover, 
.logo:focus, 
.logo:active {
    color: #ffffff !important;
    text-decoration: none !important;
    transition: opacity 0.2s ease !important;
}

/* Keeps the "Chapter" span locked to gold */
.logo span,
.logo:hover span {
    color: var(--accent-gold) !important;
}

/* Applies a clean, professional opacity fade on hover instead of a color change */
.logo:hover {
    opacity: 0.85 !important;
}


/* --- ARTICLE SHARE SYSTEM --- */
.btn-share {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--primary-deep) !important;
    padding: 6px 14px !important;
    border-radius: 50px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.2s ease !important;
}

.btn-share:hover {
    background-color: var(--accent-lavender) !important;
    border-color: var(--accent-lavender) !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

.share-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 190px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 100;
    
    /* Hidden by default with transform scaling */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.share-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.share-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    gap: 10px;
}

.share-item:hover {
    background-color: rgba(99, 102, 241, 0.08);
    color: var(--accent-lavender);
}

.share-item svg {
    flex-shrink: 0;
}