/* ═══════════════════════════════════════════════════════════════════
   FILTER CARD — the command rail + the collapsible filter card
   Shared primitive. Lifted out of modules/travel.css (Trips / Queue /
   Clients) so every list that filters speaks one anatomy; a module sheet
   places it, never restyles it.
   Loaded by the frame head partial (templates/_head_assets.html.twig),
   AFTER components.css: the rail restyles .search-input and the sort
   control composes .dropdown / .dropdown-menu / .dropdown-item.
   Depends on: tokens.css, components.css.

   Two renderings of one card, same look:
     - script-driven  <div class="filter-card open">  — a script toggles
       .open (Trips / Queue, public/js/travel-trips.js)
     - no-script      <details class="filter-card" [open]> with a
       <summary class="filter-header">; more-sections are
       <details class="filter-more-section"> with a
       <summary class="filter-more-toggle">. [open] plays the role .open
       plays on the script-driven form, chevrons included.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Command rail ────────────────────────────────────────────────────
   Approved prototype: SRC-Prototype/trips-list-ice.html (2026-07-05).
   Scope toggle / search / selects / sort / count on one glass pill.
   Hover language mirrors the sidebar wake: same duration + ease tokens,
   a glass lift instead of a color-only change. */

.controls-rail {
    /* backdrop-filter creates a stacking context; without a z-index the filter
       card (a later sibling, also a stacking context) paints over the rail and
       swallows the sort dropdown. Lift the rail above panel-level siblings. */
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border-radius: var(--src-radius-pill);
    border: 1px solid var(--src-border-ice);
    background: var(--src-surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(2, 36, 60, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    /* No margin of its own — the content-area flex gap owns page rhythm;
       inside a .controls-cluster the cluster's gap does. */
}

/* Rail + filter card grouped as one rhythmic unit: the cluster is a single
   child of the content-area's 16px rhythm and gives its two tiers half a
   step of air — the full --src-gap between them read as dead space. */
.controls-cluster {
    display: flex;
    flex-direction: column;
    gap: var(--src-space-2);
}

/* ── Scope toggle (segmented) — the bare form is bordered; inside the rail
   it is a tinted pill track ── */
.filter-toggle {
    display: inline-flex;
    border: 1px solid var(--src-border-medium);
    border-radius: var(--src-radius-interactive);
    overflow: hidden;
}

.filter-toggle-btn {
    padding: 5px 14px;
    font-size: var(--src-text-sm);
    font-weight: var(--src-weight-medium);
    color: var(--src-text-secondary);
    background: var(--src-surface-solid);
    border: none;
    cursor: pointer;
    transition: background-color var(--src-transition-state), border-color var(--src-transition-state), color var(--src-transition-state), box-shadow var(--src-transition-state);
}

.filter-toggle-btn:not(:last-child) {
    border-right: 1px solid var(--src-border-medium);
}

.filter-toggle-btn:hover {
    background: var(--src-gray-50);
}

.filter-toggle-btn.active {
    background: var(--src-primary);
    color: var(--src-text-on-dark);
}

.controls-rail .filter-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: var(--src-radius-pill);
    background: var(--src-primary-tint);
    border: none;
}

.controls-rail .filter-toggle-btn {
    border: none;
    background: transparent;
    color: var(--src-text-secondary);
    font-family: var(--src-font-body);
    font-size: 12.5px;
    font-weight: var(--src-weight-semibold);
    padding: 6px 16px;
    border-radius: var(--src-radius-pill);
    cursor: pointer;
    transition:
        color var(--src-sidebar-dur-wake) var(--src-sidebar-ease),
        background var(--src-sidebar-dur-wake) var(--src-sidebar-ease),
        box-shadow var(--src-sidebar-dur-wake) var(--src-sidebar-ease);
}

/* Text-wake only — the liquid capsule (sidebar-liquid.js, data-hl) carries
   the glass lift; this is the same no-JS fallback grammar as .sb-row. */
.controls-rail .filter-toggle-btn:hover:not(.active) {
    color: var(--src-text-heading);
}

.controls-rail .filter-toggle-btn.active {
    background: var(--src-primary);
    color: var(--src-text-on-dark);
    box-shadow: 0 2px 8px rgba(2, 36, 60, 0.3);
}

/* ── Search ── */
.controls-rail .search-wrap {
    flex: 1;
    min-width: 220px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 16px;
    border-radius: var(--src-radius-pill);
    color: var(--src-text-tertiary);
    transition:
        background var(--src-sidebar-dur-wake) var(--src-sidebar-ease),
        box-shadow var(--src-sidebar-dur-wake) var(--src-sidebar-ease);
}

.controls-rail .search-wrap:hover {
    background: rgba(255, 255, 255, 0.55);
}

.controls-rail .search-wrap:focus-within {
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 1px 4px rgba(2, 36, 60, 0.08), 0 0 0 3px rgba(2, 36, 60, 0.05);
}

.controls-rail .search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--src-text-primary);
    font-family: var(--src-font-body);
    font-size: var(--src-text-base);
    padding: 0;
    box-shadow: none;
}

