/* ==========================================================================
   Kings in the Corner - "With Two, Three or Four Players"
   Loaded only by /players/, after styles.css, pages.css and rules.css.
   Everything here is specific to that page's table-size comparison; the
   cards, felt frame and prose come from the shared files.

   1. Seat maps (the table silhouettes)
   2. Opening comparison (three tables side by side)
   3. Deal-maths table
   4. One hand at three tables
   5. Three final frames
   6. Responsive
   7. Print
   ========================================================================== */

/* ---------------------------- 1. Seat maps ------------------------------ */
/* A seat map is one felt drawing: an SVG underlay for the table outline and
   the turn arrows, with the opening layout and the seat labels as real HTML
   on top. Nothing here is baked into an image. */

.seatmap {
  --cw: 40px;                        /* redeclare the pair: --ch and --cr are */
  --ch: calc(var(--cw) * 1.44);      /* resolved where --cw is declared, not  */
  --cr: calc(var(--cw) * .1);        /* where it is used */
  position: relative;
  width: 100%; max-width: 620px;
  margin-inline: auto;
  aspect-ratio: 600 / 340;
}

.seatmap__art {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
}
.seatmap__shape { fill: rgba(255, 255, 255, .05); stroke: rgba(198, 233, 214, .5); stroke-width: 2; }
.seatmap__flow { fill: none; stroke: #7FDCAC; stroke-width: 5; stroke-linecap: round; }
.seatmap__head { fill: #7FDCAC; }

.seatmap__cards {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(3, var(--cw));
  grid-template-rows: repeat(3, auto);
  column-gap: 5px;
  justify-items: center; align-items: center;
}
.seatmap__cards .card { box-shadow: 0 6px 14px rgba(0, 0, 0, .38); }
/* the four opening cards sit in a cross. The rows overlap a little so the
   group reads as one layout, but not so much that the pips collide. */
.sm-n { grid-column: 2; grid-row: 1; }
.sm-w { grid-column: 1; grid-row: 2; margin-top: calc(var(--ch) * -.16); }
.sm-e { grid-column: 3; grid-row: 2; margin-top: calc(var(--ch) * -.16); }
.sm-s { grid-column: 2; grid-row: 3; margin-top: calc(var(--ch) * -.20); }

.seat-pill {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: #1B4C82;
  color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  white-space: nowrap;
}
.seat-pill--you { background: #0E3665; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }

/* The felt is a gradient, and its lighter end put var(--gold-light) at 4.38:1
   behind these small bold labels. Raise the gold for anything sitting on it. */
.diag__felt { --gold-light: #EACB8E; }

/* seat positions, as percentages of the map */
.pos-n  { left: 50%;  top: 6%; }
.pos-s  { left: 50%;  top: 94%; }
.pos-w  { left: 12%;  top: 50%; }
.pos-e  { left: 88%;  top: 50%; }
.pos-sw { left: 14%;  top: 90%; }
.pos-se { left: 86%;  top: 90%; }

/* numbered turn badges on the four-player map */
.turn-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #12643E;
  box-shadow: 0 0 0 2px #7FDCAC;
  color: #EAFBF1;
  font-size: 13px; font-weight: 700;
}

/* the three badges follow the clockwise order of play round the table */
.pos-t1 { left: 25%; top: 86%; }
.pos-t2 { left: 18.7%; top: 27%; }
.pos-t3 { left: 81.7%; top: 27%; }

/* the note sits below the map in normal flow; absolutely positioning it
   inside collided with the "You" seat pill at the foot of the table */
.seatmap__note {
  margin: 10px 0 0;
  text-align: center;
  color: var(--gold-light);
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}

/* ------------------------ 2. Opening comparison ------------------------- */
.tsize {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.tsize__col {
  display: grid; gap: 10px; align-content: start;
  padding: 14px 10px 12px;
  border: 1px solid rgba(198, 233, 214, .35);
  border-radius: 12px;
}
.tsize__h {
  margin: 0;
  text-align: center;
  color: var(--gold-light);
  font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.tsize .seatmap {
  --cw: 24px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  aspect-ratio: 300 / 260;
}
.tsize .seat-pill { padding: 4px 9px; font-size: 10px; }
/* the side seats sit further out on the small maps so they clear the cards */
.tsize .pos-w { left: 8%; }
.tsize .pos-e { left: 92%; }

.tsize__stock {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin: 0;
  color: #DCEFE4; font-size: 13px;
}
.tsize__stock b { color: #fff; font-size: 20px; font-family: var(--serif); }

/* a face-down stack: a hint beside the number, never the number itself */
.stockhint { display: inline-flex; flex: none; }
.stockhint i {
  display: block;
  width: 13px; height: 19px;
  border-radius: 3px;
  background: #2C4FA0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45);
}
.stockhint i + i { margin-left: -7px; }
.stockhint--sm i { width: 10px; height: 15px; }
.stockhint--sm i + i { margin-left: -5px; }

/* --------------------------- 3. Deal maths ------------------------------ */
.ptable-wrap { overflow-x: auto; margin: 18px 0 22px; }
.ptable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  background: var(--ipanel);
  border: 1px solid var(--iline);
  border-radius: 10px;
  overflow: hidden;
}
.ptable thead th {
  padding: 12px 14px;
  background: var(--nav);
  color: #fff;
  font-size: 13.5px; font-weight: 600; text-align: left;
  vertical-align: bottom;
}
.ptable th, .ptable td {
  padding: 11px 14px;
  text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--iline);
}
.ptable tbody th { color: var(--ink); font-weight: 700; }
.ptable td { color: var(--text); }
.ptable tbody tr:last-child th,
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable .num { display: inline-flex; align-items: center; gap: 8px; }

/* ------------------- 4. One hand at three tables ------------------------ */
.routes {
  display: grid;
  grid-template-columns: auto minmax(70px, 110px) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}
.routes__hand {
  --cw: 38px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: flex; align-items: center;
}
.routes__hand .card + .card { margin-left: 3px; }   /* full faces, no overlap */
.routes__hand .card { box-shadow: 0 6px 14px rgba(0, 0, 0, .38); }

.routes__label {
  margin: 0 0 8px;
  color: var(--gold-light);
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
/* Two arrows are authored, one per direction, and the media query picks the
   one that fits. Stretching the horizontal fan into a short wide box squashed
   the arrowheads into slivers. */
.routes__arrows { width: 100%; height: 150px; }
.routes__arrows path { fill: none; stroke: #7FDCAC; stroke-width: 4; stroke-linecap: round; }
.routes__arrows polygon { fill: #7FDCAC; }
.routes__down { display: none; }

.routes__ends { display: grid; gap: 10px; }
.routes__end {
  --cw: 32px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(198, 233, 214, .35);
  border-radius: 10px;
}
.routes__end .routes__label { grid-column: 1 / -1; margin: 0; }
.routes__cards { display: flex; gap: 5px; }
.routes__note { margin: 0; color: #DCEFE4; font-size: 13px; line-height: 1.35; }

/* --------------------------- 5. Final frames ---------------------------- */
.frames {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.frame {
  --cw: 44px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: grid; gap: 12px; justify-items: center; align-content: start;
  padding: 16px 12px 14px;
  border: 1px solid rgba(198, 233, 214, .35);
  border-radius: 12px;
}
.frame__h {
  margin: 0;
  color: var(--gold-light);
  font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.frame__stage { display: grid; gap: 10px; justify-items: center; min-height: calc(var(--ch) * 2.1); }
.frame__row { display: flex; gap: 5px; }
.frame__row .card { box-shadow: 0 6px 14px rgba(0, 0, 0, .38); }
.frame__tag {
  padding: 5px 12px; border-radius: 999px;
  background: #0E3665; color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.frame__turn { width: 46px; height: 26px; }
.frame__turn path { fill: none; stroke: #7FDCAC; stroke-width: 4; stroke-linecap: round; }
.frame__turn polygon { fill: #7FDCAC; }
.frame__cap {
  margin: 0; text-align: center;
  color: #DCEFE4; font-size: 12.5px; font-weight: 600;
}

/* --------------------------- 6. Responsive ------------------------------ */
@media (max-width: 900px) {
  /* the brief asks for the two-, three- and four-player views stacked in
     that order, which is already the source order */
  .tsize { grid-template-columns: minmax(0, 1fr); }
  /* keep the 300x260 ratio: the shape SVG letterboxes inside a wider box, so
     stretching the map made the outline shrink away from the cards */
  .tsize .seatmap { --cw: 30px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1); }
  .tsize .seat-pill { padding: 5px 11px; font-size: 11px; }

  .frames { grid-template-columns: minmax(0, 1fr); }

  .routes { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .routes__arrows { display: none; }
  .routes__down { display: block; width: 100%; height: 34px; }
  .routes__down path { fill: none; stroke: #7FDCAC; stroke-width: 4; stroke-linecap: round; }
  .routes__down polygon { fill: #7FDCAC; }
  .routes__hand { --cw: 34px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1);
                  justify-content: center; }

  .seatmap { --cw: 32px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1); }
  .seat-pill { padding: 5px 10px; font-size: 11px; }
  /* "Previous player" ran past the felt's right edge on a narrow phone, so the
     bottom seats move inward and the longer labels are allowed to wrap */
  .seatmap--three .pos-sw { left: 19%; }
  .seatmap--three .pos-se { left: 81%; }
  .seat-pill { white-space: normal; max-width: 36%; text-align: center; }
  .seatmap__note { font-size: 11px; }
}

@media (max-width: 700px) {
  /* Every value stays on screen: each row becomes a labelled strip rather
     than a column that scrolls out of sight. */
  .ptable-wrap { overflow-x: visible; }
  .ptable, .ptable tbody, .ptable tr, .ptable th, .ptable td { display: block; }
  .ptable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ptable tbody tr {
    margin-bottom: 12px;
    border: 1px solid var(--iline); border-radius: 10px;
    background: var(--ipanel);
  }
  .ptable tbody tr:last-child { margin-bottom: 0; }
  .ptable tbody th {
    padding: 10px 14px;
    background: var(--nav); color: #fff;
    border-bottom: 0; border-radius: 9px 9px 0 0;
  }
  .ptable tbody th::after { content: " players"; font-weight: 400; opacity: .85; }
  .ptable tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 9px 14px;
  }
  .ptable tbody td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted); font-size: 13px; font-weight: 600;
  }
  .ptable tbody tr td:last-child { border-bottom: 0; }
}

/* ------------------------------ 7. Print -------------------------------- */
@media print {
  .seatmap__shape { fill: none; stroke: #555; }
  .seatmap__flow, .routes__arrows path, .routes__down path, .frame__turn path { stroke: #555; }
  .seatmap__head, .routes__arrows polygon, .routes__down polygon, .frame__turn polygon { fill: #555; }
  .seat-pill, .turn-badge, .frame__tag { background: #FFF; color: #1A1A1A; box-shadow: 0 0 0 1px #555; }
  .seatmap__note, .tsize__h, .routes__label, .frame__h { color: #6B5A2E; }
  .tsize__stock, .routes__note, .frame__cap { color: #1A1A1A; }
  .tsize__col, .routes__end, .frame { border-color: #999; }
  .stockhint i { background: #FFF; box-shadow: inset 0 0 0 1px #555; }
  .ptable thead th { background: #FFF; color: #1A1A1A; box-shadow: inset 0 -2px 0 #555; }
}
