/* ============================================================================
   Adaptive table toolbar — the search row and the pager shed WORDS, not
   controls, as the space around them runs out.
   ============================================================================

   Reported from the running app 2026-10-27: on /alerts with both rails open,
   the pager still spelled out "First", "Previous", "Next" beside a full
   "Search" button, and the row overflowed its card.

   ⚠️ **Keyed on the container's width, NOT on which rails are open.** The two
   sidebars are independent flags on unrelated ancestors — `.wrapper
   .sidebar-collapsed` for the left, `.dd-stage.rail-collapsed` for the right
   (rail-collapse.js) — so coupling to them needs a selector spanning both,
   and still overflows on a narrow laptop, at browser zoom, or beside any rail
   added later. A container query asks the only question that matters: how
   much room is there?

   ⚠️ **This is the first container query in this codebase.** It is deliberate
   and it is the reason this file exists rather than more rules in
   `table-header.css`: the containment belongs with the behaviour that needs
   it. `.table-header`'s own layout rules stay where they are — this adds a
   component, it does not split one.

   ⚠️ **Shedding words under pressure is this product's existing behaviour**,
   not a new idea. Collapsing the left sidebar already drops its labels and
   centres the icons at 80px (`#sidebar.sidebar-collapsed` hides `h3` and
   `.CTAs`). The toolbar is simply the one place that never learned it.

   ⚠️ **Every control keeps an accessible name.** The pager anchors carry
   their own `aria-label` ("First page", "Previous page"), and the Search
   button is passed one explicitly at its call site precisely because this
   file can hide its visible word. A control whose only name is the text these
   rules remove would become an unnamed icon.
   ========================================================================= */

.table-header {
    /* The query container. `inline-size` only — `size` would require a fixed
       block size, and this row grows with its contents. */
    container-type: inline-size;
    container-name: table-toolbar;
}

/* ── The thresholds, measured rather than guessed ───────────────────────
   On /devices at a 1240px window with the rail COLLAPSED, measured
   2026-10-27:

     .table-header   840px   the space available
     search form     664px
     pager           413px
     ------------------------
     content needs  1077px   <- already 237px over, so the search input is
                                being squeezed before the rail even opens

   Opening the rail takes another ~196px (--page-rail-width is 240px, the
   collapsed stub is 44px), so the real working range is roughly 640–840px.

   ⚠️ The first pass used 720 / 600 / 440, which never fired on any real
   layout — the toolbar overflowed at 840px while every rule sat below it.
   Thresholds for a container query have to come from the container's actual
   width, not from the breakpoints one would pick for a viewport. */

/* ── Step 1 · the page indicator loses its prose ─────────────────────────
   "Page 3 of ~18" → "3", saving ~55px. The NUMBER is never hidden; it is the
   only part that says where you are. */
@container table-toolbar (max-width: 1080px) {
    .table-header .pagination-controls-top .toolbar-label {
        display: none;
    }
}

/* ── Step 2 · the pager buttons become their icons ───────────────────────
   First 78px → ~34, Previous 106 → ~34, Next 79 → ~34: about 160px back.
   They keep their chevrons and their aria-labels. */
@container table-toolbar (max-width: 940px) {
    .table-header .pagination-controls-top .item-row .toolbar-label {
        display: none;
    }
    .table-header .pagination-controls-top .item-row {
        padding-inline: 0.5rem;
    }
}

/* ── Step 2b · a list filter's options become their icons ───────────────
   segmented(..., option_icons=): the gateways status filter (2026-11-11).
   Until then it was a row of pills allowed to wrap, so opening the rail put
   Error on a second line and the toolbar grew from 76 to 116px tall. The
   segmented control never wraps; this is what it gives up instead.

   Measured on /gateways?view=list 2026-11-11, rail open, pager already at
   step 2:

       search form 360 + filter 239 + pager 170 + gaps 32 + padding 40
                                         = 841px   -> fits at 845px and up
       at a 770px toolbar, words kept     = 51px over

   Icons take the filter from 239px to about 160px. Options without an icon
   (All) keep their word; every option keeps its name, visually hidden, and
   its title on hover. */
@container table-toolbar (max-width: 844px) {
    .table-header .segmented--iconic .segmented__icon {
        display: inline-flex;
    }
    .table-header .segmented--iconic .segmented__icon + .segmented__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

/* ── Step 3 · Search follows ─────────────────────────────────────────────
   Last to go, because it is the control an operator reaches for first. */
@container table-toolbar (max-width: 720px) {
    .table-header .search-button .toolbar-label {
        display: none;
    }
    .table-header .search-button {
        padding-inline: 0.5rem;
    }
}
