/*
 * Header search autocomplete dropdown — Package C.
 *
 * Three viewport regimes:
 *
 *   ≥1024 px   anchored absolute under the input, min-width 360 px,
 *              max-width 480 px, right-edge clamped 16 px from viewport
 *              via the .is-right-aligned modifier (set by JS only when
 *              the natural left-anchor position would clip).
 *
 *   768–1023   same anchored layout, no max-width cap so the dropdown
 *              can use whatever room the input gives it.
 *
 *   ≤767 px    fixed, full-viewport-width minus 16 px gutter on each
 *              side. Decouples from the (often hidden / narrow) input
 *              so result rows stay readable.
 *
 * The JS module switches between regimes by toggling the .is-mobile
 * class set automatically below the breakpoint via media query — no
 * JS-driven width math needed.
 *
 * Brand tokens used (no new colours):
 *   #FAF7F2  page bg / row hover
 *   #FFFFFF  panel bg
 *   #1A1410  primary text
 *   #C9A961  champagne accent
 *   #A88A47  deep gold hover
 *   #E8E2D5  warm beige hairline
 *   #F2EDE3  skeleton base
 */

.site-search {
    position: relative;
}

.search-dropdown {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 70;
    box-sizing: border-box;
    width: 100%;
    min-width: 360px;
    max-width: 480px;
    background: #FFFFFF;
    border: 1px solid #E8E2D5;
    border-radius: 4px;
    box-shadow: 0 12px 32px rgba(26, 20, 16, 0.10);
    /* dvh handles iOS Safari address-bar collapse so the dropdown
     * never sticks under the keyboard. The 24 px subtraction is the
     * combined header height + the 8 px gap above. */
    max-height: calc(100dvh - 120px);
    max-height: calc(100vh - 120px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

/* When the dropdown's natural left-anchored position would clip past
 * the viewport's right edge, the JS module sets this class and the
 * panel right-aligns to the input instead. Pure CSS — no positional
 * math in JS that could be fragile under transforms or scroll. */
.search-dropdown.is-right-aligned {
    left: auto;
    right: 0;
}

.search-dropdown__list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
}

.search-dropdown__row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    min-height: 84px;
    text-decoration: none;
    color: #1A1410;
    border-top: 1px solid #E8E2D5;
    transition: background-color var(--amc-motion-fast, 240ms) var(--amc-ease-premium, cubic-bezier(0.22, 1, 0.36, 1));
    box-sizing: border-box;
}
.search-dropdown__row:first-child {
    border-top: none;
}
.search-dropdown__row:hover,
.search-dropdown__row.is-focused,
.search-dropdown__row[aria-selected="true"] {
    background: #FAF7F2;
}
.search-dropdown__row:focus-visible {
    outline: 2px solid #C9A961;
    outline-offset: -2px;
}

.search-dropdown__thumb,
.search-dropdown__thumb-skeleton {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 4px;
    background: #F2EDE3;
    object-fit: cover;
    display: block;
}
.search-dropdown__thumb--placeholder {
    background: #F2EDE3;
}

.search-dropdown__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
}

.search-dropdown__name {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    color: #1A1410;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-dropdown__category {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.3;
    letter-spacing: 0.02em;
    color: #1A1410;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer "Az összes találat megjelenítése" — sticky to the bottom of
 * the dropdown so it's always reachable even when the result list
 * scrolls internally. */
.search-dropdown__footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid #E8E2D5;
    text-decoration: none;
    color: #1A1410;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color var(--amc-motion-fast, 240ms) var(--amc-ease-premium, cubic-bezier(0.22, 1, 0.36, 1));
}
.search-dropdown__footer:hover,
.search-dropdown__footer.is-focused,
.search-dropdown__footer[aria-selected="true"] {
    color: #A88A47;
}
.search-dropdown__footer:hover .search-dropdown__footer-arrow,
.search-dropdown__footer.is-focused .search-dropdown__footer-arrow,
.search-dropdown__footer[aria-selected="true"] .search-dropdown__footer-arrow {
    transform: translateX(3px);
}
.search-dropdown__footer-arrow {
    display: inline-block;
    transition: transform var(--amc-motion-fast, 240ms) var(--amc-ease-premium, cubic-bezier(0.22, 1, 0.36, 1));
}
.search-dropdown__footer:focus-visible {
    outline: 2px solid #C9A961;
    outline-offset: -2px;
}

/* Empty / error states — non-scrolling, single message. */
.search-dropdown__empty,
.search-dropdown__error {
    padding: 24px 16px;
    text-align: center;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.4;
    color: #1A1410;
    opacity: 0.65;
}
.search-dropdown__error {
    font-size: 13px;
}

/* ─── Skeleton state ──────────────────────────────────────────────── */
.search-dropdown__row--skeleton {
    pointer-events: none;
}
.search-dropdown__text-skeleton {
    flex: 1 1 auto;
    min-width: 0;
}
.skeleton-bar {
    background: #F2EDE3;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

/* ─── Mobile: fixed, full-width minus 16px gutter ─────────────────── */
@media (max-width: 767px) {
    .search-dropdown {
        position: fixed;
        left: 16px;
        right: 16px;
        top: auto;
        /* Header height varies — anchor under the input via the form
         * still being position: relative + the absolute fallback OR
         * by the JS-set inline top in mobile mode. Default top relies
         * on the input form's position: relative inheriting, which
         * does NOT work for position: fixed children. We therefore
         * use a JS-side computation that reads form.getBoundingClientRect()
         * and writes top inline. As a safe initial value we use 64px. */
        top: 64px;
        width: auto;
        min-width: 0;
        max-width: none;
        max-height: calc(100dvh - 80px);
        max-height: calc(100vh - 80px);
    }
    .search-dropdown.is-right-aligned {
        /* On mobile we always span left:16, right:16 — disable the
         * desktop right-align modifier. */
        left: 16px;
        right: 16px;
    }
    .search-dropdown__row {
        padding: 12px 14px;
        min-height: 80px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .search-dropdown__footer,
    .search-dropdown__footer-arrow,
    .search-dropdown__row {
        transition: none;
    }
}
