/* Homepage event search: large, animated, theme-aware (dark default, .light-mode override) */

:root {
    --hs-bg: rgba(15, 18, 32, 0.78);
    --hs-border: rgba(255, 255, 255, 0.12);
    --hs-field: rgba(255, 255, 255, 0.06);
    --hs-field-focus: rgba(255, 255, 255, 0.10);
    --hs-text: #f8fafc;
    --hs-muted: #94a3b8;
    --hs-accent: #6366f1;
    --hs-accent-hover: #4f46e5;
    --hs-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
    --hs-ring: rgba(99, 102, 241, 0.35);
}

.light-mode {
    --hs-bg: rgba(255, 255, 255, 0.96);
    --hs-border: rgba(15, 23, 42, 0.10);
    --hs-field: #f1f5f9;
    --hs-field-focus: #ffffff;
    --hs-text: #0f172a;
    --hs-muted: #64748b;
    --hs-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
    --hs-ring: rgba(99, 102, 241, 0.25);
}

/* ---------- Bar ---------- */
.search-wrap {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0.55rem;
    background: var(--hs-bg);
    border: 1px solid var(--hs-border);
    border-radius: 999px;
    box-shadow: var(--hs-shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
    animation: hs-rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.search-wrap:focus-within {
    border-color: var(--hs-accent);
    box-shadow: var(--hs-shadow), 0 0 0 4px var(--hs-ring);
    transform: translateY(-1px);
}

.search-wrap .search-field {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    height: 60px;
    padding: 0 1.1rem;
    min-width: 0;
    background: var(--hs-field);
    border: 1px solid transparent;
    border-radius: 999px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.search-wrap .search-field:focus-within {
    background: var(--hs-field-focus);
    border-color: var(--hs-accent);
}

.search-wrap .search-field > i {
    color: var(--hs-muted);
    font-size: 1rem;
    flex-shrink: 0;
    transition: color 0.2s ease, transform 0.3s ease;
}

.search-wrap .search-field:focus-within > i {
    color: var(--hs-accent);
    transform: scale(1.1);
}

.search-wrap .search-field input,
.search-wrap .search-field select {
    width: 100%;
    min-width: 0;
    height: 100%;
    border: 0;
    background: transparent;
    font-size: 1.05rem;
    color: var(--hs-text);
    outline: none;
}

.search-wrap .search-field input::placeholder {
    color: var(--hs-muted);
    opacity: 0.85;
}

.search-wrap .search-field:first-child {
    flex: 1 1 320px;
}

.search-wrap .filter-field {
    flex: 0 1 200px;
}

.light-mode .search-wrap .search-field input,
.light-mode .search-wrap .search-field select {
    color: var(--hs-text);
}

/* Native date/select icons follow the theme */
.search-wrap input[type="date"],
.search-wrap select {
    color-scheme: dark;
}
.light-mode .search-wrap input[type="date"],
.light-mode .search-wrap select {
    color-scheme: light;
}

/* ---------- Buttons ---------- */
.search-wrap .search-clear,
.search-wrap .search-filter-toggle,
.search-wrap .search-btn {
    height: 60px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.5rem;
    border: 1px solid transparent;
    transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.search-wrap .search-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.search-wrap .search-btn:hover {
    background: linear-gradient(135deg, var(--hs-accent-hover), #7c3aed);
    transform: translateY(-1px);
}

.search-wrap .search-btn:active,
.search-wrap .search-clear:active,
.search-wrap .search-filter-toggle:active {
    transform: scale(0.97);
}

.search-wrap .search-clear {
    background: transparent;
    color: var(--hs-text);
    border-color: var(--hs-border);
    animation: hs-pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

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

.search-wrap .search-clear:hover {
    background: var(--hs-field);
}

.search-wrap .search-filter-toggle {
    display: none;
    background: var(--hs-field);
    color: var(--hs-text);
}

.search-wrap :focus-visible {
    outline: 2px solid var(--hs-accent);
    outline-offset: 2px;
}

/* ---------- Live results status (sits directly under the bar) ---------- */
.search-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    max-width: 1080px;
    margin: 1.25rem auto 0;
    padding: 0.7rem 1.1rem;
    border-radius: 14px;
    background: var(--hs-field);
    border: 1px solid var(--hs-border);
    color: var(--hs-muted);
    font-size: 0.95rem;
    animation: hs-rise 0.35s ease both;
}

.search-status strong {
    color: var(--hs-text);
    font-weight: 700;
}

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

.search-status .search-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--hs-accent);
    font-size: 0.8rem;
    font-weight: 600;
}

/* ---------- Animations ---------- */
@keyframes hs-rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes hs-pop {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes hs-card-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Cards re-entering after a filter/search change */
#eventsGrid .event-card.search-anim {
    animation: hs-card-in 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: var(--hs-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
    .search-wrap,
    .search-status,
    .search-wrap .search-clear,
    #eventsGrid .event-card.search-anim {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
    .search-wrap {
        border-radius: 22px;
        padding: 0.5rem;
    }

    .search-wrap .search-field {
        height: 54px;
    }

    .search-wrap .search-field:first-child {
        flex: 1 1 100%;
    }

    .search-wrap .search-filter-toggle,
    .search-wrap .search-btn,
    .search-wrap .search-clear {
        height: 52px;
        flex: 1 1 auto;
    }

    .search-wrap .search-filter-toggle {
        display: inline-flex;
    }

    .search-wrap .filter-field,
    .search-wrap .search-clear,
    .search-wrap .search-btn {
        display: none;
    }

    .search-wrap.mobile-open .filter-field {
        display: flex;
        flex: 1 1 100%;
    }

    .search-wrap.mobile-open .search-btn {
        display: inline-flex;
        flex: 1 1 100%;
    }

    .search-wrap.mobile-open .search-clear:not([hidden]) {
        display: inline-flex;
        flex: 1 1 100%;
    }
}
