/* =============================================================================
   PUBLIC HEADER SEARCH
   Native desktop/tablet pill and a progressive phone-row disclosure.
   This bundle is not loaded by the standalone apps.
   ============================================================================= */

.geekly-header-search {
    --focus-ring-color: var(--clr-focus-control, currentColor);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    margin: 0;
    padding: 0 var(--space-1) 0 var(--space-3);
    border: 1px solid var(--clr-border-rest);
    border-radius: 999px;
    background: var(--clr-bg-raised);
    color: var(--clr-text-primary);
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.geekly-header-search:focus-within {
    background: var(--clr-bg-surface);
}

.geekly-header-search:has(.geekly-header-search__input:is(:focus-visible, :focus:where([data-gk-focus="keyboard"])):not(:where([data-gk-focus="pointer"]))) {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
    outline-offset: var(--focus-ring-offset);
}

.geekly-header-search__icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    color: var(--clr-text-muted);
}

.geekly-header-search__input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--clr-text-primary);
    caret-color: var(--clr-text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    line-height: var(--lh-ui);
    letter-spacing: normal;
    text-transform: capitalize;
    appearance: none;
}

/* The containing pill supplies the complete focus ring, including on phones. */
.geekly-header-search__input:is(:focus-visible, :focus:where([data-gk-focus="keyboard"])):not(:where([data-gk-focus="pointer"])) {
    outline: none;
}

.geekly-header-search__input::placeholder {
    color: var(--clr-text-muted);
    opacity: 1;
}

.geekly-header-search__submit,
.geekly-header-search__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--clr-text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* Reserve the action's space, but omit it from focus/accessibility while empty.
   Placeholder state also supports native search without JavaScript. */
.geekly-header-search:has(.geekly-header-search__input:placeholder-shown) .geekly-header-search__submit,
.geekly-header-search[data-gk-search-has-query="false"] .geekly-header-search__submit {
    visibility: hidden;
}

.geekly-header-search__submit svg,
.geekly-header-search__close svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.geekly-header-search__submit:hover,
.geekly-header-search__close:hover {
    background: var(--clr-bg-hover);
    color: var(--clr-text-primary);
}

.geekly-header-search__submit:is(:focus-visible, :focus:where([data-gk-focus="keyboard"])):not(:where([data-gk-focus="pointer"])),
.geekly-header-search__close:is(:focus-visible, :focus:where([data-gk-focus="keyboard"])):not(:where([data-gk-focus="pointer"])) {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
    outline-offset: var(--gk-site-focus-offset, -3px);
}

.geekly-header-search--desktop {
    flex: 1 1 360px;
    max-width: 480px;
    min-width: 160px;
    height: 40px;
    margin-left: clamp(0px, 1.5vw, 24px);
    /* Enlarge the text without doubling the fixed-height chrome's gutters. */
    gap: min(var(--space-2), 8px);
    padding-inline: min(var(--space-3), 12px) min(var(--space-1), 4px);
}

.geekly-header-search--mobile {
    position: absolute;
    /* Cover the row's two existing 1px borders as well as its content box. */
    inset: -1px 0;
    width: 100%;
    height: auto;
    padding-inline: var(--space-1);
    gap: var(--space-1);
    border-radius: 0;
}

.geekly-header-search--mobile .geekly-header-search__submit,
.geekly-header-search--mobile .geekly-header-search__close {
    width: 44px;
    height: 44px;
}

.geekly-mobile-topbar__links {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    height: 100%;
}

.geekly-header-search[hidden],
.geekly-mobile-topbar__links[hidden] {
    display: none;
}

.geekly-mobile-topbar__item[data-geekly-mobile-search-trigger]:is(:focus-visible, :focus:where([data-gk-focus="keyboard"])):not(:where([data-gk-focus="pointer"])) {
    --focus-ring-color: var(--clr-focus-control, currentColor);
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
    outline-offset: var(--gk-site-focus-offset, -4px);
    border-radius: var(--radius-md);
}

@media (max-width: 767px) {
    .geekly-header-search--desktop {
        display: none;
    }
}

@media (min-width: 768px) and (max-width: 979px) {
    .geekly-header-search--desktop {
        flex-basis: 240px;
        margin-left: 0;
    }
}

@media (forced-colors: active) {
    .geekly-header-search {
        border-color: ButtonText;
    }
}
