/* The match table (journal 007; specs/table.md), as design/_shared/base.css draws it in the mockups `design/match_table_*.html`. Structure only: every colour, font, radius, shadow and texture is a token; the seats' signs, the strip's squares, the curtain and the end's battlement are the studio's pieces (journal 006, Q1). The board is drawn on the stage (z-index 1), above the DOM, over its slot; what must cover it (the toast, the menu, the curtain, the sheets) stands above the stage, at z-index 2 and up. */

/* The table in the full region: the bar, and under it the phone's column, centred, never wider than --size-column-wide in portrait; the backdrop behind it, the liquid's first frame, still, at the top, centred and tiled across, the bed past its foot (journal 006, Q2) */
.table { position: relative; display: flex; flex-direction: column; width: 100%; max-width: var(--size-column-wide); height: 100%; margin: 0 auto; overflow: hidden; background: var(--art-backdrop), var(--color-bed); image-rendering: pixelated; }
.table__bar { flex: none; position: relative; z-index: 3; }
.table__column { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }

/* The bar: the match's kind and time control, the board under it; a tap drops the match menu */
.table-bar { position: relative; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px; }
.table-bar__icon { width: 36px; height: 36px; flex: none; }
.table-bar__title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 0; border: 0; background: none; color: var(--color-text); font: inherit; }
.table-bar__kind { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: var(--font-weight-bold); font-size: var(--font-size-m); }
.table-bar__chevron { margin-left: 6px; color: var(--color-text-muted); }
.table-bar__detail { color: var(--color-text-muted); font-size: var(--font-size-xs); }
/* The connection lost: the detail line says so, in place of the board */
.table-bar__detail--reconnecting { display: inline-flex; align-items: center; gap: 6px; color: var(--color-clock-low); font-weight: var(--font-weight-semibold); }
.table-bar__pulse { width: 7px; height: 7px; border-radius: var(--radius-pill); background: var(--color-clock-low); }
/* Open, and while its slab rises: above the stage and the scrim, the title over the slab */
.table-bar--open, .table-bar--rising { z-index: 3; }
.table-bar--open .table-bar__title, .table-bar--rising .table-bar__title { position: relative; z-index: 1; }
.table-bar__chevron { display: inline-flex; vertical-align: middle; }

/* The match menu (journal 007, Q4): a slab dropped from the top over the dimmed table, the bar its first row, its sides running off the screen's top; a row an entry, its icon and its name, a line between each (Word Krieg's journal 017, entry 05) */
.drop { position: absolute; top: 0; left: 0; right: 0; display: flex; flex-direction: column; padding: 48px 6px 6px; border-style: solid; border-width: 0; border-image: var(--frame-menu); image-rendering: pixelated; filter: drop-shadow(var(--shadow-drop)); animation: drop-in var(--duration-sheet) ease-out; }
/* It drops over --duration-sheet as the menu opens and, closing, rises back over the same time, taking no tap; neither under the system's reduced motion */
.drop--closing { pointer-events: none; animation: drop-out var(--duration-sheet) ease-in forwards; }
@keyframes drop-in { from { transform: translateY(-100%); } }
@keyframes drop-out { to { transform: translateY(-100%); } }
@media (prefers-reduced-motion: reduce) { .drop { animation: none; } }
.drop__item { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 0 14px; border: 0; background: none; box-shadow: inset 0 2px 0 var(--color-line); color: var(--color-text); font: inherit; font-weight: var(--font-weight-semibold); text-align: left; }
.drop__item:disabled { color: var(--color-disabled-text); cursor: default; }
.drop__icon { display: flex; justify-content: center; width: 24px; font-size: var(--font-size-l); line-height: 1; }
.drop__item--danger { color: var(--color-danger); }
.drop__item--danger:disabled { color: var(--color-disabled-text); }

/* A seat's badge, the studio's: 14 × 14 art pixels at 2 CSS px an art pixel, large 36 × 36 on the curtain */
.badge { display: inline-block; flex: none; image-rendering: pixelated; }

