@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@layer cinder.components {
  /* ========================================
 * PIN INPUT
 * ======================================== */

  .cinder-pin-input-field {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1-5);
    inline-size: min(100%, max-content);
  }

  .cinder-pin-input-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);
    line-height: 1;
    color: var(--cinder-text-default);
  }

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

  .cinder-pin-input {
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-2);
    flex-wrap: wrap;
    max-inline-size: 100%;
  }

  .cinder-pin-input__segment {
    inline-size: 2.5rem;
    block-size: 3rem;
    padding: 0;
    font-family: var(--cinder-font-mono, ui-monospace, monospace);
    font-size: var(--cinder-text-lg);
    font-weight: var(--cinder-font-medium);
    line-height: 1;
    text-align: center;
    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);
  }

  @media (hover: hover) {
    .cinder-pin-input__segment:hover:not(:disabled) {
      border-color: var(--cinder-border-strong);
    }
  }

  .cinder-pin-input__segment: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. This rule
       previously ALSO strengthened the border to --cinder-border-strong on focus,
       which is the exact double-treatment decision 7 is about: a segment got a
       heavier border AND a ring simultaneously. The strengthened border is dropped
       rather than kept, so the ring is the only focus affordance; the unfocused
       segments beside it keep their resting borders, which is what makes the
       focused one read. Hover still steps up to --cinder-border-strong above. */
    border-color: transparent;
    box-shadow: var(--_cinder-focus-ring-shadow);
  }

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

  .cinder-pin-input__segment:disabled {
    cursor: not-allowed;
    color: var(--cinder-text-disabled);
    background: var(--cinder-surface-inset);
  }

  @media (forced-colors: active) {
    .cinder-pin-input__segment:focus-visible {
      outline: var(--cinder-ring-width) solid Highlight;
    }
  }

  .cinder-pin-input-field__description {
    margin: 0;
    font-size: var(--cinder-text-xs);
    color: var(--cinder-text-muted);
  }

  .cinder-pin-input-field__error {
    margin: 0;
    font-size: var(--cinder-text-xs);
    color: var(--cinder-status-danger-text);
  }
}
