/*
 * THE NUMERIC FIELD, in its two presentations. The BARE BOX is the same control
 * surface as a text field: the ROOT carries the edge, the ground and the ring
 * (§2.3), the input only the digits.
 *
 * A `stepper` spends no surface at all: the two discs are the edges and the figure
 * between them is the same field with its box surrendered. 32 and 56 are the
 * stepper's own measures — a disc between `IconButton`'s `md` and `lg` rungs, and
 * a figure slot a four-digit quantity does not shove the + out of.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-number-input {
    display: flex;
    flex-direction: row;
    min-width: 0;
  }


  .lotics-number-input:not([data-stepper]) {
    align-items: stretch;
    height: var(--lotics-control-height);
    border-width: 1px;
    border-style: solid;
    border-color: var(--input);
    border-radius: var(--lotics-radius-control);
    background-color: var(--card);
    transition-property: border-color, outline-color;
    transition-duration: var(--lotics-duration-fast);
    transition-timing-function: var(--lotics-ease-standard);
  }

  .lotics-number-input:not([data-stepper]):not([data-disabled]):hover {
    border-color: var(--lotics-border-hover);
  }

  /* The HOST paints the surface AND owns the text inset — one box, one owner. */
  .lotics-number-input:not([data-stepper])[data-seamless] {
    border-width: 0;
    background-color: transparent;
  }

  .lotics-number-input:not([data-stepper]):focus-within {
    outline-width: var(--lotics-ring-width);
    outline-style: solid;
    outline-color: var(--ring);
    outline-offset: 0;
  }

  .lotics-number-input:not([data-stepper])[data-seamless]:focus-within {
    outline-style: none;
  }

  .lotics-number-input[data-disabled] {
    opacity: var(--lotics-disabled-opacity);
  }


  .lotics-number-input[data-stepper] {
    align-items: center;
    align-self: flex-start;
    gap: var(--lotics-space-16);
  }

  /* The field between them is what gives way; a step control squeezed under its
     own disc is a target nobody can hit. */
  .lotics-number-input__decrement,
  .lotics-number-input__increment {
    flex-shrink: 0;
    --lotics-icon-button-size: 32px;
    border-width: 1px;
    border-style: solid;
    border-color: var(--border);
  }

  /* The figure takes the SLOT, so the stepper is 152 wide whatever the parent
     offers: `flex: 1` would hand it the input's ~20ch intrinsic width. */
  .lotics-number-input[data-stepper] .lotics-number-input__input {
    flex: 0 0 auto;
    width: 56px;
    padding-inline: 0;
    font-weight: var(--lotics-weight-medium);
    text-align: center;
  }


  .lotics-number-input__input {
    flex: 1;
    min-width: 0;
    align-self: stretch;
    margin: 0;
    padding-block: 0;
    padding-inline: var(--lotics-space-8);
    border-width: 0;
    border-style: solid;
    border-color: transparent;
    border-radius: 0;
    background-color: transparent;
    color: var(--lotics-ink-default);
    font-family: var(--font-sans);
    font-size: var(--lotics-input-text);
    line-height: var(--lotics-input-leading);
    letter-spacing: var(--lotics-input-tracking);
    font-weight: var(--lotics-weight-regular);
    appearance: none;
    /* The shell owns the ring, so the element inside it must not draw a second. */
    outline-style: none;
    cursor: text;
  }

  .lotics-number-input__input::placeholder {
    color: var(--lotics-ink-placeholder);
    /* Firefox dims a placeholder by default; the ink role already is the dim. */
    opacity: 1;
  }

  /* THE FAR EDGE, for a money column. It rides the INPUT, because the figure is
     the input's own text whether the reader is reading it or typing in it. A
     `stepper` keeps its centred figure: the rule above is one class deeper. */
  .lotics-number-input__input[data-align="right"] {
    text-align: right;
  }

  .lotics-number-input__input[data-seamless] {
    padding-inline: 0;
  }

  .lotics-number-input__input[data-disabled] {
    cursor: default;
  }
}
