/*
 * THE INLINE-MANAGED GRID. Every column box — the heading's, the cell's and the
 * footer's — takes one rule, which is what keeps a right-aligned heading over
 * its own digits.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  /* OWNS ITS OWN SCROLL. This grid sheds nothing, so at a width its columns
     cannot fit, something has to scroll; the page must not be it. */
  .lotics-data-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
  }

  /* `min-width: 0` — the row gives way and its CELLS hold their floors. An
     intrinsic floor here resolves against a scroll container as the inline
     editors' own widths, and a grid that fits at desk width invents a
     scrollbar. */
  .lotics-data-grid__row,
  .lotics-data-grid__head {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    min-width: 0;
    gap: var(--lotics-register-inset);
    min-height: var(--lotics-register-row);
  }

  .lotics-data-grid__head {
    margin-bottom: var(--lotics-space-4);
    border: 0 solid var(--border);
    border-bottom-width: 1px;
  }

  /* A FLOOR, not `min-width: 0`: the flexible identity column absorbs the whole
     squeeze, and at 0 it absorbs it to nothing — rows of unlabelled money, with
     no overflow to notice. */
  .lotics-data-grid__cell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-width: var(--lotics-data-grid-flex-min);
  }

  .lotics-data-grid__cell[data-fixed] {
    flex: none;
    width: var(--lotics-data-grid-col-width);
    min-width: 0;
  }

  /* NOBODY ASKED FOR THE SLACK — every column states a width, so the widths
     become floors and the columns grow together. */
  .lotics-data-grid[data-slack] .lotics-data-grid__cell[data-fixed] {
    flex: 1 0 var(--lotics-data-grid-col-width);
    width: auto;
  }

  .lotics-data-grid__cell[data-align="right"] {
    align-items: flex-end;
  }

  .lotics-data-grid__lead {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: none;
    width: var(--lotics-data-grid-lead-width);
  }

  .lotics-data-grid__group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
    min-width: 0;
  }

  .lotics-data-grid__group[data-separated] {
    margin-top: var(--lotics-space-8);
    padding-top: var(--lotics-space-8);
    border: 0 solid var(--border);
    border-top-width: 1px;
  }

  /* A BAND, on the register's own band and its own width: bleeding the hover
     pill past the grid would widen the scroll port by that much. */
  .lotics-data-grid__section {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    min-width: 0;
    min-height: var(--lotics-register-row);
    gap: var(--lotics-space-8);
    border: 0 solid var(--border);
    border-radius: calc(var(--lotics-radius-control) - var(--lotics-space-2));
    background-color: transparent;
    background-image: none;
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    color: var(--lotics-ink-default);
    appearance: none;
    cursor: auto;
    text-align: start;
    touch-action: manipulation;
    user-select: none;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  .lotics-data-grid__section[data-pressable]:hover {
    background-color: var(--lotics-wash-hover);
  }

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