/*
 * THE BORDERED DATE FIELD — one frame around one segment group, or two joined by an en-dash, plus
 * the calendar mark. The frame owns the ring via `:focus-within`, since tabbing between groups
 * fires blur-then-focus that a JS flag flickers on.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-date-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    /* Squeezed, the year runs under the calendar mark. */
    min-width: min-content;
    height: var(--lotics-control-height);
    padding-inline: var(--lotics-space-8);
    gap: var(--lotics-space-4);
    border-width: 1px;
    border-style: solid;
    border-color: var(--border);
    border-radius: var(--lotics-radius-control);
    background-color: var(--card);
    --lotics-icon-color: var(--lotics-ink-muted);
    transition-property: border-color, outline-color;
    transition-duration: var(--lotics-duration-fast);
    transition-timing-function: var(--lotics-ease-standard);
  }

  .lotics-date-field:not([data-disabled]):not([data-seamless]):hover {
    border-color: var(--lotics-border-hover);
  }

  .lotics-date-field:not([data-disabled]):not([data-seamless]):focus-within {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }

  .lotics-date-field[data-disabled] {
    background-color: var(--muted);
    --lotics-icon-color: var(--lotics-ink-inactive);
  }

  /*
   * With verbs on the field the wrapper owns the box (`field_surface.css`), height included: a
   * fixed rung inside it would overflow by the given-up borders.
   */
  .lotics-date-field[data-seamless] {
    height: auto;
    align-self: stretch;
    padding-inline: 0;
    border-width: 0;
    background-color: transparent;
  }

  .lotics-date-field__segments {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1;
    min-width: 0;
  }

  /*
   * Over the segments and click-transparent, so an empty field reads as one prompt; gone once a
   * segment focuses.
   */
  .lotics-date-field__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: var(--card);
    pointer-events: none;
  }

  /* One line, cut with an ellipsis rather than wrapped under the field's edge. */
  .lotics-date-field__prompt {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* The prompt and the range's dash are set in the segments' own rung, which grows on a phone: in `sm` beside
     16px digits they read as a second type in one field. */
  .lotics-date-field__prompt,
  .lotics-date-field__dash {
    color: var(--lotics-ink-muted);
    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-input-weight);
  }

  .lotics-date-field__dash {
    flex-shrink: 0;
    white-space: pre;
  }

  .lotics-date-field:focus-within .lotics-date-field__placeholder {
    display: none;
  }
}
