/* 2.1 胡 The Hu tally and 2.2 named hands (Track A). Loaded after table-life.css on every table
   page. Timed styles read the variables table life writes on the element they move (--beat on
   each line, --hush on the hush, --stamp-alpha and --stamp-scale on the card), never on the
   board. Without a timing controller (the lessons) every line is simply written. The card's
   rules name .board.classic-table so they outrank the desktop table's seal (table-grand.css),
   which loads later. */

/* The table holds its breath for a beat: a soft shade over the felt, gone within 180 ms. */
.hu-hush {
  position: absolute;
  inset: 0;
  z-index: 18;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, #0000 25%, #120d08 100%);
  opacity: calc(var(--hush, 0) * 0.32);
}

/* The card: the win's seal become a page of the club's scorebook, in the seal's own slot. Its
   paper is drawn underneath, so the top tier's paper-cut can sit behind it. */
.board.classic-table .call-stamp.call-stamp-win.has-tally {
  --tally-ink: #2b241c;
  --tally-paper: #fbf4e4;
  --tally-rule: #d9c7a0;
  --tally-red: var(--club-red, #b7472f);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: none;
  justify-items: stretch;
  align-items: start;
  gap: 7px;
  width: min(300px, calc(100% - 32px));
  min-width: 0;
  max-width: none;
  padding: 13px 16px 12px;
  color: var(--tally-ink);
  text-align: left;
  background: none;
  border: 0;
  box-shadow: none;
  /* A page with no timing controller (the lessons) shows the finished card, whole. */
  opacity: var(--stamp-alpha, 1);
  transform: translate(-50%, -50%) rotate(-1.5deg) scale(var(--stamp-scale, 1));
}
.board.classic-table .call-stamp.has-tally::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, #0000 27px, #b7472f22 27px 28px, #0000 28px), var(--tally-paper);
  border: 1px solid var(--tally-rule);
  border-radius: 6px;
  box-shadow:
    0 0 0 3px var(--tally-paper),
    0 0 0 4px var(--tally-rule),
    0 12px 26px #1a120a59;
}
.board.classic-table .call-stamp.has-tally.call-stamp-mine::before {
  box-shadow:
    0 0 0 3px var(--tally-paper),
    0 0 0 5px var(--club-mustard, #e2b654),
    0 12px 26px #1a120a59;
}
.board.classic-table .has-tally .tally-head {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.board.classic-table .call-stamp.has-tally .stamp-glyph {
  display: grid;
  flex: none;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--tally-paper);
  grid-row: auto;
  font-size: 32px;
  background: var(--tally-red);
  border-radius: 5px;
  box-shadow:
    inset 0 0 0 2px var(--tally-red),
    inset 0 0 0 3.5px var(--tally-paper);
}
.board.classic-table .has-tally .tally-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.board.classic-table .call-stamp.has-tally .stamp-word {
  color: var(--tally-red);
  font-size: 11px;
}
.board.classic-table .call-stamp.has-tally .stamp-who {
  color: var(--tally-ink);
  font:
    400 23px/1.05 'DM Serif Display',
    'Noto Serif SC',
    Georgia,
    serif;
  overflow-wrap: anywhere;
}

/* 2.2's headline row: the hand's name in brush, ink on paper. Black glyphs over a vermilion rule
   on the card's cream, with no glow, no sparkle and nothing that rolls. It is pressed in with
   the heavier chop: a touch large as it lands, set by its own --beat. */
.board.classic-table .has-tally .tally-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 9px;
  min-width: 0;
  padding-bottom: 5px;
  color: var(--tally-ink);
  border-bottom: 2px solid var(--tally-red);
  font:
    400 20px/1.1 'DM Serif Display',
    Georgia,
    serif;
  text-wrap: balance;
  opacity: var(--beat, 1);
  scale: calc(1 + (1 - var(--beat, 1)) * 0.12);
  transform-origin: 0 100%;
}
.board.classic-table .has-tally .tally-name .tally-name-zh {
  flex: none;
  font:
    700 28px/1 'Noto Serif SC',
    'Songti SC',
    serif;
  letter-spacing: 0.04em;
}
.board.classic-table .has-tally .tally-name .tally-name-en {
  min-width: 0;
}
/* A long English name ("Seven Flowers Steal the Eighth") drops one type size and may take a
   second line. */