/* The seats of two to four, at their start corners (journal 002, Q35): those of the top corners above the board, those of the bottom corners below; a hexagon's top or bottom corner centred */
.table__seats { flex: none; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 4px 16px; }
.seats__slot { min-width: 0; }
.seats__slot--left { grid-column: 1; }
.seats__slot--right { grid-column: 2; }
.seats__slot--centre { grid-column: 1 / -1; width: 50%; justify-self: center; }
.seat { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px; clip-path: var(--shape-cut); background: var(--color-surface); font-size: var(--font-size-s); }
/* The seat to move, ringed in its colour */
.seat--turn.seat--amber { box-shadow: inset 0 0 0 2px var(--color-amber); }
.seat--turn.seat--violet { box-shadow: inset 0 0 0 2px var(--color-violet); }
.seat--turn.seat--blue { box-shadow: inset 0 0 0 2px var(--color-blue); }
.seat--turn.seat--green { box-shadow: inset 0 0 0 2px var(--color-green); }
.seat__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* A long name truncates; the clock keeps its width */
.seat__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: var(--font-weight-semibold); }
.seat__tag { color: var(--color-text-muted); font-weight: var(--font-weight-regular); }
.seat__counts { display: inline-flex; gap: 6px; font-size: var(--font-size-xs); font-variant-numeric: tabular-nums; font-weight: var(--font-weight-semibold); color: var(--color-text-muted); }
.seat__count--hidden { color: var(--color-disabled-text); }
.seat__clock { flex: none; min-width: 48px; padding: 2px 6px; clip-path: var(--shape-cut); background: var(--color-surface-raised); color: var(--color-text-muted); text-align: center; font-variant-numeric: tabular-nums; font-weight: var(--font-weight-semibold); }
/* The mover's clock, counting, in its colour; low, in the clock's warning */
.seat__clock--running { color: var(--color-text-on-colour); }
.seat--amber .seat__clock--running { background: var(--color-amber); }
.seat--violet .seat__clock--running { background: var(--color-violet); }
.seat--blue .seat__clock--running { background: var(--color-blue); }
.seat--green .seat__clock--running { background: var(--color-green); }
.seat .seat__clock--low { background: var(--color-clock-low); color: var(--color-text-on-colour); }
.seat--out { color: var(--color-text-muted); }
.seat__out { flex: none; color: var(--color-text-muted); font-weight: var(--font-weight-semibold); }

/* The board's slot: the board draws itself over it on the stage, whole in it (Q20); the table sizes it to what the column leaves */
.table__board { position: relative; flex: 1 1 0; min-height: 0; display: flex; justify-content: center; align-items: flex-start; padding: 4px 16px; }
.board-slot { position: relative; flex: none; touch-action: manipulation; }
/* The cell layer (journal 007, The table for a screen reader): a button on each cell, under the stage's canvas, invisible; a tap on one is the slot's */
.cells { position: absolute; inset: 0; }
.cells[hidden] { display: none; }
.cell { position: absolute; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; opacity: 0; }
/* The announcer: a polite live region, visually hidden */
.announcer { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* While the table measures what the column leaves the board, the panel takes its least */
.table--measuring .panel { flex: 0 0 var(--size-panel-min); }

/* The turn's strip: a square an action in the mover's colour, filled as each is made, the actions left, Pass, and without fog the take-back's hint (journal 002, Q19 and Q36) */
.table__strip { flex: none; }
.strip { display: flex; flex-direction: column; gap: 4px; margin: 6px 16px; padding: 8px 12px; clip-path: var(--shape-cut); background: var(--color-surface); }
.strip__row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.strip__squares { display: inline-flex; gap: 4px; flex: none; }
.strip__square { display: block; }
.strip__text { flex: 1; min-width: 0; font-weight: var(--font-weight-semibold); }
.strip__pass { flex: none; min-height: 40px; padding: 0 16px; }
.strip__hint { margin: 0; color: var(--color-text-muted); font-size: var(--font-size-xs); }

/* A refusal (journal 007, Q7): Word Krieg's toast, a plaque floating over the board's foot, taking no taps */
.table__toast { position: absolute; left: 40px; right: 40px; bottom: 18px; z-index: 2; pointer-events: none; }
.toast { padding: 12px 14px; clip-path: var(--shape-cut); background: var(--color-surface-bright); color: var(--color-text); font-size: var(--font-size-s); font-weight: var(--font-weight-semibold); text-align: center; }

/* An offer of a draw in the strip's place (journal 007, Q5 and Q6): the line on a row of its own, the name in its colour; the answers on a row below, Decline and Accept side by side, Withdraw alone across */
.offer { display: flex; flex-direction: column; gap: 6px; margin: 6px 16px; }
.offer__line { padding: 14px 12px; clip-path: var(--shape-cut); background: var(--color-surface-raised); font-weight: var(--font-weight-semibold); text-align: center; }
.offer__name { white-space: pre; }
.offer__name--amber { color: var(--color-amber); }
.offer__name--violet { color: var(--color-violet); }
.offer__name--blue { color: var(--color-blue); }
.offer__name--green { color: var(--color-green); }
.answer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.answer--single { grid-template-columns: 1fr; }
.answer .button { min-height: 40px; }

/* The curtain under the bar (journal 007, One phone and The pause; journal 002, Q23 and Q38; Q8): over the column, the bar above it; its wall built on a canvas from the seat's brick at 2 CSS px an art pixel (js/table/wall.js); its content set once the wall stands, fading in over 160 ms; taken down, the content goes first; going, it takes no taps */
.curtain { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 0 32px; text-align: center; cursor: default; }
.curtain__wall { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; image-rendering: pixelated; }
/* A wall whose tile could not be had: the page's ground, whole, in its place */
.curtain__wall--plain { background: var(--color-bg); }
.curtain > :not(.curtain__wall) { position: relative; z-index: 1; opacity: 0; pointer-events: none; transition: opacity 160ms linear; }
.curtain--built > :not(.curtain__wall) { opacity: 1; pointer-events: auto; }
.curtain.curtain--down > :not(.curtain__wall) { opacity: 0; pointer-events: none; }
.curtain--down { pointer-events: none; }
.curtain__title { margin: 8px 0 0; font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); overflow-wrap: anywhere; }
.curtain__line { margin: 0; color: var(--color-text-muted); }
.curtain__clock { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; clip-path: var(--shape-cut); background: var(--color-surface); font-weight: var(--font-weight-bold); font-variant-numeric: tabular-nums; }
/* The hand-over's call to tap, in the next mover's colour */
.curtain__tap { margin-top: 28px; font-weight: var(--font-weight-bold); }
.curtain__tap--amber { color: var(--color-amber); }
.curtain__tap--violet { color: var(--color-violet); }
.curtain__tap--blue { color: var(--color-blue); }
.curtain__tap--green { color: var(--color-green); }
.curtain__resume { width: 100%; max-width: 200px; min-height: 52px; margin-top: 16px; }

