/**
 * search.css
 * Styling for Pagefind Static Search Modal and Standalone Search Page.
 * Gemini: created 2026-09-03 - Static Site Search using Pagefind (GH Issue #17) agent change
 */

:root {
    --pagefind-ui-scale: 0.95;
    --pagefind-ui-primary: #f59e0b;
    --pagefind-ui-text: #e5e5e5;
    --pagefind-ui-background: #1e1e1e;
    --pagefind-ui-border: #333333;
    --pagefind-ui-tag: #262626;
    --pagefind-ui-border-width: 1px;
    --pagefind-ui-border-radius: 10px;
    --pagefind-ui-image-border-radius: 8px;
    --pagefind-ui-image-box-ratio: 16 / 9;
    --pagefind-ui-font: inherit;
}

/* -------------------------------------------------------------
 * Global Search Trigger Button in Navbar
 * ------------------------------------------------------------- */
.nav-search-button {
    background: transparent;
    border: none;
    cursor: pointer;
    line-height: 1;
}

/* -------------------------------------------------------------
 * Search Modal Dialog (HTML5 Top Layer)
 * ------------------------------------------------------------- */
dialog#ebo-search-modal:not([open]) {
    display: none !important;
}

/* Gemini: changed 2026-09-05 - Fix mobile search modal bottom clipping and height constraints (GH Issue #38) agent change */
dialog#ebo-search-modal[open] {
    border: none;
    border-radius: 16px;
    padding: 0;
    max-width: 720px;
    width: 92%;
    height: 80vh;
    height: 80dvh;
    max-height: 640px;
    min-height: 360px;
    background: rgba(24, 24, 24, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.12);
    color: #eee;
    position: fixed;
    inset: 0;
    margin: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 10000;
}

dialog#ebo-search-modal::backdrop {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.search-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(32, 32, 32, 0.6);
}

.search-modal-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f59e0b;
    margin: 0;
}

.search-modal-title svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.search-modal-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-kbd-hint {
    font-size: 0.75rem;
    color: #888;
    background: rgba(255, 255, 255, 0.08);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.search-modal-close {
    background: transparent;
    border: none;
    color: #a3a3a3;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.search-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.search-modal-body {
    padding: 1.5rem 1.75rem 2rem 1.75rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#pagefind-modal-container .pagefind-ui__form {
    margin-bottom: 0.5rem;
}

/* -------------------------------------------------------------
 * Pagefind UI Theme Overrides & Fine Tuning
 * ------------------------------------------------------------- */
.pagefind-ui {
    font-family: inherit;
}

/* Gemini: changed 2026-09-03 - Refined clear button inside search input and symmetrical padding agent change */
.pagefind-ui .pagefind-ui__search-input {
    background: #141414 !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    color: #f5f5f5 !important;
    border-radius: 10px !important;
    font-size: 1.05rem !important;
    padding: 0.85rem 2.8rem 0.85rem 2.8rem !important;
    height: 52px !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pagefind-ui .pagefind-ui__search-input:focus {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important;
    outline: none !important;
}

.pagefind-ui .pagefind-ui__search-clear {
    position: absolute !important;
    top: 13px !important;
    right: 14px !important;
    transform: none !important;
    width: 26px !important;
    height: 26px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 50% !important;
    color: #a3a3a3 !important;
    font-size: 0 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3) !important;
    z-index: 2 !important;
}

.pagefind-ui .pagefind-ui__search-clear::before {
    content: "✕" !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    color: #a3a3a3 !important;
    transition: color 0.15s ease !important;
}

.pagefind-ui .pagefind-ui__search-clear:hover {
    background: rgba(245, 158, 11, 0.2) !important;
    border-color: rgba(245, 158, 11, 0.5) !important;
    color: #fbbf24 !important;
    transform: scale(1.08) !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3) !important;
}

.pagefind-ui .pagefind-ui__search-clear:hover::before {
    color: #fbbf24 !important;
}

.pagefind-ui .pagefind-ui__search-clear:active {
    transform: scale(0.92) !important;
}

.pagefind-ui .pagefind-ui__message {
    color: #9ca3af !important;
    font-size: 0.9rem !important;
    padding: 0.75rem 0 !important;
}

