/* ============================================================
   SEARCH OVERLAY — site-wide <dialog> opened from the nav icon.
   Phones: full-screen sheet. 640px+: centred panel under a dimmed
   backdrop. Results are compact rows (thumb, name, price).
============================================================ */
.search {
    padding: 0;
    border: none;
    background: var(--cream);
    color: var(--ink);
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
}
.search::backdrop { background: oklch(16.5% 0.007 50 / 0.45); }
/* Stop the page behind scrolling while the overlay is open. */
:root:has(.search[open]) { overflow: hidden; }

.search__panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.search__form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--pad-x);
    border-bottom: 2px solid var(--line);
    flex-shrink: 0;
    transition: border-color 0.2s;
}
.search__form:focus-within { border-bottom-color: var(--pink); }
.search__icon {
    color: var(--ink-soft);
    flex-shrink: 0;
}
.search__input {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-sans);
    font-weight: 600;
    /* 16px or larger stops iOS Safari zooming the page on focus. */
    font-size: 16px;
    outline: none;
}
/* Drop the browser's own clear button — it sat right beside the close X. */
.search__input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search__input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
}
.search__close {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 999px;
    background: none;
    color: var(--ink);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.2s;
}
.search__close:hover { background: var(--cream-2); }

.search__results {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px calc(var(--pad-x) - 8px) 24px;
}
.search__results:empty { padding: 0; }

.search__list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.search__result {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 64px;
    padding: 8px;
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none;
    transition: background 0.15s;
}
.search__result:hover { background: var(--cream-2); text-decoration: none; }
.search__thumb {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: cover;
    background: var(--cream-2);
}
.search__text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.search__name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.search__meta {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-soft);
}
.search__all {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    margin: 8px 8px 0;
    border-top: 1px solid var(--line);
    font-weight: 700;
    font-size: 14px;
    color: var(--ink);
}
.search__all:hover { color: var(--pink-deep); text-decoration: none; }
.search__empty {
    margin: 0;
    padding: 20px 8px;
    font-size: 14px;
    color: var(--ink-soft);
}
.search__empty a,
.search-page__empty a {
    color: var(--ink);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.search__close:focus-visible,
.search__result:focus-visible,
.search__all:focus-visible,
.search__empty a:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

@media (min-width: 640px) {
    .search {
        width: min(640px, calc(100% - 2 * var(--pad-x)));
        height: auto;
        max-height: min(80vh, 720px);
        /* The UA modal style pins top and bottom to 0, which stretches an
           auto-height dialog to max-height. Release the bottom so the panel
           is only as tall as its results. */
        bottom: auto;
        margin: 10vh auto auto;
        border-radius: 16px;
        box-shadow: var(--shadow-lift);
    }
    .search__panel { max-height: min(80vh, 720px); }
    .search__form { padding: 10px 14px 10px 20px; }
    .search__results { padding: 8px 12px 16px; }
}

/* ============================================================
   SEARCH RESULTS PAGE — /search (Enter / "View all" / no-JS)
============================================================ */
.search-page__form {
    display: flex;
    gap: 10px;
    max-width: 640px;
    margin-bottom: 28px;
}
.search-page__input {
    flex: 1;
    min-width: 0;
    height: 50px;
    padding: 0 20px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--cream);
    color: var(--ink);
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 16px;
}
.search-page__input:focus {
    outline: none;
    border-color: var(--pink);
}
.search-page__summary {
    margin: 0 0 20px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.search-page__empty {
    margin: 0;
    color: var(--ink-soft);
}