/* The end (journal 007, The end; journal 002, Q39): the sheet's slab over the lower table, the board above it whole; along its top the winner's battlement, in its colour, a merlon centred (none in a draw); the winner's large badge beside the title, the reason, the others in the order they went out, the actions */
.end { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; flex-direction: column; gap: 10px; padding: 22px 20px 28px; border-style: solid; border-width: 0; border-image: var(--frame-sheet); image-rendering: pixelated; filter: drop-shadow(var(--shadow-drop)); animation: sheet-up var(--duration-sheet) ease-out; }
.end--amber::before, .end--violet::before, .end--blue::before, .end--green::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 60px; pointer-events: none; }
.end--amber::before { background: var(--art-end-battlement-amber); }
.end--violet::before { background: var(--art-end-battlement-violet); }
.end--blue::before { background: var(--art-end-battlement-blue); }
.end--green::before { background: var(--art-end-battlement-green); }
@media (prefers-reduced-motion: reduce) { .end { animation: none; } }
.end__winner { display: flex; align-items: center; justify-content: center; gap: 12px; }
.end__title { margin: 0; font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); text-align: center; overflow-wrap: anywhere; }
.end__reason { margin: 0; text-align: center; }
/* Lowered for chat on a phone (journal 010): the sheet hidden, the panel under it shown and raised */
.end[hidden] { display: none; }
/* Chat on the end sheet, on a phone: a quiet Lip under the actions, the panel's badge beside its word (journal 010, Q2) */
.sheet__chat { display: flex; align-items: center; justify-content: center; gap: 8px; }
.sheet__chat[hidden] { display: none; }
.standings { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.standings__row { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; clip-path: var(--shape-cut); background: var(--color-surface); font-size: var(--font-size-s); }
.standings__place { width: 16px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; font-weight: var(--font-weight-bold); }
.standings__name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: var(--font-weight-semibold); }
.standings__when { flex: none; color: var(--color-text-muted); }

