@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@layer cinder.components {
  /* ========================================
 * COMBOBOX
 * Single-select with synchronous local filtering.
 * ======================================== */

  .cinder-combobox {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1-5);
  }

  .cinder-combobox__label {
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-medium);
    color: var(--cinder-text-default);
  }

  .cinder-combobox__label[data-disabled] {
    color: var(--cinder-text-disabled);
  }

  .cinder-combobox__control {
    position: relative;
  }

  .cinder-combobox__input {
    display: block;
    width: 100%;
    min-height: 2.25rem;
    padding: var(--cinder-space-1-5) var(--cinder-space-3);
    font-size: var(--cinder-text-sm);
    font-family: inherit;
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-default);
    background: var(--cinder-surface-raised);
    border: 1px solid var(--cinder-border);
    border-radius: var(--cinder-radius-md);
    appearance: none;
    transition:
      border-color var(--cinder-duration-fast) var(--cinder-ease-standard),
      box-shadow var(--cinder-duration-fast) var(--cinder-ease-standard);
  }

  /* Sticky-hover suppression on touch. */
  @media (hover: hover) {
    .cinder-combobox__input:hover:not(:disabled) {
      border-color: var(--cinder-border-strong);
    }
  }

  .cinder-combobox__input: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);
  }

  .cinder-combobox__input[aria-invalid='true'] {
    border-color: var(--cinder-status-danger-solid);
  }

  .cinder-combobox__input:disabled {
    background: var(--cinder-surface-inset);
    color: var(--cinder-text-disabled);
    border-color: var(--cinder-border-muted);
    cursor: not-allowed;
  }

  .cinder-combobox__panel {
    margin: var(--cinder-space-1) 0 0 0;
    padding: var(--cinder-space-1);
    min-inline-size: 0;
    max-inline-size: min(32rem, calc(100vw - var(--cinder-space-4)));
  }

  .cinder-combobox__listbox {
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 16rem;
    overflow-y: auto;
  }

  /* Geometry, padding, active fill, keyboard cursor ring, and disabled state
   come from the shared `cinder-_option-row` primitive on the markup — only
   the component-specific typography and pointer affordance live here. */
  .cinder-combobox__option {
    cursor: pointer;
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-default);
  }

  .cinder-combobox__option-avatar {
    flex: 0 0 auto;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--cinder-radius-full);
    object-fit: cover;
  }

  .cinder-combobox__option-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .cinder-combobox__option-label {
    line-height: inherit;
  }

  .cinder-combobox__option-description {
    font-size: var(--cinder-text-xs);
    color: var(--cinder-text-muted);
    line-height: var(--cinder-leading-snug);
  }

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

  .cinder-combobox__empty-panel {
    margin: var(--cinder-space-1) 0 0 0;
    min-inline-size: 0;
    max-inline-size: unset;
  }

  .cinder-combobox__empty {
    padding: var(--cinder-space-3);
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-muted);
    text-align: center;
  }

  .cinder-combobox__empty-status {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

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

  .cinder-combobox__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. */

  /* Forced Colors Mode: restore outline-based focus ring for the combobox input
 * because box-shadow is ignored in Windows High Contrast Mode. */
  @media (forced-colors: active) {
    .cinder-combobox__input:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 3px;
    }
  }
}
