/* ==========================================================================================================
   Edgewise · Position Quiz + the shared oval table (position-quiz-table.js, also used by the Skill Check).
   Mirrors the app's TableDiagram: felt oval with a wood rail, seat chips around it, a white dealer button.
   ========================================================================================================== */

/* ── Oval table ────────────────────────────────────────────────────────────────────────────────────── */

.ptable {
  --seat-w: clamp(44px, 13.5cqi, 60px);
  --seat-h: clamp(27px, 7.4cqi, 33px);
  --seat-font: clamp(.6875rem, .55rem + 1.1cqi, .8125rem);
  --rail: clamp(6px, 1.8cqi, 11px);
  container-type: inline-size;
  position: relative;
  width: min(100%, 31rem);
  aspect-ratio: 1.58;
  margin-inline: auto;
  isolation: isolate;
  font-family: var(--g-font);
}

.ptable--crowded {
  --seat-w: clamp(40px, 12cqi, 54px);
  --seat-font: clamp(.625rem, .5rem + 1cqi, .75rem);
}

/* Felt + wood rail with a gold hairline, lit from above. */
.ptable__felt {
  position: absolute;
  inset: 17% 12%;
  z-index: 0;
  display: grid;
  place-items: center;
  border: var(--rail) solid transparent;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 55% at 50% 38%, rgba(255, 255, 255, .1), transparent 70%) padding-box,
    radial-gradient(ellipse 80% 90% at 50% 45%, #227A50 0%, var(--felt-top, #1D6A46) 35%, #135036 70%, var(--felt-bottom, #0C3A27) 100%) padding-box,
    linear-gradient(180deg, #6B4A2C 0%, #3B2A1A 38%, #2A1D11 70%, #4A3420 100%) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(233, 185, 73, .3),
    inset 0 -22px 40px -18px rgba(0, 0, 0, .55),
    inset 0 10px 24px -14px rgba(255, 255, 255, .12),
    0 0 0 1px rgba(0, 0, 0, .55),
    0 26px 50px -22px rgba(0, 0, 0, .95),
    0 10px 20px -12px rgba(0, 0, 0, .7);
}

/* Felt fibre. */
.ptable__felt::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .2;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* The card room's mark printed on the felt. */
.ptable__logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, .16);
  font: italic 500 clamp(.75rem, .5rem + 1.6cqi, 1.0625rem)/1 var(--font-display, ui-serif, Georgia, serif);
  letter-spacing: .02em;
  translate: 0 -6%;
}

.ptable--crowded .ptable__logo,
.ptable--hu .ptable__logo {
  translate: 0 0;
}

.ptable__logo .g-icon {
  width: 1.1em;
  height: 1.1em;
  color: rgba(233, 185, 73, .3);
}

.ptable__center {
  position: relative;
  display: grid;
  justify-items: center;
}

.ptable__seats {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Seat chips */
.ptable__seat {
  position: absolute;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
  display: grid;
  place-items: center;
  min-width: var(--seat-w);
  height: var(--seat-h);
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #24332E, #18221F);
  color: rgba(255, 255, 255, .94);
  font: 700 var(--seat-font)/1 var(--g-font);
  letter-spacing: .01em;
  white-space: nowrap;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .15),
    inset 0 1px 0 rgba(255, 255, 255, .08),
    0 6px 14px -6px rgba(0, 0, 0, .95);
  transition: background .3s, color .3s, scale .3s cubic-bezier(.2, 1.3, .4, 1), box-shadow .3s, opacity .3s;
  -webkit-tap-highlight-color: transparent;
}

button.ptable__seat {
  cursor: pointer;
  touch-action: manipulation;
}

/* 44px touch target without growing the chip. */
button.ptable__seat::before {
  content: "";
  position: absolute;
  inset: max(-8px, calc((44px - var(--seat-h)) / -2)) -4px;
  border-radius: 999px;
}

.ptable__label {
  display: block;
  min-height: 1em;
}

.ptable--anon .ptable__seat .ptable__label::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  margin: auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, .28);
}

.ptable.is-named .ptable__label {
  animation: ptable-fade .45s ease both;
}

