/* ==========================================================================
   Reusable select2 skin for the front site (Figma: QF - BilAraby -
   WebsiteDesign-Concept-2, node 40004861:37556 "Select Country").

   Applies to selects rendered through <x-front.select> (or any select carrying
   .ba-select2), which init with containerCssClass 'ba-select2-container' and
   dropdownCssClass 'ba-select2-dropdown' - see select2-revamp.js. select2
   re-parents the dropdown to <body>, so it cannot be scoped under the
   container and needs its own class; everything here keys off those two so
   nothing leaks onto the admin theme or the pre-existing .select2 usages on
   the watchlist page.

   THEME: select2-revamp.js inits with theme 'ba', which switches off the skin
   select2 ships - every rule in its stylesheet is scoped under
   .select2-container--default, and none of that matches once the theme class
   is .select2-container--ba. What survives is its structural base layer, which
   still writes three-class rules like `.select2-container
   .select2-selection--single .select2-selection__rendered`. That is why the
   inner pieces below are reached through the longer
   `.ba-select2-container.select2-container .select2-selection ...` chain
   rather than the shortest selector that reads well - don't shorten them.

   Turning the theme off also means anything the default skin used to provide
   and the design still wants (the results cursor, for one) has to be written
   here explicitly.

   Three states come from the design:
     closed/empty     - translucent cream tint, hairline border, regular label
     open             - white pill + panel, inset highlight, ambient shadow
     closed/selected  - cream-50 pill, white border, bold label, shadow
   ========================================================================== */

/* The native <select> is only hidden once select2 has replaced it; until then
   the unstyled control would flash on slow connections. Guarded on the script
   having run at all (html.ba-select2-ready, set by select2-revamp.js) so a
   failed/blocked bundle leaves a usable native control behind instead of an
   invisible one. */
html.ba-select2-ready .ba-select2:not(.select2-hidden-accessible) { visibility: hidden; }

/* --------------------------------------------------------------------------
   Closed control (the pill)
   -------------------------------------------------------------------------- */
/* The pill hugs its label, the way every pill in this design does - a fixed
   width would leave a short value floating in dead space. select2 writes an
   inline width on the container it injects, so !important is the only way to
   hand sizing back to the content. The `width` prop still pins it when a page
   needs a set size; max-width keeps a long label from overflowing its column
   (the label itself then ellipsises). */
.ba-select2-field { max-width: 100%; }
.ba-select2-container.select2-container {
    width: var(--ba-select-w, auto) !important;
    max-width: 100%;
}