.pagefind-ui .pagefind-ui__result {
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 1.25rem 0 !important;
    transition: background 0.15s;
}

.pagefind-ui .pagefind-ui__result:hover {
    background: rgba(255, 255, 255, 0.02) !important;
}

.pagefind-ui .pagefind-ui__result-link {
    color: #f59e0b !important;
    font-weight: 600 !important;
    font-size: 1.1rem !important;
    text-decoration: none !important;
    transition: color 0.15s;
}

.pagefind-ui .pagefind-ui__result-link:hover {
    color: #fbbf24 !important;
    text-decoration: underline !important;
}

.pagefind-ui .pagefind-ui__result-excerpt {
    color: #d1d5db !important;
    font-size: 0.92rem !important;
    line-height: 1.55 !important;
    margin-top: 0.4rem !important;
}

.pagefind-ui mark {
    background: rgba(245, 158, 11, 0.3) !important;
    color: #fbbf24 !important;
    padding: 0.1rem 0.25rem !important;
    border-radius: 3px !important;
    font-weight: 600 !important;
}

.pagefind-ui .pagefind-ui__result-tags {
    margin-top: 0.5rem !important;
    display: flex !important;
    gap: 0.4rem !important;
    flex-wrap: wrap !important;
}

.pagefind-ui .pagefind-ui__result-tag {
    background: #262626 !important;
    color: #f59e0b !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
    border-radius: 6px !important;
    font-size: 0.75rem !important;
    padding: 0.2rem 0.55rem !important;
    font-weight: 500 !important;
}

.pagefind-ui .pagefind-ui__filter-panel {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding-bottom: 1rem !important;
    margin-bottom: 1rem !important;
}

.pagefind-ui .pagefind-ui__filter-name {
    color: #f59e0b !important;
    font-weight: 600 !important;
    font-size: 0.88rem !important;
}

.pagefind-ui .pagefind-ui__filter-value {
    background: #262626 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #e5e5e5 !important;
    border-radius: 6px !important;
    padding: 0.25rem 0.6rem !important;
    font-size: 0.82rem !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
}

.pagefind-ui .pagefind-ui__filter-value:hover {
    border-color: #f59e0b !important;
    color: #f59e0b !important;
}

.pagefind-ui .pagefind-ui__filter-value[aria-pressed="true"] {
    background: #f59e0b !important;
    color: #121212 !important;
    border-color: #f59e0b !important;
    font-weight: 600 !important;
}

.pagefind-ui .pagefind-ui__button {
    background: #262626 !important;
    color: #f5f5f5 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 8px !important;
    padding: 0.6rem 1.25rem !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    transition: background 0.15s, border-color 0.15s;
}

.pagefind-ui .pagefind-ui__button:hover {
    background: #333333 !important;
    border-color: #f59e0b !important;
    color: #f59e0b !important;
}

/* -------------------------------------------------------------
 * Standalone Search Page (/search.html)
 * ------------------------------------------------------------- */
.search-page-section {
    max-width: 900px;
    margin: 2.5rem auto 4rem auto;
    padding: 0 1.5rem;
}

.search-page-card {
    background: rgba(24, 24, 24, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
    /* Gemini: changed 2026-09-05 - Mobile search modal responsive positioning and safe-area adjustments (GH Issue #38) agent change */
    dialog#ebo-search-modal[open] {
        width: 94%;
        max-width: 100%;
        min-height: 180px;
        top: max(1rem, env(safe-area-inset-top, 16px));
        bottom: auto;
        left: 0;
        right: 0;
        margin: 0 auto;
        max-height: 85vh;
        max-height: calc(100dvh - max(1rem, env(safe-area-inset-top, 16px)) - env(safe-area-inset-bottom, 16px) - 1.5rem);
        border-radius: 14px;
    }

    .search-modal-header {
        padding: 0.9rem 1.15rem;
    }

    .search-modal-body {
        padding: 1.15rem 1.15rem 2rem 1.15rem;
    }

    .search-page-card {
        padding: 1.5rem;
    }

    .nav-search-shortcut {
        display: none;
    }
}
