/*
File: global.css
Contains essential styles loaded on every page: layout, header, footer, etc.
v15.3 - Fix for invisible search close icon.
*/

/* --- Generic --- */
body {
    font-family: var(--font-body);
    color: #334155;
    line-height: 1.8;
    background-color: #f8fafc;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Default heading sizes for each context */
h1, .h1, .single .entry-title { font-size: 2.5rem; font-weight: 800; color: var(--color-headings); }
.archive-title { font-size: 2rem; }
h2, .h2 { font-size: 1.8rem; font-weight: 700; color: var(--color-headings); }
.archive .entry-title, .blog .entry-title, .search .entry-title { font-size: 1.25rem; }
h3, .h3 { font-size: 1.5rem; font-weight: 700; color: var(--color-headings); }
h4, .h4 { font-size: 1.2rem; font-weight: 700; color: var(--color-headings); }
h5, .h5 { font-size: 1.1rem; font-weight: 700; color: var(--color-headings); }
h6, .h6 { font-size: 1rem; font-weight: 700; color: var(--color-headings); }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-headings); line-height: 1.4; margin-top: 1.5em; margin-bottom: 0.8em; }

/* --- Accessibility --- */
.screen-reader-text { border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute !important; width: 1px; word-wrap: normal !important; }
.skip-link:focus { background-color: #eee; clip: auto !important; clip-path: none; color: #444; display: block; font-size: 1em; height: auto; left: 5px; line-height: normal; padding: 15px 23px 14px; text-decoration: none; top: 5px; width: auto; z-index: 100000; }

/* --- Header Styles --- */
.site-header {
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0;
    position: relative;
    z-index: 998;
}
.site-header .header-container { display: flex; justify-content: space-between; align-items: center; max-width: 1280px; margin: 0 auto; padding: 1rem 20px; }
.site-branding { display: flex; align-items: center; gap: 15px; }
.site-title a { text-decoration: none; color: var(--color-header-text); font-size: 28px; font-weight: 700; }
.site-description { display: none; }

/* --- Desktop Navigation --- */
.main-navigation { margin-left: auto; }
.main-navigation ul { margin: 0; padding: 0; list-style: none; display: flex; }
.main-navigation li { margin: 0 5px; position: relative; }
.main-navigation a { color: #334155; font-weight: 500; text-transform: none; font-size: 15px; display: block; padding: 8px 15px; text-decoration: none; border-radius: 6px; transition: color 0.2s ease, background-color 0.2s ease; }
.main-navigation a:hover, .main-navigation .current-menu-item > a { color: var(--color-primary); background-color: #f8fafc; }
.menu-toggle { display: none; }
.submenu-toggle { display: none; }

/* --- Desktop Submenu Styles --- */
.main-navigation .sub-menu { display: none; position: absolute; top: 100%; left: 0; background-color: #fff; padding: 8px; min-width: 220px; z-index: 999; border: 1px solid #e2e8f0; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05); border-radius: 8px; text-align: left; margin-top: 5px; }
.main-navigation li:hover > .sub-menu { display: block; }
.main-navigation .sub-menu li { margin: 0; width: 100%; }
.main-navigation .sub-menu a { padding: 8px 12px; font-size: 14px; border-bottom: none; }
.main-navigation .sub-menu .sub-menu { top: -9px; left: 100%; }

/* --- Desktop Dropdown Arrow Indicator --- */
.main-navigation .menu-item-has-children > a { padding-right: 25px; }
.main-navigation .menu-item-has-children > a .menu-item-text::after { content: '▾'; font-size: 16px; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.main-navigation .sub-menu .menu-item-has-children > a .menu-item-text::after { content: '▸'; right: 15px; }

/* --- Header Actions --- */
.header-actions { display: flex; align-items: center; gap: 20px; margin-left: 20px; }

/* --- Layout Styles --- */
.site-content { max-width: 1280px; margin: 0 auto; padding: 30px 20px 40px; }
.content-area-wrapper { display: flex; flex-wrap: wrap; gap: 40px; }
.site-main { flex: 1; min-width: 0; }
.widget-area { width: 360px; flex-shrink: 0; }

/* --- Sticky Sidebar --- */
.content-area-wrapper { align-items: flex-start; }
.widget-area { position: -webkit-sticky; position: sticky; top: 30px; }

/* --- Remove top margin from the first element in content boxes --- */
.site-main > :first-child,
.widget-area .widget > :first-child { margin-top: 0; }

/* --- Content Styles --- */
.entry-content { line-height: 1.8; }
.entry-content p, .entry-content ul, .entry-content ol { margin-bottom: 1.5em; }
.entry-content a { text-decoration: underline; }
.entry-content a:hover { text-decoration: none; }

/* --- Footer Styles --- */
.site-footer { background-color: #1e293b; color: #cbd5e1; padding: 40px 20px; font-size: 0.9rem; margin-top: 40px; }
.site-footer a { color: #fff; }
.site-footer .footer-container { max-width: 1280px; margin: 0 auto; }
.footer-widgets-area { display: flex; justify-content: space-between; gap: 30px; margin-bottom: 40px; padding-bottom: 40px; border-bottom: 1px solid #334155; }
.footer-widget-column { width: 25%; }
.footer-widgets-area .widget-title { color: #fff; }
.site-info { text-align: center; }

/* --- Mobile & Tablet Responsive Styles --- */
@media (max-width: 992px) {
    .site-branding { margin-right: auto; }
    .main-navigation { margin-left: 0; }
    .main-navigation ul { display: none; }
    .menu-toggle { display: block; padding: 0; border: none; background: transparent; font-size: 1em; width: 1.5em; height: 1.5em; cursor: pointer; position: relative; z-index: 10001; }
    .menu-toggle-icon { display: block; width: 100%; height: 2px; background-color: var(--color-header-text); position: relative; transition: background-color 0.2s ease-in-out; }
    .menu-toggle-icon::before, .menu-toggle-icon::after { content: ''; display: block; width: 100%; height: 2px; background-color: var(--color-header-text); position: absolute; left: 0; transition: transform 0.3s ease-in-out; }
    .menu-toggle-icon::before { top: -0.5em; }
    .menu-toggle-icon::after { top: 0.5em; }

    .mobile-menu-open .site-header {
        z-index: 10000;
    }

    #primary-menu {
        display: block;
        position: fixed;
        top: 0;
        right: -300px;
        width: 300px;
        height: 100vh;
        background: #fff;
        padding: 60px 20px 20px;
        z-index: 1;
        overflow-y: auto;
        transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    }

    .mobile-menu-open #primary-menu {
        transform: translateX(-300px);
    }

    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.4s ease, visibility 0.4s ease;
    }

    .mobile-menu-open .mobile-menu-overlay {
        opacity: 1;
        visibility: visible;
    }

    .main-navigation li { margin: 0; width: 100%; text-align: left; }
    .main-navigation a { padding: 1em 0; font-size: 1.1rem; font-weight: bold; color: var(--color-text); border-bottom: 1px solid #eee; }
    .main-navigation li:first-child a { border-top: none; }

    .mobile-menu-open .menu-toggle { position: fixed; right: 20px; top: 1rem; }
    .mobile-menu-open .menu-toggle-icon { background-color: transparent; }
    .mobile-menu-open .menu-toggle-icon::before { transform: translateY(0.5em) rotate(45deg); }
    .mobile-menu-open .menu-toggle-icon::after { transform: translateY(-0.5em) rotate(-45deg); }

    .main-navigation .menu-item-has-children { position: relative; }
    .main-navigation .menu-item-has-children > a::after { display: none; }
    .submenu-toggle { display: block; position: absolute; right: 0; top: 0; width: 50px; height: 50px; background: transparent; border: none; cursor: pointer; }
    .submenu-toggle::before { content: '▾'; font-size: 1.2rem; color: var(--color-text); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); transition: transform 0.3s ease; }
    .submenu-open > .submenu-toggle::before { transform: translate(-50%, -50%) rotate(180deg); }
    
    #primary-menu .sub-menu { display: none; position: static; width: 100%; background-color: #f8fafc; box-shadow: none; border: none; padding: 0 0 0 15px; border-radius: 0; border-bottom: 1px solid #eee; }
    #primary-menu .sub-menu a { padding-left: 0; font-size: 1rem; font-weight: normal; border-color: #e5e5e5; }
    #primary-menu .sub-menu li:first-child a { border-top: 1px solid #e5e5e5; }
}

@media (max-width: 768px) {
    .site-content { padding: 30px 15px; }
    .content-area-wrapper, .footer-widgets-area { flex-direction: column; }
    .site-main, .widget-area { width: 100%; }
    .widget-area { position: static; }
}

/* --- Back to Top Button --- */
#back-to-top-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #1e293b; /* Black background */
    color: #ffffff; /* White color for the icon and any accidental text */
    border: none;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    cursor: pointer;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0; /* Hides any text inside the link */
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
}

#back-to-top-btn::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    /* This uses the 'color' from the rule above (#ffffff) to color the icon */
    background-color: currentColor; 
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"/></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"/></svg>');
    -webkit-mask-size: cover;
    mask-size: cover;
}

#back-to-top-btn:hover {
    background-color: #334155; /* Darker grey on hover */
    color: #ffffff; /* Ensures icon stays white on hover */
    text-decoration: none;
}

#back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* --- 404 Page Styles --- */
.error-404 {
    text-align: center;
    padding: 60px 20px;
}

.error-404 .page-title {
    font-size: 6rem; /* Large, impactful 404 number */
    font-weight: 800;
    color: var(--color-headings);
    margin: 0;
    line-height: 1;
}

.error-404 .error-subtitle {
    font-size: 1.5rem;
    color: var(--color-headings);
    margin: 10px 0 20px;
    font-weight: 500;
}

.error-404 .error-message {
    font-size: 1.1rem;
    color: var(--color-body-text);
    max-width: 500px;
    margin: 0 auto 30px;
}

/* Style the search form on the 404 page */
.error-404 .search-form {
    max-width: 400px;
    margin: 0 auto 30px;
    display: flex;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.error-404 .search-field {
    width: 100%;
    border: none;
    padding: 12px 15px;
    font-size: 1rem;
}

.error-404 .search-submit {
    background-color: var(--color-primary);
    color: #fff;
    border: none;
    padding: 0 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.error-404 .search-submit:hover {
    background-color: #334155; /* A darker shade */
}

/* Style for the "Return to Homepage" button */
.error-404 .back-to-home-button {
    display: inline-block;
    background-color: var(--color-primary);
    color: #fff;
    padding: 12px 25px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.error-404 .back-to-home-button:hover {
    background-color: #334155;
    transform: translateY(-2px);
    color: #fff;
}
/* --- Search Overlay Styles --- */
.search-toggle-icon { display: block; width: 24px; height: 24px; background-color: var(--color-header-text); -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>') no-repeat center; mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>') no-repeat center; }
.search-toggle-icon:hover { background-color: var(--color-primary); }
.search-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); z-index: 99999; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.search-overlay-active .search-overlay { opacity: 1; visibility: visible; }
.search-overlay-content { width: 100%; max-width: 600px; padding: 20px; }
.search-overlay .search-field { width: 100%; border: none; border-bottom: 2px solid var(--color-text); background: transparent; font-size: 2rem; font-family: var(--font-headings); padding: 10px 0; outline: none; text-align: center; }
.search-overlay .search-submit { display: none; }

.search-close-btn { 
    position: absolute; 
    top: 30px; 
    right: 30px; 
    width: 40px; 
    height: 40px; 
    background: transparent; 
    border: none; 
    cursor: pointer; 
    opacity: 0.8;
    transition: opacity 0.2s ease;
}
.search-close-btn:hover {
    opacity: 1;
}

/* === FIX: Set a specific dark color for the close icon 'X' === */
.search-close-btn::before, .search-close-btn::after { 
    content: ''; 
    position: absolute; 
    top: 50%; 
    left: 15%; 
    width: 70%; 
    height: 2px; 
    background-color: #334155; /* Hardcoded dark color */
}
.search-close-btn::before { transform: rotate(45deg); }
.search-close-btn::after { transform: rotate(-45deg); }

/* --- Live Search Results --- */
#search-results-container { margin-top: 20px; max-height: 50vh; overflow-y: auto; }
.live-search-results { list-style: none; padding: 0; margin: 0; }
.live-search-results li a { display: flex; align-items: center; gap: 15px; padding: 10px; border-bottom: 1px solid #eee; text-decoration: none; color: var(--color-text); }
.live-search-results li a:hover { background-color: #f4f4f4; }
.live-search-results img { width: 50px; height: 50px; object-fit: cover; border-radius: 3px; }
.live-search-results span { font-size: 1.1rem; }
.live-search-no-results { text-align: center; font-size: 1.2rem; color: #777; }
.spinner { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--color-primary); border-radius: 50%; margin: 20px auto; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }