/* ==========================================================================
   HEADER STRUCTURE
   ========================================================================== */

.header {
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
    transition: var(--transition);
}

/* Navigation container */
.nav-container {
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    height: var(--header-height);
    position: relative;
}

/* Desktop/tablet: logo left-aligned against header-left */
@media (min-width: 769px) {
    .nav-container {
        justify-content: flex-start;
    }
    
    .logo {
        margin-left: 0; /* Remove any auto-centering */
    }
    
    .nav-wrapper {
        margin-left: auto; /* Push nav to the right */
    }
}

/* Mobile: keep existing centered layout */
@media (max-width: 768px) {
    .nav-container {
        justify-content: space-between;
    }
    
    .nav-wrapper {
        margin-left: 0;
    }
}

/* ==========================================================================
   HEADER SECTIONS
   ========================================================================== */

/* Left section - Forum hamburger menu */
.header-left {
    display: flex;
    align-items: center;
    width: 60px;
    justify-content: flex-start;
}

/* Centre section - Logo */
.site-title {
    font-size: 1.2rem;
    line-height: 1;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.site-title:hover {
    color: var(--primary-color);
}

.site-title span  {
    font-weight: 400;
    color: var(--primary-color);
    font-size: 1.4rem;
    gap: 0rem !important;
}

.site-title:hover span {
    color: var(--text-color);
} 

/* Right section - Navigation wrapper */
.nav-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
}

/* ==========================================================================
   HEADER BUTTONS (Universal styling)
   ========================================================================== */

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    min-width: 40px;
    min-height: 40px;
}

.header-btn:hover,
.header-btn:focus {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
}

.header-btn .material-icon {
    font-size: 1.25rem;
}

/* ==========================================================================
   NAVIGATION MENU
   ========================================================================== */

.nav-menu {
    display: flex;
    list-style: none;
    gap: 1rem;
    margin: 0;
    padding: 0;
    align-items: center;
    font-family: var(--font-family-title);
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
}

.nav-menu a:hover,
.nav-menu a:focus {
    color: var(--primary-color);
    background-color: var(--bg-secondary);
}

/* Home icon styling */
.nav-menu li:first-child a {
    padding: 0.5rem;
}

/* ==========================================================================
   SEARCH FUNCTIONALITY
   ========================================================================== */

/* Search toggle button */
.search-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.search-toggle:hover,
.search-toggle:focus {
    background: rgba(214, 92, 69, 0.1);
    color: var(--primary-color);
}

.search-toggle.active {
    background: var(--primary-color);
    color: #fff;
}

/* Search container */
.search-container {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--ui-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    min-width: 320px;
    z-index: 1001;
}

.search-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Search form */
.search-form {
    padding: 1rem;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 2px solid var(--ui-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(214, 92, 69, 0.1);
}

.search-field {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-color);
}

.search-field:focus {
    outline: none;
}

.search-field::placeholder {
    color: var(--text-muted);
}

.search-submit,
.search-close {
    background: none;
    border: none;
    padding: 0.75rem;
    cursor: pointer;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.search-submit:hover,
.search-close:hover {
    color: var(--primary-color);
}

.search-close {
    border-left: 1px solid var(--ui-border);
}

/* ==========================================================================
   THEME TOGGLE
   ========================================================================== */

.theme-toggle {
    position: relative;
}

[data-theme="dark"] .theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: inline-block !important;
}

[data-theme="light"] .theme-icon-light {
    display: inline-block;
}

[data-theme="light"] .theme-icon-dark {
    display: none;
}

/* ==========================================================================
   MOBILE PAGE TOGGLE (Right hamburger)
   ========================================================================== */

.mobile-page-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    font-size: 18px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    color: var(--text-color);
}

.mobile-page-toggle:hover {
    background-color: var(--bg-secondary);
}

.hamburger {
    width: 25px;
    height: 3px;
    background: var(--text-color);
    margin: 3px 0;
    transition: var(--transition);
    transform-origin: center;
}

/* Hamburger animation */
.mobile-page-toggle.active .hamburger:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-page-toggle.active .hamburger:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.mobile-page-toggle.active .hamburger:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

.home #mobile-menu-toggle,
.front-page #mobile-menu-toggle,
.blog #mobile-menu-toggle,
.archive #mobile-menu-toggle,
.single-post #mobile-menu-toggle {
    visibility: hidden;
}

/* ==========================================================================
   MATERIAL ICONS STYLING
   ========================================================================== */

