/* ════════════════════════════════════════════
   brick.news — Search Overlay  v1.0
   ════════════════════════════════════════════ */

/* ── Backdrop (desktop only) ───────────────── */
.srch-backdrop {
    display: none;
    position: fixed; inset: 0;
    z-index: 99;
    background: rgba(0,0,0,.42);
    animation: srch-fade .15s ease;
}
.srch-backdrop.active { display: block; }
@keyframes srch-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Wrapper that contains form + overlay ─── */
.nav-search-wrap {
    position: relative;
    flex: 1 1 0%;
    min-width: 0;
    max-width: 400px;
}
@media (max-width: 900px) { .nav-search-wrap { display: none; } }

/* The actual <form> inside the wrap */
.nav-search-form { position: relative; }

/* ── Overlay panel ──────────────────────────── */
.srch-overlay {
    position: fixed;
    /* top / left / width set by JS on desktop; mobile overrides below */
    background: #fff;
    border: 1px solid rgba(0,0,0,.1);
    border-radius: 12px;
    box-shadow: var(--shadow-search);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1001;
    animation: srch-drop .14s ease;
    /* stays hidden via [hidden] attr */
}
@keyframes srch-drop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile header (input row) ─────────────── */
.srch-mobile-hdr {
    display: none;
    align-items: center;
    gap: .65rem;
    padding: .65rem .85rem;
    background: #1A1A1A;
    border-radius: 0;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}
