/* ==========================================================================
   Select2 theme: "thracite"
   --------------------------------------------------------------------------
   Loaded after Django's bundled select2.min.css (see SELECT2_CSS in
   settings.py), so it wins on load order. The widget sets
   ``data-theme="thracite"`` (SELECT2_THEME) and
   ``data-dropdown-css-class="thracite-dropdown"`` — the second one matters
   because Select2 appends the dropdown to <body>, outside the container that
   carries the theme class.

   Everything here mirrors the plain <input class="field-input"> rules in
   main.css so the Select2 box is indistinguishable from the other controls.
   ========================================================================== */

/* Container
   -------------------------------------------------------------------------- */

.select2-container--thracite {
    display: block;
    width: 100% !important;
    margin: 0;
    font-family: var(--body-font);
}

.select2-container--thracite .select2-selection--single {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 54px;
    background: rgba(242, 242, 239, .02);
    border: 1px solid var(--line);
    border-radius: 0;
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.select2-container--thracite:hover .select2-selection--single { border-color: #35342b; }

.select2-container--thracite.select2-container--focus .select2-selection--single,
.select2-container--thracite.select2-container--open .select2-selection--single {
    outline: none;
    border-color: var(--ember);
    background: rgba(242, 242, 239, .035);
    box-shadow: 0 0 0 1px rgba(201, 106, 63, .35);
}
.select2-container--thracite .select2-selection--single:focus-visible {
    outline: 2px solid var(--ember);
    outline-offset: 2px;
}

.select2-container--thracite.select2-container--disabled .select2-selection--single {
    background: transparent;
    border-color: var(--line-soft);
    cursor: not-allowed;
    opacity: .55;
}

/* Selected text / placeholder
   -------------------------------------------------------------------------- */

.select2-container--thracite .select2-selection__rendered {
    flex: 1 1 auto;
    display: block;
    padding: var(--control-pad-y) var(--control-pad-x);
    padding-inline-end: 46px;
    color: var(--ink);
    font-family: var(--body-font);
    font-size: 14.5px;
    font-weight: 400;
    line-height: 1.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select2-container--thracite[dir="rtl"] .select2-selection__rendered {
    padding-inline-end: 46px;
    padding-inline-start: var(--control-pad-x);
    text-align: right;
}

.select2-container--thracite .select2-selection__placeholder { color: var(--ink-faint); }

.select2-container--thracite .select2-selection__clear {
    position: absolute;
    inset-inline-end: 38px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-faint);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1;
}
.select2-container--thracite .select2-selection__clear:hover { color: var(--ember); }

/* Arrow
   -------------------------------------------------------------------------- */

.select2-container--thracite .select2-selection__arrow {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
    height: 100%;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-inline-start: 1px solid var(--line);
}
.select2-container--thracite .select2-selection__arrow b { display: none; }
.select2-container--thracite .select2-selection__arrow::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 1px solid var(--ink-faint);
    border-bottom: 1px solid var(--ink-faint);
    transform: translateY(-2px) rotate(45deg);
    transition: transform .2s ease, border-color .15s;
}
.select2-container--thracite.select2-container--open .select2-selection__arrow::after {
    transform: translateY(2px) rotate(225deg);
    border-color: var(--ember);
}
.select2-container--thracite.select2-container--open .select2-selection__arrow,
.select2-container--thracite.select2-container--focus .select2-selection__arrow {
    border-inline-start-color: rgba(201, 106, 63, .35);
}

/* Dropdown (rendered in <body>, hence the explicit class)
   -------------------------------------------------------------------------- */

.select2-dropdown.thracite-dropdown {
    background: var(--coal-raise);
    border: 1px solid var(--line);
    border-radius: 0;
    margin: 5px 0;
    box-shadow: 0 22px 48px rgba(0, 0, 0, .55);
    overflow: hidden;
}

.thracite-dropdown .select2-search--dropdown { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.thracite-dropdown .select2-search--dropdown .select2-search__field {
    width: 100%;
    background: rgba(242, 242, 239, .03);
    border: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
    font-family: var(--body-font);
    font-size: 13.5px;
    line-height: 1.7;
    padding: 9px 11px;
    outline: none;
    transition: border-color .15s;
}
.thracite-dropdown .select2-search--dropdown .select2-search__field:focus { border-color: var(--ember); }
.thracite-dropdown .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { display: none; }

.thracite-dropdown .select2-results > .select2-results__options {
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}
.thracite-dropdown .select2-results > .select2-results__options::-webkit-scrollbar { width: 6px; }
.thracite-dropdown .select2-results > .select2-results__options::-webkit-scrollbar-thumb { background: var(--line); }

.thracite-dropdown .select2-results__option {
    position: relative;
    padding: 13px 16px;
    color: var(--ink-dim);
    font-family: var(--body-font);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.8;
    border-bottom: 1px solid var(--line-soft);
    transition: color .12s, background .12s;
}
.thracite-dropdown .select2-results__options > li:last-child { border-bottom: none; }

.thracite-dropdown .select2-results__option[aria-selected="true"] {
    color: var(--ink);
    background: rgba(242, 242, 239, .035);
}
.thracite-dropdown .select2-results__option[aria-selected="true"]::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--ember);
}

.thracite-dropdown .select2-results__option--highlighted[aria-selected] {
    background: var(--ember);
    color: var(--coal);
}
.thracite-dropdown .select2-results__option--highlighted[aria-selected]::before { background: var(--coal); }

.thracite-dropdown .select2-results__option[aria-disabled="true"] { color: var(--ink-faint); cursor: not-allowed; }

.thracite-dropdown .select2-results__message,
.thracite-dropdown .select2-no-results,
.thracite-dropdown .select2-searching,
.thracite-dropdown .select2-load-more {
    padding: 14px 16px;
    color: var(--ink-faint);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .06em;
}

/* Invalid state, driven by forms.js / Django errors
   -------------------------------------------------------------------------- */

.field--invalid .select2-container--thracite .select2-selection--single {
    border-color: var(--ember);
    background: rgba(201, 106, 63, .05);
}
.field--invalid .select2-container--thracite .select2-selection__arrow { border-inline-start-color: rgba(201, 106, 63, .35); }