.nav-menu .material-symbols-outlined,
.search-toggle .material-symbols-outlined,
.search-submit .material-symbols-outlined,
.search-close .material-symbols-outlined,
.theme-toggle .material-icon {
    font-size: 20px;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* ==========================================================================
   MOBILE STYLES
   ========================================================================== */

@media (max-width: 768px) {
    .nav-container {
        padding: 0 1rem;
        flex-wrap: nowrap;
    }
    
    /* Show mobile page toggle */
    .mobile-page-toggle {
        display: flex;
    }
    
    /* Mobile navigation wrapper */
    .nav-wrapper {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-color);
        flex-direction: column;
        align-items: stretch;
        box-shadow: var(--shadow);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-20px);
        transition: var(--transition);
        border-top: 1px solid var(--ui-border);
        z-index: 999;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
    }
    
    .nav-wrapper.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    /* Mobile navigation menu */
    .nav-menu {
        flex-direction: column;
        gap: 0;
        padding: 0;
        width: 100%;
    }
    
    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid var(--ui-border);
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu a,
    .nav-menu .search-toggle,
    .nav-menu .theme-toggle {
        padding: 1rem 1.5rem;
        width: 100%;
        text-align: left;
        justify-content: flex-start;
        border-radius: 0;
        background: transparent;
        border: none;
        color: var(--text-color);
        font-weight: 500;
        gap: 0.75rem;
    }
    
    .nav-menu a:hover,
    .nav-menu .search-toggle:hover,
    .nav-menu .theme-toggle:hover {
        background: rgba(214, 92, 69, 0.1);
        color: var(--primary-color);
    }
    
    /* Add text labels for mobile buttons */
    .nav-menu .search-toggle::after {
        content: 'Search';
        font-family: inherit;
        font-weight: 500;
    }
    
    .nav-menu .theme-toggle::after {
        content: 'Toggle theme';
        font-family: inherit;
        font-weight: 500;
    }
    
    /* Mobile search container */
    .search-container {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border: none;
        border-radius: 0;
        box-shadow: var(--shadow);
        min-width: auto;
        z-index: 998;
        max-height: 0;
        overflow: hidden;
        padding: 0;
    }
    
    .search-container.active {
        max-height: 100px;
        padding: 1rem;
    }
    
    .search-container .search-form {
        padding: 0;
    }
    
}

/* ==========================================================================
   VERY SMALL MOBILE STYLES
   ========================================================================== */

@media (max-width: 480px) {
    .nav-container {
        padding: 0 0.75rem;
    }
    
    .mobile-page-toggle {
        padding: 6px;
    }
    
    .mobile-page-toggle .hamburger {
        width: 20px;
        height: 2px;
        margin: 2px 0;
    }
    
    .nav-menu a,
    .nav-menu .search-toggle,
    .nav-menu .theme-toggle {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
    
    .search-container.active {
        padding: 0.75rem;
    }
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* Focus styles */
.nav-menu a:focus,
.search-toggle:focus,
.search-field:focus,
.search-submit:focus,
.search-close:focus,
.mobile-page-toggle:focus,
.theme-toggle:focus,
.header-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove outline when not using keyboard navigation */
.nav-menu a:focus:not(:focus-visible),
.search-toggle:focus:not(:focus-visible),
.mobile-page-toggle:focus:not(:focus-visible),
.theme-toggle:focus:not(:focus-visible),
.header-btn:focus:not(:focus-visible) {
    outline: none;
}

/* Search field focus styling */
.search-field:focus {
    outline: none;
}

.search-field:focus + .search-submit {
    color: var(--primary-color);
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.search-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.search-submit:disabled .material-symbols-outlined {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

@media (prefers-contrast: high) {
    .header {
        border-bottom-width: 2px;
    }
    
    .nav-wrapper {
        border-width: 2px;
    }
    
    .search-container {
        border-width: 2px;
    }
    
    .search-input-wrapper {
        border-width: 2px;
    }
    
    .mobile-page-toggle .hamburger {
        background: currentColor;
        height: 4px;
    }
}

/* ==========================================================================
   REDUCED MOTION SUPPORT
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .header,
    .nav-wrapper,
    .search-container,
    .mobile-page-toggle .hamburger,
    .search-input-wrapper,
    .nav-menu a,
    .search-toggle,
    .theme-toggle,
    .header-btn {
        transition: none;
    }
    
    .search-submit:disabled .material-symbols-outlined {
        animation: none;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .header {
        position: static;
        box-shadow: none;
        border-bottom: 1px solid #000;
    }
    
    .nav-wrapper,
    .search-container,
    .mobile-page-toggle,
    .theme-toggle {
        display: none;
    }
    
    .logo {
        color: #000;
    }
}