/* ==========================================================================
   OneBuy Personal — organisation type-ahead
   Markup: cra_onebuy_personal_join_form_shortcode()
   Behaviour: assets/js/organisation-picker.js
   ========================================================================== */

.onebuy-org,
.onebuy-org *,
.onebuy-org *::before,
.onebuy-org *::after {
    box-sizing: border-box;
}

.onebuy-org {
    --org-navy: #073F59;
    --org-teal: #0E7C86;
    --org-border: #B8CBD1;
    --org-hover: #EEF6F7;
    --org-muted: #61737D;
}

/* The dropdown anchors to this wrapper, so it always opens flush under the
   input instead of cutting through the help text below it. */
.onebuy-org__field {
    position: relative;
}

/* Room for the spinner, reserved permanently so nothing shifts when it appears. */
.onebuy-org__input {
    padding-right: 42px;
}

.onebuy-org__spinner {
    position: absolute;
    top: 50%;
    right: 15px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #D6E1E5;
    border-top-color: var(--org-teal);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
}

.onebuy-org__field.is-loading .onebuy-org__spinner {
    opacity: 1;
    animation: onebuy-org-spin .6s linear infinite;
}

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

/* A spinning ring carries no meaning without the motion, and the "Searching…"
   row already states it — so drop the spinner rather than freeze it. */
@media (prefers-reduced-motion: reduce) {
    .onebuy-org__field.is-loading .onebuy-org__spinner {
        opacity: 0;
        animation: none;
    }
}

.onebuy-org__help {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--org-muted);
}

/* --------------------------------------------------------------------------
   The list
   -------------------------------------------------------------------------- */

.onebuy-org__list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    margin: 0;
    padding: 6px;
    max-height: 264px;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    background: #fff;
    border: 1px solid var(--org-border);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(7, 63, 89, .16);
}

.onebuy-org__list[hidden] { display: none; }

.onebuy-org__list::-webkit-scrollbar { width: 10px; }
.onebuy-org__list::-webkit-scrollbar-thumb {
    background: #D6E1E5;
    border: 3px solid #fff;
    border-radius: 10px;
}

/* --------------------------------------------------------------------------
   Options
   -------------------------------------------------------------------------- */

.onebuy-org__option {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 7px;
    font-size: 15px;
    line-height: 1.35;
    color: var(--org-navy);
    cursor: pointer;
    transition: background-color .12s ease;
}

.onebuy-org__option:hover,
.onebuy-org__option.is-active {
    background: var(--org-hover);
}

.onebuy-org__option.is-active {
    box-shadow: inset 0 0 0 1px var(--org-teal);
}

/* The two fixed choices are not search results — separate and mark them so
   they never read as "the organisation you were looking for". */
.onebuy-org__option--fixed {
    color: var(--org-teal);
    font-weight: 500;
}

.onebuy-org__option:not(.onebuy-org__option--fixed) + .onebuy-org__option--fixed {
    margin-top: 7px;
    padding-top: 15px;
    border-top: 1px solid #E4ECEE;
    border-radius: 0;
}

.onebuy-org__note {
    padding: 10px 12px 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--org-muted);
}

.onebuy-org__note--loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.onebuy-org__note--loading::before {
    content: "";
    width: 12px;
    height: 12px;
    flex: none;
    border: 2px solid #D6E1E5;
    border-top-color: var(--org-teal);
    border-radius: 50%;
    animation: onebuy-org-spin .6s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .onebuy-org__note--loading::before { animation: none; }
}

/* --------------------------------------------------------------------------
   The revealed "Organisation name" field
   -------------------------------------------------------------------------- */

.onebuy-org__other {
    margin-top: 18px;
    padding: 16px;
    background: #F7FAFB;
    border: 1px solid #E4ECEE;
    border-radius: 10px;
}

.onebuy-org__other[hidden] { display: none; }

.onebuy-org__other label {
    display: block;
    margin-bottom: 8px;
}

.onebuy-org__other .onebuy-org__help {
    margin-bottom: 0;
}