.controls-rail .search-input::placeholder { color: var(--src-text-tertiary); }

/* ── Sort — a details.dropdown whose summary wears .sort-trigger ── */
.sort-trigger {
    display: inline-flex;
    list-style: none;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--src-border-medium);
    border-radius: var(--src-radius-interactive);
    background: var(--src-surface-solid);
    color: var(--src-text-primary);
    font-size: var(--src-text-sm);
    cursor: pointer;
    transition: border-color var(--src-transition-state);
}

.sort-trigger::-webkit-details-marker { display: none; }
.sort-trigger:hover {
    border-color: var(--src-border-strong);
}

.sort-label {
    color: var(--src-text-tertiary);
}

/* The Sort control is the shared details.dropdown (its menu, its items, its
   [open] rule in components.css); the page only places the menu under the
   trigger's left edge and sizes the items to the toolbar. */
.sort-menu { left: 0; right: auto; min-width: 180px; }
.sort-opt { font-size: var(--src-text-sm); }

.sort-opt.active {
    background: var(--src-sapphire-tint);
    color: var(--src-sapphire);
    font-weight: var(--src-weight-medium);
}

.controls-rail .sort-trigger {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--src-text-secondary);
    font-weight: var(--src-weight-medium);
    padding: 6px 16px;
    border-radius: var(--src-radius-pill);
    border: 1px solid var(--src-border-input);
    /* Transparent so the liquid capsule (z1, beneath) shows through on hover */
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition:
        border-color var(--src-sidebar-dur-wake) var(--src-sidebar-ease),
        color var(--src-sidebar-dur-wake) var(--src-sidebar-ease);
}

.controls-rail .sort-trigger:hover {
    border-color: var(--src-border-strong);
    color: var(--src-text-heading);
}

/* The chosen option's label — the script that picks an option writes here */
.controls-rail .sort-trigger .sort-value {
    color: var(--src-text-heading);
    font-weight: var(--src-weight-semibold);
}

/* ── Rail select — a native <select> wearing the sort-trigger pill ── */
.controls-rail .rail-select {
    appearance: none;
    -webkit-appearance: none;
    font-family: var(--src-font-body);
    font-size: 12.5px;
    font-weight: var(--src-weight-medium);
    color: var(--src-text-secondary);
    padding: 6px 32px 6px 16px;
    border-radius: var(--src-radius-pill);
    border: 1px solid var(--src-border-input);
    /* Transparent (chevron only) so the liquid capsule shows through on hover */
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2302243C' stroke-opacity='.45' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    white-space: nowrap;
    transition:
        border-color var(--src-sidebar-dur-wake) var(--src-sidebar-ease),
        color var(--src-sidebar-dur-wake) var(--src-sidebar-ease);
}

.controls-rail .rail-select:hover {
    border-color: var(--src-border-strong);
    color: var(--src-text-heading);
}

.controls-rail .rail-select:focus {
    outline: none;
    border-color: var(--src-border-strong);
    box-shadow: 0 0 0 3px rgba(2, 36, 60, 0.08);
}

