/*
 * THE PERIOD FILTER — the panel and the field that floats it. `data-variant`
 * separates the two roots: the panel is a column of regions, the field is one
 * control-height row, and each half of this sheet is scoped to its own.
 *
 * Which preset arrangement is on screen is decided from the VIEWPORT and arrives
 * as `data-layout`: at 768 and up a sidebar, below it a strip under the calendar.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  /* NO `min-width: 0` on the panel or the column inside it: their width is driven
     by what they HOLD, and a zero floor lets the flex row collapse the panel
     while the calendar overflows it. */
  .lotics-date-filter[data-variant="panel"] {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: var(--lotics-space-16);
    border-radius: var(--lotics-radius-control);
    background-color: var(--card);
  }

  .lotics-date-filter[data-layout="strip"] {
    flex-direction: column;
  }

  /* 128, not 140: the calendars come to ~617px and the popover is anchored only
     at 768 and up, so the sidebar has ~135px before the panel is wider than the
     narrowest screen that shows it. */
  .lotics-date-filter__presets {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 128px;
  }

  .lotics-date-filter[data-layout="strip"] .lotics-date-filter__presets {
    flex-direction: row;
    align-items: center;
    min-width: 0;
    gap: var(--lotics-space-4);
    padding-top: var(--lotics-space-8);
    border-top: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .lotics-date-filter__presets::-webkit-scrollbar {
    display: none;
  }

  .lotics-date-filter__preset {
    margin-bottom: var(--lotics-space-2);
  }

  /* In the strip a preset is as wide as its LABEL: a menu row fills its list by
     default, which across a strip is six rows of one screen each. */
  .lotics-date-filter[data-layout="strip"] .lotics-date-filter__preset {
    flex-shrink: 0;
    width: auto;
  }

  .lotics-date-filter__main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-width: 0;
  }

  /* Both bounds are ALWAYS shown: they are what tells the reader a range is
     half-picked and which end is still open. */
  .lotics-date-filter__bounds {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--lotics-space-16);
    padding-block: var(--lotics-space-8);
  }

  .lotics-date-filter__bound {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    padding-left: var(--lotics-space-8);
  }

  .lotics-date-filter__bound-time {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: var(--lotics-space-4);
  }

  /* THE FIELD — its height is the control constant, never padding tuned against a
     leading, which moves when the type rung does. */
  .lotics-date-filter[data-variant="field"] {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    /* NO zero floor: the field is as wide as the period it names for as long as
       its toolbar has room, rather than shrinking to a "J…". */
    height: var(--lotics-control-height);
    gap: var(--lotics-space-8);
    margin: 0;
    padding-inline: var(--lotics-space-12);
    border-width: 1px;
    border-style: solid;
    border-color: var(--border);
    border-radius: var(--lotics-radius-control);
    background-color: var(--card);
    background-image: none;
    color: var(--lotics-ink-default);
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    text-align: start;
    appearance: none;
    cursor: default;
    outline-style: none;
    transition-property: border-color, outline-color;
    transition-duration: var(--lotics-duration-fast);
    transition-timing-function: var(--lotics-ease-standard);
  }

  .lotics-date-filter[data-variant="field"]:hover {
    border-color: var(--lotics-border-hover);
  }

  .lotics-date-filter[data-variant="field"]:focus-visible,
  .lotics-date-filter[data-variant="field"][data-popup-open] {
    outline-width: var(--lotics-ring-width);
    outline-style: solid;
    outline-color: var(--ring);
    outline-offset: 0;
  }

  /* The calendar mark carries whether the filter is SET: an unfiltered field is
     all placeholder, and its glyph reads as one. */
  .lotics-date-filter__mark {
    --lotics-icon-color: var(--lotics-ink-muted);
  }

  .lotics-date-filter[data-variant="field"][data-filtered] .lotics-date-filter__mark {
    --lotics-icon-color: var(--lotics-ink-default);
  }

  /* Takes the slack; below its longest word the clamp is what gives way. */
  .lotics-date-filter__value {
    flex: 1;
    min-width: 0;
  }

  .lotics-date-filter__chevron {
    --lotics-icon-color: var(--lotics-ink-muted);
  }
}
