/* Where you are, in the ink that acts (`--primary`): a grey underline reads as a divider, and the accent
   would be the screen's only blue beside a near-black CTA. Three boxes: the button carries the underline
   and the 4px holding the wash off it; the `surface` the padding, radius and hover ground, so a wash is a
   pill above the rule; the `line` the label's row, so a `caption` sits under the words. */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  /* The strip is one line in every order: its list is the scroller, so tabs that do not fit scroll inside
     it behind a fade and the page never scrolls sideways. */
  .lotics-tabs {
    display: block;
    min-width: 0;
  }

  /* A sequence's walk is one unbreakable box, since a wrapped flow reads as two pipelines. */
  .lotics-tabs__walk {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: var(--lotics-space-4);
  }

  /* A mask, not a gradient, since the ground varies; masks read alpha only, so `currentcolor` just means
     opaque. */
  .lotics-tabs__list[data-ahead] {
    mask-image: linear-gradient(
      to right,
      currentcolor calc(100% - var(--lotics-tabs-fade)),
      transparent 100%
    );
  }

  .lotics-tabs__list[data-behind] {
    mask-image: linear-gradient(to right, transparent 0, currentcolor var(--lotics-tabs-fade));
  }

  .lotics-tabs__list[data-behind][data-ahead] {
    mask-image: linear-gradient(
      to right,
      transparent 0,
      currentcolor var(--lotics-tabs-fade),
      currentcolor calc(100% - var(--lotics-tabs-fade)),
      transparent 100%
    );
  }

  .lotics-tabs__stage {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    flex-shrink: 0;
  }

  /* On the label line, not the cell's middle, which moves when a stage reserves a caption. */
  .lotics-tabs__chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--lotics-space-24);
    height: calc(var(--lotics-space-8) + var(--lotics-leading-sm));
    padding-block-start: var(--lotics-space-8);
    color: var(--lotics-ink-inactive);
  }

  /* All and the outcomes stand outside the walk, fenced by one rule, and do not shrink. */
  .lotics-tabs__all,
  .lotics-tabs__outcomes {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    flex-shrink: 0;
    gap: var(--lotics-space-4);
  }

  /* A label-line-tall box with a centred hairline; from the pill's top it reads as a column border. */
  .lotics-tabs__rule {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--lotics-space-16);
    height: calc(var(--lotics-space-8) + var(--lotics-leading-sm));
    padding-block-start: var(--lotics-space-8);
  }

  .lotics-tabs__rule::before {
    content: "";
    width: 1px;
    height: 20px;
    background: var(--border);
  }

  /* One line, one behaviour: the bar scrolls, since a wrapped strip reads as two strips — a sequence's as
     two pipelines — and moves its tabs under the reader. The fade says there is more; no scrollbar. */
  .lotics-tabs__list {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: var(--lotics-space-4);
    /* One rung, so a tab is legible until it leaves. */
    --lotics-tabs-fade: var(--lotics-space-24);
    /* The browser's scroll stops at the port edge, leaving a tab under the fade, so the inset is the
       fade. */
    scroll-padding-inline: var(--lotics-tabs-fade);
  }

  /* On the tab, since a sequence wraps it in a stage box. */
  .lotics-tabs__tab {
    --lotics-tabs-dot: 6px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
    margin: 0;
    padding: 0 0 var(--lotics-space-4);
    /* 3px, the component's own: a hairline reads as no position, a fourth pixel as a bar. */
    border: 0 solid transparent;
    border-bottom-width: 3px;
    background: transparent;
    background-image: none;
    appearance: 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);
    font-weight: var(--lotics-weight-regular);
    font-feature-settings: var(--lotics-font-features);
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: border-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  .lotics-tabs__tab[data-active] {
    border-bottom-color: var(--primary);
  }

  .lotics-tabs__tab:focus-visible {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }

  .lotics-tabs__tab[data-disabled] {
    cursor: default;
    opacity: var(--lotics-disabled-opacity);
  }

  /* 12, the rung of every pill control (`ChoiceStrip`, `Chip`). */
  .lotics-tabs__surface {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding-block: var(--lotics-space-8);
    padding-inline: var(--lotics-space-12);
    border-radius: var(--lotics-radius-control);
    background: transparent;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  .lotics-tabs__line {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    /* 6 — the mark's gutter. */
    gap: var(--lotics-space-6);
  }

  .lotics-tabs__tab:hover .lotics-tabs__surface {
    background: var(--lotics-wash-hover);
  }

  .lotics-tabs__tab:active .lotics-tabs__surface {
    background: var(--lotics-wash-selected);
  }

  .lotics-tabs__status {
    width: var(--lotics-tabs-dot);
    height: var(--lotics-tabs-dot);
    flex-shrink: 0;
    border-radius: var(--lotics-radius-full);
    background: var(--lotics-tabs-status, var(--lotics-tone-zinc-solid));
  }

  .lotics-tabs__label {
    min-width: 0;
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    font-weight: var(--lotics-weight-regular);
    font-feature-settings: var(--lotics-font-features);
    color: var(--lotics-ink-muted);
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }

  /* Weight and ink too: an underline answers only once the eye reaches the rule. */
  .lotics-tabs__tab[data-active] .lotics-tabs__label {
    font-weight: var(--lotics-weight-medium);
    color: var(--lotics-ink-default);
  }

  /* Starts under the label's first letter, left-aligned as a figure. */
  .lotics-tabs__caption {
    font-family: var(--font-sans);
    font-size: var(--lotics-text-xs);
    line-height: var(--lotics-leading-xs);
    letter-spacing: var(--lotics-tracking-xs);
    font-weight: var(--lotics-weight-regular);
    font-feature-settings: var(--lotics-font-features);
    color: var(--lotics-ink-muted);
    text-align: start;
    white-space: nowrap;
  }

  .lotics-tabs__tab[data-status] .lotics-tabs__caption {
    margin-inline-start: calc(var(--lotics-tabs-dot) + var(--lotics-space-6));
  }

  /* The label yields; a count never clips. */
  .lotics-tabs__count {
    flex-shrink: 0;
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    font-weight: var(--lotics-weight-regular);
    font-feature-settings: var(--lotics-font-features);
    color: var(--lotics-ink-muted);
  }
}
