/* ============================================
   DEDIVERSIA — Search Overlay
   ============================================ */

/* --- Trigger button in header --- */
.nav-search {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 12px;
    background: rgba(0, 180, 160, .06);
    border: 1px solid rgba(0, 180, 160, .15);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: .82rem;
    color: var(--c-text-muted);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}
.nav-search:hover {
    background: rgba(0, 180, 160, .12);
    border-color: rgba(0, 180, 160, .3);
    color: var(--c-accent-1);
    transform: translateY(-1px);
}
.nav-search svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.nav-search-label {
    font-weight: 500;
}
.nav-search kbd {
    font-family: inherit;
    background: rgba(255, 255, 255, .7);
    border: 1px solid rgba(0, 180, 160, .18);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: .68rem;
    color: var(--c-text-muted);
    line-height: 1.2;
}
@media (max-width: 980px) {
    .nav-search-label,
    .nav-search kbd { display: none; }
    .nav-search {
        padding: 0;
        width: 36px;
        height: 36px;
        justify-content: center;
        gap: 0;
    }
    .nav-search svg { width: 16px; height: 16px; }
}

/* --- Overlay backdrop --- */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(254, 252, 243, .82);
    backdrop-filter: blur(28px) saturate(120%);
    -webkit-backdrop-filter: blur(28px) saturate(120%);
    opacity: 0;
    visibility: hidden;
    transition: opacity .32s ease, visibility .32s;
}
.search-overlay[data-open="true"] {
    opacity: 1;
    visibility: visible;
}

/* Tropical washes on top of the blur — the brand atmosphere */
.search-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 12% 0%,  rgba(0, 201, 219, .14) 0%, transparent 45%),
        radial-gradient(ellipse at 90% 18%, rgba(255, 107, 107, .12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 95%, rgba(255, 184, 48, .10) 0%, transparent 55%),
        radial-gradient(ellipse at 0% 80%,  rgba(124, 77, 255, .07) 0%, transparent 50%);
    z-index: 0;
}

/* Faint grain for texture */
.search-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: .035;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/></svg>");
}

/* --- Container --- */
.search-container {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: 14vh 28px 120px;
    transform: translateY(16px) scale(.985);
    opacity: 0;
    transition: opacity .35s ease .04s, transform .45s cubic-bezier(.34, 1.56, .64, 1) .04s;
}
.search-overlay[data-open="true"] .search-container {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* --- Close button --- */
.search-close {
    position: fixed;
    top: 22px;
    right: 28px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, .8);
    border: 1px solid rgba(0, 180, 160, .15);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: .8rem;
    font-weight: 500;
    color: var(--c-text);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(0, 180, 160, .08);
}
.search-close:hover {
    background: #fff;
    border-color: var(--c-accent-2);
    color: var(--c-accent-2);
    transform: translateY(-1px);
}
.search-close kbd {
    background: rgba(0, 180, 160, .08);
    border: 1px solid rgba(0, 180, 160, .15);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: .68rem;
    font-family: inherit;
    color: var(--c-text-muted);
    line-height: 1.2;
}

/* --- Headline (the brand moment) --- */
.search-headline {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6.5vw, 4.5rem);
    line-height: .96;
    letter-spacing: -.02em;
    margin: 0 0 38px;
    color: var(--c-text);
}
.search-headline em {
    font-style: normal;
    background: var(--c-gradient-hero);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* --- Input --- */
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border: 2px solid rgba(0, 180, 160, .18);
    border-radius: 64px;
    padding: 6px 24px 6px 26px;
    box-shadow: 0 8px 32px rgba(0, 180, 160, .08), 0 2px 6px rgba(0, 180, 160, .04);
    transition: border-color .25s, box-shadow .25s;
}
.search-input-wrap:focus-within {
    border-color: var(--c-accent-2);
    box-shadow: 0 0 0 4px rgba(255, 107, 107, .12), 0 12px 36px rgba(255, 107, 107, .14);
}
.search-input-icon {
    width: 22px;
    height: 22px;
    color: var(--c-accent-1);
    flex-shrink: 0;
    transition: color .25s;
}
.search-input-wrap:focus-within .search-input-icon {
    color: var(--c-accent-2);
}
.search-input {
    flex: 1;
    background: transparent;
    border: 0;
    outline: 0;
    padding: 20px 0;
    font-family: var(--font-body);
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--c-text);
    min-width: 0;
}
.search-input::placeholder {
    color: var(--c-text-muted);
    opacity: .7;
    font-weight: 400;
}
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
    background: rgba(0, 180, 160, .08);
    border: 0;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--c-text-muted);
    transition: var(--transition);
    flex-shrink: 0;
}
.search-clear:hover {
    background: rgba(255, 107, 107, .15);
    color: var(--c-accent-2);
    transform: rotate(90deg);
}

/* --- Empty state: trending chips --- */
.search-empty {
    margin-top: 36px;
}
.search-empty-label {
    font-family: var(--font-display);
    font-size: .82rem;
    font-weight: 600;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .12em;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.search-empty-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(0, 180, 160, .25), transparent);
}
.search-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.search-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border: 1.5px solid rgba(0, 180, 160, .15);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: .92rem;
    font-weight: 500;
    color: var(--c-text);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 180, 160, .05);
}
.search-chip:hover {
    background: rgba(0, 180, 160, .06);
    border-color: var(--c-accent-1);
    color: var(--c-accent-1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 180, 160, .14);
}
.search-chip-emoji {
    font-size: 1.05rem;
    line-height: 1;
}

