/* ============================================
   Navbar — Interconnected Search Design
   ============================================ */

.navbar {
    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-gray-100);
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow: visible;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.navbar.scrolled {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border-bottom-color: transparent;
}

.navbar.navbar-hidden {
    transform: translateY(-100%);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    padding: 0 var(--spacing-3xl);
    max-width: 1300px;
    margin: 0 auto;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

/* ── Logo — no drag, no hover opacity ── */
.navbar-brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
    opacity: 1 !important;
    transition: none !important;
    /* Prevent browser image drag */
    -webkit-user-drag: none;
    user-select: none;
}

.navbar-brand:hover,
.navbar-brand:focus {
    opacity: 1 !important;
}

.navbar-brand img {
    height: 48px;
    width: auto;
    display: block;
    /* Belt-and-suspenders for older browsers */
    pointer-events: none;
    -webkit-user-drag: none;
    -moz-user-drag: none;
    user-select: none;
}

/* Re-enable pointer-events on the anchor so clicks still register */
.navbar-brand {
    pointer-events: auto;
}

/* ── Left group ── */
.navbar-left {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-shrink: 0;
    transition: opacity 0.18s ease;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ── Nav links — sliding underline ── */
.navbar-link {
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--color-black);
    padding: 4px 0;
    position: relative;
    display: inline-block;
    opacity: 1 !important;
    transition: none;
}

.navbar-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1.5px;
    background-color: var(--color-black);
    transition: width 0.2s ease;
}

.navbar-link:hover { opacity: 1 !important; }
.navbar-link:hover::after { width: 100%; }

/* ── Right group ── */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-shrink: 0;
    z-index: 10;
    transition: opacity 0.18s ease;
}

.navbar-right-item {
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--color-black);
    padding: 4px 0;
    position: relative;
    display: inline-block;
    opacity: 1 !important;
    transition: none;
}

.navbar-right-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1.5px;
    background-color: var(--color-black);
    transition: width 0.2s ease;
}

.navbar-right-item:hover { opacity: 1 !important; }
.navbar-right-item:hover::after { width: 100%; }

/* ── Get Started CTA ── */
.navbar-cta {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-black);
    background-color: var(--color-white);
    padding: 10px 24px;
    border: 1px solid var(--color-gray-200);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    opacity: 1 !important;
    flex-shrink: 0;
    display: inline-block;
    border-radius: 0;
    -webkit-user-drag: none;
    user-drag: none;
}

.navbar-cta:hover {
    background-color: var(--color-gray-50);
    border-color: var(--color-gray-300);
    color: var(--color-black);
    opacity: 1 !important;
}

/* ── Search icon ── */
.search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-black);
    padding: 0;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.search-toggle:hover { opacity: 0.5; }
.search-toggle svg { width: 18px; height: 18px; }

/* ═══════════════════════════════════════════════════════════
   SEARCH SYSTEM
   All three pieces share the SAME left / right bounds:
     left:  calc(var(--logo-offset, 140px) + 1.5rem)
     right: calc(var(--spacing-3xl) + 96px)    ← leaves room for Cancel
   This makes input-box and dropdown perfectly aligned.
   ═══════════════════════════════════════════════════════════ */

/* Shared positioning variable shorthand */
:root {
    --search-left:  calc(var(--logo-offset, 140px) + 1.5rem);
    --cancel-width: 88px;
    --cancel-gap:   8px;
    /* Right edge of search input = Cancel starts here */
    --search-right: calc(var(--spacing-3xl) + var(--cancel-width) + var(--cancel-gap));
}

/* ── 1. Search input container ── */
.navbar-search-container {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left:  var(--search-left);
    right: var(--search-right);
    height: 42px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 20;
}

.navbar-search-input-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    border: 1px solid var(--color-gray-200);
    background-color: var(--color-white);
    padding: 0 14px;
    gap: 10px;
    box-sizing: border-box;
    border-radius: 0;
    /* Bottom border removed when dropdown is open — see .search-active below */
    transition: border-bottom-color 0s 0.1s; /* slight delay so it doesn't flash */
}

.navbar-search-icon-left {
    display: flex;
    align-items: center;
    color: var(--color-black);
    opacity: 0.45;
    flex-shrink: 0;
}

.navbar-search-icon-left svg { width: 16px; height: 16px; }

.navbar-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--color-black);
    background: transparent;
    padding: 0;
    min-width: 0;
}

.navbar-search-input::placeholder { color: var(--color-gray-400); }

/* ── 2. Cancel button — independently positioned ── */
.navbar-search-cancel {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: var(--spacing-3xl);
    width: var(--cancel-width);
    height: 42px;
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-black);
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: 0;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    z-index: 21;
    white-space: nowrap;
}

.navbar-search-cancel:hover {
    background-color: var(--color-gray-50);
    border-color: var(--color-gray-300);
    color: var(--color-black);
}

/* ── 3. Search results dropdown ── */
/* Shares EXACT same left/right as .navbar-search-container */
.search-dropdown-panel {
    position: absolute;
    /* top: 53px precisely matches the bottom edge of the 42px centered search input */
    top: 53px; 
    left:  var(--search-left);
    right: var(--search-right);
    background-color: var(--color-white);
    /* Gray border on 3 sides, no top — connects to input bottom */
    border: 1px solid var(--color-gray-200);
    border-top: none;
    border-radius: 0;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 500;
    max-height: 60vh;
    overflow-y: auto;
}