.srch-mobile-input {
    flex: 1;
    height: 38px;
    padding: .45rem 1rem;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: var(--radius-pill);
    font: .875rem var(--font-body);
    background: rgba(255,255,255,.1);
    color: #fff;
    outline: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.srch-mobile-input::placeholder { color: rgba(255,255,255,.45); }
.srch-mobile-input:focus {
    background: #fff;
    color: var(--color-text);
    border-color: var(--color-primary, #3B4AA8);
}
.srch-mobile-input:focus::placeholder { color: var(--color-text-3); }
.srch-mobile-close {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    background: none; border: none;
    color: rgba(255,255,255,.75); font-size: 1.1rem;
    cursor: pointer; flex-shrink: 0; border-radius: 50%;
    transition: background var(--transition-fast);
}
.srch-mobile-close:hover { background: rgba(255,255,255,.12); }

/* ── Type pills — always visible at top of overlay ── */

/* ── Recent searches ────────────────────────── */
.srch-recents { padding: .1rem 0 .5rem; }
.srch-recents-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: .55rem 1rem .35rem;
}
.srch-recents-label {
    font: 600 .68rem var(--font-body);
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-text-3, #9A9A9A);
}
.srch-clear-all {
    background: none; border: none;
    font: .7rem var(--font-body);
    color: var(--color-text-3, #9A9A9A);
    cursor: pointer; padding: 0;
    transition: color var(--transition-fast);
}
.srch-clear-all:hover { color: var(--color-primary, #3B4AA8); text-decoration: underline; }
.srch-recent-list { list-style: none; margin: 0; padding: 0; }
.srch-recent-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .38rem 1rem;
    transition: background var(--transition-fast);
}
.srch-recent-item:hover { background: var(--color-surface-2, #F0F2F5); }
.srch-recent-icon { color: var(--color-text-3, #9A9A9A); font-size: .85rem; flex-shrink: 0; }
.srch-recent-text {
    flex: 1; font: .85rem var(--font-body);
    color: var(--color-text, #1A1A1A);
    cursor: pointer; background: none; border: none;
    text-align: left; padding: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.srch-recent-text:hover { color: var(--color-primary, #3B4AA8); }
.srch-recent-rm {
    background: none; border: none;
    color: var(--color-text-3, #9A9A9A);
    font-size: .9rem; line-height: 1;
    cursor: pointer; padding: 0 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}
.srch-recent-item:hover .srch-recent-rm { opacity: 1; }
.srch-recent-rm:hover { color: var(--color-red-alt, #DC2626); }

/* ── Results section ────────────────────────── */
.srch-results { display: flex; flex-direction: column; }

/* Pills row — always visible when overlay is open */
.srch-pills {
    display: flex; align-items: center; gap: .3rem;
    padding: .7rem 1rem .6rem;
    border-bottom: 1px solid var(--color-border, #E8E4DF);
    flex-wrap: wrap;
    flex-shrink: 0;
}
.srch-pill {
    padding: .2rem .6rem;
    border: 1px solid var(--color-border, #E8E4DF);
    border-radius: var(--radius-pill);
    font: 500 .7rem var(--font-body);
    color: var(--color-text-2, #5C5C5C);
    background: transparent;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
    white-space: nowrap;
}
.srch-pill:hover { color: var(--color-primary, #3B4AA8); border-color: var(--color-primary, #3B4AA8); }
.srch-pill.srch-pill-active {
    background: var(--color-primary, #3B4AA8);
    border-color: var(--color-primary, #3B4AA8);
    color: #fff;
}

/* Count label */
.srch-count {
    padding: .4rem 1rem .1rem;
    font: .7rem var(--font-body);
    color: var(--color-text-3, #9A9A9A);
    flex-shrink: 0;
}

/* Result rows */
.srch-list { padding: .25rem 0; }
.srch-row {
    display: flex; align-items: center; gap: .7rem;
    padding: .5rem .75rem;
    margin: 0 .3rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: background var(--transition-fast);
}
.srch-row:hover { background: var(--color-surface-2, #F0F2F5); }

/* Thumbnail */
.srch-thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}
.srch-thumb-ph {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: var(--color-surface-2, #F0F2F5);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    color: var(--color-text-3, #9A9A9A);
}

/* Title */
.srch-title {
    flex: 1;
    font: 500 .875rem/1.3 var(--font-display);
    color: var(--color-text, #1A1A1A);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.srch-row:hover .srch-title { color: var(--color-primary, #3B4AA8); }

/* Type tag */
.srch-tag {
    flex-shrink: 0;
    font: 700 .6rem var(--font-body);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .14rem .42rem;
    border-radius: 4px;
    white-space: nowrap;
}
.srch-tag-article   { background: #e0e7ff; color: #3730a3; }
.srch-tag-review    { background: #fef3c7; color: #92400e; }
.srch-tag-news      { background: #dbeafe; color: #1e40af; }
.srch-tag-guide     { background: #d1fae5; color: #065f46; }
.srch-tag-interview { background: #fce7f3; color: #9d174d; }
.srch-tag-deal      { background: #ffe4e6; color: #9f1239; }
.srch-tag-event     { background: #ede9fe; color: #5b21b6; }
.srch-tag-set       { background: #fef3c7; color: #78350f; }
.srch-tag-convention   { background: #ede9fe; color: #5b21b6; }
.srch-tag-exposition   { background: #fee2e2; color: #991b1b; }
.srch-tag-workshop     { background: #f3e8ff; color: #6b21a8; }
.srch-tag-lego-market  { background: #dbeafe; color: #1e40af; }
.srch-tag-make-and-take{ background: #d1fae5; color: #065f46; }
.srch-tag-set-release  { background: #fef3c7; color: #92400e; }
.srch-tag-other        { background: #f3f4f6; color: #6b7280; }

/* Date + author meta */
.srch-meta {
    flex-shrink: 0;
    text-align: right;
    min-width: 60px;
}
.srch-date, .srch-author {
    display: block;
    font: .68rem var(--font-body);
    color: var(--color-text-3, #9A9A9A);
    white-space: nowrap;
}

/* Loading state */
.srch-loading {
    display: flex; align-items: center; justify-content: center;
    gap: .5rem;
    padding: 1.5rem 1rem;
    font: .85rem var(--font-body);
    color: var(--color-text-3, #9A9A9A);
}
.srch-spin {
    width: 16px; height: 16px;
    border: 2px solid var(--color-border, #E8E4DF);
    border-top-color: var(--color-primary, #3B4AA8);
    border-radius: 50%;
    animation: srch-spin .65s linear infinite;
    flex-shrink: 0;
}
@keyframes srch-spin { to { transform: rotate(360deg); } }

/* View all link */
.srch-view-all {
    display: block;
    text-align: center;
    padding: .6rem 1rem .75rem;
    font: 500 .8rem var(--font-body);
    color: var(--color-primary, #3B4AA8);
    text-decoration: none;
    border-top: 1px solid var(--color-border, #E8E4DF);
    margin-top: .25rem;
    flex-shrink: 0;
}
.srch-view-all:hover { text-decoration: underline; }

/* ── Empty state ────────────────────────────── */
.srch-empty { padding: .75rem 1rem 1rem; }
.srch-empty-label {
    font: 600 .8rem/1.4 var(--font-body);
    color: var(--color-text-2, #5C5C5C);
    margin-bottom: .65rem;
}
.srch-empty-list { list-style: none; margin: 0; padding: 0; }
.srch-empty-list li { border-bottom: 1px solid var(--color-border, #E8E4DF); }
.srch-empty-list li:last-child { border-bottom: none; }

.srch-community {
    display: flex; align-items: center; gap: .85rem;
    margin-top: 1rem;
    padding: .85rem 1rem;
    background: #f5f7ff;
    border: 1px solid #e0e7ff;
    border-radius: var(--radius-md-lg);
}
.srch-community-text {
    flex: 1;
    font: .8rem/1.45 var(--font-body);
    color: var(--color-text-2, #5C5C5C);
}
.srch-community-text strong {
    display: block;
    font-size: .875rem;
    color: var(--color-text, #1A1A1A);
    margin-bottom: .2rem;
}
.srch-community-btn {
    flex-shrink: 0;
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .9rem;
    background: var(--color-facebook);
    border-radius: var(--radius-md);
    color: #fff !important;
    font: 600 .78rem var(--font-body);
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--transition-fast);
}
.srch-community-btn:hover { background: var(--color-facebook-h, #1565C0); color: #fff !important; }
.srch-community-btn i { color: #fff !important; }

/* ── Full-page /search results (SSR) ────────── */
.srch-page-result {
    display: flex; align-items: center; gap: .85rem;
    padding: .85rem 0;
    border-bottom: 1px solid var(--color-border, #E8E4DF);
    text-decoration: none;
    color: inherit;
}
.srch-page-result:hover .srch-title { color: var(--color-primary, #3B4AA8); }
.srch-page-thumb {
    width: 56px; height: 56px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
}
.srch-page-thumb-ph {
    width: 56px; height: 56px;
    border-radius: var(--radius-md);
    background: var(--color-surface-2, #F0F2F5);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1.3rem;
    color: var(--color-text-3, #9A9A9A);
}
.srch-page-info { flex: 1; min-width: 0; }
.srch-page-title {
    font: 500 1rem/1.35 var(--font-display);
    color: var(--color-text, #1A1A1A);
    margin-bottom: .3rem;
    display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.srch-page-meta {
    display: flex; align-items: center; flex-wrap: wrap; gap: .35rem;
    font: .75rem var(--font-body);
    color: var(--color-text-3, #9A9A9A);
}
.srch-page-filters {
    display: flex; align-items: center; gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

/* ── Mobile: full-screen overlay (≤900px matches the nav collapse) ── */
@media (max-width: 900px) {
    .srch-overlay {
        position: fixed !important;
        inset: 0 !important;
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        border-radius: 0 !important;
        max-height: 100dvh !important;
        border: none !important;
        z-index: 1001;
        overflow: hidden;
    }
    /* Only show as flex when NOT hidden — do NOT apply display:flex to the base rule */
    .srch-overlay:not([hidden]) { display: flex; flex-direction: column; }
    .srch-mobile-hdr { display: flex !important; }
    .srch-pills { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .srch-list, .srch-recents, .srch-results { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .srch-backdrop { display: none !important; }
}
/* Prevent body scroll when overlay open on mobile */
body.srch-open { overflow: hidden; }
