/**
 * mod_finderocb – stylesheet
 *
 * Structural styles use class selectors (.js-finder-searchform, .js-finder-search-query)
 * so the rules apply correctly when multiple module instances exist on the page.
 *
 * Per-instance colour customisation is injected inline by tmpl/default.php,
 * scoped via the unique form ID (#form-mod-finder-ocb-{moduleId}).
 *
 * Note: #sp-search is a Helix Ultimate template position — kept for backward
 * compatibility but not required by this module's core behaviour.
 */

/* ── Template position wrapper ─────────────────────────────────────────────── */
#sp-search {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* ── Form container ─────────────────────────────────────────────────────────── */
.js-finder-searchform.mod-finder {
    position: relative; /* anchor for the feedback panel */
}

/* ── Search input (hidden by default in toggle mode) ────────────────────────── */
.js-finder-searchform.mod-finder .js-finder-search-query {
    display: none;
    width: 0;
    position: absolute;
    z-index: 100;
    top: -3px;
    right: -40px;
    border-radius: 100px;
    transition: width 0.9s ease;
}

/* ── Toggle button ──────────────────────────────────────────────────────────── */
.js-finder-searchform.mod-finder .btn-mod-finder-ocb {
    padding: 6px 8px 8px !important;
    border-radius: 100%;
    z-index: 105;
    border: 0;
    cursor: pointer;
    /* Default icon colour — overridden per-instance by inline <style> in default.php */
    color: #0F7366 !important;
}

/* ── Awesomplete dropdown ───────────────────────────────────────────────────── */
.js-finder-searchform.mod-finder .awesomplete > ul {
    z-index: 200;
    top: 40px;
    width: 300px;
    border-radius: 20px;
    padding: 15px;
}

/* ── Mobile overrides ───────────────────────────────────────────────────────── */
@media screen and (max-width: 992px) {
    .js-finder-searchform.mod-finder .js-finder-search-query {
        font-size: 14px !important;
        top: -2px;
        right: -37px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Feedback component
   ─────────────────────────────────────────────────────────────────────────────
   Shown/hidden and state-managed entirely by script.js.
   States controlled via the data-state attribute: "error" | "loading"
   Uses aria-live="polite" (set in markup) so screen readers announce updates.
   ═══════════════════════════════════════════════════════════════════════════════ */

.mod-finder-ocb-feedback {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.375rem;
    padding: 0.35rem 0.875rem 0.35rem 0.625rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    width: max-content;
    max-width: 100%;
    animation: finderOcbFadeIn 0.18s ease both;
    /* Prevent feedback width from shifting form layout */
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    white-space: nowrap;
    pointer-events: none; /* doesn't intercept clicks */
    z-index: 150;
}

/* Hidden via HTML attribute — specificity must beat [hidden]'s display:none */
.mod-finder-ocb-feedback[hidden] {
    display: none !important;
}

/* ── State: error ──── */
.mod-finder-ocb-feedback[data-state="error"] {
    background-color: #fff1f0;
    border: 1px solid #ffa39e;
    color: #cf1322;
}

/* ── State: loading ── */
.mod-finder-ocb-feedback[data-state="loading"] {
    background-color: #f6ffed;
    border: 1px solid #95de64;
    color: #237804;
}

/* ── Icon slot ──────── */
.mod-finder-ocb-feedback__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    font-style: normal;
}

/* Error icon — unicode × */
.mod-finder-ocb-feedback[data-state="error"] .mod-finder-ocb-feedback__icon::before {
    content: '✕';
    font-size: 0.7rem;
    line-height: 1;
}

/* Loading icon — CSS spinner */
.mod-finder-ocb-feedback[data-state="loading"] .mod-finder-ocb-feedback__icon::before {
    content: '';
    display: block;
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid #95de64;
    border-top-color: #237804;
    border-radius: 50%;
    animation: finderOcbSpin 0.7s linear infinite;
}

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes finderOcbSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes finderOcbFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mod-finder-ocb-feedback {
        animation: none;
    }

    .mod-finder-ocb-feedback[data-state="loading"] .mod-finder-ocb-feedback__icon::before {
        animation: none;
        border-top-color: #237804;
    }
}
