/* storefront-search.css - header autocomplete (Item #10).
 *
 * Two layouts share these styles:
 *   - Desktop (≥640px): inline dropdown anchored under the search input.
 *   - Mobile  (<640px): full-screen overlay with a sticky search bar at top.
 *
 * Brand tokens consumed: --bg, --bg-alt, --bg3, --text, --text-dim, --border,
 * --accent, --accent-dark. All defined in assets/css/style.css.
 */

/* ── Desktop inline search ───────────────────────────────────────────── */
.ss-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.ss-input {
    /* Responsive width: ~18vw of viewport, never less than 180px, never more
       than 280px. Tightened from clamp(220, 26vw, 420) on 2026-05-10 because
       at ≥1441px (where this control is visible) the wider value was
       starving .main-nav and forcing labels like "GIFT CARDS" to wrap to
       two lines. Long-term plan is overflow-into-hamburger when nav doesn't
       fit; this is the cheap interim. */
    width: clamp(180px, 18vw, 280px);
    height: 36px;
    padding: 0 36px 0 12px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-alt, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.ss-input:focus {
    border-color: var(--accent, #dc2626);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
}
.ss-input::-webkit-search-cancel-button { display: none; }

.ss-spinner {
    position: absolute;
    right: 10px;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border, #e2e8f0);
    border-top-color: var(--accent, #dc2626);
    border-radius: 50%;
    animation: ss-spin 0.7s linear infinite;
    display: none;
    pointer-events: none;
}
.ss-wrap.is-loading .ss-spinner { display: block; }
@keyframes ss-spin { to { transform: rotate(360deg); } }

.ss-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    width: 380px;
    max-width: calc(100vw - 24px);
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--bg, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    z-index: 1000;
    display: none;
}
.ss-wrap.is-open .ss-results { display: block; }

.ss-item {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    text-decoration: none;
    color: var(--text);
    border-radius: 6px;
    align-items: center;
    cursor: pointer;
}
.ss-item:hover,
.ss-item.is-active {
    background: var(--bg3, #f1f5f9);
}

.ss-thumb {
    width: 40px;
    height: 56px;
    flex: 0 0 40px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--bg-alt, #f8fafc);
}
.ss-thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim, #64748b);
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
}

.ss-meta { flex: 1; min-width: 0; }
.ss-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ss-set {
    font-size: 0.78rem;
    color: var(--text-dim, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.ss-badges {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    flex: 0 0 auto;
}
.ss-badge {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 999px;
    line-height: 1.2;
}
.ss-badge--game-mtg     { background: #fef3c7; color: #92400e; }
.ss-badge--game-pokemon { background: #dbeafe; color: #1e40af; }
.ss-badge--game-yugioh  { background: #fce7f3; color: #9d174d; }
.ss-badge--game-other   { background: #e2e8f0; color: #475569; }
.ss-badge--stock        { background: #dcfce7; color: #14532d; }
.ss-badge--view         { background: var(--bg3, #f1f5f9); color: var(--text-dim, #64748b); }

[data-theme="dark"] .ss-badge--game-mtg     { background: #78350f; color: #fef3c7; }
[data-theme="dark"] .ss-badge--game-pokemon { background: #1e3a8a; color: #dbeafe; }
[data-theme="dark"] .ss-badge--game-yugioh  { background: #831843; color: #fce7f3; }
[data-theme="dark"] .ss-badge--game-other   { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .ss-badge--stock        { background: #14532d; color: #dcfce7; }

.ss-empty,
.ss-error {
    padding: 18px 14px;
    text-align: center;
    color: var(--text-dim, #64748b);
    font-size: 0.88rem;
}

/* ── Mobile full-screen overlay (<640px) ─────────────────────────────── */
.ss-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg, #ffffff);
    z-index: 1100;
    flex-direction: column;
}
.ss-overlay.is-open { display: flex; }

.ss-overlay-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    background: var(--bg, #ffffff);
}
.ss-overlay-input {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg-alt, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    outline: none;
}
.ss-overlay-close {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    line-height: 0;
}
.ss-overlay-close:hover { background: var(--bg3, #f1f5f9); }

.ss-overlay-results {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 8px;
}
.ss-overlay-results .ss-item { padding: 12px; }

/* Inline desktop search input is shown only when the full desktop nav is
 * shown - i.e. >1440px. Below that, the header collapses into hamburger and
 * the drawer holds its own search form, so the inline input is hidden.
 *
 * Was 639px; bumped to 1440px so search hides BEFORE the brand name has to
 * fight for space (brand-name priority is enforced in style.css logo block). */
/* Visibility now driven by JS Priority Plus overflow logic in inc/header.php
   (style.css section 21b). Removing the static breakpoint so the search bar
   participates in the same dynamic show/hide as the nav items. JS adds
   .nav-overflow when there isn't room. */
@media (min-width: 640px) {
    .ss-overlay         { display: none !important; }
}
