/* =============================================================================
   Header Search Overlay
   Trigger button in the header right-cluster + slide-down command-palette
   overlay that mounts SearchBarWidget (hero layout).
   ========================================================================== */

/* ---------- Trigger button --------------------------------------------------- */

.header-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4375rem 0.5rem 0.4375rem 0.75rem;
    background: rgba(127, 127, 127, 0.08);
    border: 1px solid rgba(127, 127, 127, 0.15);
    color: var(--text-secondary, inherit);
    border-radius: 999px;
    cursor: pointer;
    line-height: 1;
    transition: background-color 140ms ease-out, color 140ms ease-out, border-color 140ms ease-out;
}

.header-search-trigger:hover,
.header-search-trigger:focus-visible {
    background-color: rgba(127, 127, 127, 0.14);
    border-color: rgba(127, 127, 127, 0.25);
    color: var(--text-primary, inherit);
    outline: none;
}

.header-search-trigger:focus-visible {
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 36, 144, 200), 0.25);
}

.header-search-trigger .fa-search {
    font-size: 0.875rem;
    opacity: 0.85;
}

.header-search-shortcut-hint {
    display: none;
    align-items: center;
    gap: 0.0625rem;
    padding-left: 0.0625rem;
    font-size: 0.6875rem;
    line-height: 1;
}

.header-search-shortcut-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-primary, inherit);
    background: var(--bg-primary, #fff);
    border: 1px solid rgba(127, 127, 127, 0.25);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.header-search-shortcut-hint kbd + kbd {
    margin-left: 0.125rem;
}

@media (min-width: 992px) {
    .header-search-shortcut-hint {
        display: inline-flex;
    }
}

/* ---------- Overlay --------------------------------------------------------- */

.header-search-overlay {
    position: fixed;
    inset: 0;
    /* Sit above Bootstrap dropdowns / popovers (--z-popover: 1060) so any
       open header dropdowns (language, theme, user) don't bleed through. */
    z-index: 1075;
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease-out;
}

.header-search-overlay[hidden] {
    display: none;
}

.header-search-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.header-search-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

@supports not (backdrop-filter: blur(8px)) {
    .header-search-backdrop {
        background: rgba(0, 0, 0, 0.75);
    }
}

/* ---------- Panel ----------------------------------------------------------- */

.header-search-panel {
    position: absolute;
    top: 6vh;
    left: 50%;
    transform: translate(-50%, -16px);
    width: min(720px, 92vw);
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, inherit);
    border: 1px solid rgba(var(--bg-secondary-rgb, 0, 0, 0), 0.08);
    border-radius: var(--radius-xl, 1rem);
    box-shadow: var(--shadow-2xl, 0 25px 50px -12px rgba(0, 0, 0, 0.4));
    opacity: 0;
    overflow: hidden;
    transition:
        transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
        opacity 200ms ease-out;
}

.header-search-overlay.is-open .header-search-panel {
    transform: translate(-50%, 0);
    opacity: 1;
}

.header-search-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem 0.5rem;
}

.header-search-panel-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #6b7280);
}

.header-search-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: 0;
    color: var(--text-secondary, #6b7280);
    border-radius: var(--radius-md, 0.5rem);
    cursor: pointer;
    transition: background-color 140ms ease-out, color 140ms ease-out;
}

.header-search-close:hover,
.header-search-close:focus-visible {
    background-color: rgba(var(--bg-secondary-rgb, 0, 0, 0), 0.08);
    color: var(--text-primary, inherit);
    outline: none;
}

.header-search-panel-body {
    padding: 0.75rem 1.25rem 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

/* The mounted SearchBarWidget dropdown renders in-flow inside the panel
   instead of absolute-positioned (no need - we ARE the overlay). */
.header-search-panel-body .search-bar-widget .search-dropdown {
    position: relative;
    box-shadow: none;
    border: 1px solid rgba(var(--bg-secondary-rgb, 0, 0, 0), 0.08);
    margin-top: 0.75rem;
    max-height: 50vh;
}

/* Hide the submit + back buttons inside the overlay. The submit button gets
   visually misplaced because it's anchored to the input-wrapper (which now
   also contains the in-flow dropdown), and Enter-to-submit makes it
   redundant in a command-palette UX. */
.header-search-panel-body .search-bar-widget .search-bar-btn,
.header-search-panel-body .search-bar-widget .search-bar-back-btn {
    display: none !important;
}

/* Reclaim the right padding the missing submit button used to need so the
   placeholder text can use the full input width. */
.header-search-panel-body .search-bar-widget.search-bar-hero .search-bar-input {
    padding-right: 3rem;
}

/* Re-anchor the clear (X) button to the input row, not the wrapper center
   (the wrapper now also contains the in-flow dropdown). */
.header-search-panel-body .search-bar-widget .search-bar-clear-btn {
    top: 1.875rem;
    right: 1rem;
    transform: translateY(-50%);
}

/* ---------- Footer hint row ------------------------------------------------- */

.header-search-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(var(--bg-secondary-rgb, 0, 0, 0), 0.04);
    border-top: 1px solid rgba(var(--bg-secondary-rgb, 0, 0, 0), 0.08);
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

.header-search-footer-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.header-search-footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    padding: 0.125rem 0.375rem;
    font-family: inherit;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-primary, inherit);
    background: var(--bg-primary, #fff);
    border: 1px solid rgba(var(--bg-secondary-rgb, 0, 0, 0), 0.15);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

@media (max-width: 575px) {
    .header-search-footer {
        gap: 0.875rem;
        flex-wrap: wrap;
    }
    .header-search-footer-item span {
        display: none;
    }
}

/* ---------- Body scroll lock when overlay is open --------------------------- */

body.header-search-active {
    overflow: hidden;
}

/* ---------- Mobile sizing --------------------------------------------------- */

@media (max-width: 575px) {
    .header-search-panel {
        top: 0;
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
}

/* ---------- Reduced motion -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .header-search-overlay,
    .header-search-panel,
    .header-search-trigger,
    .header-search-close {
        transition-duration: 0.01ms !important;
    }
}