/* ── Active state — all three pieces appear together ── */
.navbar.search-active .navbar-left {
    opacity: 0;
    pointer-events: none;
}

.navbar.search-active .navbar-right {
    opacity: 0;
    pointer-events: none;
}

.navbar.search-active .navbar-search-container {
    opacity: 1;
    pointer-events: auto;
}

.navbar.search-active .navbar-search-cancel {
    opacity: 1;
    pointer-events: auto;
}

/* Key: remove bottom border of input so it flows into the dropdown */
.navbar.search-active .navbar-search-input-wrapper {
    border-bottom-color: transparent;
}

.navbar.search-active .search-dropdown-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ─────────────────────────────────────────────
   Results & Hints
   ───────────────────────────────────────────── */
.search-results { width: 100%; }

.search-results-empty {
    text-align: center;
    padding: 1.25rem 0;
    font-size: 0.9rem;
    color: var(--color-gray-500);
}

.search-results-empty svg {
    width: 32px;
    height: 32px;
    margin: 0 auto 0.625rem;
    opacity: 0.35;
    display: block;
}

.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-gray-100);
    cursor: pointer;
    transition: background-color 0.12s ease;
    background: var(--color-white);
    opacity: 1 !important;
}

.search-result-item:first-child { border-top: 1px solid var(--color-gray-100); }
.search-result-item:last-child  { border-bottom: none; }
.search-result-item:hover { background-color: var(--color-gray-50); }

.search-result-category {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.search-result-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-black);
    margin-bottom: 2px;
}

.search-result-excerpt {
    font-size: 0.85rem;
    color: var(--color-gray-600);
    line-height: 1.4;
}

.search-hints-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

.search-hints-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-hint-tag {
    padding: 4px 14px;
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-black);
    border: 1px solid var(--color-gray-200);
    border-radius: 0;
    background: var(--color-white);
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.search-hint-tag:hover {
    background-color: var(--color-gray-50);
    border-color: var(--color-gray-300);
    color: var(--color-black);
}

/* ─────────────────────────────────────────────
   Mobile (<= 992px)
   ───────────────────────────────────────────── */
@media (max-width: 992px) {
    .navbar-inner {
        padding: 0 1rem;
        height: 56px;
    }
    .navbar-brand img { height: 32px; }
    .navbar-menu,
    .navbar-right-item { display: none; }
    
    /* Hide desktop CTA on mobile */
    .navbar-cta.desktop-cta { display: none; }
    
    /* Mobile right controls container */
    .mobile-nav-controls {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        z-index: 10;
    }
    
    /* Hide desktop search toggle on mobile */
    #search-toggle { display: none; }
    
    /* Mobile icons */
    .mobile-nav-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: transparent;
        cursor: pointer;
        color: var(--color-black);
        padding: 0;
        transition: opacity 0.15s ease;
    }
    
    .mobile-nav-btn:hover { opacity: 0.6; }
    .mobile-nav-btn svg { width: 22px; height: 22px; }
    
    /* Mobile search styles - full width, can cover logo */
    :root {
        --mobile-search-left: 1rem;
        --mobile-search-right: calc(1rem + var(--cancel-width) + var(--cancel-gap));
    }
    
    .navbar-search-container {
        left: var(--mobile-search-left);
        right: var(--mobile-search-right);
    }
    
    .search-dropdown-panel {
        left: var(--mobile-search-left);
        right: var(--mobile-search-right);
    }
    
    .navbar-search-cancel {
        right: 1rem;
    }
    
    /* Mobile sidebar overlay */
    .mobile-sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 998;
    }
    
    .mobile-sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile sidebar */
    .mobile-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        background-color: var(--color-white);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 999;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }
    
    .mobile-sidebar.active {
        transform: translateX(0);
    }
    
    /* Mobile sidebar header */
    .mobile-sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        border-bottom: 1px solid var(--color-gray-100);
    }
    
    .mobile-sidebar-header .navbar-brand img {
        height: 40px;
    }
    
    .mobile-sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: transparent;
        cursor: pointer;
        color: var(--color-black);
        padding: 0;
        transition: opacity 0.15s ease;
    }
    
    .mobile-sidebar-close:hover { opacity: 0.6; }
    .mobile-sidebar-close svg { width: 22px; height: 22px; }
    
    /* Mobile sidebar navigation */
    .mobile-sidebar-nav {
        padding: 1rem 0;
        flex: 1;
    }
    
    .mobile-nav-link {
        display: block;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        font-weight: 500;
        color: var(--color-black);
        text-decoration: none;
        transition: background-color 0.15s ease;
        opacity: 1 !important;
    }
    
    .mobile-nav-link:hover {
        background-color: var(--color-gray-50);
        opacity: 1 !important;
    }
    
    .mobile-nav-divider {
        height: 1px;
        background-color: var(--color-gray-100);
        margin: 0.75rem 1.5rem;
    }
    
    /* Mobile CTA */
    .mobile-sidebar-cta {
        padding: 1rem 1.5rem;
        border-top: 1px solid var(--color-gray-100);
    }
    
    .mobile-sidebar-cta .navbar-cta {
        width: 100%;
        text-align: center;
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
    }

    /* Hide navbar when sidebar is open */
    body.sidebar-open .navbar {
        display: none;
    }
}

/* Desktop: hide mobile controls */
@media (min-width: 993px) {
    .mobile-nav-controls,
    .mobile-sidebar-overlay,
    .mobile-sidebar {
        display: none !important;
    }
}
