/*
 * THE BORDERED DATE FIELD — one frame around one segment group, or two joined by
 * an en-dash for a range, plus the calendar mark.
 *
 * The frame owns the ring, with `:focus-within`, because the thing being focused
 * is a segment INSIDE one control (`docs/accessibility.md`) — and because tabbing
 * between two groups fires blur-then-focus, which 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;
    min-width: 0;
    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);
  }

  /* ONE BOX, ONE OWNER: with verbs on the field the wrapper takes the border, the
     ground, the inset and the ring (`field_surface.css`). The height goes with
     them — a fixed rung inside a box already one rung tall overflows it by the
     two borders it just gave up. */
  .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;
  }

  /* Painted OVER the segments and click-transparent, so the empty field reads as
     one prompt rather than a row of dashes, and it goes the moment a segment
     takes focus. */
  .lotics-date-field__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: var(--card);
    pointer-events: none;
  }

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