@media (hover: hover) and (pointer: fine) {
  .ptable:not(.is-locked) button.ptable__seat:hover {
    background: linear-gradient(180deg, #2F433C, #22302B);
    box-shadow:
      inset 0 0 0 1px rgba(233, 185, 73, .55),
      0 0 18px -4px rgba(233, 185, 73, .35),
      0 6px 14px -6px rgba(0, 0, 0, .95);
    scale: 1.06;
  }
}

.ptable button.ptable__seat:focus-visible {
  outline: 2px solid var(--gold, #E9B949);
  outline-offset: 3px;
}

.ptable:not(.is-locked) button.ptable__seat:active {
  scale: .96;
}

.ptable__seat.is-lit {
  background: linear-gradient(180deg, #F6D47A 0%, var(--gold, #E9B949) 55%, #D9A63A 100%);
  color: #14100A;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .5),
    0 0 0 1px rgba(0, 0, 0, .35),
    0 0 26px -2px rgba(233, 185, 73, .6),
    0 6px 14px -6px rgba(0, 0, 0, .9);
}

.ptable__seat.is-selected {
  scale: 1.14;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px rgba(0, 0, 0, .45),
    0 6px 14px -6px rgba(0, 0, 0, .9);
}

.ptable__seat.is-lit.is-selected {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .5),
    0 0 0 2px #fff,
    0 0 0 4px rgba(0, 0, 0, .45),
    0 0 26px -2px rgba(233, 185, 73, .6);
}

.ptable__seat.is-folded {
  opacity: .42;
}

.ptable__seat.is-folded .ptable__label {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(255, 255, 255, .55);
}

.ptable.is-locked button.ptable__seat {
  cursor: default;
}

/* Answer marks: icon + the seat's state, never colour alone. */
.ptable__mark:empty {
  display: none;
}

.ptable__mark {
  --icon-ink: #0E1613;
  position: absolute;
  top: -9px;
  right: -9px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #0E1613;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .6);
  animation: ptable-pop .34s cubic-bezier(.2, 1.4, .4, 1) both;
}

.ptable__seat.is-correct .ptable__mark { color: var(--good, #34C77B); }
.ptable__seat.is-wrong .ptable__mark { color: var(--bad, #FF5D5D); }

.ptable__seat.is-wrong {
  background: color-mix(in srgb, var(--bad, #FF5D5D) 22%, #18221F);
}

.ptable__dealer {
  position: absolute;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: clamp(17px, 5cqi, 22px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFFFF, #ECEBE4 70%, #D7D5CB);
  color: #111;
  font: 800 clamp(.5625rem, .45rem + .8cqi, .6875rem)/1 var(--g-font);
  box-shadow: 0 2px 5px rgba(0, 0, 0, .55), inset 0 0 0 1.5px rgba(0, 0, 0, .08);
}

/* Seats settle in around the table. */
@media (prefers-reduced-motion: no-preference) {
  .ptable .ptable__seat {
    animation: ptable-seat .5s cubic-bezier(.2, .9, .3, 1.15) both;
    animation-delay: calc(var(--i, 0) * 35ms);
  }

  .ptable .ptable__dealer {
    animation: ptable-fade .4s ease .25s both;
  }
}

@keyframes ptable-seat {
  from { opacity: 0; scale: .6; }
  to { opacity: 1; scale: 1; }
}

@keyframes ptable-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ptable-pop {
  from { opacity: 0; scale: .3; }
  to { opacity: 1; scale: 1; }
}

@media (forced-colors: active) {
  .ptable__seat { border: 1px solid CanvasText; }
  .ptable__seat.is-lit { outline: 2px solid Highlight; }
  .ptable__felt { border-color: CanvasText; }
}

/* ── Position Quiz ─────────────────────────────────────────────────────────────────────────────────── */

.pq .game__stage {
  align-content: start;
  gap: clamp(8px, 2cqi, 14px);
  background:
    radial-gradient(70% 55% at 50% 0%, rgba(233, 185, 73, .09), transparent 70%),
    radial-gradient(90% 75% at 50% 10%, rgba(29, 106, 70, .3), transparent 72%),
    linear-gradient(180deg, #101A16, #0B120F);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .06),
    inset 0 1px 0 rgba(255, 255, 255, .06),
    0 12px 30px -18px rgba(0, 0, 0, .8);
}

.pq .game__stage::before {
  opacity: .08;
}

.pq-kind {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 700 .6875rem/1.2 var(--g-font);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold, #E9B949);
}

.pq-prompt {
  max-width: 30rem;
  font: 650 clamp(1.0625rem, .95rem + 1cqi, 1.3125rem)/1.35 var(--g-font);
  letter-spacing: -.01em;
  color: #fff;
  text-wrap: balance;
}

.pq-hint {
  min-height: 1.3em;
  font: 500 .8125rem/1.3 var(--g-font);
  color: var(--g-faint);
}

.pq-table-slot {
  width: 100%;
}

.pq .ptable {
  margin-block: clamp(2px, 1cqi, 8px);
}

.game--compact.pq .ptable {
  width: min(100%, 22rem);
  aspect-ratio: 1.72;
}

.game--compact.pq .pq-kind {
  display: none;
}

.pq-reveal-name {
  color: var(--g-text);
  font-weight: 700;
  font-size: .9375rem;
}

.pq-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.pq-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font: 600 .8125rem/1.2 var(--g-font);
  color: var(--g-dim);
  cursor: pointer;
  user-select: none;
}

.pq-switch input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  cursor: pointer;
  transition: background-color .2s;
}

.pq-switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  transition: translate .22s cubic-bezier(.2, .8, .2, 1);
}

.pq-switch input:checked {
  background: var(--gold, #E9B949);
}

.pq-switch input:checked::after {
  translate: 16px 0;
}

.pq-switch input:focus-visible {
  outline: 2px solid var(--gold, #E9B949);
  outline-offset: 3px;
}

.pq-switch:hover {
  color: var(--g-text);
}

/* Forced colours drop the fill, shadow and white knob: draw the track and knob in system colours instead. */
@media (forced-colors: active) {
  .pq-switch input {
    border: 1px solid CanvasText;
  }

  .pq-switch input::after {
    top: 2px;
    left: 2px;
    background: CanvasText;
  }

  .pq-switch input:checked {
    border-color: Highlight;
    background: Highlight;
  }

  .pq-switch input:checked::after {
    background: HighlightText;
  }
}

.pq-upsell {
  margin: 0;
  font: 500 .8125rem/1.45 var(--g-font);
  color: var(--g-faint);
  text-wrap: pretty;
  animation: g-rise .4s cubic-bezier(.2, .8, .2, 1) both;
}

.pq-upsell a {
  color: var(--gold, #E9B949);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: rgba(233, 185, 73, .4);
  text-underline-offset: .2em;
}

.pq-upsell a:hover {
  text-decoration-color: currentColor;
}

.pq-upsell a:focus-visible {
  outline: 2px solid var(--gold, #E9B949);
  outline-offset: 2px;
  border-radius: 3px;
}

.pq .game__titles {
  flex-basis: 7rem;
}

/* Seat names are short: two answers per row everywhere. */
.pq .g-choices[data-count="4"],
.pq .g-choices[data-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@container game (max-width: 520px) {
  .pq .g-choice {
    min-height: 50px;
    padding: 10px 12px;
    font-size: .9375rem;
    line-height: 1.25;
  }

  .pq .g-choice__key { display: none; }
}

.game--compact.pq {
  --g-gap: 10px;
}

.game--compact.pq .game__stage {
  min-height: 0;
  gap: 8px;
  padding: 14px 10px 12px;
}

.game--compact.pq .pq-prompt {
  font-size: clamp(1rem, .92rem + .8cqi, 1.125rem);
}

.game--compact.pq .ptable {
  margin-block: 0;
}

.game--compact.pq .g-next {
  min-height: 48px;
}

.game--compact.pq .game__feedback .g-feedback {
  padding: 12px 14px;
}

.game--compact.pq .g-feedback__body {
  font-size: .8125rem;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .ptable__mark,
  .ptable.is-named .ptable__label,
  .pq-upsell {
    animation: none;
  }

  .ptable__seat {
    transition: none;
  }
}
