/* ==========================================================================
   searchBox.css

   Default generated DOM:

   <div id="user-search" class="ui-search-box ui-search-box-width-full">   (role="search" when landmark:true)
     <label class="ui-search-box-label" for="user-search-input">Search users</label>
     <div class="ui-search-box-row">
       <div class="ui-search-box-control">
         <input id="user-search-input" class="ui-search-box-input" type="search" autocomplete="off"
                enterkeyhint="search" spellcheck="false" placeholder="" aria-describedby="user-search-help">
         <span class="ui-search-box-busy-icon" aria-hidden="true" hidden><i class="fa-solid fa-spinner"></i></span>   (while busy)
         <span class="ui-search-box-clear-host" hidden> → Button (icon, "Clear search") </span>
       </div>
       <span class="ui-search-box-button-host"> → Button ("Search", optional magnifier before it; or icon Button) </span>   (showSearchButton)
     </div>
     <div class="ui-search-box-scopes-host"> → CheckboxRadio (single, chips) </div>   (scopes)
     <div id="user-search-help" class="ui-search-box-help"></div>                     (hidden when empty)
   </div>

   Conditional structures:
   - labelVisible:false: .ui-search-box-visually-hidden on the label (still the accessible name);
   - busy: .ui-search-box-busy + aria-busy="true" on the root; a spinner appears at the end of the field (static with
     reduced motion);
   - width: .ui-search-box-width-{small|medium|large|full|fit-content} on the root, as TextInput.

   The browser's own clear button and search decoration are hidden, so every browser shows the same
   clear button. The field has no magnifier icon; the Search Button can show one (searchButtonIcon, ICON_BUTTON). The control reuses TextInput's tokens so both fields look alike.
   rotate(360deg) in the spinner keyframes is a geometric constant (one full turn), not a design value.

   STYLE GROUPS. The rules are in three parts; a class can appear in more than one part, each time with
   different properties. Values are design tokens written directly in the rules (no component variables).
     1. APPEARANCE  colours, borders, corners, type, motion. Change freely: only the look changes.
     2. DIMENSIONS  sizes, spacing, widths. Change with care: the component keeps working, its size changes.
     3. STRUCTURE   layout, behaviour, states, accessibility (focus ring, hidden text). Do not change.
   Text uses the typography roles of design-system.css (--font-ui, --fw-ui, --fw-ui-strong, …), never --font-sans
   or --fw-* directly, so a change of a role reaches every component.
   To restyle, change a value in part 1 or 2 (client/local-styling marks app values [APP]), or write the same
   selector with the new value in a stylesheet that loads later, in @layer overrides.
   ui-catalog source and client/local-styling use this file with the app look; client/showcase-styling keeps
   the original values, which the lines marked [APP] name in brackets (library / original).
   Borders use physical sides (top, right, bottom, left): a value set for one side only does not mirror in
   right-to-left languages.
   ========================================================================== */