/* ── Rail count — quiet result total, mono numerals like the filter card ── */
.controls-rail .rail-count {
    font-size: var(--src-text-sm);
    color: var(--src-text-tertiary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-right: 10px;
}

.controls-rail .rail-count strong {
    color: var(--src-text-heading);
    font-weight: var(--src-weight-semibold);
    font-family: var(--src-font-mono);
}

/* ─── Filter card: glass panel ───────────────────────────────────── */

.filter-card {
    border: 1px solid var(--src-border-subtle);
    background: var(--src-surface-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--src-radius-secondary);
    box-shadow: var(--src-shadow-card);
}

.filter-header {
    display: flex;
    align-items: center;
    gap: var(--src-space-4);
    padding: 12px 16px;
    cursor: pointer;
    border-radius: var(--src-radius-secondary) var(--src-radius-secondary) 0 0;
    transition: background var(--src-transition-state);
    /* A <summary> header drops the disclosure marker; harmless on a <div> */
    list-style: none;
}

.filter-header::-webkit-details-marker { display: none; }

.filter-header:hover {
    background: rgba(2, 36, 60, 0.02);
}

.filter-header-icon {
    color: var(--src-text-tertiary);
    font-size: 16px;
    display: flex;
    align-items: center;
}

.filter-header-label {
    font-size: var(--src-text-base);
    font-weight: var(--src-weight-semibold);
    color: var(--src-text-heading);
}

.filter-header-pills {
    display: flex;
    gap: 6px;
    margin-left: 4px;
    flex-wrap: wrap;
}

.filter-header-summary {
    font-size: var(--src-text-sm);
    color: var(--src-text-tertiary);
    font-family: var(--src-font-mono);
    font-variant-numeric: tabular-nums;
}

.filter-header-chevron {
    margin-left: auto;
    color: var(--src-text-tertiary);
    font-size: 14px;
    transition: transform var(--src-transition-transform);
}

.filter-card.open .filter-header-chevron,
.filter-card[open] .filter-header-chevron {
    transform: rotate(180deg);
}

.filter-card.open .filter-header,
.filter-card[open] .filter-header {
    border-bottom: 1px solid var(--src-border-subtle);
}

.filter-body {
    display: none;
    padding: 16px;
}

.filter-card.open .filter-body,
.filter-card[open] .filter-body {
    display: block;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 0;
}

.filter-row + .filter-row {
    border-top: 1px solid var(--src-border-subtle);
}

.filter-row-label {
    font-size: 10px;
    font-weight: var(--src-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--src-tracking-widest);
    color: var(--src-text-tertiary);
    flex: 0 0 96px;
}

.filter-row-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
}

/* ── More-sections — the script-driven form is a .filter-more-toggle div
   followed by a .filter-more div that gains .open; the no-script form is a
   details.filter-more-section whose summary is the toggle. ── */
.filter-more-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    border-top: 1px solid var(--src-border-subtle);
    font-size: 11px;
    font-weight: var(--src-weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--src-text-secondary);
    cursor: pointer;
    user-select: none;
    transition: color var(--src-transition-state);
    list-style: none;
}

.filter-more-toggle::-webkit-details-marker { display: none; }

.filter-more-toggle:hover {
    color: var(--src-sandstone-hover);
}

.filter-more-toggle i {
    font-size: 10px;
    transition: transform var(--src-transition-transform);
}

/* Both forms turn the right-pointing chevron down when open: the disclosure
   by [open], the script-driven toggle by the .open its script sets. */
.filter-more-section[open] > .filter-more-toggle i,
.filter-more-toggle.open i {
    transform: rotate(90deg);
}

.filter-more {
    display: none;
}

.filter-more.open {
    display: block;
}

/* ── Active-filter bar: chips of what is applied + clear ── */
.filter-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--src-border-subtle);
    margin-top: 4px;
}

.filter-active-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-active-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--src-radius-pill);
    font-size: 11px;
    font-weight: var(--src-weight-medium);
    background: var(--src-sapphire-tint);
    color: var(--src-sapphire);
}

.filter-active-chip .chip-x {
    font-size: 12px;
    line-height: 1;
    padding: 0;
    color: inherit;
    opacity: 0.6;
    transition: opacity var(--src-transition-state);
}

.filter-active-chip .chip-x:hover {
    opacity: 1;
}

/* ── The no-script form's links. A chip, a scope or evidence segment, and an
   applied-filter chip are LINKS there (each one the list's URL with that one
   value changed), never buttons a script reads — they wear the same look. ── */
a.filter-chip,
a.filter-toggle-btn,
a.filter-active-chip { text-decoration: none; }
a.filter-toggle-btn { display: inline-flex; align-items: center; }

