/* The evening: interludes, the last hand and the podium (Track C). Loaded after table-life.css
   on every table page. Timed styles read the variables table life writes on the element they
   move (--timed, --stamp-alpha…), never on the board. */

/* A new wind's seal (南, 西, 北) and the last hand's (终) stand across the middle of the felt in
   the greeting's slot, as the 连庄 seal does: jade for a new wind, ink for the last hand. Their
   small line is the standings, so they keep their own width and wrap it. */
.call-stamp:is(
  .call-stamp-windSouth,
  .call-stamp-windWest,
  .call-stamp-windNorth,
  .call-stamp-lastHand
) {
  left: 50%;
  width: max-content;
  max-width: min(320px, calc(100% - 16px));
  background: var(--club-teal, #1f5c4a);
}
.call-stamp.call-stamp-lastHand {
  color: var(--club-mustard, #e2b654);
  background: var(--club-ink, #2b241c);
  border-color: var(--club-mustard, #e2b654);
  transform: translate(-50%, -50%) rotate(2deg) scale(var(--stamp-scale, 1));
}
.call-stamp-lastHand .stamp-word {
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: none;
}
.call-stamp:is(
    .call-stamp-windSouth,
    .call-stamp-windWest,
    .call-stamp-windNorth,
    .call-stamp-lastHand
  )
  .stamp-who {
  text-wrap: balance;
}
.call-stamp-lastHand .stamp-who {
  color: var(--club-paper, #fdf8ee);
}
.call-stamp-lastHand .stamp-who:empty {
  display: none;
}
.classic-table.life-stamping:is(
    [data-life-stamp='windSouth'],
    [data-life-stamp='windWest'],
    [data-life-stamp='windNorth'],
    [data-life-stamp='lastHand']
  )
  .desktop-focus {
  visibility: hidden;
}
/* A phone on its side: glyph beside the words, low on the shallow felt and nearly flat, as the
   win's seal lies, clear of the dock below and of the speech bubble above. */
.landscape-centre
  .call-stamp:is(
    .call-stamp-windSouth,
    .call-stamp-windWest,
    .call-stamp-windNorth,
    .call-stamp-lastHand
  ) {
  transform: translate(-50%, calc(-50% - 16px)) rotate(-1deg) scale(var(--stamp-scale, 1));
  grid-auto-flow: row;
  grid-template-columns: auto auto;
  row-gap: 1px;
  max-width: calc(100% - 24px);
}
.landscape-centre
  .call-stamp:is(
    .call-stamp-windSouth,
    .call-stamp-windWest,
    .call-stamp-windNorth,
    .call-stamp-lastHand
  )
  .stamp-glyph {
  grid-row: 1 / 3;
  font-size: 30px;
}
.landscape-centre
  .call-stamp:is(
    .call-stamp-windSouth,
    .call-stamp-windWest,
    .call-stamp-windNorth,
    .call-stamp-lastHand
  )
  :is(.stamp-word, .stamp-who) {
  justify-self: start;
  text-align: left;
}
@media (min-width: 1360px) and (not ((max-width: 1400px) and (max-height: 900px) and (orientation: landscape) and (pointer: coarse))) {
  .play-area
    > .classic-table
    .call-stamp:is(.call-stamp-windSouth, .call-stamp-windWest, .call-stamp-windNorth) {
    max-width: 340px;
    background: linear-gradient(145deg, #2a6b56, #174536);
  }
  .play-area > .classic-table .call-stamp.call-stamp-lastHand {
    max-width: 340px;
    color: #f1d89b;
    background: linear-gradient(145deg, #3a3026, #211a13);
    border-color: #e4bf6d;
  }
}

/* The podium: the end of a game at the practice table. One column on a phone, four places in
   a row on a wider screen, first place tallest. */
.solo-home.evening-podium {
  width: min(880px, calc(100% - 24px));
  text-align: center;
}
.evening-podium .evening-kicker {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.evening-podium h1 {
  margin: 6px 0 4px;
  text-wrap: balance;
}
.evening-podium h2 {
  margin: 18px 0 8px;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--club-muted, #6a5e4c);
}
.evening-places {
  display: grid;
  gap: 8px;
  margin: 12px 0 8px;
  padding: 0;
  list-style: none;
}
.evening-place {
  position: relative;
  display: grid;
  grid-template-columns: 52px 56px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  text-align: left;
  background: color-mix(in srgb, var(--club-paper, #fdf8ee) 88%, var(--club-mustard, #e2b654));
  border: 1px solid var(--club-line, #d9ccb0);
  border-radius: 12px;
}
.evening-place[data-place='1'] {
  background: color-mix(in srgb, var(--club-paper, #fdf8ee) 70%, var(--club-mustard, #e2b654));
  border-color: var(--club-mustard, #e2b654);
  box-shadow: 0 4px 14px #2b241c1f;
}
.evening-rank {
  font-size: 13px;
  font-weight: 800;
  color: var(--club-muted, #6a5e4c);
}
.evening-place[data-place='1'] .evening-rank {
  color: var(--club-red, #b7472f);
}
.evening-portrait {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
}
.evening-face {
  width: 56px;
  height: 56px;
  object-fit: cover;
  object-position: 50% 12%;
  border-radius: 50%;
  background: var(--club-teal, #1f5c4a);
  border: 2px solid var(--club-paper, #fdf8ee);
}
.evening-wind {
  display: inline-block;
  width: 40px;
}
.evening-wind img {
  display: block;
  width: 100%;
}
.evening-name {
  font-weight: 700;
  color: var(--club-ink, #2b241c);
  /* A name wraps between its words ("Uncle / Lim"), and breaks inside one only if it must. */
  overflow-wrap: break-word;
}
.evening-points {
  font-variant-numeric: tabular-nums;
  color: var(--club-ink, #2b241c);
}
/* 冠: the last hand changed who was first. A small chop pressed onto the corner of the face. */
.evening-crown {
  position: absolute;
  right: -10px;
  bottom: -6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--club-paper, #fdf8ee);
  font:
    400 20px/1 'Noto Serif SC',
    'Songti SC',
    serif;
  background: var(--club-red, #b7472f);
  border: 2px double var(--club-paper, #fdf8ee);
  border-radius: 6px;
  transform: rotate(-8deg);
  box-shadow: 0 2px 6px #2b241c40;
}
.evening-podium .evening-line {
  margin: 10px auto 4px;
  max-width: 34em;
  font-size: 16px;
  text-align: center;
}
.evening-line-words {
  color: var(--club-ink, #2b241c);
  font-style: italic;
}
.evening-line-who {
  white-space: nowrap;
}
.evening-line-who::before {
  content: '— ';
}
.evening-hand {
  margin: 16px 0 6px;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--club-line, #d9ccb0);
}
.evening-hand h2 {
  margin-top: 0;
}
.evening-hand-who {
  margin: 4px 0 !important;
  color: var(--club-ink, #2b241c) !important;
}
.evening-hand-tiles {
  margin: 8px 0 6px;
  gap: 2px;
}
.evening-hand-tiles .winning-set {
  display: inline-flex;
  gap: 1px;
  margin: 0 2px;
}
/* Up to 14 tiles in one row across a 390 px phone: 14 × 20 px with the gaps between sets. */
@media (max-width: 520px) {
  .evening-hand {
    padding-inline: 0;
  }
  .evening-hand-tiles {
    flex-wrap: nowrap;
    gap: 1px;
  }
  .evening-hand-tiles .winning-set {
    margin: 0 1px;
  }
  .evening-hand-tiles .tile {
    --tile-w: 20px;
    --tile-h: 28px;
  }
}
.evening-hand-called,
.evening-hand-patterns {
  margin: 2px 0 !important;
  font-size: 14px !important;
}
.evening-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.evening-actions > button {
  min-height: 44px;
  width: 100%;
}
@media (min-width: 720px) {
  .evening-places {
    grid-template-columns: repeat(4, 1fr);
    align-items: end;
  }
  .evening-place {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 4px;
    min-height: 150px;
    padding: 12px 8px;
    text-align: center;
  }
  .evening-place[data-place='1'] {
    min-height: 206px;
  }
  .evening-place[data-place='2'] {
    min-height: 188px;
  }
  .evening-portrait,
  .evening-face {
    width: 72px;
    height: 72px;
  }
  .evening-wind {
    width: 48px;
  }
  .evening-actions {
    grid-template-columns: repeat(3, 1fr);
    max-width: 560px;
    margin-inline: auto;
  }
  .evening-actions > .primary {
    grid-column: 1 / -1;
  }
  /* With the party table's entry there are four under Play again: two rows of two. */
  .evening-actions:has(> .party-entry) {
    grid-template-columns: repeat(2, 1fr);
  }
}
/* The podium rises once, the first time the game's end is drawn. */
@keyframes evening-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}
@keyframes evening-press {
  0% {
    opacity: 0;
    transform: rotate(-8deg) scale(1.6);
  }
  60% {
    opacity: 1;
  }
}
.evening-rises .evening-place {
  animation: evening-rise 520ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.evening-rises .evening-place:nth-child(1) {
  animation-delay: 360ms;
}
.evening-rises .evening-place:nth-child(2) {
  animation-delay: 240ms;
}
.evening-rises .evening-place:nth-child(3) {
  animation-delay: 120ms;
}
.evening-rises .evening-crown {
  animation: evening-press 360ms ease-out 900ms backwards;
}
@media (prefers-reduced-motion: reduce) {
  .evening-rises :is(.evening-place, .evening-crown) {
    animation: none;
  }
}
