/* ============================================================
   ihe-select — custom dropdown that fully replaces the native
   <select> open list (which can't be CSS-styled). Built by
   ihe-select.js, which upgrades any <select class="ihe-select">.
   Closed = a styled trigger button; open = a styled panel we
   fully control (white card, brand hover, scrollable list).
   Falls back to the plain native <select> if JS is off.
   ============================================================ */

:root {
    --ihe-sel-primary: #F93A0B;
    --ihe-sel-text: #2e2e42;
    --ihe-sel-muted: #6e6e6e;
    --ihe-sel-border: #e0e0e0;
    --ihe-sel-hover-bg: #faf8f4;
}

/* The wrapper the JS injects around each upgraded select. */
.ihe-select-wrap {
    position: relative;
    width: 100%;
    font-family: inherit;
}

/* Hide the original native select once upgraded (kept in DOM for the value + form post). */
.ihe-select-wrap > select.ihe-select {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* Closed state — the trigger button. Inherits enough to sit inside
   either the hero (borderless) or the filter sidebar (bordered).
   Explicit resets so a host page's global `button {}` styles (e.g. a
   filled background) can never bleed into the trigger. */
.ihe-select-wrap > .ihe-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    cursor: pointer;
    background: transparent;
    background-color: transparent;
    background-image: none;
    border: none;
    box-shadow: none;
    color: var(--ihe-sel-text);
    font-family: inherit;
    font-size: inherit;
    font-weight: normal;
    line-height: 1.2;
    text-align: left;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    user-select: none;
}
.ihe-select-trigger:focus { outline: none; }

/* Defensive: a host page or theme may have a generic button:hover /
   button:focus / button:active rule that paints a background (we saw the
   trigger turn orange on hover from exactly this). Force the trigger to
   use ONLY its intended background in every state via a variable. The
   homepage leaves it transparent; the Jobs sidebar sets it to white (see
   each page's CSS). This beats theme hover rules without hard-coding a color. */
.ihe-select-wrap > .ihe-select-trigger,
.ihe-select-wrap > .ihe-select-trigger:hover,
.ihe-select-wrap > .ihe-select-trigger:focus,
.ihe-select-wrap > .ihe-select-trigger:active,
.ihe-select-wrap > .ihe-select-trigger:focus-visible {
    background: var(--ihe-trigger-bg, transparent) !important;
    background-image: none !important;
}
.ihe-select-trigger .ihe-select-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ihe-select-trigger .ihe-select-caret {
    flex: 0 0 auto;
    width: 12px; height: 8px;
    transition: transform 0.18s ease;
    pointer-events: none;
}
.ihe-select-trigger .ihe-select-caret path { stroke: var(--ihe-sel-primary); }
.ihe-select-wrap.is-open .ihe-select-caret { transform: rotate(180deg); }

/* Open state — the panel. Fully ours. */
.ihe-select-panel {
    position: fixed;
    z-index: 100000;
    background: #fff;
    border: 1px solid var(--ihe-sel-border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    padding: 6px;
    max-height: 280px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: none;
    animation: ihe-select-in 0.12s ease;
}
.ihe-select-wrap.is-open .ihe-select-panel { display: block; }

@keyframes ihe-select-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ihe-select-option {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--ihe-sel-text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.ihe-select-option:hover,
.ihe-select-option.is-active {
    background: var(--ihe-sel-hover-bg);
    color: var(--ihe-sel-primary);
}
.ihe-select-option.is-selected {
    font-weight: 600;
    color: var(--ihe-sel-primary);
}
.ihe-select-option.is-selected::after {
    content: "✓";
    float: right;
    margin-left: 12px;
    font-weight: 700;
}

/* Scrollbar polish (WebKit) */
.ihe-select-panel::-webkit-scrollbar { width: 10px; }
.ihe-select-panel::-webkit-scrollbar-thumb {
    background: #e2ded6;
    border-radius: 8px;
    border: 3px solid #fff;
}
.ihe-select-panel::-webkit-scrollbar-thumb:hover { background: #d2cdc2; }

/* On small screens, render the panel as a centered sheet so it never
   overflows the viewport or sits half-off the edge of a narrow form. */
@media (max-width: 600px) {
    .ihe-select-panel {
        position: fixed;
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 16px;
        max-height: 60vh;
        border-radius: 14px;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    }
    .ihe-select-option { padding: 14px 14px; font-size: 16px; }
    /* dim the page behind the sheet */
    .ihe-select-backdrop {
        position: fixed; inset: 0; z-index: 99999;
        background: rgba(0, 0, 0, 0.35);
        display: none;
    }
    .ihe-select-wrap.is-open .ihe-select-backdrop { display: block; }
}
