/* Shared table UI: the board shell (docs/ux/desktop-proposal.md cards N1 and N2). Owner: desktop Q2.
   Classes: .tui-lane*. The fit rule sizes a board's cards from its cell (below). Desktop only: a phone is untouched. */
.tui-lane { display: flex; flex-wrap: wrap; align-content: flex-start; gap: var(--tui-gap); min-width: 0; }

/* --tui-fit-w is registered, so it is a finished length at the board: the container units are worked out against the boards area there, and the cards under it
   (which sit inside other boxes) inherit pixels, not the formula. */
@property --tui-fit-w { syntax: '<length>'; inherits: false; initial-value: 56px; }

/* [fit] N2: in the quadrant layout every board is a cell of the boards area, and its cards are as big as 6, 10 or 15 of them fit in it (data-fit s, m, l; data-fit="x"
   is more than 15: the cards stay at the 44px minimum and the board scrolls). A bucket tries a few columns × rows and takes the best, so a wide short cell
   (2 seats: one column, 1000px × 250px) and a near-square one (4 seats) both fill. --tui-board-chrome is what a board spends on its head, land row and
   padding, and --tui-board-chrome-w what it spends beside its cards (your zone piles): each table sets them where it keeps those. Plain CSS (container units): no script, so it follows the window as it resizes. The result is --tui-card-w,
   which both tables already turn into their own card width. */
@media (min-width: 900px) and (min-height: 501px) {
  .tui[data-layout="quad"] .tui-boards { container-type: size; }
  .tui[data-layout="quad"] .tui-board {
    --q-cols: 2;
    --q-w: calc((100cqw - 2 * var(--tui-boards-pad, 8px) - (var(--q-cols) - 1) * var(--tui-boards-gap, 8px)) / var(--q-cols) - 20px - var(--tui-board-chrome-w, 0px));
    --q-h: calc((100cqh - 2 * var(--tui-boards-pad, 8px) - var(--tui-boards-gap, 8px)) / 2 - var(--tui-board-chrome, 110px));
    --q-g: 12px; --q-tap: 1; /* (--q-g: a gap and some slack for the 1.4× width a tapped card takes; --q-tap: each card's share of width, which board.js sets from the tapped share: 1 + .4 * tapped / count) */
  }
  .tui[data-layout="quad"][data-seats="2"] .tui-board { --q-cols: 1; }
  /* a candidate: c columns of cards over r rows, as wide as the cell's width and height allow */
  .tui[data-layout="quad"] .tui-board[data-fit] { /* (s: 6 or fewer; the buckets after it win by order) */
    --tui-fit-w: clamp(44px, max(
      min(calc((var(--q-w) - 5 * var(--q-g)) / (6 * var(--q-tap))), calc((var(--q-h)) / 1.395)),
      min(calc((var(--q-w) - 2 * var(--q-g)) / (3 * var(--q-tap))), calc((var(--q-h) - var(--q-g)) / 2.79)),
      min(calc((var(--q-w) - var(--q-g)) / (2 * var(--q-tap))), calc((var(--q-h) - 2 * var(--q-g)) / 4.185))), var(--tui-card-max, 112px));
  }
  .tui[data-layout="quad"] .tui-board[data-fit="m"] {
    --tui-fit-w: clamp(44px, max(
      min(calc((var(--q-w) - 9 * var(--q-g)) / (10 * var(--q-tap))), calc((var(--q-h)) / 1.395)),
      min(calc((var(--q-w) - 4 * var(--q-g)) / (5 * var(--q-tap))), calc((var(--q-h) - var(--q-g)) / 2.79)),
      min(calc((var(--q-w) - 3 * var(--q-g)) / (4 * var(--q-tap))), calc((var(--q-h) - 2 * var(--q-g)) / 4.185))), var(--tui-card-max, 112px));
  }
  .tui[data-layout="quad"] .tui-board[data-fit="l"] {
    --tui-fit-w: clamp(44px, max(
      min(calc((var(--q-w) - 14 * var(--q-g)) / (15 * var(--q-tap))), calc((var(--q-h)) / 1.395)),
      min(calc((var(--q-w) - 7 * var(--q-g)) / (8 * var(--q-tap))), calc((var(--q-h) - var(--q-g)) / 2.79)),
      min(calc((var(--q-w) - 4 * var(--q-g)) / (5 * var(--q-tap))), calc((var(--q-h) - 2 * var(--q-g)) / 4.185)),
      min(calc((var(--q-w) - 3 * var(--q-g)) / (4 * var(--q-tap))), calc((var(--q-h) - 3 * var(--q-g)) / 5.58))), var(--tui-card-max, 112px));
  }
  .tui[data-layout="quad"] .tui-board[data-fit="x"] { --tui-fit-w: 44px; }
  .tui[data-layout="quad"] .tui-board[data-fit] { --tui-card-w: var(--tui-fit-w); }
}

/* hold-and-slide preview (core.js TableUI.scrubber): the card under the finger */
.tui-scrub { outline: 3px solid var(--tui-accent, #4f8cff); outline-offset: 1px; filter: brightness(1.25); }