.board.classic-table .has-tally .tally-name.is-long .tally-name-en {
  font-size: 17px;
}

/* The lines of the scorebook, one per beat, each inking in on its own beat. */
.board.classic-table .has-tally .tally-beats {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 7px 0 0;
  list-style: none;
  border-top: 1px solid var(--tally-rule);
}
.board.classic-table .has-tally .tally-beat {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 9px;
  min-height: 20px;
  font: 600 13.5px/1.2 var(--club-body-font, system-ui, sans-serif);
  opacity: var(--beat, 1);
  translate: calc((1 - var(--beat, 1)) * -8px) 0;
}
.board.classic-table .has-tally .tally-mark {
  width: 16px;
  height: 16px;
  color: var(--tally-ink);
}
.board.classic-table .has-tally .tally-mark.mark-petal {
  color: #b8466a;
}
.board.classic-table .has-tally .tally-mark.mark-paw {
  color: #7a5431;
}
.board.classic-table .has-tally .tally-mark.mark-chop {
  color: var(--tally-red);
}
.board.classic-table .has-tally .tally-label {
  min-width: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.board.classic-table .has-tally .tally-label [lang] {
  margin-left: 2px;
  color: var(--tally-red);
  font:
    700 14px/1 'Noto Serif SC',
    'Songti SC',
    serif;
}
.board.classic-table .has-tally .tally-tai {
  color: var(--tally-red);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
/* The total, pressed in last with the heavier chop: its pips ink in together. */
.board.classic-table .has-tally .tally-beat.tally-total {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 3px;
  padding-top: 7px;
  border-top: 1px solid #2b241c40;
}
.board.classic-table .has-tally .tally-pips {
  display: flex;
  gap: 5px;
}
.board.classic-table .has-tally .tally-pips i {
  width: 13px;
  height: 13px;
  border: 1.5px solid #2b241c4d;
  border-radius: 2px;
}
.board.classic-table .has-tally .tally-pips i.inked {
  background: var(--tally-red);
  border-color: var(--tally-red);
  scale: calc(1 + (1 - var(--beat, 1)) * 0.5);
}
.board.classic-table .has-tally .tally-sum {
  white-space: nowrap;
  font:
    400 26px/1 'DM Serif Display',
    Georgia,
    serif;
}
.board.classic-table .has-tally .tally-sum b {
  color: var(--tally-red);
  font-weight: 400;
}
.board.classic-table .has-tally .tally-margin {
  color: #6b5840;
  opacity: var(--beat, 1);
  font: italic 500 12.5px/1.3 var(--club-body-font, system-ui, sans-serif);
  text-wrap: balance;
}
.board.classic-table .call-stamp.has-tally .stamp-reaction {
  max-width: none;
  margin-top: 0;
  color: var(--tally-ink);
  border-top-color: var(--tally-rule);
}

/* Today's paper confetti falls behind the paper, never over its lines. */
.board.classic-table .call-stamp.has-tally > span.stamp-confetti {
  z-index: -2;
}

/* The top tier: one still red paper-cut behind the card's corner, the hand's glyph at its
   centre. No lights-down, no larger confetti. */
.board.classic-table .call-stamp.has-tally > span.tally-emblem {
  position: absolute;
  top: -40px;
  right: -104px;
  z-index: -2;
  width: 112px;
  height: 112px;
  rotate: 8deg;
  filter: drop-shadow(0 4px 6px #1a120a40);
}
.board.classic-table .has-tally .tally-emblem svg {
  display: block;
  width: 100%;
  height: 100%;
}
.board.classic-table .has-tally .tally-emblem text {
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  font-weight: 700;
}

/* 自摸 brushed beside a tile the winner drew themselves. */
.hand-won .winning-piece.winning-tile {
  position: relative;
}
.self-draw-brush {
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  z-index: 2;
  padding: 1px 3px;
  color: var(--club-paper, #fdf8ee);
  font:
    700 11px/1 'Noto Serif SC',
    'Songti SC',
    serif;
  white-space: nowrap;
  background: var(--club-red, #b7472f);
  border-radius: 3px;
  opacity: var(--reveal, 1);
  translate: -50% 0;
  pointer-events: none;
}
/* The brush sits with the winner's tiles, which face their owner, but it is a label for the
   viewer: it turns back upright, as the bonus values do (tile-skin.css). The phone's side seats
   turn each tile, not the row, so their brush is upright already. */
:is(.seat-top, .landscape-seat-top, .portrait-top) .self-draw-brush {
  rotate: 180deg;
}
:is(.seat-left, .landscape-seat-left) .self-draw-brush {
  rotate: -90deg;
}
:is(.seat-right, .landscape-seat-right) .self-draw-brush {
  rotate: 90deg;
}

/* The 胡 chop: the Hu button as a vermilion square that presses 2 px. The glyph is art; the
   button's own words still name it for assistive technology. Specific enough to outrank the
   table's own button colours, which load earlier. */
:is(.board, .live-board) .move-actions > button[data-action-type='win'][data-action] {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding-left: 7px;
  color: var(--club-paper, #fdf8ee);
  background: var(--club-red, #b7472f);
  border: 0;
  box-shadow: 0 3px 0 #7d2c1b;
}
:is(.board, .live-board) .move-actions > button[data-action-type='win'][data-action]:hover {
  color: var(--club-paper, #fdf8ee);
  background: #c4523a;
}
:is(.board, .live-board) .move-actions > button[data-action-type='win'][data-action]::before {
  content: '胡' / '';
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font:
    700 22px/1 'Noto Serif SC',
    'Songti SC',
    serif;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}
:is(.board, .live-board)
  .move-actions
  > button[data-action-type='win'][data-action]:active:not(:disabled) {
  box-shadow: 0 1px 0 #7d2c1b;
  transform: translateY(2px);
}

/* Phones: the card takes the seal's slot in the felt, with at most five rows. After the third
   line, the rest share one line before the total. */
.board.classic-table :is(.landscape-centre, .portrait-centre) .call-stamp.call-stamp-win.has-tally {
  width: min(250px, calc(100vw - 110px));
  gap: 5px;
  padding: 9px 11px 9px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .call-stamp.has-tally .stamp-glyph {
  width: 34px;
  height: 34px;
  font-size: 24px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .call-stamp.has-tally .stamp-who {
  font-size: 18px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-beats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  padding-top: 5px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-beat {
  flex: 1 0 100%;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  column-gap: 6px;
  min-height: 17px;
  font-size: 12px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-beat.tally-total {
  grid-template-columns: minmax(0, 1fr) auto;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-mark {
  width: 13px;
  height: 13px;
}
/* The headline on a phone: at most 56 px tall, two lines at most for a long name. */
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-name {
  gap: 1px 7px;
  padding-bottom: 4px;
  font-size: 16px;
}
.board.classic-table
  :is(.landscape-centre, .portrait-centre)
  .has-tally
  .tally-name
  .tally-name-zh {
  font-size: 22px;
}
.board.classic-table
  :is(.landscape-centre, .portrait-centre)
  .has-tally
  .tally-name.is-long
  .tally-name-en {
  font-size: 14px;
}
/* Upright, the card stands on the felt's lower edge, below the seats' bubbles at the sides. */
.board.classic-table .portrait-centre .call-stamp.call-stamp-win.has-tally {
  top: auto;
  bottom: 8px;
  transform: translate(-50%, 0) rotate(-1.5deg) scale(var(--stamp-scale, 1));
  transform-origin: 50% 100%;
}
/* The folded lines run on together, each kept whole: one that does not fit moves to the next
   line rather than being cut (phoneFolds in dist/hu-tally.js keeps them to one or two lines). */
.board.classic-table .portrait-centre .has-tally .tally-beats {
  display: block;
}
.board.classic-table .portrait-centre .has-tally .tally-beat:not(.is-folded) {
  margin-bottom: 2px;
  white-space: normal;
}
.board.classic-table .portrait-centre .has-tally .tally-beat.tally-total {
  margin-top: 4px;
}
.board.classic-table .portrait-centre .has-tally .tally-beat.is-folded {
  display: inline;
  margin-right: 7px;
  line-height: 19px;
}
.board.classic-table
  .portrait-centre
  .has-tally
  .tally-beat.is-folded
  :is(.tally-mark, .tally-label, .tally-tai) {
  display: inline;
  white-space: nowrap;
}
.board.classic-table .portrait-centre .has-tally .tally-beat.is-folded .tally-mark {
  margin-right: 4px;
  vertical-align: -2px;
}
.board.classic-table .portrait-centre .has-tally .tally-beat.is-folded .tally-tai {
  margin-left: 4px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-sum {
  font-size: 21px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-pips i {
  width: 11px;
  height: 11px;
}
.board.classic-table :is(.landscape-centre, .portrait-centre) .has-tally .tally-margin {
  font-size: 11.5px;
}
.board.classic-table
  :is(.landscape-centre, .portrait-centre)
  .call-stamp.has-tally
  .stamp-reaction {
  display: none;
}
/* On a phone the felt has no room beside the card: a paper-cut there would land on the
   winner's flowers and sets (the very tiles that made the hand). So a small one sits inside the
   card, on the paper and under the ink, at the right of the head row, which keeps that corner
   free for it: it covers only the card, never a tile. */
.board.classic-table .portrait-centre .call-stamp.has-tally > span.tally-emblem {
  top: 8px;
  right: 10px;
  z-index: -1;
  width: 40px;
  height: 40px;
  rotate: 6deg;
  filter: none;
}
.board.classic-table .portrait-centre .call-stamp.has-tally:has(> .tally-emblem) .tally-head {
  padding-right: 44px;
}
/* A short phone (360×740) has a shallow felt: the card packs tighter, so its top stays below the
   side seats' speech bubbles, which sit level with the top of the rivers. */
@media (max-height: 780px) {
  .board.classic-table .portrait-centre .call-stamp.has-tally > span.tally-emblem {
    top: 5px;
    width: 32px;
    height: 32px;
  }
  .board.classic-table .portrait-centre .call-stamp.call-stamp-win.has-tally {
    gap: 2px;
    padding: 6px 10px;
  }
  .board.classic-table .portrait-centre .call-stamp.has-tally .stamp-glyph {
    width: 28px;
    height: 28px;
    font-size: 20px;
  }
  .board.classic-table .portrait-centre .call-stamp.has-tally .stamp-who {
    font-size: 17px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-name .tally-name-zh {
    font-size: 19px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-name {
    padding-bottom: 2px;
    font-size: 15px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-beats {
    padding-top: 3px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-beat {
    min-height: 15px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-beat:not(.is-folded) {
    margin-bottom: 0;
  }
  .board.classic-table .portrait-centre .has-tally .tally-beat.is-folded {
    line-height: 17px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-beat.tally-total {
    margin-top: 2px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-sum {
    font-size: 19px;
  }
  .board.classic-table .portrait-centre .has-tally .tally-margin {
    font-size: 11px;
    line-height: 1.25;
  }
}

/* A phone on its side has a shallow felt, and the compact dock covers its lower edge: the card
   lies flat along the top of the felt, no more than 60% of the felt's height. It keeps right of
   centre, clear of the side seats' bubbles and the line beside the face across. The 胡 stands at
   its left; who won and the hand's name share its first line, then the lines and the total run
   on beside it, then the margin: three rows, so a named hand fits above the dock too. */
.board.classic-table .landscape-centre .call-stamp.call-stamp-win.has-tally {
  top: 4px;
  left: calc(50% + 36px);
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-auto-flow: row;
  align-items: center;
  gap: 0 10px;
  width: min(356px, calc(100vw - 488px));
  max-height: 60%;
  padding: 5px 12px;
  transform: translate(-50%, 0);
}
.board.classic-table .landscape-centre .has-tally .tally-head {
  display: contents;
}
.board.classic-table .landscape-centre .call-stamp.has-tally .stamp-glyph {
  grid-row: 1 / span 3;
  align-self: start;
  width: 32px;
  height: 32px;
  font-size: 22px;
}
.board.classic-table .landscape-centre .call-stamp.has-tally .stamp-word {
  display: none;
}
.board.classic-table .landscape-centre .call-stamp.has-tally .stamp-who {
  font-size: 15px;
}
.board.classic-table .landscape-centre .has-tally .tally-title {
  grid-column: 2;
  grid-row: 1;
}
.board.classic-table .landscape-centre .has-tally .tally-beats {
  grid-column: 2 / -1;
  padding-top: 0;
  border-top: 0;
}
/* Lying flat, the headline runs on after who won, on one line, with a thinner rule. */
.board.classic-table .landscape-centre .has-tally .tally-name {
  grid-column: 3;
  grid-row: 1;
  flex-wrap: nowrap;
  min-width: 0;
  padding-bottom: 2px;
  border-bottom-width: 1.5px;
  font-size: 13px;
  white-space: nowrap;
}
.board.classic-table .landscape-centre .has-tally .tally-name .tally-name-zh {
  font-size: 17px;
}
.board.classic-table .landscape-centre .has-tally .tally-name.is-long .tally-name-en {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}
.board.classic-table .landscape-centre .has-tally .tally-beat {
  display: inline-flex;
  flex: 0 1 auto;
  gap: 3px;
  min-height: 15px;
  font-size: 11.5px;
  white-space: nowrap;
}
.board.classic-table .landscape-centre .has-tally .tally-beat.tally-total {
  flex: 1 0 auto;
  justify-content: flex-end;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.board.classic-table .landscape-centre .has-tally .tally-pips {
  display: none;
}
.board.classic-table .landscape-centre .has-tally .tally-sum {
  font-size: 17px;
}
.board.classic-table .landscape-centre .has-tally .tally-margin {
  grid-column: 2 / -1;
  font-size: 11px;
}
/* A tablet on its side (an iPad at 1024×768) uses the same flat layout, but its felt is deep:
   the top of the felt is the across seat's rack, so the card lies in the middle of the felt,
   over the rivers, and never on the hand of a winner sitting across. */
@media (min-height: 600px) {
  .board.classic-table .landscape-centre .call-stamp.call-stamp-win.has-tally {
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
/* Lying flat, the small paper-cut sits in the 胡's column, under the chop, inside the card. */
.board.classic-table .landscape-centre .call-stamp.has-tally > span.tally-emblem {
  top: auto;
  right: auto;
  bottom: 5px;
  left: 12px;
  z-index: -1;
  width: 32px;
  height: 32px;
  rotate: 6deg;
  filter: none;
}
/* Reduced motion: the finished card is simply there for its hold, with no hush and no ink. */
@media (prefers-reduced-motion: reduce) {
  .classic-table .call-stamp.call-stamp-win.has-tally {
    display: grid;
  }
  .hu-hush {
    display: none;
  }
  .board.classic-table .has-tally :is(.tally-beat, .tally-name, .tally-margin) {
    opacity: 1;
    translate: none;
    scale: none;
  }
  .board.classic-table .has-tally .tally-pips i.inked {
    scale: 1;
  }
  :is(.board, .live-board)
    .move-actions
    > button[data-action-type='win'][data-action]:active:not(:disabled) {
    transform: none;
  }
}
