/* The mat (spec §8): seats on a compass, the trick in the middle, the held last trick, the deck
   in the cut, the chien on the table, the arrow and the ring; and the hand's fan. Every position
   is keyed on a slot name the JS computes (mat.js SLOTS); nothing here knows a rule. */

.mat { position: relative; height: 100%; --trick-w: 64px; }

/* the card's own frame line, scaled up: it marks where a tap plays the lifted card */
.mat__rule {
  position: absolute;
  inset: 100px 88px 56px;
  border: 1px solid var(--filet);
  border-radius: 18px;
  opacity: .7;
  pointer-events: none;
}

/* ---- seats ---- */

/* scoped to the mat: the waiting room's seat list (shell.css) shares the class name */
.mat .seat {
  position: absolute;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 104px;
  font-size: 13px;
  line-height: 1.2;
}

.seat__head { display: flex; align-items: center; gap: 5px; max-width: 100%; }

.seat__initial {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--carton);
  color: var(--encre);
  font: 700 14px/1 var(--font-index);
}

/* the ring: gilt, pulsing by opacity, on the acting seat only */
.seat__initial::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid var(--dorure);
  border-radius: 50%;
  opacity: 0;
}

.seat.is-acting .seat__initial::after {
  opacity: 1;
  animation: ring-pulse calc(1.8s * var(--motion)) ease-in-out infinite;
}

@keyframes ring-pulse { 50% { opacity: .45; } }

/* camps: the taker and the partner in ink, the defence on stock, "?" on the rule's colour */
.seat[data-camp="taker"] .seat__initial,
.seat[data-camp="partner"] .seat__initial { background: var(--encre); color: var(--carton); box-shadow: 0 0 0 2px var(--carton); }
.seat[data-camp="unknown"] .seat__initial { background: var(--filet); color: var(--craie); }

.seat__name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* presence: chalk when connected, the rule's colour when not — never green, never gilt */
.seat__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--craie); }
.seat.is-away .seat__dot { background: var(--filet); }
.seat.is-away .seat__name { opacity: .7; }
.seat__away { font-size: 12px; }

.seat__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }

.chip {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .28);
  font: 600 12px/1.4 var(--font-ui);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chip[data-kind="dealer"] { background: var(--carton); color: var(--encre); font-family: var(--font-index); }
.chip[data-kind="contract"], .chip[data-kind="chelem"] { background: var(--encre); color: var(--carton); }
.chip[data-kind="tricks"] { font-family: var(--font-index); }
/* "appelle R♦" is short enough to stay on one line */

/* a small fan of backs, one per card held */
.seat__fan { position: relative; display: block; height: 30px; width: calc(17px + (var(--n) - 1) * 3px); }
.seat__fan .card { --card-w: 17px; position: absolute; left: calc(var(--i) * 3px); top: 0; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .3); }

/* the portrait compass: me at the bottom, play running anticlockwise, so (me + 1) is on my right */
/* my seat takes the mat's full width, so the taker's chips sit in one line beside the name
   instead of a word per line (screenshots, 2026-09-25) */
.seat[data-slot="me"] { left: 8px; right: 8px; bottom: 2px; flex-direction: row; justify-content: center; width: auto; gap: 8px; }
.seat[data-slot="me"] .seat__chips { min-width: 0; justify-content: flex-start; }
.seat[data-slot="r"]  { right: 2px; top: 50%; transform: translateY(-50%); }
.seat[data-slot="t"]  { left: 50%; top: 2px; transform: translateX(-50%); width: 150px; }
.seat[data-slot="l"]  { left: 2px; top: 50%; transform: translateY(-50%); }
.seat[data-slot="rt"] { right: 6px; top: 6px; }
.seat[data-slot="lt"] { left: 6px; top: 6px; }
.seat[data-slot="rm"] { right: 2px; top: 36%; transform: translateY(-50%); }
.seat[data-slot="lm"] { left: 2px; top: 36%; transform: translateY(-50%); }
/* the side seats stop short of the trick's column (100 px in at four, 86 at five), and their
   chips are a size smaller so "Garde contre" or "joue seule" fits on one line */
.seat[data-slot="r"], .seat[data-slot="l"] { width: 94px; }
.seat[data-slot="rm"], .seat[data-slot="lm"] { width: 82px; }
.seat:is([data-slot="r"], [data-slot="l"], [data-slot="rm"], [data-slot="lm"]) .chip { padding: 1px 5px; font-size: 11px; }
/* and a long name takes a line of its own under the initial rather than shrinking to "Jean-…" */
.seat:is([data-slot="r"], [data-slot="l"], [data-slot="rm"], [data-slot="lm"]) .seat__head { flex-wrap: wrap; justify-content: center; row-gap: 0; }
.seat__head { min-width: 0; }
.seat[data-slot="tr"] { right: 16%; top: 2px; }
.seat[data-slot="tl"] { left: 16%; top: 2px; }

