@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
/* An option marked `code` draws its label with Text (truncate="middle"). */
@import '/assets/fd9298c09de0dca6e6f69ba164f8ce07cc11e4cae4e90e48c028efdf82bf549b/components/text/text.css';
@layer cinder.components {
  /* ========================================
 * SELECT
 * ======================================== */

  .cinder-select-field {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1-5);
  }

  /* ----------------------------------------
 * Label
 * ---------------------------------------- */

  .cinder-select-field__label {
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-1);
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-medium);
    /* The line height is the form-field label's, the one Input and Combobox use, so a Select
       beside them in a row has a label of the same height (row 74d). */
    color: var(--cinder-text-default);
  }

  .cinder-select-field__label[data-disabled] {
    color: var(--cinder-text-disabled);
    cursor: not-allowed;
  }

  /* ----------------------------------------
 * Select control
 * ---------------------------------------- */

  .cinder-select-field__control {
    display: block;
    position: relative;
    inline-size: 100%;
  }

  .cinder-select {
    display: block;
    width: 100%;
    min-height: var(--cinder-control-height-md);
    padding-block: var(--cinder-space-1);
    /* 40px at the end clears Cinder's chevron (18px, 12px in from the end) in every appearance. */
    padding-inline: var(--cinder-space-3) var(--cinder-space-10);

    font-size: var(--cinder-text-sm);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-default);

    background-color: var(--cinder-control-background);

    border: 1px solid var(--cinder-control-border);
    border-radius: var(--cinder-control-radius);

    appearance: none;
    cursor: pointer;

    transition:
      border-color var(--cinder-duration-fast) var(--cinder-ease-standard),
      box-shadow var(--cinder-duration-fast) var(--cinder-ease-standard);
  }

  /* A native select too narrow for its value ends it in an ellipsis instead of cutting it off
     mid-letter (s2#4). The listbox trigger truncates its value span itself. */
  .cinder-select:not([data-cinder-presentation='listbox']) {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* Size: the shared control height for the step, with block padding that
     keeps the 14px line box inside it. */
  .cinder-select.select-size-small {
    min-height: var(--cinder-control-height-sm);
    padding-block: var(--cinder-space-0-5);
  }

  .cinder-select.select-size-large {
    min-height: var(--cinder-control-height-lg);
    padding-block: var(--cinder-space-2);
  }

  /* ----------------------------------------
 * Filled appearance (COR-2313)
 *
 * An inset fill inside the same 1px `--cinder-control-border` edge, so the boundary keeps its 3:1
 * contrast (the fill alone measures about 1.1:1), with a 12px radius and the shared 2px focus
 * ring. A select with no `appearance` follows its density: filled under
 * `data-density='comfortable'`, outlined otherwise, and an explicit `appearance='outlined'` opts
 * out. The component marks a ghost select `outlined` always, and an inline one unless it asks
 * for `filled`, so the density default never fills either. The density selector keeps its
 * specificity at or below the state rules, which sit after it, so disabled, inert and read-only
 * still win.
 * ---------------------------------------- */

  .cinder-select[data-cinder-appearance='filled'],
  .cinder-select:where([data-density='comfortable'] *):not([data-cinder-appearance='outlined']) {
    background-color: var(--cinder-surface-inset);
    border-radius: var(--cinder-radius-lg);
  }

  /* The comfortable density's filled select is 48px, the `lg` step, at the default `md` size. */
  .cinder-select:where([data-density='comfortable'] *):not(
      [data-cinder-appearance='outlined']
    ).select-size-medium {
    min-height: var(--cinder-control-height-lg);
  }

  /* Focus lifts the fill to the control surface under the 2px ring. */
  .cinder-select[data-cinder-appearance='filled']:focus-visible,
  .cinder-select:where([data-density='comfortable'] *):not(
      [data-cinder-appearance='outlined']
    ):focus-visible {
    background-color: var(--cinder-control-background);
  }

  @media (hover: hover) {
    .cinder-select:hover:not(:disabled):not([aria-disabled='true']) {
      border-color: var(--cinder-control-border-hover);
    }
  }

  .cinder-select:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    /* Ring replaces the border while focused rather than stacking on it — the two
       together read as one heavier shape than either was designed to be. */
    border-color: transparent;
    box-shadow: var(--_cinder-focus-ring-shadow);
  }

  /* Forced Colors Mode: box-shadow is ignored; restore an outline-based ring so
 * keyboard focus remains visible in Windows High Contrast and print modes. */
  @media (forced-colors: active) {
    .cinder-select:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 3px;
    }
  }

  .cinder-select:disabled {
    background-color: var(--cinder-control-background-disabled);
    border-color: var(--cinder-control-border-disabled);
    color: var(--cinder-text-disabled);
    cursor: not-allowed;
  }

  /*
   * Inert (a stale region's mutating select): drawn like a disabled one, but it keeps focus and
   * its value stays readable, because the value is old data and old data keeps its contrast.
   */
  .cinder-select[aria-disabled='true'] {
    background-color: var(--cinder-control-background-disabled);
    border-color: var(--cinder-control-border-disabled);
    cursor: not-allowed;
  }

  .cinder-select.select-variant-ghost[aria-disabled='true'] {
    background-color: transparent;
    border-color: transparent;
  }

  /*
   * Empty guard — visual indicator when no options are available. Not
   * `disabled` (the field's `disabled` binding stays false here), so the
   * WCAG 1.4.11 3:1 floor still applies: the dashed border is the affordance
   * that carries the "unavailable" meaning, so it must not be diluted.
   * CIN-603: this used to be `opacity: 0.5` on the whole control, which
   * multiplied the base rule's `border.control` boundary down to ~24%
   * effective alpha along with everything else. Dimming the text color
   * instead of the element keeps the dashed border at its tier's full,
   * undiluted alpha.
   */
  .cinder-select[data-cinder-empty='true'] {
    border-style: dashed;
    color: var(--cinder-text-muted);
    cursor: not-allowed;
  }

  /* ----------------------------------------
 * Decorative chevron
 * The glyph, its size and its inset are the shared field chevron
 * (`styles/components/_field-chevron.css`), so Select, Combobox and MultiSelect
 * put it in the same place. The state rules below stay Select's own.
 * ---------------------------------------- */

  .cinder-select:disabled + .cinder-select-field__chevron {
    color: var(--cinder-text-disabled);
  }

  .cinder-select[data-cinder-empty='true'] + .cinder-select-field__chevron {
    opacity: 0.5;
  }

  /* Forced Colors Mode: the shared chevron paints with ButtonText; a disabled
 * select uses the conventional `GrayText` system color to match how the rest of
 * the disabled control reads in High Contrast. */
  @media (forced-colors: active) {
    .cinder-select:disabled + .cinder-select-field__chevron {
      background-color: GrayText;
    }
  }

  /* ----------------------------------------
 * Error / invalid state
 * ---------------------------------------- */

  .cinder-select[aria-invalid='true'] {
    border-color: var(--cinder-control-border-invalid);
  }

  @media (hover: hover) {
    .cinder-select[aria-invalid='true']:hover:not(:disabled) {
      border-color: oklch(from var(--cinder-control-border-invalid) calc(l - 0.06) c h);
    }
  }

  /* ----------------------------------------
 * Ghost variant
 * No border or fill at rest, a neutral tint on hover and while open, the focus ring wrapping
 * the whole control, the chevron kept. For a select inside a bordered container (a composer,
 * an inline toolbar), so the row of controls reads as one surface that lines up with the
 * container's own text inset. The tint is the same ink wash the vertical navigation item uses
 * for hover, so a ghost select and a ghost button feel alike.
 * ---------------------------------------- */

  .cinder-select.select-variant-ghost {
    background-color: transparent;
    border-color: transparent;
    padding-inline: var(--cinder-pad-control) calc(var(--cinder-pad-control) + 1.25rem);
  }

  /* `tone="accent"`: the value reads in the accent, for the select that names what its container is
   * about to do. */
  .cinder-select-field[data-cinder-tone='accent'] .cinder-select {
    color: var(--cinder-accent-text);
    font-weight: var(--cinder-font-semibold);
  }

  /* min-inline-size: 0 lets a ghost select in a flex row give up width before it overflows the
   * container (a composer at phone width): its value ellipsizes instead of running past the
   * border. A row that would rather wrap sets flex-wrap on itself. */
  .cinder-select-field.select-variant-ghost {
    inline-size: fit-content;
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  /* A ghost select draws no face at rest, so its words are what the eye lines up. A `flush` one,
   * which leads its row under text, is pulled back by its inline padding and its 1px transparent
   * border, so its text starts at the field edge, on the text above it, rather than 11px inside it;
   * only its hover tint and ring reach past the edge (COR-2489). The control moves, not the field,
   * so a visible label or a message under it keeps the edge. It is opt-in: a ghost select after
   * another control keeps its place, so a row never overlaps. */
  .cinder-select-field.select-variant-ghost[data-cinder-flush] .cinder-select-field__control {
    margin-inline-start: calc(-1 * (var(--cinder-pad-control) + 1px));
  }

  .cinder-select-field.select-variant-ghost .cinder-select-field__control {
    inline-size: auto;
    min-inline-size: 0;
  }

  /* A native ghost select takes the width of its widest option instead of filling the field. */
  .cinder-select-field.select-variant-ghost .cinder-select {
    inline-size: auto;
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  .cinder-select.select-variant-ghost + .cinder-select-field__chevron {
    inset-inline-end: var(--cinder-pad-control);
    inline-size: 0.875rem;
    block-size: 0.875rem;
    -webkit-mask-size: 0.875rem 0.875rem;
    mask-size: 0.875rem 0.875rem;
  }

  @media (hover: hover) {
    .cinder-select.select-variant-ghost:hover:not(:disabled):not(:focus-visible) {
      background-color: color-mix(in oklch, var(--cinder-border-ink), transparent 94%);
      border-color: transparent;
    }
  }

  /* The ring wraps the whole control (the tight ring is the shared one); the border stays
     transparent so it never stacks on the ring. */
  .cinder-select.select-variant-ghost[aria-expanded='true']:not(:disabled) {
    background-color: color-mix(in oklch, var(--cinder-border-ink), transparent 94%);
  }

  .cinder-select.select-variant-ghost:disabled {
    background-color: transparent;
    border-color: transparent;
  }

  .cinder-select.select-variant-ghost[aria-invalid='true'] {
    border-color: var(--cinder-control-border-invalid);
  }

  /* ----------------------------------------
 * Inline variant (COR-2313)
 * A select inside a sentence ("Archive messages from [sender]"). The value takes the surrounding
 * font family, size and weight, the control is the `sm` height whatever `size` says, and the
 * width follows the longest option instead of filling the line. The end padding and the chevron
 * are the shared ones, so the caret never overlaps the text.
 * ---------------------------------------- */

  .cinder-select-field.select-variant-inline {
    display: inline-flex;
    inline-size: auto;
    min-inline-size: 0;
    max-inline-size: 100%;
    vertical-align: middle;
  }

  .cinder-select-field.select-variant-inline .cinder-select-field__control {
    inline-size: auto;
    min-inline-size: 0;
  }

  .cinder-select.select-variant-inline {
    inline-size: auto;
    min-inline-size: 0;
    max-inline-size: 100%;
    min-height: var(--cinder-control-height-sm);
    padding-block: var(--cinder-space-0-5);
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
  }

  /* ----------------------------------------
 * Read-only
 * Shows its value and takes focus, but does not open: no pointer affordance, no hover change.
 * ---------------------------------------- */

  .cinder-select[aria-readonly='true'] {
    cursor: default;
  }

  /* A value that cannot change reads as plain text: no fill, no border and no chevron, so it is
     not mistaken for a greyed-out control. It keeps the full text colour for contrast and the
     focus ring, and its label drops to normal weight (sweep S24). */
  .cinder-select[aria-readonly='true']:not(:disabled):not([aria-disabled='true']) {
    background-color: transparent;
    border-color: transparent;
    padding-inline: 0;
  }

  .cinder-select[aria-readonly='true']:not(:disabled):not([aria-disabled='true'])
    + .cinder-select-field__chevron {
    display: none;
  }

  .cinder-select-field:has(
      .cinder-select[aria-readonly='true']:not(:disabled):not([aria-disabled='true'])
    )
    .cinder-select-field__label {
    font-weight: var(--cinder-font-normal);
  }

  @media (hover: hover) {
    .cinder-select[aria-readonly='true']:hover:not(:disabled) {
      border-color: transparent;
    }

    .cinder-select.select-variant-ghost[aria-readonly='true']:hover:not(:disabled):not(
        :focus-visible
      ) {
      background-color: transparent;
    }
  }

  /* ----------------------------------------
 * Listbox presentation: the trigger
 * A button drawn like the native select. The chevron stays the shared absolutely positioned
 * glyph, so both presentations line up.
 * ---------------------------------------- */

  .cinder-select[data-cinder-presentation='listbox'] {
    display: flex;
    align-items: center;
    font-family: inherit;
    text-align: start;
    white-space: nowrap;
  }

  .cinder-select__text {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    column-gap: var(--cinder-space-1-5);
    min-inline-size: 0;
  }

  .cinder-select__prefix {
    flex: none;
    color: var(--cinder-text-muted);
  }

  .cinder-select__prefix + .cinder-select__value,
  .cinder-select__leading + .cinder-select__value {
    font-weight: var(--cinder-font-semibold);
  }

  .cinder-select__prefix + .cinder-select__leading + .cinder-select__value {
    font-weight: var(--cinder-font-semibold);
  }

  .cinder-select__leading {
    flex: none;
    display: inline-flex;
    align-items: center;
  }

  .cinder-select__value {
    flex: 1 1 auto;
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Muted words on the same line as a label: an option's suffix or the trigger's triggerSuffix. */
  .cinder-select__suffix {
    font-weight: var(--cinder-font-normal);
    color: var(--cinder-text-muted);
  }

  /* A chosen `code` option: Text cuts the label in its middle, so the value is a flex box that gives
     it the room left and never an ellipsis of its own. */
  .cinder-select__value[data-cinder-code] {
    display: flex;
    overflow: visible;
    overflow-wrap: normal;
  }

  .cinder-select__value[data-cinder-placeholder] {
    color: var(--cinder-text-muted);
  }

  .cinder-select[data-cinder-presentation='listbox']:disabled .cinder-select__value {
    color: var(--cinder-text-disabled);
  }

  /* ----------------------------------------
 * Listbox presentation: the panel
 * ---------------------------------------- */

  .cinder-select__panel.cinder-popover {
    margin: var(--cinder-space-1) 0 0 0;
    padding: var(--cinder-space-1);
    min-inline-size: 0;
    max-inline-size: min(28rem, calc(100vw - var(--cinder-space-4)));
    overflow: hidden;
  }

  /* A ghost or inline trigger hugs its content, so the list is not held to that narrow width. */
  .cinder-select__panel.cinder-popover:has(> .cinder-select__content.select-variant-ghost),
  .cinder-select__panel.cinder-popover:has(> .cinder-select__content.select-variant-inline) {
    min-inline-size: min(16rem, calc(100vw - var(--cinder-space-4)));
  }

  .cinder-select__content {
    display: flex;
    flex-direction: column;
    min-block-size: 0;
    max-block-size: min(24rem, calc(100vh - var(--cinder-space-8)));
  }

  /* The options scroll; the footer stays put under them. The listbox element itself owns the
     options by id and holds no markup, so group messages can sit outside it. */
  .cinder-select__scroll {
    min-block-size: 0;
    overflow-y: auto;
  }

  /* Empty, but still in the accessibility tree: `display: none` would drop what it owns. */
  .cinder-select__listbox {
    margin: 0;
    padding: 0;
    block-size: 0;
    list-style: none;
    overflow: hidden;
  }

  .cinder-select__options {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .cinder-select__option {
    align-items: flex-start;
    cursor: pointer;
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-default);
  }

  .cinder-select__option-leading {
    flex: none;
    display: inline-flex;
    align-items: center;
    /* Lines the mark up with the label line when the option has more lines under it. */
    min-block-size: calc(1em * var(--cinder-leading-normal));
  }

  .cinder-select__option-text {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
  }

  .cinder-select__option-label {
    font-weight: var(--cinder-font-medium);
    line-height: var(--cinder-leading-normal);
    overflow-wrap: anywhere;
  }

  /* An identifier keeps one line and gives way in its middle, so the row never wraps it. */
  .cinder-select__option-label[data-cinder-code] {
    display: flex;
    min-inline-size: 0;
    overflow-wrap: normal;
  }

  .cinder-select__option-description,
  .cinder-select__option-note {
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-snug);
    color: var(--cinder-text-muted);
    overflow-wrap: anywhere;
  }

  /* The current option: the accent tint and a check, the same current-item look the sidebar
     uses. The keyboard cursor keeps its inset ring on top. */
  .cinder-_option-row.cinder-select__option[aria-selected='true'] {
    background: var(--cinder-accent-background);
  }

  .cinder-select__option[aria-selected='true'] .cinder-select__option-label {
    color: var(--cinder-accent-text);
    font-weight: var(--cinder-font-semibold);
  }

  .cinder-select__option-check {
    flex: none;
    align-self: center;
    margin-inline-start: auto;
    color: var(--cinder-accent-text);
  }

  .cinder-select__option[aria-disabled='true'] {
    cursor: not-allowed;
  }

  .cinder-select__option[aria-disabled='true'] .cinder-select__option-description,
  .cinder-select__option[aria-disabled='true'] .cinder-select__option-note {
    color: var(--cinder-text-muted);
  }

  .cinder-select__group[data-cinder-divided] {
    margin-block-start: var(--cinder-space-1);
    padding-block-start: var(--cinder-space-1);
    border-block-start: 1px solid var(--cinder-border-muted);
  }

  /* Non-selectable text under a group heading. A link inside it is a keyboard stop of its own. */
  .cinder-select__group-message {
    padding: 0 var(--cinder-space-2) var(--cinder-space-1);
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-snug);
    color: var(--cinder-text-muted);
  }

  .cinder-select__group-message a,
  .cinder-select__footer a {
    color: var(--cinder-accent-text);
    text-decoration: underline;
  }

  .cinder-select__footer {
    flex: none;
    margin-block-start: var(--cinder-space-1);
    padding: var(--cinder-space-2) var(--cinder-space-2) var(--cinder-space-1);
    border-block-start: 1px solid var(--cinder-border-muted);
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-snug);
    color: var(--cinder-text-muted);
  }

  /* Docked sheet on a phone: clear the safe area. */
  .cinder-select__panel.cinder-popover[data-cinder-sheet='docked'] {
    padding-block-end: max(var(--cinder-space-1), env(safe-area-inset-bottom));
  }

  /* ----------------------------------------
 * Supporting text
 * ---------------------------------------- */

  .cinder-select-field__description {
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-muted);
    margin: 0;
  }

  .cinder-select-field__error {
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-status-danger-text);
    margin: 0;
  }

  /* The shared `_form-field-error.css` partial (imported by the required
     `cinder/styles` base, CIN-315) keeps the always-present live region out
     of layout when no error is active — no per-component copy needed here. */
}