/* The panel under the board (journal 007, Layouts): flat, a line along its top 34 px below the strip, and over the line a pill holding Chat, its unread count beside it; it takes the height the board leaves */
.panel { touch-action: pan-x pan-y; flex: 1 1 0; min-height: var(--size-panel-min); display: flex; flex-direction: column; margin-top: 34px; border-top: 2px solid var(--color-line); background: var(--color-surface); }
.panel__tabs { position: relative; z-index: 1; display: flex; flex: none; align-self: center; margin-top: -28px; padding: 2px; border-style: solid; border-width: 0; border-image: var(--frame-pill-holder); image-rendering: pixelated; }
.panel__tab { width: 124px; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px; border-style: solid; border-width: 0; border-image: var(--frame-pill-glass); image-rendering: pixelated; color: var(--color-text); font-size: var(--font-size-s); font-weight: var(--font-weight-semibold); }
.panel__badge { min-width: 20px; min-height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; clip-path: var(--shape-cut); background: var(--color-surface-bright); color: var(--color-text); font-size: var(--font-size-xs); font-weight: var(--font-weight-bold); font-variant-numeric: tabular-nums; }
/* The list in it, clipped 8 px under its top */
.panel__body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 12px; clip-path: inset(8px 0 0 0); }
/* Chat's widget, the panel's body */
.panel__body--chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
/* The end sheet covers the lower table on a phone: the panel under it gives the board its place, until the sheet is lowered for chat */
.table--ended:not(.table--end-lowered) .table__column > .panel { display: none; }

/* The panel raised on a phone (journal 007, Q9; Word Krieg's journal 018): the board shrinks whole into the top-left corner at 150 px, the seats stand beside it, one under another; the strip folds away until the panel is lowered */
.table--raised .table__column { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "board top" "board bottom" "panel panel"; column-gap: 4px; }
.table--raised .table__board { grid-area: board; width: 150px; margin: 0 0 12px 16px; padding: 0; }
.table--raised .table__seats--above { grid-area: top; align-self: start; }
.table--raised .table__seats--below { grid-area: bottom; align-self: end; margin-bottom: 12px; }
.table--raised .seats { grid-template-columns: minmax(0, 1fr); margin: 0 16px 0 4px; }
.table--raised .seats__slot--left, .table--raised .seats__slot--right { grid-column: 1; }
.table--raised .seats__slot--centre { width: auto; }
.table--raised .table__strip { display: none; }
.table--raised .panel { grid-area: panel; min-height: 0; }

/* The panel moving between the two layouts (Word Krieg's journal 018): js/table/panel.js lays each part at the rise by transforms; the panel keeps its line's place and reaches the column's foot; the strip takes no taps; nothing is selected on the way */
.table--moving .panel { flex: none; user-select: none; -webkit-user-select: none; }
.table--moving .table__strip { pointer-events: none; }

/* The panel's drag on a phone (js/table/panel.js). Lowered, its list does not scroll, a vertical touch anywhere on it is the panel's and a horizontal one the phrases' row's. Raised, the rest of it stays so, and its list scrolls: at its top (marked by the drag) only up its content, a touch moving down being the panel's */
.table[data-layout="phone"] .panel, .table[data-layout="phone"] .panel * { touch-action: pan-x; }
.table--raised[data-layout="phone"] .chat-widget__list { touch-action: pan-y; }
.table--raised[data-layout="phone"] .chat-widget__list * { touch-action: auto; }
.table--raised[data-layout="phone"] .chat-widget__list[data-at-top] { touch-action: pan-y; touch-action: pan-x pan-down; }

/* Wide, with chat (journal 007, Q10; Word Krieg's journal 007, entry 04): the phone's column, 440 wide, and the panel beside it at full height, a line along its side; the end sheet over the column alone. Without chat the column stands alone, centred */
.table--beside { display: grid; max-width: none; justify-content: center; grid-template-columns: minmax(0, 440px) minmax(0, 392px); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "bar panel" "column panel"; }
.table--beside > .table__bar { grid-area: bar; }
.table--beside > .table__column { grid-area: column; }
.table--beside > .panel { grid-area: panel; min-height: 0; margin-top: 0; padding-top: 34px; border-top: 0; border-left: 2px solid var(--color-line); }
.table--beside > .end { grid-column: 1 / 2; grid-row: 1 / -1; }

/* A phone on its side (journal 007, Layouts): the bar and a notice to turn it upright; the match goes on behind it */
.sideways { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 0 32px; border-top: 2px solid var(--color-line); background: var(--color-surface); }
.sideways__icon { font-size: var(--font-size-xl); color: var(--color-text-muted); }
.sideways__text { margin: 0; font-size: var(--font-size-l); font-weight: var(--font-weight-bold); text-align: center; }
.table:not(.table--sideways) > .sideways { display: none; }
.table--sideways { max-width: none; }
.table--sideways > :not(.table__bar):not(.sideways) { display: none; }
