:root {
    --bg-color: #ffffff;
    --text-primary: #1a2b4c;
    --header-bg: #ffffff;
    --border-color: #eeeeee;
    --icon-color: #1a2b4c;
}

[data-theme="dark"] {
    --bg-color: #093454;
    --text-primary: #ffffff;
    --header-bg: #093454;
    --border-color: #0e4b78;
    --icon-color: #ffffff;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- 2. Responsive Header Layout (Flexbox) --- */
.site-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease;
}

/* Flex container ensuring fully responsive scaling without a max-width cap */
.header-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
    padding: 1rem 5%;
    width: 100%;
    box-sizing: border-box;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* --- 3. Logo Swapping Logic & Sizing --- */
.site-branding {
    flex: 0 1 auto;
}

.logo-link img {
    height: auto;
    width: auto;
    max-height: 90px;
    max-width: 100%;
    object-fit: contain;
    /* display: block; */
}

.logo-dark { display: none; }
.logo-light { display: block; }
[data-theme="dark"] .logo-dark { display: block; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; }

/* --- 4. Menu & Toggle Button Styling --- */
.menu-toggle {
    display: none; /* Hide burger icon on desktop */
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.3s ease;
}

.menu-wrapper {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.main-navigation a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.main-navigation a:hover {
    opacity: 0.7;
}

.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--icon-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.theme-toggle-btn:hover {
    opacity: 0.7;
}

.theme-toggle-btn svg {
    width: 24px;
    height: 24px;
}

.toggle-icon.moon { display: none; }
.toggle-icon.sun { display: block; }
[data-theme="dark"] .toggle-icon.moon { display: block; }
[data-theme="dark"] .toggle-icon.sun { display: none; }

/* --- 5. Mobile Responsiveness --- */
@media (max-width: 768px) {
    .site-header {
        position: relative; 
    }

    .menu-toggle {
        display: block; 
    }

    .menu-wrapper {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--header-bg);
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        align-items: flex-start;
        padding: 1.5rem 5%;
        box-sizing: border-box;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        
        /* Smooth fade and slide transition for mobile dropdown */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    }

    /* Show menu when Underscores JS adds the .toggled class */
    .main-navigation.toggled .menu-wrapper {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .main-navigation ul {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .main-navigation a {
        display: block;
        width: 100%;
        padding: 1rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .theme-toggle-btn {
        margin-top: 1rem;
        padding: 0.5rem 0;
        justify-content: flex-start;
        width: 100%;
    }
}


/* a:visited fix */
/* ==========================================================================
   Global Visited Link Fixes (Removes Default Browser Purple)
   ========================================================================== */

/* 1. Global reset: forces visited text links to inherit their parent color */
a:visited {
    color: inherit; 
}

/* 2. Specific fix for your primary buttons to maintain contrast */
.btn-primary,
.btn-primary:visited {
    color: var(--bg-color); /* Keeps text inside the button perfectly inverted */
}

/* 3. Specific fix for your Teal accent links (Read More, etc.) */
.service-link:visited,
.archive-read-more:visited,
.archive-service-read-more:visited {
    color: #17a2b8;
}

/* 4. Fix for post and service titles */
.service-title a:visited,
.blog-card-title a:visited,
.archive-card-title a:visited,
.archive-service-card-title a:visited {
    color: var(--text-primary);
}