/* Shared table UI: hand (docs/ux/table-v2-spec.md §5). Owner: C07.
   hand.css blocks: [phone + drawer] C07, [landscape] C07, [desktop flat row] C15.
   Classes: .tui-hand*. Phone portrait first, then the landscape and desktop blocks. */

/* [phone + drawer] C07: one row of whole cards that scrolls sideways; ▴ opens every card at full width over the boards */
.tui-hand { position: relative; height: var(--tui-hand-h); }
.tui-hand-in {
  --cw: var(--tui-hand-card-w); --ch: calc(var(--tui-hand-card-w) * 1.395);
  position: relative; z-index: 6; display: flex; align-items: center; height: 100%; min-width: 0;
  background: var(--tui-panel); border-top: 1px solid var(--tui-line);
}
.tui-hand-toggle { flex: none; width: var(--tui-tap); height: var(--tui-tap); padding: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.tui-hand-cards { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--tui-gap); height: 100%; padding: 0 8px 0 2px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.tui-hand-cards::-webkit-scrollbar { display: none; }
.tui-hand-cards .pt-slot { flex: none; scroll-snap-align: start; }
.tui-hand-cards .pt-card { left: 0; top: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .55); }
.tui-hand-cards .pt-slot.castable .pt-card { box-shadow: 0 0 0 2px rgba(53, 194, 122, .85), 0 2px 8px rgba(0, 0, 0, .55); }
.tui-hand-cards .pt-slot.ar-sel .pt-card { box-shadow: 0 0 0 3px var(--tui-gold), 0 0 14px rgba(227, 185, 95, .6); }
.tui-hand-cards .ar-cav { top: 3px; left: 3px; z-index: 2; }
.tui-hand-empty { color: var(--tui-muted); font-size: 13px; padding: 0 10px; }
.tui-hand-in.tui-open {
  --cw: calc((100vw - 4 * var(--tui-gap) - 12px) / 3); --ch: calc(var(--cw) * 1.395);
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; height: auto; max-height: 68dvh; flex-direction: column; align-items: stretch;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .6);
}
.tui-hand-in.tui-open .tui-hand-toggle { align-self: flex-end; }
.tui-hand-in.tui-open .tui-hand-cards { flex-wrap: wrap; align-content: flex-start; height: auto; padding: 0 6px 8px; overflow-y: auto; overflow-x: hidden; scroll-snap-type: none; }

/* [landscape] C07: a shorter row */
@media (orientation: landscape) and (max-height: 500px) {
  .tui-hand { height: var(--tui-hand-h-land); }
  .tui-hand-in { --cw: calc(var(--tui-hand-h-land) / 1.395 - 8px); --ch: calc(var(--tui-hand-h-land) - 8px); }
  .tui-hand-in.tui-open { --cw: var(--tui-hand-card-w); }
}

/* [desktop flat row] C15: one flat, centred row of whole cards; a card lifts on hover; the row scrolls sideways when it's long.
   Selectors start with .tui so a table's own single-class hand rules (the online phone block's fixed height and padding) don't fight the row. */
@media (min-width: 900px) and (min-height: 501px) {
  .tui .tui-hand { height: auto; }
  .tui .tui-hand-in {
    --cw: var(--tui-hand-card-w); --ch: calc(var(--tui-hand-card-w) * 1.395);
    position: relative; height: auto; box-sizing: border-box; padding: var(--tui-hand-lift, 16px) 12px 8px;
  }
  .tui .tui-hand-toggle { display: none; }
  /* margin: auto on the first and last card centres a short row and, unlike justify-content: center, keeps a long row's first card reachable */
  .tui .tui-hand-cards { height: auto; justify-content: flex-start; gap: var(--tui-gap); padding: 0; overflow-x: auto; overflow-y: hidden; scroll-snap-type: none; }
  /* #1342: a mouse has no sideways swipe, so a long row shows a thin scrollbar (and the wheel scrolls it: hand.js) */
  .tui .tui-hand-cards { scrollbar-width: thin; scrollbar-color: var(--tui-line) transparent; }
  .tui .tui-hand-cards::-webkit-scrollbar { display: block; height: 8px; }
  .tui .tui-hand-cards > :first-child { margin-left: auto; }
  .tui .tui-hand-cards > :last-child { margin-right: auto; }
  .tui .tui-hand-cards > * { flex: none; transition: transform .12s ease-out; }
  .tui .tui-hand-cards > *:hover { transform: translateY(calc(-1 * var(--tui-hand-lift, 16px) + 2px)); position: relative; z-index: 5; }
  /* a drawer opened on a phone and left in that state when the window grew: the same flat row */
  .tui .tui-hand-in.tui-open { position: relative; max-height: none; flex-direction: row; box-shadow: none; --cw: var(--tui-hand-card-w); --ch: calc(var(--tui-hand-card-w) * 1.395); }
  .tui .tui-hand-in.tui-open .tui-hand-cards { flex-wrap: nowrap; overflow-x: auto; padding: 0; }
}

/* A finger on the hand's row slides over the cards (each one is lifted and shown big while it is under the finger; board.js/core.js scrubber), so the row does not scroll with the finger: it scrolls by itself near its
   edges while scrubbing. Only on a touch screen, and not in the open drawer (which scrolls up and down). */
@media (pointer: coarse) {
  .tui-hand-in:not(.tui-open) .tui-hand-cards { touch-action: none; }
}
.tui-hand-cards .tui-scrub { transform: translateY(-10px); z-index: 5; }
.tui-hand-cards.tui-scrubbing { scroll-snap-type: none !important; scroll-behavior: auto; }
