/* ==========================================================================
   Outliyr Search Modal
   Design tokens: system font stack, max border-radius 4px, subtle shadows
   ========================================================================== */

/* ---------- Scroll lock ---------- */
body.outliyr-search-open {
    overflow: hidden;
}

/* ---------- Modal overlay ---------- */
.outliyr-search-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 6vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #1a1a1a;
}

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

/* ---------- Backdrop ---------- */
.outliyr-search-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: outliyr-fade-in 0.15s ease-out;
}

/* ---------- Panel ---------- */
.outliyr-search-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    animation: outliyr-slide-in 0.15s ease-out;
    overflow: hidden;
}

/* ---------- Input wrap ---------- */
.outliyr-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.outliyr-search-icon {
    flex-shrink: 0;
    color: #6b7280;
    width: 22px;
    height: 22px;
}

.outliyr-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: 0;
    padding: 10px 4px;
    font-size: 18px; /* prevents iOS zoom + larger for prominence */
    font-family: inherit;
    font-weight: 400;
    color: #1a1a1a;
    background: transparent;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.outliyr-search-input:focus {
    outline: none;
}

.outliyr-search-input::placeholder {
    color: #9ca3af;
}

/* Hide browser clear button */
.outliyr-search-input::-webkit-search-cancel-button,
.outliyr-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.outliyr-search-clear {
    flex-shrink: 0;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.outliyr-search-clear:hover {
    background: #e5e7eb;
    color: #1a1a1a;
}

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

.outliyr-search-kbd {
    flex-shrink: 0;
    padding: 2px 6px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #f9fafb;
    color: #9ca3af;
    font-size: 11px;
    font-family: inherit;
    line-height: 1.4;
}

/* ---------- Close button ---------- */
.outliyr-search-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #6b7280;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.outliyr-search-close:hover {
    background: #f3f4f6;
    color: #1a1a1a;
}

/* ---------- Filter tabs ---------- */
.outliyr-search-filters {
    display: flex;
    gap: 6px;
    padding: 12px 20px 16px;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.outliyr-search-filters::-webkit-scrollbar {
    display: none;
}

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

.outliyr-search-modal .outliyr-search-filter-btn {
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.4;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.outliyr-search-modal .outliyr-search-filter-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.outliyr-search-modal .outliyr-search-filter-btn.active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
}

.outliyr-search-filter-count {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.7;
}

/* ---------- Results area ---------- */
.outliyr-search-results {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 0 0;
}

.outliyr-search-results:empty {
    display: none;
}

/* ---------- Result item ---------- */
.outliyr-search-result {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 20px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
    cursor: pointer;
}

.outliyr-search-result-thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    background: #f3f4f6;
}

.outliyr-search-result-body {
    flex: 1;
    min-width: 0;
}

.outliyr-search-result:hover {
    background: #f9fafb;
}

.outliyr-search-result.active {
    background: #f3f4f6;
    border-left: 3px solid #1a1a1a;
    padding-left: 17px;
}

.outliyr-search-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 2px;
    line-height: 1.3;
}

.outliyr-search-result-title mark {
    background: #fef3c7;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.outliyr-search-result-excerpt {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.outliyr-search-result-excerpt mark {
    background: #fef3c7;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.outliyr-search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #9ca3af;
}

.outliyr-search-result-type {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    background: #f3f4f6;
    border-radius: 3px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
}

.outliyr-search-result-discount {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    background: #ecfdf5;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #059669;
}

/* ---------- Default state (topics + trending) ---------- */
.outliyr-search-default {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 20px;
}

.outliyr-search-default:empty {
    display: none;
}

.outliyr-search-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin: 0 0 8px;
}

.outliyr-search-section-label:not(:first-child) {
    margin-top: 20px;
}

/* Topic chips grid */
.outliyr-search-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 4px;
}

.outliyr-search-topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.outliyr-search-topic-chip:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.outliyr-search-topic-emoji {
    font-size: 15px;
    line-height: 1;
}

/* Trending links */
.outliyr-search-trending {
    list-style: none;
    margin: 0;
    padding: 0;
}

.outliyr-search-trending li {
    margin: 0;
    padding: 0;
}

.outliyr-search-trending-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px;
    color: #374151;
    font-size: 14px;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
}

.outliyr-search-trending-link:hover {
    background: #f3f4f6;
}

.outliyr-search-trending-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: #9ca3af;
}

/* ---------- No-results state ---------- */
.outliyr-search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: #6b7280;
}

.outliyr-search-no-results-query {
    font-weight: 600;
    color: #1a1a1a;
}

/* ---------- Error state ---------- */
.outliyr-search-error {
    padding: 24px 16px;
    text-align: center;
    color: #6b7280;
}

.outliyr-search-error a {
    color: #3b82f6;
    text-decoration: underline;
}

/* ---------- Footer ---------- */
.outliyr-search-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 12px;
    color: #9ca3af;
}

.outliyr-search-footer kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #fff;
    font-size: 11px;
    font-family: inherit;
    line-height: 1.4;
    margin-right: 2px;
}

/* ---------- Nav trigger ---------- */
.outliyr-search-trigger a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* CSS-only magnifying glass for desktop nav trigger (avoids LiteSpeed SVG optimization) */
.outliyr-search-nav-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: relative;
    vertical-align: middle;
    margin-right: 5px;
}

.outliyr-search-nav-icon::after {
    content: '';
    display: block;
    width: 2px;
    height: 6px;
    background: currentColor;
    position: absolute;
    bottom: -5px;
    right: -2px;
    transform: rotate(-45deg);
    border-radius: 1px;
}

/* Hide GeneratePress default search icon — replaced by our SEARCH trigger */
.navigation-search,
.nav-search-enabled .main-navigation .search-item {
    display: none !important;
}

/* ---------- Mobile search trigger (outside hamburger) ---------- */
.outliyr-search-mobile-trigger {
    display: none; /* hidden on desktop, shown via mobile media query */
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #1a1a1a;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.outliyr-search-mobile-trigger:active {
    background: #f3f4f6;
}

/* CSS-only magnifying glass icon (avoids LiteSpeed SVG optimization) */
.outliyr-search-mobile-icon {
    display: block;
    width: 18px;
    height: 18px;
    border: 2px solid #1a1a1a;
    border-radius: 50%;
    position: relative;
}

.outliyr-search-mobile-icon::after {
    content: '';
    display: block;
    width: 2px;
    height: 8px;
    background: #1a1a1a;
    position: absolute;
    bottom: -7px;
    right: -3px;
    transform: rotate(-45deg);
    border-radius: 1px;
}

/* ---------- Animations ---------- */
@keyframes outliyr-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes outliyr-slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .outliyr-search-modal {
        padding-top: 0;
        align-items: stretch;
    }

    .outliyr-search-panel {
        max-width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
        animation: none;
    }

    .outliyr-search-results {
        flex: 1;
    }

    .outliyr-search-default {
        flex: 1;
    }

    .outliyr-search-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Show mobile search trigger */
    .outliyr-search-mobile-trigger {
        display: flex;
    }

    /* Hide ESC kbd on mobile */
    .outliyr-search-kbd {
        display: none;
    }

    /* Hide keyboard hints on mobile */
    .outliyr-search-footer {
        display: none;
    }
}