/* ---- the trick ---- */

/* below the top seats and their fans, above the me strip: the trick never sits under a name */
.trick { position: absolute; inset: 110px 100px 62px; }
.mat[data-players="5"] { --trick-w: 58px; }
.mat[data-players="5"] .trick { top: 150px; left: 86px; right: 86px; }   /* five cards need the width */
.mat[data-players="5"] .mat__rule { top: 140px; left: 84px; right: 84px; }

.trick__play { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.trick__card { --card-w: var(--trick-w); }
.trick .card[disabled] { opacity: 1; cursor: default; }
/* the held trick's winner, ringed in chalk: "who took it" is the one question it answers */
.trick__play.is-winner .card { box-shadow: 0 0 0 3px var(--craie), var(--shadow-card); }

/* each card at its player's compass point, turned 6° toward them */
.trick__play[data-slot="me"] { left: 50%; bottom: 0; transform: translateX(-50%); }
.trick__play[data-slot="t"]  { left: 50%; top: 0; transform: translateX(-50%); }
.trick__play[data-slot="r"]  { right: 6px; top: 50%; transform: translateY(-50%) rotate(-6deg); }
.trick__play[data-slot="l"]  { left: 6px; top: 50%; transform: translateY(-50%) rotate(6deg); }
.trick__play[data-slot="rt"] { right: 0; top: 0; transform: rotate(-6deg); }
.trick__play[data-slot="lt"] { left: 0; top: 0; transform: rotate(6deg); }
.trick__play[data-slot="rm"] { right: 0; top: 58%; transform: translateY(-50%) rotate(-6deg); }
.trick__play[data-slot="lm"] { left: 0; top: 58%; transform: translateY(-50%) rotate(6deg); }
.trick__play[data-slot="tr"] { right: 12%; top: 0; transform: rotate(-6deg); }
.trick__play[data-slot="tl"] { left: 12%; top: 0; transform: rotate(6deg); }

/* the lead underlined; at five, a name tag under each card */
.trick__play.is-lead::after { content: ""; width: 70%; height: 3px; border-radius: 2px; background: var(--craie); }
.trick__tag { font-size: 10px; line-height: 1.2; white-space: nowrap; }
.play:not([data-orientation="landscape"]) .mat:not([data-players="5"]) .trick__tag { display: none; }

/* the arrow in the trick area points at the acting seat, gilt like the ring */
.trick__arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-bottom: 14px solid var(--dorure);
  transform: translate(-50%, -50%) rotate(var(--deg)) translateY(-30px);
}

.trick__arrow[data-slot="t"]  { --deg: 0deg; }
.trick__arrow[data-slot="r"]  { --deg: 90deg; }
.trick__arrow[data-slot="me"] { --deg: 180deg; }
.trick__arrow[data-slot="l"]  { --deg: 270deg; }
.trick__arrow[data-slot="rt"] { --deg: 45deg; }
.trick__arrow[data-slot="lt"] { --deg: 315deg; }
.trick__arrow[data-slot="rm"] { --deg: 100deg; }
.trick__arrow[data-slot="lm"] { --deg: 260deg; }
.trick__arrow[data-slot="tr"] { --deg: 35deg; }
.trick__arrow[data-slot="tl"] { --deg: 325deg; }

.trick__label { position: absolute; left: -60px; right: -60px; bottom: -20px; text-align: center; font-size: 13px; }

/* the deck edge-on in tartan while someone cuts */
.trick__deck { position: absolute; left: 50%; top: 50%; width: 48px; height: 86px; transform: translate(-50%, -50%); }
.trick__deck .card { --card-w: 48px; position: absolute; left: 0; top: 0; }
.trick__deck .card:nth-child(2) { transform: translate(2px, -2px); }
.trick__deck .card:nth-child(3) { transform: translate(4px, -4px); }
.trick__deck .card:nth-child(4) { transform: translate(6px, -6px); }

/* the cut: one tap under the deck, no slider — the server draws the position (deal-01) */
.mat__cut {
  position: absolute;
  left: 50%;
  top: calc(50% + 58px);
  transform: translateX(-50%);
  min-width: 140px;
  min-height: 52px;
  font: 700 20px/1 var(--font-index);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}

/* the chien face up on the mat while the taker makes the écart: three to a row */
.trick[data-kind="chien"] .trick__label { top: 0; bottom: auto; }
.trick__chien { position: absolute; left: 0; right: 0; top: 24px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.trick__chien .card { --card-w: 54px; }

/* a poignée another seat has shown, over the trick, until Vu */
.mat__poignee {
  position: absolute;
  inset: 36px 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sheet);
  background: rgba(19, 55, 48, .94);
}