.ba-select2-container.select2-container .select2-selection {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 12px 16px;
    border: 1px solid rgba(177, 175, 165, .5);
    border-radius: 61px;
    background: rgba(236, 230, 211, .4);
    outline: none;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.ba-select2-container.select2-container .select2-selection .select2-selection__rendered {
    /* `auto` basis, not 0: the pill is shrink-to-fit, so the label has to
       report its natural width as the container's intrinsic size. Growing is
       still on, which is what keeps the chevron pinned to the trailing edge
       when a page does pin a wider `width`. */
    flex: 1 1 auto;
    min-width: 0;
    /* select2's base rule pads this for the arrow it absolutely positions; the
       arrow is a flex sibling here, so the padding is dead weight that would
       shift the label off the design's 16px inset. */
    padding: 0;
    font-family: var(--primary-font, 'Almarai'), sans-serif;
    font-size: 16px;
    font-weight: 400;
    /* 24px from the design, not select2's 28px, which is tuned to its own
       28px-tall control and would push the label off-centre in a 48px pill. */
    line-height: 24px;
    color: var(--hr-brown-500, #1b190c);
    text-align: start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Empty / placeholder state -------------------------------------------
   select2 paints the placeholder through the same node as a real value, so
   both the muted default colour it ships (#999) and the bold weight the
   selected state adds below have to be undone here. This is the design's
   resting pill: translucent cream, hairline, regular-weight label. */
.ba-select2-container.select2-container .select2-selection .select2-selection__placeholder {
    font-weight: 400;
    color: var(--hr-brown-500, #1b190c);
}
/* Marker class for pages that need to target the resting state directly; the
   styling above already covers the default case. */
.ba-select2-container.ba-select2--empty .select2-selection {
    background: rgba(236, 230, 211, .4);
    border-color: rgba(177, 175, 165, .5);
    box-shadow: none;
}
.ba-select2-container.ba-select2--empty .select2-selection .select2-selection__rendered { font-weight: 400; }

/* Chevron. select2's arrow is an absolutely positioned <b> with a CSS-triangle
   border; blanking the borders and painting the design's stroked glyph as a
   background keeps select2's own show/hide behaviour intact. */
.ba-select2-container.select2-container .select2-selection .select2-selection__arrow {
    position: static;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    top: auto;
    right: auto;
    margin-inline-start: 8px;
    background: url("../images/press-releases-revamp/icon-chevron-down.svg") no-repeat center / 11px 6px;
    transition: transform .2s ease;
}
.ba-select2-container.select2-container .select2-selection .select2-selection__arrow b { display: none; }

/* Clear ("x") sits before the chevron rather than floating over the label. */
.ba-select2-container.select2-container .select2-selection .select2-selection__clear {
    order: 1;
    position: static;
    float: none;
    width: auto;
    height: auto;
    margin: 0 0 0 8px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: var(--hr-brown-300, #66655c);
    background: none;
    border: 0;
}
.ba-select2-container.select2-container .select2-selection .select2-selection__clear:hover { color: var(--hr-brown-500, #1b190c); }

/* Selected state: cream-50 fill, white hairline, bold label, ambient shadow +
   the inset top highlight every pill in this design system carries. */
.ba-select2-container.ba-select2--has-value .select2-selection {
    background: var(--hr-cream-50, #fefefd);
    border-color: #fff;
    box-shadow:
        inset 0 4px 6.1px rgba(255, 255, 255, .23),
        2px 23px 14px rgba(0, 0, 0, .02),
        1px 10px 10px rgba(0, 0, 0, .03),
        0 3px 6px rgba(0, 0, 0, .03);
}
.ba-select2-container.ba-select2--has-value .select2-selection .select2-selection__rendered { font-weight: 700; }
/* The chevron thickens with the label. Same 10x5 glyph as the default one, at
   stroke-width 2 instead of 1 - the viewBox is 12x7 rather than 11x6 only so
   the fatter stroke has room to sit inside it without clipping, hence the
   matching background-size. */
.ba-select2-container.ba-select2--has-value .select2-selection .select2-selection__arrow {
    background-image: url("../images/press-releases-revamp/icon-chevron-down-bold.svg");
    background-size: 12px 7px;
}

/* Open state: white pill, chevron flipped. */
.ba-select2-container.select2-container--open .select2-selection {
    background: #fff;
    border-color: rgba(177, 175, 165, .5);
    box-shadow:
        inset 0 4px 6.1px rgba(255, 255, 255, .23),
        2px 23px 7px rgba(0, 0, 0, .02),
        1px 10px 5px rgba(0, 0, 0, .03),
        0 3px 3px rgba(0, 0, 0, .03);
}
.ba-select2-container.select2-container--open .select2-selection .select2-selection__arrow { transform: rotate(180deg); }

.ba-select2-container.select2-container--focus .select2-selection { border-color: rgba(177, 175, 165, .9); }

.ba-select2-container.select2-container--disabled .select2-selection { opacity: .55; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Multi-select: same pill, values render as cream tags
   -------------------------------------------------------------------------- */
.ba-select2-container.select2-container .select2-selection--multiple { height: auto; min-height: 48px; }
.ba-select2-container.select2-container .select2-selection--multiple .select2-selection__rendered {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    white-space: normal;
}
.ba-select2-container.select2-container .select2-selection .select2-selection__choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 2px 10px;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--hr-brown-500, #1b190c);
    background: var(--hr-cream-500, #f9f7e9);
    border: 1px solid rgba(177, 175, 165, .5);
    border-radius: 61px;
}
.ba-select2-container.select2-container .select2-selection .select2-selection__choice__remove {
    order: 2;
    position: static;
    margin: 0;
    padding: 0;
    color: var(--hr-brown-300, #66655c);
    background: none;
    border: 0;
}
.ba-select2-container.select2-container .select2-search--inline .select2-search__field {
    margin: 0;
    height: 24px;
    font-family: inherit;
    font-size: 16px;
    line-height: 24px;
    color: var(--hr-brown-500, #1b190c);
}

/* --------------------------------------------------------------------------
   Dropdown panel (re-parented to <body> by select2)
   -------------------------------------------------------------------------- */
.ba-select2-dropdown.select2-dropdown {
    margin-top: 4px;
    border: 1px solid rgba(177, 175, 165, .5);
    border-radius: 16px;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(66.95px);
    backdrop-filter: blur(66.95px);
    box-shadow:
        inset 0 4px 6.1px rgba(255, 255, 255, .23),
        2px 23px 7px rgba(0, 0, 0, .02),
        1px 10px 5px rgba(0, 0, 0, .03),
        0 3px 3px rgba(0, 0, 0, .03);
    overflow: hidden;
}
/* select2 flips this class on when the panel opens upwards. */
.ba-select2-dropdown.select2-dropdown--above { margin-top: 0; margin-bottom: 4px; }

/* The scroll container for a long list (countries, topics). select2 also writes
   an inline max-height here from its own `dropdownParent` measuring, so the
   height is set through --ba-select-menu-h, which select2-revamp.js stamps on
   the panel from the component's `menu-height` - a custom property cannot be
   inherited from the field, the panel being a child of <body>. */
.ba-select2-dropdown.select2-dropdown .select2-results > .select2-results__options {
    max-height: var(--ba-select-menu-h, 160px);
    padding: 0;
    overflow-y: auto;
    /* Don't hand the scroll on to the page once the list bottoms out. */
    overscroll-behavior: contain;
    /* Firefox has no scrollbar pseudo-elements; this pair is the whole of its
       styling API, and is why the WebKit block below has to say it all again.
       The second value is the TRACK, and it stays transparent on purpose - see
       the note below. */
    scrollbar-width: thin;
    scrollbar-color: var(--ba-select-scroll-thumb, var(--hr-yellow-500, #d98500)) transparent;
}

.ba-select2-dropdown.select2-dropdown .select2-results__option {
    padding: 8px 16px;
    font-family: var(--primary-font, 'Almarai'), sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    color: var(--hr-brown-500, #1b190c);
    background: transparent;
    /* The design draws a hairline between rows, not around them - a bottom
       border on every option plus none on the last gives exactly that without
       an extra element per row. */
    border-bottom: 1px solid rgba(177, 175, 165, .4);
    /* Came from the default skin, which the theme override switches off. */
    cursor: pointer;
}
.ba-select2-dropdown.select2-dropdown .select2-results__option:last-child { border-bottom: 0; }

/* NEVER key row state off aria-selected in this version of select2. It does
   not mean "this is the chosen value" - results.js sets aria-selected="true"
   on the row it FOCUSES and "false" on the one it leaves, so the attribute
   tracks the highlight, not the selection. The chosen value is marked solely
   by the --selected class. Reading it the other way is what made hover look
   broken on every row except the current value.

   Order matters more than specificity here: both rules below are equal weight,
   so --highlighted wins simply by coming second, and it therefore lands on the
   chosen row too. Don't reorder them.

   The chosen value gets no distinguishing treatment: weight in this component
   means "a value is set", which is said once, by the pill. Bolding the row
   would also reflow it on every open, a bold label being wider than a regular
   one. */
.ba-select2-dropdown.select2-dropdown .select2-results__option--selected {
    font-weight: 400;
    color: var(--hr-brown-500, #1b190c);
    background: transparent;
}
/* Hover and keyboard navigation are one state - select2 sets --highlighted for
   both - and it is a fill change only; the row's type never moves. */
.ba-select2-dropdown.select2-dropdown .select2-results__option--highlighted {
    color: var(--hr-brown-500, #1b190c);
    background: rgba(236, 230, 211, .4);
}
.ba-select2-dropdown.select2-dropdown .select2-results__message {
    color: var(--hr-brown-300, #66655c);
    border-bottom: 0;
    cursor: default;
}
/* Same reasoning as above - state comes from classes, not ARIA attributes.
   A row that is not --selectable (a disabled option, or a group heading) never
   receives --highlighted, so it correctly stays flat on hover. */
.ba-select2-dropdown.select2-dropdown .select2-results__option--disabled {
    color: var(--hr-brown-300, #66655c);
    cursor: default;
}
.ba-select2-dropdown.select2-dropdown .select2-results__option--group {
    padding: 8px 16px 4px;
    color: var(--hr-brown-300, #66655c);
    font-size: 14px;
    cursor: default;
}

/* WebKit/Blink scrollbar - the same bar the FAQ lists use (.cta-faq-right on
   Contact, .smt-faq-col-right .faq-lists on Annual Gathering): a 6px gutter, a
   fully rounded thumb in the accent, and nothing else.

   The TRACK is transparent on purpose, and that is the whole point of copying
   this pattern. Painting the groove - which the first pass did, reading the
   design's 2px rule literally - draws a permanent coloured line down the side
   of the panel, and the transparent inset needed to slim it to 2px then reads
   as a white channel beside it. With no groove at all there is nothing to
   leave a gap against: only the moving bar is visible.

   The track's vertical margin survives because the track is the thumb's
   runway, so insetting it is what stops the bar running into the panel's 16px
   rounded corners. It is 6px rather than the 12px this started at: the runway
   is also what the thumb's length is measured against, so every pixel taken
   off the track shortens the bar too. 6px still clears the corner now that the
   groove behind it is transparent. */
.ba-select2-dropdown.select2-dropdown .select2-results__options::-webkit-scrollbar { width: 6px; }
.ba-select2-dropdown.select2-dropdown .select2-results__options::-webkit-scrollbar-track {
    margin: 6px 0;
    background: transparent;
}
.ba-select2-dropdown.select2-dropdown .select2-results__options::-webkit-scrollbar-thumb {
    background: var(--ba-select-scroll-thumb, var(--hr-yellow-500, #d98500));
    border-radius: 3px;
    /* The thumb's length is otherwise purely proportional - visible height over
       content height - so a long list (countries, say) shrinks it to an
       unusable few pixels. This is the floor, and it is the knob to raise if
       the bar should read longer still on short lists; on those it has no
       effect, the proportional length already being greater. */
    min-height: 48px;
}

/* Search box, when the component is rendered with search enabled. */
.ba-select2-dropdown.select2-dropdown .select2-search--dropdown { padding: 8px; }
.ba-select2-dropdown.select2-dropdown .select2-search--dropdown .select2-search__field {
    padding: 8px 14px;
    font-family: var(--primary-font, 'Almarai'), sans-serif;
    font-size: 15px;
    line-height: 22px;
    color: var(--hr-brown-500, #1b190c);
    border: 1px solid rgba(177, 175, 165, .5);
    border-radius: 61px;
    outline: none;
}
.ba-select2-dropdown.select2-dropdown .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--hr-yellow-500, #d98500);
}

/* --------------------------------------------------------------------------
   RTL - select2 mirrors its own container, so only the bits that were pinned
   with physical values need flipping.
   -------------------------------------------------------------------------- */
/* select2's own RTL rule re-pads the label for the arrow it would have
   absolutely positioned; it ties this file on specificity, so the reset has to
   be restated rather than left to the LTR rule above. */
.ba-select2-container.select2-container[dir="rtl"] .select2-selection .select2-selection__rendered { padding: 0; }
[dir="rtl"] .ba-select2-container.select2-container .select2-selection .select2-selection__clear { margin: 0 8px 0 0; }
/* Nothing to flip for the scrollbar any more: the bar is symmetric, and WebKit
   moves it to the leading edge on its own. */
