@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/input/input.css';

@layer cinder.components {
  /* ========================================
 * NUMBER INPUT
 * ======================================== */

  /* A number is short: cap the field at about ten characters wide instead of the
   * full form width. :where() keeps the specificity at zero so a consumer class
   * can widen it. */
  :where(.cinder-number-input-field) {
    max-inline-size: 10rem;
  }

  /* A unit beside the number (an adornment such as "days") takes its own room, so the cap grows
   * by that much and the digits keep theirs: under 10rem the steppers and the unit would leave a
   * three-digit value too little to show whole. */
  :where(.cinder-number-input-field:has(.cinder-number-input__adornment)) {
    max-inline-size: 14rem;
  }

  /* What the field is besides its text: both steppers (each stepper's 1px rule is inside its
   * width), the group's two 1px borders and the text slot's padding. A parent that sizes the
   * number to its content (DurationField) adds this to the text the slot must show. */
  .cinder-number-input-field {
    --_cinder-number-input-stepper-size: 2.25rem;
    --_cinder-number-input-chrome: calc(
      2 * var(--_cinder-number-input-stepper-size) + 2px + var(--cinder-space-3) +
        var(--cinder-space-2)
    );
  }

  .cinder-input-group:has(> .cinder-number-input__input) > .cinder-number-input__input {
    padding-inline-end: var(--cinder-space-2);
  }

  .cinder-input-group:has(> .cinder-number-input__input) > .cinder-input-group__trailing {
    align-items: stretch;
    max-inline-size: none;
    gap: 0;
    padding-inline: 0;
  }

  /* Every number starts at the leading edge, with a unit or without one, so a column of fields
   * reads down one edge. With a unit, the text area is sized to its value so the unit follows the
   * digits ("90 minutes") and the slack falls after the unit, before the steppers. Where
   * field-sizing is unsupported the input keeps filling the row, start-aligned, with the unit
   * after it. */
  .cinder-input-group:has(.cinder-number-input__adornment) > .cinder-number-input__input {
    padding-inline-end: var(--cinder-space-1);
  }

  @supports (field-sizing: content) {
    .cinder-input-group:has(.cinder-number-input__adornment) > .cinder-number-input__input {
      field-sizing: content;
      /* Content sizing applies only to an automatic width, and Input declares a full one: without
       * this a field in a fixed-width box kept its share of the row, and the unit sat a field's
       * width from the number. */
      inline-size: auto;
      flex: 0 1 auto;
      min-inline-size: 4ch;
    }

    .cinder-input-group:has(.cinder-number-input__adornment) > .cinder-input-group__trailing {
      flex: 1 1 auto;
    }

    .cinder-input-group:has(.cinder-number-input__adornment)
      .cinder-input-group__trailing
      > .cinder-number-input__adornment {
      flex: 1 1 auto;
    }
  }

  .cinder-number-input[data-invalid] .cinder-number-input__stepper {
    border-inline-start-color: var(--cinder-control-border-invalid);
  }

  .cinder-number-input__stepper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    inline-size: var(--_cinder-number-input-stepper-size);
    padding: 0;
    background: transparent;
    border: none;
    border-inline-start: 1px solid var(--cinder-border-muted);
    color: var(--cinder-text-muted);
    font-size: var(--cinder-text-sm);
    cursor: pointer;
    appearance: none;
    transition:
      background var(--cinder-duration-fast) var(--cinder-ease-standard),
      color var(--cinder-duration-fast) var(--cinder-ease-standard);
  }

  .cinder-number-input__adornment {
    display: inline-flex;
    align-items: center;
    padding-inline: var(--cinder-space-1) var(--cinder-space-2);
    color: var(--cinder-text-muted);
    white-space: nowrap;
  }

  @media (hover: hover) {
    .cinder-number-input__stepper:hover:not(:disabled) {
      background: var(--cinder-surface-hover);
      color: var(--cinder-text-default);
    }
  }

  .cinder-number-input__stepper:focus-visible {
    /* Transparent placeholder keeps the forced-colors outline channel; the visible
   * ring is an INSET box-shadow so the focused stepper is individually
   * identifiable. (The outer .cinder-number-input:focus-within ring only signals
   * that *some* child has focus, not which one — and an outset ring here would
   * collide with it.) This is a self-owned ring, distinct from the shared
   * --_cinder-focus-ring-shadow outer-ring recipe used by most controls. */
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: inset 0 0 0 var(--cinder-ring-width) var(--cinder-ring-color);
    background: var(--cinder-surface-hover);
    color: var(--cinder-text-default);
  }

  @media (forced-colors: active) {
    .cinder-number-input__stepper:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: -2px;
    }
  }

  .cinder-number-input__stepper:disabled {
    color: var(--cinder-text-disabled);
    cursor: not-allowed;
  }

  /* A coarse pointer's 44 by 44 target is a pseudo-element, which takes no layout space, so the
     stepper keeps its painted width and the field's height. */
  @media (any-pointer: coarse) {
    .cinder-number-input__stepper {
      position: relative;
    }

    .cinder-number-input__stepper::after {
      content: '';
      position: absolute;
      inset-block: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
      inset-inline: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
    }
  }
}
