/* np-select.css — the shared single-value dropdown (np-select.js): a themed,
   searchable list in place of the browser's own, which cannot be themed (its
   hover / selected highlight is the operating system's blue). Every colour is a
   product token, so it follows the organisation's brand and light / dark mode.
   Loaded by both layouts, after np-theme.css. */

/* ── The native select: still in the page, still the posted control, out of sight.
   Not display:none — a validator must still be able to focus it (np-select.js
   passes that focus on to the visible control). ── */
select.np-sel__native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-width: 0 !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    white-space: nowrap !important;
}

/* ── The visible control. It wears the native select's own classes (np-select,
   validation state, per-screen modifiers), so those rules style it exactly as
   they styled the select. The defaults below are wrapped in :where() — zero
   specificity — so ANY such class wins over them; they only give a select that
   had no class of its own (a wizard-built field) the standard field look. ── */
:where(.np-sel__trigger) {
    display: inline-block;
    width: auto;
    max-width: 100%;
    padding: 10px var(--np-space-3);
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    color: var(--np-color-text-primary);
    background-color: var(--np-color-surface);
    border: 1px solid var(--np-color-field-border);
    border-radius: var(--np-radius-2);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:where(.np-sel__trigger--block) {
    display: block;
    width: 100%;
}
:where(.np-sel__trigger):hover { border-color: var(--np-color-field-border-hover); }
:where(.np-sel__trigger):focus {
    outline: none;
    border-color: var(--np-color-brand-primary);
    box-shadow: 0 0 0 4px var(--np-color-focus-halo);
}
:where(.np-sel__trigger):disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* What the control needs whatever classes it wears: room for the chevron, text
   that starts at the leading edge, and one line that truncates. */
.np-sel__trigger {
    position: relative;
    padding-right: 2.25rem;
    text-align: start;
    cursor: pointer;
}
.np-sel__trigger[hidden] { display: none; }
.np-sel__trigger:disabled { cursor: not-allowed; }
/* Open: the same ring as keyboard focus, so the field the list belongs to is
   unmistakable while focus sits in the list. */
.np-sel__trigger--open {
    border-color: var(--np-color-brand-primary);
    box-shadow: 0 0 0 4px var(--np-color-focus-halo);
}
.np-sel__value {
    display: block;
    min-height: 1.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* A prompt ("Choose a folder…", "All types") reads quieter than a real choice. */
.np-sel__trigger--placeholder .np-sel__value { color: var(--np-color-text-muted); }
.np-sel__chevron {
    position: absolute;
    top: 50%;
    right: var(--np-space-3);
    display: inline-flex;
    transform: translateY(-50%);
    color: var(--np-color-brand-primary);
    pointer-events: none;
    transition: transform 0.15s ease;
}
.np-sel__trigger--open .np-sel__chevron { transform: translateY(-50%) rotate(180deg); }
.np-sel__trigger:disabled .np-sel__chevron { color: var(--np-color-text-muted); }

/* The "×" that clears the choice — shown only when a value is chosen and the
   list has a blank option to go back to. Sits just inside the chevron, in a 24px
   target; quiet at rest, brand-coloured on hover. */
.np-sel__trigger--clearable { padding-right: 3.75rem; }
.np-sel__clear {
    position: absolute;
    top: 50%;
    right: calc(var(--np-space-3) + 1.25rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    transform: translateY(-50%);
    color: var(--np-color-text-muted);
    border-radius: var(--np-radius-pill);
    cursor: pointer;
}
.np-sel__clear[hidden] { display: none; }
.np-sel__clear svg {
    width: 14px;
    height: 14px;
}
.np-sel__clear:hover {
    color: var(--np-color-brand-primary);
    background: var(--np-color-surface-tinted);
}

/* ── The list. Shown in the browser's top layer (popover) so nothing can clip
   it; these rules also undo the popover's built-in centring and chrome.
   position: fixed is the fallback where popover is unavailable. ── */
.np-sel__panel {
    position: fixed;
    inset: auto;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    width: max-content;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: var(--np-color-text-primary);
    background: var(--np-color-surface);
    border: 1px solid var(--np-color-border);
    border-radius: var(--np-radius-2);
    box-shadow: var(--np-shadow-3);
    font-size: var(--np-fs-body);
    line-height: 1.5;
}

.np-sel__search {
    flex: 0 0 auto;
    padding: var(--np-space-2);
    border-bottom: 1px solid var(--np-color-border);
}
.np-sel__search-input {
    display: block;
    width: 100%;
    padding: var(--np-space-2) var(--np-space-3);
    font-family: inherit;
    font-size: var(--np-fs-body);
    line-height: 1.5;
    color: var(--np-color-text-primary);
    background: var(--np-color-surface);
    border: 1px solid var(--np-color-field-border);
    border-radius: var(--np-radius-1);
}
.np-sel__search-input::placeholder { color: var(--np-color-text-muted); }
.np-sel__search-input:focus {
    outline: none;
    border-color: var(--np-color-brand-primary);
    box-shadow: 0 0 0 3px var(--np-color-focus-halo);
}

.np-sel__list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: var(--np-space-1);
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: var(--np-color-brand-accent) transparent;
}
.np-sel__list:focus { outline: none; }
.np-sel__list[hidden] { display: none; }

.np-sel__option {
    display: flex;
    align-items: center;
    gap: var(--np-space-3);
    min-height: 2.25rem;
    padding: var(--np-space-1) var(--np-space-3);
    border-radius: var(--np-radius-1);
    cursor: pointer;
}
.np-sel__option[hidden] { display: none; }
.np-sel__option-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}
.np-sel__option--placeholder .np-sel__option-label { color: var(--np-color-text-muted); }

/* The highlighted option — pointer hover and keyboard position are ONE state, as
   on a native list. A tinted fill plus a brand bar at the leading edge, so it is
   not signalled by colour alone (WCAG 1.4.1). */
.np-sel__option.is-active {
    background: var(--np-color-surface-tinted);
}

/* The chosen option: brand text and a tick. The tick is the non-colour signal. */
.np-sel__option-check {
    flex: 0 0 auto;
    display: inline-flex;
    color: var(--np-color-brand-primary);
    visibility: hidden;
}
.np-sel__option.is-selected { color: var(--np-color-brand-primary); }
.np-sel__option.is-selected .np-sel__option-label { color: var(--np-color-brand-primary); }
.np-sel__option.is-selected .np-sel__option-check { visibility: visible; }

.np-sel__option[aria-disabled="true"] {
    color: var(--np-color-text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.np-sel__group {
    padding: var(--np-space-2) var(--np-space-3) var(--np-space-1);
    color: var(--np-color-text-muted);
    font-size: var(--np-fs-xsmall);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.np-sel__group[hidden] { display: none; }

.np-sel__empty {
    margin: 0;
    padding: var(--np-space-4) var(--np-space-3);
    color: var(--np-color-text-muted);
    text-align: center;
}
.np-sel__empty[hidden] { display: none; }

/* ── Phone-width: a bottom sheet. An anchored box under a field is a small,
   fiddly target on a phone; a sheet gives full-width rows a thumb can hit, a
   title saying which field it is for, and an explicit Close. ── */
.np-sel__panel--sheet {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    max-height: 75vh;
    max-height: 75dvh;
    border-width: 1px 0 0;
    border-radius: var(--np-radius-3) var(--np-radius-3) 0 0;
    /* Clear of the home indicator on notched phones. */
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.np-sel__panel--sheet::backdrop { background: rgba(15, 23, 42, 0.45); }
.np-sel__sheet-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--np-space-3);
    padding: var(--np-space-3) var(--np-space-3) var(--np-space-3) var(--np-space-4);
    border-bottom: 1px solid var(--np-color-border);
}
.np-sel__sheet-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.np-sel__sheet-close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    color: var(--np-color-brand-primary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--np-radius-pill);
    cursor: pointer;
}
.np-sel__sheet-close:hover { background: var(--np-color-surface-tinted); }
.np-sel__sheet-close:focus-visible {
    outline: 2px solid var(--np-color-focus);
    outline-offset: 2px;
}
.np-sel__panel--sheet .np-sel__search { padding: var(--np-space-3) var(--np-space-4); }
.np-sel__panel--sheet .np-sel__search-input { padding: var(--np-space-3); }
.np-sel__panel--sheet .np-sel__list { padding: var(--np-space-2); }
/* 48px rows: the comfortable minimum for a thumb. */
.np-sel__panel--sheet .np-sel__option {
    min-height: 3rem;
    padding: var(--np-space-2) var(--np-space-4);
}

@media (prefers-reduced-motion: reduce) {
    :where(.np-sel__trigger),
    .np-sel__chevron { transition: none; }
}

/* Windows High Contrast / forced colours: fills are not painted, so the
   highlighted and chosen options are redrawn in system colours. */
@media (forced-colors: active) {
    .np-sel__option.is-active {
        background: Highlight;
        color: HighlightText;
        box-shadow: none;
        forced-color-adjust: none;
    }
    .np-sel__option.is-active .np-sel__option-label,
    .np-sel__option.is-active .np-sel__option-check { color: HighlightText; }
}

/* Printed pages show the chosen value, never an open list. */
@media print {
    .np-sel__panel { display: none; }
    .np-sel__chevron { display: none; }
}