@layer components {

    /* ======================================================================
       1. APPEARANCE — change freely
       ====================================================================== */
    /* component font and normal weight; the typed text needs them explicitly (form fields do not inherit the page font) */
    .ui-search-box, .ui-search-box-input { font-family:var(--font-ui); font-weight:var(--fw-ui); }
    .ui-search-box-label { color:var(--c-text); font-size:var(--fs-label); font-weight:var(--fw-ui-strong); line-height:var(--lh-compact); }
    .ui-search-box-control {
        border-top: 0 solid var(--c-border);   /* [APP] as TextInput: bottom line only (library: var(--border-thin) on every side) */
        border-right: 0 solid var(--c-border);
        border-bottom: var(--border-thin) solid var(--c-border);
        border-left: 0 solid var(--c-border);
        border-top-left-radius: 0;   /* [APP] square corners (library: var(--radius-control)) */
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
        background-color:var(--c-surface); transition:border-color var(--transition-1);
    }
    .ui-search-box-control:focus-within { border-color:var(--c-accent); }
    .ui-search-box-control:has(.ui-search-box-input:disabled) { background-color:var(--c-surface-muted); }
    .ui-search-box-input:disabled { color:var(--c-muted); -webkit-text-fill-color:var(--c-muted); }

    /* DISABLED LABEL — the label of a disabled search box uses the secondary text colour (disabled:true, or inside a
       disabled fieldset). The help text is already --c-muted. To change the colour, edit this line (a plain
       .ui-search-box-label rule elsewhere cannot override it). */
    .ui-search-box:has(.ui-search-box-input:disabled) .ui-search-box-label { color:var(--c-muted); }

    .ui-search-box-busy-icon { color:var(--c-muted); font-size:var(--icon-size-medium); }
    .ui-search-box-input { min-block-size:calc(var(--control-height) - (1 * var(--border-thin))); color:var(--c-text); font-size:var(--fs-control); }   /* [APP] one border (library: 2 *) */
    .ui-search-box-help { color:var(--c-muted); font-size:var(--fs-label); line-height:var(--lh-body); }
    .ui-search-box-busy-icon i { animation:ui-search-box-spin var(--spinner-duration) linear infinite; }

    /* ======================================================================
       2. DIMENSIONS — change with care
       ====================================================================== */
    .ui-search-box { gap:var(--gap-tight); }
    .ui-search-box-row { gap:var(--gap-inline-items); }
    .ui-search-box-control { min-block-size:calc(var(--control-height) - var(--border-thin)); }   /* [APP] with the one bottom border the box is exactly --control-height, as Select and Calendar (library: var(--control-height)) */
    .ui-search-box-busy-icon { padding-inline-end:var(--gap-tight); }

    /* width option (as TextInput): the whole search box — label, field with its button, scopes and hint */
    .ui-search-box-width-small { inline-size:var(--percentage-s); }
    .ui-search-box-width-medium { inline-size:var(--percentage-m); }
    .ui-search-box-width-large { inline-size:var(--percentage-l); }
    .ui-search-box-width-full { inline-size:var(--percentage-full); }
    .ui-search-box-width-fit-content { inline-size:fit-content; }
    .ui-search-box-input { padding:var(--padding-control); }
    .ui-search-box-clear-host { padding-inline-end:var(--gap-tight); }
    .ui-search-box-message-host { margin-block-start:var(--gap-tight); }

    /* ======================================================================
       3. STRUCTURE — do not change
       ====================================================================== */
    .ui-search-box { display:grid; min-inline-size:0; max-inline-size:var(--percentage-full); }
    .ui-search-box-visually-hidden { position:absolute; inline-size:1px; block-size:1px; margin:-1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
    .ui-search-box-row { display:flex; align-items:center; min-inline-size:0; }
    .ui-search-box-control { display:flex; flex:1 1 auto; align-items:center; min-inline-size:0; }
    .ui-search-box-control:has(.ui-search-box-input:focus-visible) { outline:var(--focus-outline); outline-offset:var(--focus-offset); }
    .ui-search-box-busy-icon { display:inline-flex; flex:0 0 auto; line-height:1; }
    .ui-search-box-busy-icon[hidden] { display:none; }
    .ui-search-box-width-fit-content .ui-search-box-input { inline-size:auto; }
    .ui-search-box-input { flex:1 1 auto; inline-size:100%; min-inline-size:0; border:0; outline:0; background-color:transparent; -webkit-appearance:none; appearance:none; }
    .ui-search-box-input::-webkit-search-cancel-button, .ui-search-box-input::-webkit-search-decoration { -webkit-appearance:none; appearance:none; }
    .ui-search-box-clear-host { display:inline-flex; flex:0 0 auto; }
    .ui-search-box-clear-host[hidden] { display:none; }
    .ui-search-box-message-host:empty { display:none; }
    .ui-search-box-help[hidden] { display:none; }
    @keyframes ui-search-box-spin { to { transform:rotate(360deg); } }
    @media (prefers-reduced-motion:reduce) { .ui-search-box-busy-icon i { animation:none; } }
    @media (max-width:768px) { .ui-search-box { max-inline-size:100%; } }
    /* Label on the left: labelPosition START, or INHERIT inside an element with the class ui-labels-start.
       Applies only while the nearest container (e.g. Form, ContentGroup, CollapsiblePanel) is at least 36rem wide;
       narrower, the label returns on top. 36rem is a literal because custom properties cannot be used in container queries.
       Label column width: --form-label-width (design-system.css); gap between label and field: --gap-toolbar. */
    @container (min-width:36rem) {
        :is(.ui-labels-start .ui-search-box:not(.ui-search-box-label-top), .ui-search-box.ui-search-box-label-start) { grid-template-columns:var(--form-label-width) minmax(0,1fr); column-gap:var(--gap-toolbar); }
        /* label on the left with width SMALL / MEDIUM / LARGE: the row keeps the full width and the option sizes the field
           column (a share of the row, never more than the room beside the label) */
        :is(.ui-labels-start .ui-search-box:not(.ui-search-box-label-top), .ui-search-box.ui-search-box-label-start).ui-search-box-width-small { inline-size:var(--percentage-full); grid-template-columns:var(--form-label-width) minmax(0,min(var(--percentage-s), 100% - var(--form-label-width) - var(--gap-toolbar))); }
        :is(.ui-labels-start .ui-search-box:not(.ui-search-box-label-top), .ui-search-box.ui-search-box-label-start).ui-search-box-width-medium { inline-size:var(--percentage-full); grid-template-columns:var(--form-label-width) minmax(0,min(var(--percentage-m), 100% - var(--form-label-width) - var(--gap-toolbar))); }
        :is(.ui-labels-start .ui-search-box:not(.ui-search-box-label-top), .ui-search-box.ui-search-box-label-start).ui-search-box-width-large { inline-size:var(--percentage-full); grid-template-columns:var(--form-label-width) minmax(0,min(var(--percentage-l), 100% - var(--form-label-width) - var(--gap-toolbar))); }
        :is(.ui-labels-start .ui-search-box:not(.ui-search-box-label-top), .ui-search-box.ui-search-box-label-start) > * { grid-column:2; }
        :is(.ui-labels-start .ui-search-box:not(.ui-search-box-label-top), .ui-search-box.ui-search-box-label-start) > .ui-search-box-label { grid-column:1; float:inline-start; margin:0; align-self:center; }
    }
}