/* ── Filter chip — a pressable option with an optional dot / icon and count ── */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: var(--src-radius-pill);
    border: 1px solid var(--src-border-input);
    background: var(--src-surface-solid);
    color: var(--src-text-secondary);
    font-family: var(--src-font-body);
    font-size: var(--src-text-sm);
    font-weight: var(--src-weight-medium);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--src-transition-state), border-color var(--src-transition-state), color var(--src-transition-state);
}

.filter-chip:hover {
    border-color: rgba(177, 139, 83, 0.38);
    color: var(--src-text-primary);
}

/* After :hover, so the pressed state wins the tie at equal specificity */
.filter-chip.active {
    background: var(--src-primary);
    color: var(--src-text-on-dark);
    border-color: var(--src-primary);
    font-weight: var(--src-weight-semibold);
}

.filter-chip .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filter-chip i {
    font-size: 13px;
}

.filter-chip-count {
    font-family: var(--src-font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 10.5px;
    font-weight: var(--src-weight-semibold);
    min-width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--src-radius-round);
    background: var(--src-primary-tint);
    color: var(--src-text-tertiary);
    margin-left: 2px;
    padding: 0 4px;
}

.filter-chip.active .filter-chip-count {
    background: rgba(255, 255, 255, 0.2);
    color: var(--src-text-on-dark);
}

/* ── Date range inputs ── */
.filter-date-input {
    padding: 6px 10px;
    border: 1px solid var(--src-border-input);
    border-radius: var(--src-radius-pill);
    background: var(--src-surface-solid);
    color: var(--src-text-primary);
    font-size: 11.5px;
    font-family: var(--src-font-mono);
    font-variant-numeric: tabular-nums;
    outline: none;
    transition: border-color var(--src-transition-state);
}

.filter-date-input:focus {
    border-color: var(--src-sapphire);
}

.filter-date-sep {
    font-size: var(--src-text-sm);
    color: var(--src-text-tertiary);
}

/* ── Typeahead ── The no-script form is a native <select> wearing the
   input's look inside the card's GET form: the same pill, a chevron in
   place of the clear button, the menu the browser's own. */
.filter-typeahead {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 260px;
    border-radius: var(--src-radius-pill);
    border: 1px solid var(--src-border-input);
    background: var(--src-surface-solid);
}

.filter-typeahead-input {
    width: 100%;
    padding: 6px 28px 6px 30px;
    border: 1px solid var(--src-border-medium);
    border-radius: var(--src-radius-interactive);
    background: var(--src-surface-solid);
    color: var(--src-text-primary);
    font-size: var(--src-text-sm);
    font-family: var(--src-font-body);
    outline: none;
    transition: border-color var(--src-transition-state);
}

.filter-typeahead-input:focus {
    border-color: var(--src-sapphire);
}

.filter-typeahead-input::placeholder {
    color: var(--src-text-tertiary);
}

select.filter-typeahead-input {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2302243C' stroke-opacity='.45' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.filter-typeahead-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--src-text-tertiary);
    pointer-events: none;
}

.filter-typeahead-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--src-text-tertiary);
    cursor: pointer;
    line-height: 1;
    padding: 2px;
}

.filter-typeahead-clear:hover {
    color: var(--src-text-primary);
}

.filter-typeahead-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: var(--src-z-dropdown, 100);
    max-height: 220px;
    overflow-y: auto;
    margin-top: 4px;
    background: var(--src-surface-solid);
    border: 1px solid var(--src-border-medium);
    border-radius: var(--src-radius-medium);
    box-shadow: var(--src-shadow-dropdown, 0 4px 12px rgba(0,0,0,0.12));
}

.filter-typeahead-menu.open {
    display: block;
}

.filter-typeahead-item {
    padding: 7px 12px;
    font-size: var(--src-text-sm);
    color: var(--src-text-primary);
    cursor: pointer;
    transition: background var(--src-transition-state);
}

.filter-typeahead-item:hover,
.filter-typeahead-item.kb-active {
    background: var(--src-gray-50);
}

.filter-typeahead-item.selected {
    background: var(--src-sapphire-tint);
    color: var(--src-sapphire);
    font-weight: var(--src-weight-medium);
}
