/**
 * Header Styles
 * 
 * @package CursorTheme
 */

/* Header Container */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #161719;
    padding: 2rem 0;
    transition: background-color 0.3s ease;
}

/* Add padding-bottom to header on all pages except homepage */
body.home .site-header {
    padding-bottom: 1rem;
}

body:not(.home) .site-header {
    margin-bottom: 3rem;
}

.site-header .container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
}

/* Logo */
.site-logo {
    font-size: 4rem;
    font-weight: 700;
    color: #E63946;
    text-decoration: none;
}

.site-logo a {
    color: #E63946;
    text-decoration: none;
}

/* Categories Button */
.categories-btn {
    background: transparent;
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    border-radius: 40px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.categories-btn:hover {
    background: white;
    color: #161719;
}

/* Header Search */
.header-search {
    position: relative;
    width: 70%;
    max-width: none;
    margin: 0 120px 0 0;
    justify-self: center;
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 50px;
    padding: 8px 12px 8px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 1);
}

#header-search-input {
    width: 100%;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    color: #161719;
    font-size: 14px;
    transition: all 0.3s ease;
    outline: none;
}

#header-search-input::placeholder {
    color: #828282;
}

.search-submit {
    position: relative;
    background: #E63946;
    border: none;
    cursor: pointer;
    padding: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.search-submit:hover {
    background: #d62839;
    box-shadow: 0 2px 12px rgba(230, 57, 70, 0.4);
    transform: translateY(-1px);
}

.search-submit svg {
    width: 20px;
    height: 20px;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #212121;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.search-results.active {
    display: block;
}

.search-results-item {
    padding: 12px 16px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-results-item:hover {
    background: #2a2a2a;
}

.search-results-item:last-child {
    border-bottom: none;
}

.search-results-item a {
    color: white;
    text-decoration: none;
    display: block;
}

.search-results-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: white;
}

.search-results-item-excerpt {
    font-size: 12px;
    color: #ccc;
    line-height: 1.4;
}

.search-results-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* Mobile Styles */
@media (max-width: 768px) {
    /* Remove margin-bottom on mobile */
    body:not(.home) .site-header {
        margin-bottom: 0;
    }
    
    .site-header .container {
        grid-template-columns: 50px 1fr 50px;
        gap: 1rem;
    }
    
    /* Hide desktop elements */
    .site-logo {
        display: none;
    }
    
    .header-search {
        display: none;
    }
    
    .categories-btn {
        display: none;
    }
    
    /* Show mobile logo (centered) */
    .site-logo-mobile {
        display: block;
        text-align: center;
        justify-self: center;
    }
    
    /* Mobile Hamburger Menu */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        gap: 5px;
    }
    
    .mobile-menu-toggle span {
        width: 24px;
        height: 2px;
        background: white;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(8px, -8px);
    }
    
    /* Mobile Categories Menu */
    .mobile-categories-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: #161719;
        z-index: 9999;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }
    
    .mobile-categories-menu.active {
        left: 0;
    }
    
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1.5rem;
        border-bottom: 1px solid #333;
    }
    
    .mobile-menu-header h2,
    .mobile-menu-title {
        color: white;
        font-size: 1.5rem;
        margin: 0;
    }
    
    .mobile-menu-close {
        background: transparent;
        border: none;
        color: white;
        font-size: 2rem;
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    
    .mobile-categories-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .mobile-categories-list li {
        border-bottom: 1px solid #333;
    }
    
    .mobile-categories-list a {
        display: block;
        padding: 1rem 1.5rem;
        color: white;
        text-decoration: none;
        transition: background 0.2s ease;
    }
    
    .mobile-categories-list a:hover {
        background: #2a2a2a;
    }
    
    /* Mobile Search Icon */
    .mobile-search-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
    }
    
    .mobile-search-toggle svg {
        color: white;
    }
    
    /* Mobile Search Overlay - dark overlay only (no blur here) */
    .mobile-search-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(10px);
        z-index: 9998;
        display: none;
    }
    
    .mobile-search-overlay.active {
        display: block;
    }
    
    /* Prevent scroll when search is active */
    body.mobile-search-active {
        overflow: hidden;
    }
    
    /* Search bar in black box at top - above blur */
    .mobile-search-content {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 9999;
        padding-top: 0;
    }
    
    .mobile-search-form {
        display: flex;
        align-items: center;
        background: #161719;
        border-radius: 0;
        padding: 15px 20px;
        padding-right: 60px; /* Space for close button */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        margin-bottom: 0;
        width: 100%;
        border-bottom: 1px solid #333;
        position: relative;
        z-index: 10000;
    }
    
    #mobile-search-input {
        flex: 1;
        background: transparent;
        border: none;
        color: white;
        font-size: 16px;
        outline: none;
        padding-right: 10px;
    }
    
    /* Hide native clear button (blue x) on search input */
    #mobile-search-input::-webkit-search-cancel-button {
        -webkit-appearance: none;
        appearance: none;
        display: none;
    }
    
    #mobile-search-input::-webkit-search-decoration {
        -webkit-appearance: none;
    }
    
    #mobile-search-input::placeholder {
        color: #828282;
    }
    
    .mobile-search-submit {
        background: #E63946;
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        margin-left: 8px;
    }
    
    /* Position close button inside the black search box */
    .mobile-search-close {
        position: absolute;
        top: 50%;
        right: 15px;
        transform: translateY(-50%);
        background: transparent;
        border: none;
        color: white;
        font-size: 2rem;
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10001;
        margin: 0;
        padding: 0;
        line-height: 1;
    }
    
    .mobile-search-results {
        background: #212121;
        border-radius: 0;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        margin-top: 0;
        width: 100%;
        position: relative;
        z-index: 9999;
    }
    
    .mobile-search-results .search-results-item {
        padding: 12px 16px;
        border-bottom: 1px solid #333;
    }
    
    .mobile-search-results .search-results-item:last-child {
        border-bottom: none;
    }
    
    .mobile-search-results .search-results-item a {
        color: white;
        text-decoration: none;
        display: block;
    }
}

/* Desktop: Hide mobile elements */
@media (min-width: 769px) {
    .mobile-menu-toggle,
    .mobile-categories-menu,
    .site-logo-mobile,
    .mobile-search-toggle,
    .mobile-search-overlay {
        display: none;
    }
}

/* Header Opacity on Scroll */
.site-header.scrolled {
    background: rgba(22, 23, 25, 0.95);
}
