/*
 * Site search: header search box, live dropdown and the full results page.
 * Colours, radii and fonts come from the active theme's --theme-* variables,
 * so all four themes pick this up without per-theme rules. Logical properties
 * (inline-start/end) keep it correct for right-to-left pages.
 */

.site-search {
    position: relative;
    width: 100%;
}

/* ── Input ─────────────────────────────────────────────────────────────── */
.site-search__field {
    position: relative;
    display: flex;
    align-items: center;
}

.site-search__icon {
    position: absolute;
    inset-inline-start: 1rem;
    font-size: 0.95rem;
    color: var(--theme-text-muted, #64748b);
    pointer-events: none;
    transition: color 0.15s ease;
}

.site-search__input {
    width: 100%;
    height: 2.9rem;
    padding-block: 0;
    padding-inline: 2.7rem 3.4rem;
    font-family: var(--theme-font-body, system-ui, sans-serif);
    font-size: 0.95rem;
    color: var(--theme-text, #334155);
    background: var(--theme-bg-alt, #f8f9fb);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: 999px;
    outline: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.site-search__input::placeholder {
    color: var(--theme-text-muted, #64748b);
    opacity: 0.85;
}

/* Hide the browser's own clear button; Escape and the text field are enough. */
.site-search__input::-webkit-search-cancel-button,
.site-search__input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.site-search__input:hover {
    border-color: var(--theme-border-strong, #cbd5e1);
}

.site-search__input:focus {
    background: var(--theme-bg-card, #fff);
    border-color: var(--theme-accent, #00838f);
    box-shadow: 0 0 0 4px rgba(var(--theme-accent-rgb, 0, 131, 143), 0.16), var(--theme-shadow-md);
}

.site-search__field:focus-within .site-search__icon {
    color: var(--theme-accent, #00838f);
}

.site-search__kbd {
    position: absolute;
    inset-inline-end: 0.9rem;
    min-width: 1.5rem;
    padding: 0.1rem 0.4rem;
    font-family: var(--theme-font-mono, monospace);
    font-size: 0.72rem;
    line-height: 1.3;
    text-align: center;
    color: var(--theme-text-muted, #64748b);
    background: var(--theme-bg-card, #fff);
    border: 1px solid var(--theme-border-strong, #cbd5e1);
    border-radius: 6px;
    box-shadow: 0 1px 0 var(--theme-border-strong, #cbd5e1);
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.site-search__input:focus ~ .site-search__kbd,
.site-search.is-loading .site-search__kbd {
    opacity: 0;
}

.site-search__spinner {
    position: absolute;
    inset-inline-end: 1rem;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(var(--theme-accent-rgb, 0, 131, 143), 0.25);
    border-top-color: var(--theme-accent, #00838f);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.site-search.is-loading .site-search__spinner {
    opacity: 1;
    animation: site-search-spin 0.7s linear infinite;
}

@keyframes site-search-spin {
    to { transform: rotate(360deg); }
}

/* ── Dropdown panel ────────────────────────────────────────────────────── */
.site-search__panel {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 0.5rem);
    z-index: 1045;
    max-height: min(32rem, 70vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.4rem;
    background: var(--theme-bg-card, #fff);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: var(--theme-radius-lg, 12px);
    box-shadow: var(--theme-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));
    animation: site-search-pop 0.12s ease-out;
}

.site-search__panel[hidden] {
    display: none;
}

@keyframes site-search-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Groups and items (shared by the dropdown and the results page) ───── */
.ss-group-label {
    padding: 0.55rem 0.7rem 0.3rem;
    font-family: var(--theme-font-heading, system-ui, sans-serif);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--theme-text-muted, #64748b);
}

.ss-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.55rem 0.7rem;
    color: var(--theme-text, #334155);
    text-decoration: none;
    border-radius: calc(var(--theme-radius, 8px) + 2px);
    transition: background-color 0.12s ease;
}

.ss-item:hover,
.ss-item:focus-visible,
.ss-item.is-active {
    color: var(--theme-text, #334155);
    text-decoration: none;
    background: rgba(var(--theme-accent-rgb, 0, 131, 143), 0.08);
    outline: none;
}

.ss-item.is-active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 22%;
    bottom: 22%;
    width: 3px;
    border-radius: 3px;
    background: var(--theme-accent, #00838f);
}

.ss-item__icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.95rem;
    color: var(--theme-accent, #00838f);
    background: rgba(var(--theme-accent-rgb, 0, 131, 143), 0.1);
    border-radius: 0.7rem;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.ss-item:hover .ss-item__icon,
.ss-item.is-active .ss-item__icon {
    color: var(--theme-text-on-accent, #fff);
    background: var(--theme-accent, #00838f);
}

/* Profile photos fill the tile; the placeholder icon is used when there is none. */
.ss-item__icon--photo {
    overflow: hidden;
    background: var(--theme-bg-alt, #f8f9fb);
}

.ss-item__icon--photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.ss-item:hover .ss-item__icon--photo,
.ss-item.is-active .ss-item__icon--photo {
    background: var(--theme-bg-alt, #f8f9fb);
}

.ss-item__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.ss-item__title {
    font-family: var(--theme-font-heading, system-ui, sans-serif);
    font-size: 0.93rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--theme-text-heading, #1a2744);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ss-item__sub {
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--theme-text-muted, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Content excerpts may run two lines so the matched words stay visible. */
.ss-item__sub--snippet {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
}

.ss-item__meta {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.ss-chip {
    padding: 0.12rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--theme-text-muted, #64748b);
    background: var(--theme-bg-alt, #f8f9fb);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: 999px;
}

.ss-lock,
.ss-ext {
    font-size: 0.72rem;
    color: var(--theme-text-muted, #64748b);
}

.ss-lock {
    color: var(--theme-highlight, #f7931d);
}

.ss-item mark {
    padding: 0 0.1em;
    color: inherit;
    background: rgba(var(--theme-accent-rgb, 0, 131, 143), 0.2);
    border-radius: 3px;
}

/* ── Dropdown footer, hints, empty and error states ───────────────────── */
.ss-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.35rem -0.4rem -0.4rem;
    padding: 0.55rem 1rem;
    font-size: 0.75rem;
    color: var(--theme-text-muted, #64748b);
    background: var(--theme-bg-alt, #f8f9fb);
    border-top: 1px solid var(--theme-border, #e2e8f0);
    border-radius: 0 0 var(--theme-radius-lg, 12px) var(--theme-radius-lg, 12px);
}

.ss-footer a {
    font-weight: 600;
    color: var(--theme-accent, #00838f);
    text-decoration: none;
}

.ss-footer a:hover {
    text-decoration: underline;
}

.ss-footer kbd {
    padding: 0.05rem 0.35rem;
    font-family: var(--theme-font-mono, monospace);
    font-size: 0.7rem;
    color: var(--theme-text-muted, #64748b);
    background: var(--theme-bg-card, #fff);
    border: 1px solid var(--theme-border-strong, #cbd5e1);
    border-radius: 5px;
}

.ss-message,
.ss-empty {
    padding: 1.6rem 1rem;
    text-align: center;
    color: var(--theme-text-muted, #64748b);
}

.ss-message i,
.ss-empty > i {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
    opacity: 0.55;
}

.ss-empty__title {
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: var(--theme-text-heading, #1a2744);
}

.ss-empty__hint {
    margin: 0;
    font-size: 0.85rem;
}

/* ── Full results page ─────────────────────────────────────────────────── */
.ss-results-group {
    margin-top: 1.75rem;
}

.ss-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--theme-text-muted, #64748b);
}

.ss-group-count {
    padding: 0 0.5rem;
    font-size: 0.72rem;
    letter-spacing: 0;
    color: var(--theme-text-muted, #64748b);
    background: var(--theme-bg-alt, #f8f9fb);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: 999px;
}

.ss-card {
    padding: 0.4rem;
    background: var(--theme-bg-card, #fff);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: var(--theme-radius-lg, 12px);
    box-shadow: var(--theme-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.ss-card .ss-item__title,
.ss-card .ss-item__sub {
    white-space: normal;
}

/* ── Small screens ─────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    /* 16px stops iOS Safari from zooming the page when the box is focused. */
    .site-search__input {
        font-size: 1rem;
    }

    .site-search__panel {
        max-height: 60vh;
    }

    .ss-chip {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-search__panel,
    .site-search.is-loading .site-search__spinner {
        animation: none;
    }

    .site-search__input,
    .ss-item,
    .ss-item__icon {
        transition: none;
    }
}
