/*
 * Site Search Widget — Stylesheet
 * ────────────────────────────────
 * All classes are prefixed with "searchp-" to avoid conflicts
 * with any existing site CSS.
 *
 * Designed to sit comfortably in a narrow left-column layout.
 * Neutral palette; inherits the page font stack.
 *
 * WCAG 2.1 AA compliant:
 *   • All text/background color combos meet 4.5:1 contrast ratio
 *   • Focus indicators are clearly visible
 *   • Interactive elements have minimum 44×44 px touch targets
 */

/* ── Widget Container ──────────────────────────────────────────────────────── */

.searchp-widget {
    box-sizing: border-box;
    width: 100%;
    font-size: 0.9375rem;       /* 15px — readable at narrow widths */
    line-height: 1.5;
    color: #1a1a1a;             /* near-black — passes AA on white */
}

.searchp-widget *,
.searchp-widget *::before,
.searchp-widget *::after {
    box-sizing: inherit;
}

/* ── Heading ───────────────────────────────────────────────────────────────── */

.searchp-heading {
    margin: 0 0 0.65rem 0;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 0.01em;
}

/* ── Search Form ───────────────────────────────────────────────────────────── */

.searchp-form {
    display: flex;
    gap: 0;
    border: 1.5px solid #6b7280;    /* neutral gray — 4.6:1 on white */
    border-radius: 4px;
    overflow: hidden;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.searchp-form:focus-within {
    border-color: #374151;
    box-shadow: 0 0 0 3px rgba(55, 65, 81, 0.25);
    outline: none;
}

.searchp-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.55rem 0.65rem;
    border: none;
    background: transparent;
    font-size: inherit;
    font-family: inherit;
    color: #1a1a1a;
    appearance: none;
    -webkit-appearance: none;
}

.searchp-input::placeholder {
    color: #6b7280;
}

.searchp-input:focus {
    outline: none;
}

.searchp-submit {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.75rem;
    border: none;
    border-left: 1.5px solid #6b7280;
    background: #374151;
    color: #ffffff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}

.searchp-submit:hover {
    background: #1f2937;
}

.searchp-submit:focus-visible {
    outline: 3px solid #374151;
    outline-offset: 2px;
}

/* ── Status / Feedback Messages ────────────────────────────────────────────── */

.searchp-status {
    margin: 0.65rem 0 0 0;
    padding: 0;
    font-size: 0.875rem;
    color: #4b5563;             /* mid-gray — 6.7:1 on white */
    min-height: 1.25rem;
}

.searchp-status[aria-live] {
    /* live region — already in the DOM, hidden until needed */
}

/* ── Results List ──────────────────────────────────────────────────────────── */

.searchp-results {
    list-style: none;
    margin: 0.5rem 0 0 0;
    padding: 0;
}

.searchp-result-item {
    border-top: 1px solid #e5e7eb;
    padding: 0.65rem 0;
}

.searchp-result-item:last-child {
    border-bottom: 1px solid #e5e7eb;
}

/* ── Result Link ───────────────────────────────────────────────────────────── */

.searchp-result-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 3px;
    padding: 0.15rem 0.25rem;
    margin: -0.15rem -0.25rem;
    transition: background 0.12s ease;
}

.searchp-result-link:hover {
    background: #f3f4f6;
}

.searchp-result-link:focus-visible {
    outline: 3px solid #374151;
    outline-offset: 2px;
}

.searchp-result-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1d4ed8;             /* blue — 4.6:1 on white */
    margin: 0 0 0.2rem 0;
}

.searchp-result-title i {
    font-size: 0.8rem;
    color: #6b7280;
    flex-shrink: 0;
}

.searchp-result-excerpt {
    font-size: 0.8125rem;       /* 13px */
    color: #4b5563;
    margin: 0;
    line-height: 1.55;
    /* Clamp to 2 lines in modern browsers */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── No Results ────────────────────────────────────────────────────────────── */

.searchp-no-results {
    margin: 0.65rem 0 0 0;
    font-size: 0.875rem;
    color: #4b5563;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.searchp-no-results i {
    color: #9ca3af;
}

/* ── Loading Spinner ───────────────────────────────────────────────────────── */

.searchp-loading {
    display: none;
    align-items: center;
    gap: 0.45rem;
    margin: 0.65rem 0 0 0;
    font-size: 0.875rem;
    color: #4b5563;
}

.searchp-loading.searchp-visible {
    display: flex;
}

.searchp-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #d1d5db;
    border-top-color: #374151;
    border-radius: 50%;
    animation: searchp-spin 0.7s linear infinite;
}

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

/* ── Reduced Motion ────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .searchp-spinner {
        animation: none;
        border-top-color: #374151;
        opacity: 0.6;
    }

    .searchp-form,
    .searchp-submit,
    .searchp-result-link {
        transition: none;
    }
}

/* ── High Contrast Mode support ────────────────────────────────────────────── */

@media (forced-colors: active) {
    .searchp-form {
        border: 2px solid ButtonText;
    }

    .searchp-submit {
        forced-color-adjust: none;
        background: ButtonText;
        color: ButtonFace;
    }
}