/* --- Results --- */
.search-results {
    margin-top: 24px;
}
.search-section {
    margin-top: 36px;
    animation: search-section-in .45s cubic-bezier(.34, 1.56, .64, 1) both;
}
.search-section:first-child { margin-top: 18px; }
.search-section-head {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-display);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--c-accent-1);
    margin: 0 0 8px;
    padding: 0 16px;
}
.search-section-head::before {
    content: '';
    flex-shrink: 0;
    width: 22px;
    height: 2px;
    background: var(--c-accent-1);
    border-radius: 2px;
}
.search-section-head::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(0, 180, 160, .25), transparent);
}
.search-section-count {
    color: var(--c-text-muted);
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: none;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 16px;
    border-radius: 18px;
    cursor: pointer;
    transition: background .2s, transform .2s;
    text-decoration: none;
    color: inherit;
    animation: search-row-in .42s cubic-bezier(.34, 1.56, .64, 1) both;
}
.search-row:hover,
.search-row[aria-selected="true"] {
    background: linear-gradient(135deg, rgba(0, 180, 160, .06), rgba(255, 107, 107, .04));
}
.search-row[aria-selected="true"] {
    box-shadow: inset 0 0 0 1.5px rgba(255, 107, 107, .25);
}
.search-row-emoji {
    font-size: 1.95rem;
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 180, 160, .08), rgba(255, 184, 48, .1));
    border-radius: 16px;
    flex-shrink: 0;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.search-row:hover .search-row-emoji,
.search-row[aria-selected="true"] .search-row-emoji {
    transform: translateY(-3px) rotate(-3deg);
}
.search-row-body {
    flex: 1;
    min-width: 0;
}
.search-row-name {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 600;
    color: var(--c-text);
    margin: 0 0 2px;
    line-height: 1.25;
}
.search-row-desc {
    font-size: .88rem;
    color: var(--c-text-muted);
    margin: 0;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.search-row-arrow {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-muted);
    transition: transform .25s, color .25s;
    opacity: .55;
}
.search-row:hover .search-row-arrow,
.search-row[aria-selected="true"] .search-row-arrow {
    transform: translateX(6px);
    color: var(--c-accent-2);
    opacity: 1;
}

/* Highlighter mark on matched substring */
.search-row mark,
.search-chip mark {
    background: linear-gradient(transparent 58%, rgba(255, 184, 48, .55) 58%, rgba(255, 184, 48, .55) 92%, transparent 92%);
    color: inherit;
    padding: 0 1px;
    border-radius: 1px;
}

/* --- No results state --- */
.search-noresults {
    margin-top: 40px;
    padding: 32px;
    text-align: center;
    background: rgba(255, 255, 255, .6);
    border: 1.5px dashed rgba(0, 180, 160, .2);
    border-radius: 24px;
}
.search-noresults-emoji {
    font-size: 2.6rem;
    margin-bottom: 14px;
    display: block;
}
.search-noresults p {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 0 0 6px;
    color: var(--c-text);
}
.search-noresults p:last-of-type {
    color: var(--c-text-muted);
    font-family: var(--font-body);
    font-size: .92rem;
    margin-bottom: 18px;
}
.search-noresults .search-chips {
    justify-content: center;
}

/* --- Footer hints --- */
.search-footer {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 22px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, .8);
    border: 1px solid rgba(0, 180, 160, .12);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: .76rem;
    color: var(--c-text-muted);
    z-index: 2;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 20px rgba(0, 180, 160, .08);
}
.search-footer span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.search-footer kbd {
    background: var(--c-surface);
    border: 1px solid rgba(0, 180, 160, .15);
    padding: 2px 7px;
    border-radius: 6px;
    font-family: inherit;
    font-size: .7rem;
    line-height: 1.2;
    color: var(--c-text);
    min-width: 16px;
    text-align: center;
}
@media (max-width: 600px) {
    .search-footer { display: none; }
    .search-container { padding-top: 11vh; padding-bottom: 64px; }
    .search-close { top: 14px; right: 14px; padding: 8px 12px; font-size: .75rem; }
    .search-headline { margin-bottom: 28px; }
    .search-input { font-size: 1.15rem; padding: 16px 0; }
    .search-input-wrap { padding: 4px 18px 4px 20px; gap: 12px; }
    .search-row { padding: 12px 12px; gap: 14px; }
    .search-row-emoji { width: 48px; height: 48px; font-size: 1.65rem; border-radius: 14px; }
    .search-row-name { font-size: 1rem; }
    .search-row-desc { font-size: .82rem; }
}

/* --- Body lock when overlay open --- */
body.search-open {
    overflow: hidden;
}

/* --- Animations --- */
@keyframes search-row-in {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes search-section-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .search-overlay,
    .search-container,
    .search-row,
    .search-section,
    .search-row-emoji,
    .search-chip { animation: none !important; transition: opacity .15s !important; }
}