.mat__poignee-title { font: 700 16px/1.2 var(--font-index); text-align: center; }
.mat__poignee-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.mat__poignee-cards .card { --card-w: 40px; }

/* ---- the hand ---- */

.hand .card {
  position: absolute;
  left: var(--pad-x, 16px);
  top: 12px;
  z-index: var(--z);
  transform: translate(var(--x), calc(var(--y) + var(--lift, 0px)));
  transition: transform calc(120ms * var(--motion)) ease-out;
}

.hand .card.is-legal { --lift: -6px; }
.hand .card.is-selected { --lift: -14px; outline: 2px solid var(--craie); }
.hand .card.is-lifted { --lift: -18px; z-index: calc(var(--z) + 100); }
.hand .card.is-locked { filter: brightness(calc(var(--card-dim) * .7)) saturate(.6); }

/* ---- landscape: seats in the top strip in play order, and the trick as a row ----
   A phone on its side leaves the mat about 120 px of height: a compass of five cards cannot fit
   it without cards covering cards (screenshots, 2026-09-25). The trick becomes one row in the
   order it was played, each card tagged with its player, and the strip's ring says who acts. */

.play[data-orientation="landscape"] .mat {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  align-content: flex-start;
  padding: 2px 8px;
  --trick-w: 50px;
}

.play[data-orientation="landscape"] .mat { flex-wrap: nowrap; align-items: flex-start; gap: 6px; }
.play[data-orientation="landscape"] .seat__chips { flex-wrap: nowrap; }
/* five seats and their words fill the strip: the backs go, the count chips stay */
.play[data-orientation="landscape"] .mat[data-players="5"] .seat__fan { display: none; }
.play[data-orientation="landscape"] .mat[data-players="5"] .seat__name { max-width: 64px; }
.play[data-orientation="landscape"] .mat[data-players="5"] .chip { padding: 1px 5px; font-size: 11px; }
.play[data-orientation="landscape"] .seat { position: static; flex-direction: row; flex: 0 1 auto; min-width: 0; width: auto; gap: 4px; font-size: 12px; transform: none; }
.play[data-orientation="landscape"] .seat__initial { width: 24px; height: 24px; font-size: 12px; }
.play[data-orientation="landscape"] .seat__name { max-width: 72px; }
.play[data-orientation="landscape"] .seat__head,
.play[data-orientation="landscape"] .seat:is([data-slot="r"], [data-slot="l"], [data-slot="rm"], [data-slot="lm"]) .seat__head { min-width: 0; flex-wrap: nowrap; }

/* my own chips: bottom left of the mat, out of the strip so the strip never wraps */
.play[data-orientation="landscape"] .seat--me {
  position: absolute;
  left: 8px;
  right: auto;
  bottom: 2px;
  max-width: calc(22% - 14px);
  flex-wrap: wrap;
  justify-content: flex-start;
}
.play[data-orientation="landscape"] .seat__fan { height: 18px; width: calc(10px + (var(--n) - 1) * 1.5px); }
.play[data-orientation="landscape"] .seat__fan .card { --card-w: 10px; left: calc(var(--i) * 1.5px); }
.play[data-orientation="landscape"] .mat__rule,
.play[data-orientation="landscape"] .mat[data-players="5"] .mat__rule { inset: 34px 22% 4px; border-radius: 14px; }
.play[data-orientation="landscape"] .trick,
.play[data-orientation="landscape"] .mat[data-players="5"] .trick {
  inset: 38px 22% 6px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
  --trick-w: 44px;
}
.play[data-orientation="landscape"] .trick__play { position: static; transform: none; }
.play[data-orientation="landscape"] .trick__arrow { display: none; }
.play[data-orientation="landscape"] .trick__deck { position: relative; left: auto; top: auto; transform: none; }
.play[data-orientation="landscape"] .mat__cut { position: static; transform: none; align-self: center; }
/* the held trick's line sits at the end of the row, clear of the tags */
.play[data-orientation="landscape"] .trick[data-kind="held"] .trick__label { position: static; align-self: center; max-width: 9em; text-align: left; }
.play[data-orientation="landscape"] .trick[data-kind="chien"] { flex-direction: column; align-items: center; gap: 2px; }
.play[data-orientation="landscape"] .trick[data-kind="chien"] .trick__label,
.play[data-orientation="landscape"] .trick[data-kind="chien"] .trick__chien { position: static; }
.play[data-orientation="landscape"] .trick__chien { top: 18px; }
.play[data-orientation="landscape"] .trick__chien .card { --card-w: 40px; }
.play[data-orientation="landscape"] .mat__poignee { inset: 4px 20%; gap: 6px; padding: 6px; }
.play[data-orientation="landscape"] .mat__poignee-cards .card { --card-w: 32px; }
