/* SCD-463 — Header search overlay styles.
 *
 * Phase 11 baseline. Polished against the Figma overlay frames
 * (1170:8916 Empty, 1170:2781 Default, 1170:8332 Preview) in the audit step.
 */

.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: block;
    opacity: 1;
    transition: opacity 160ms ease-out;
}
.search-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.search-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 20, 35, 0.5);
    cursor: pointer;
}

.search-overlay__panel {
    position: relative;
    margin: 96px auto 0;
    max-width: 720px;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(15, 20, 35, 0.25);
    overflow: hidden;
}

/* Figma "Select" component (node 1170:5156): the bar is just an icon + input
   in a white box with 1px Gray/300 border, 8 px radius, 10/14 padding, and a
   subtle drop shadow. Sits inside the panel with 24 px outer padding (the
   panel itself stays white-on-rounded; the input has its own border). */
.search-overlay__bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin: 24px;
    background: #FFFFFF;
    border: 1px solid #D5D7DA;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(10, 13, 18, 0.05);
}
.search-overlay__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.search-overlay__icon img { display: block; }
.search-overlay__input {
    /* Inter Regular 14/20, placeholder #717680 (Gray/500) — Figma I1170:5156;…;1202:1721 */
    flex: 1 1 auto;
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
    color: #1F2533;
}
.search-overlay__input::placeholder { color: #717680; opacity: 1; }

.search-overlay__body { padding: 16px 24px 24px; }
.search-overlay__body.is-hidden { display: none; }

.search-overlay__section + .search-overlay__section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #F4F5FA;
}
.search-overlay__section-title {
    font-size: 13px;
    font-weight: 600;
    color: #6B7280;
    margin: 0 0 12px;
    text-transform: capitalize;
}

.search-overlay__categories {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 0; margin: 0;
    list-style: none;
}
.search-overlay__category {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    border-radius: 12px;
    text-decoration: none;
    color: #1F2533;
    background: #F8F9FB;
    transition: background 120ms ease-out;
    text-align: center;
}
.search-overlay__category:hover { background: #EEF1FB; color: #465DA6; }
.search-overlay__category-icon {
    /* 36×36 tile from the Figma "Frame 15153" with the 20×20 icon centered. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}
.search-overlay__category-icon img {
    /* The icon SVGs ship with Brand/600 (#465DA6) hard-coded — they render
       at exactly 20×20 inside the 36×36 tile, matching Figma node 1313:7085. */
    width: 20px;
    height: 20px;
    display: block;
}
.search-overlay__category-title {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
}

.search-overlay__keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0; margin: 0;
    list-style: none;
}
.search-overlay__keyword {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: #F4F5FA;
    color: #4B5563;
    font-size: 13px;
    text-decoration: none;
}
.search-overlay__keyword:hover { background: #EEF1FB; color: #465DA6; }

.search-overlay__top-list { padding: 0; margin: 0; list-style: none; }
.search-overlay__top-row {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 12px;
    padding: 8px 0;
    text-decoration: none;
    color: inherit;
}
.search-overlay__top-thumb {
    width: 56px; height: 56px;
    object-fit: cover;
    border-radius: 6px;
    background: #F4F5FA;
    display: block;
}
.search-overlay__top-body { min-width: 0; }
.search-overlay__top-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #1F2533;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 500;
}
.search-overlay__top-row:hover .search-overlay__top-title { color: #465DA6; }
.search-overlay__top-sub {
    display: block;
    margin-top: 2px;
    color: #6B7280;
    font-size: 12px;
}

/* Echo row at the top of the preview state — Figma frame 1170:8855 /
   1170:9081 ("Frame 15054"): 20×20 magnifier, 8 px gap, typed query
   (14/20 Inter Regular, #717680), and a right-aligned "Search of all"
   link. The whole row is the navigation target so users can click
   anywhere on it. */
.search-overlay__echo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 24px 16px;
    color: #717680;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 20px;
    text-decoration: none;
    border-bottom: 1px solid #F0F1F4;
    margin-bottom: 16px;
}
.search-overlay__echo:hover { color: #465DA6; }
.search-overlay__echo-icon { display: inline-flex; flex: 0 0 auto; }
.search-overlay__echo-icon img { display: block; }
.search-overlay__echo-query {
    flex: 1 1 auto;
    color: #1F2533;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-overlay__echo-cta {
    flex: 0 0 auto;
    color: #717680;
}
.search-overlay__echo:hover .search-overlay__echo-cta { color: #465DA6; }

/* Hide individual preview sections that have no results for this query. */
.search-overlay__section[data-preview-section][data-empty="true"] { display: none; }

/* Mobile back arrow — hidden by default, revealed by the mobile breakpoint. */
.search-overlay__back {
    display: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: #1F2533;
    padding: 0;
    margin-right: 8px;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.search-overlay__back:hover { color: #465DA6; }

/* =================================================================
   Mobile (≤768) — Figma file Qkw1rAqYvxShVppu34QlEv, node 1342:4080.
   Full-screen sheet: panel fills viewport, bar gains a back arrow,
   discovery panel becomes a horizontal scroller, top-articles thumb
   doubles to 80×80, and the trending-keyword chips switch from filled
   to outlined.
   ================================================================= */
@media (max-width: 768px) {
    .search-overlay__panel {
        margin: 0;
        border-radius: 0;
        max-width: 100%;
        min-height: 100vh;
        overflow-y: auto;
        box-shadow: none;
    }

    /* Input bar floats inside the sheet with a 16-px gutter; back-arrow
       sits before the magnifier. */
    .search-overlay__bar {
        margin: 16px;
        padding: 10px 14px;
        border-radius: 8px;
    }
    .search-overlay__back {
        display: inline-flex;
    }

    .search-overlay__body { padding: 0 16px 24px; }

    /* Discovery categories — horizontal scroller (Figma 1318:13367
       shows 4 visible with the 5th implied by horizontal overflow). */
    .search-overlay__categories {
        grid-template-columns: none;
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 12px;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 0 0 4px;
        margin: 0 -16px;        /* bleed to the screen edges */
        padding-left: 16px;
        padding-right: 16px;
    }
    .search-overlay__categories::-webkit-scrollbar { display: none; }
    .search-overlay__categories > li {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }
    .search-overlay__category {
        width: 80px;
        padding: 10px 4px;
    }
    .search-overlay__category-title {
        font-size: 11px;
        line-height: 1.3;
    }

    /* Trending keyword chips — outlined instead of filled. */
    .search-overlay__keyword {
        background: transparent;
        border: 1px solid #D5D7DA;
        color: #1F2533;
    }
    .search-overlay__keyword:hover {
        background: transparent;
        border-color: #465DA6;
    }

    /* Top articles — larger square thumb, divider per row. */
    .search-overlay__top-row {
        grid-template-columns: 80px 1fr;
        gap: 12px;
        padding: 12px 0;
        border-bottom: 1px solid #F0F1F4;
    }
    .search-overlay__top-thumb {
        width: 80px;
        height: 80px;
    }
    .search-overlay__top-title {
        font-size: 15px;
        line-height: 22px;
    }
}
