/* ============================================================
   iplay.free — SHARED card table styles (pairs with cards.js).
   Kept out of theme.css so the non-card games don't load it.
   The pit stays dark in both themes, so card faces stay white in
   light and dark alike; only the theme tokens around them flip.
   ============================================================ */

:root {
  /* Card inks: the red keeps 4.6:1 on the white face (WCAG AA text) and the
     near-black keeps the red/black LUMINANCE gap (4.0:1; 3.0 protanopia,
     4.8 deuteranopia), so the two colours still part for colour-blind
     players. The suit shapes carry the meaning too. */
  --card-red: #d6336c;
  --card-black: #14101f;
  --card-face: #ffffff;
  --card-edge: rgba(20, 16, 31, 0.22);
  --card-back-1: #7c6cff;
  --card-back-2: #5a4ad1;
  --card-sel: var(--pink);
  --card-target: var(--teal);
  --card-focus: #ffe066;
}

/* The frame + pit paddings are set by Cards.applyGeometry (narrow on
   phones, standard once there is room). */
.cards-pit {
  direction: ltr;
}
.cards-root {
  position: relative;
  margin: 0 auto;
  /* A card table reads left to right in every language, including ar. */
  direction: ltr;
  /* The empty felt still scrolls the page on touch; the cards don't (they
     are dragged — see .card below). */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ---------- piles: the slot you see + the whole-column drop target ---------- */
.cards-root .lane {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: var(--cr);
  outline: none;
  cursor: pointer;
}
.cards-root .lane .slot {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--cr);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Free cells: a dashed bay; homes: a solid ring with their suit. */
.cards-root .lane.cell .slot {
  box-shadow: none;
  border: 2px dashed rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.1);
}
.cards-root .lane.home .slot {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
}
.cards-root .slot-suit {
  width: 52%;
  height: 52%;
  /* opacity on the whole icon, not a translucent fill: the club's
     overlapping circles would otherwise show darker seams */
  fill: #fff;
  opacity: 0.34;
}
.cards-root .lane.locked {
  cursor: default;
}
.cards-root .lane.locked .slot {
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.05) 0 5px,
    rgba(255, 255, 255, 0.12) 5px 10px
  );
}
.cards-root .lane.locked .lock {
  width: 46%;
  height: 46%;
  fill: #fff;
  opacity: 0.5;
}
/* A legal destination (helpers on): a dashed ring round the whole pile —
   shape, not only colour, so it reads apart from the selected cards. */
.cards-root .lane.target {
  outline: 2px dashed var(--card-target);
  outline-offset: -2px;
  background: rgba(25, 195, 178, 0.1);
}
.cards-root .lane.hint {
  background: rgba(25, 195, 178, 0.18);
  outline: 3px solid var(--card-target);
  outline-offset: -3px;
  animation: cards-pulse-lane 0.85s ease-in-out 3;
}

/* ---------- cards ---------- */
.cards-root .card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--cr);
  background: var(--card-face);
  color: var(--card-black);
  box-shadow:
    inset 0 0 0 1px var(--card-edge),
    0 1px 2px rgba(0, 0, 0, 0.45);
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 700;
  overflow: hidden;
  cursor: pointer;
  /* Dragging starts on a card: the browser must not pan from here. */
  touch-action: none;
  will-change: transform;
  transition:
    transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1),
    top 0.12s ease;
}
.cards-root.instant .card,
.cards-root .card.dragging {
  transition: none;
}
.cards-root .card.dragging {
  cursor: grabbing;
  box-shadow:
    inset 0 0 0 1px var(--card-edge),
    0 8px 18px rgba(0, 0, 0, 0.5);
}
.cards-root .card.red {
  color: var(--card-red);
}
.cards-root .card .strip {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  height: var(--rank);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1px;
}
.cards-root .card .rank {
  display: block;
  font-size: var(--rank);
  line-height: 1;
  max-width: var(--rankw);
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
/* "10" is the widest index: pull its two digits together. */
.cards-root .card .rank.two {
  letter-spacing: -0.07em;
}
.cards-root .card .strip .suit {
  flex: none;
  width: var(--suit);
  height: var(--suit);
  fill: currentColor;
}
.cards-root .card .pip {
  position: absolute;
  left: 50%;
  top: var(--pip-top);
  width: var(--pip);
  height: var(--pip);
  margin-left: calc(var(--pip) / -2);
  fill: currentColor;
}
/* Jack / Queen / King: the letter rides on the big suit (no court art). */
.cards-root .card .court {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--pip-top);
  height: var(--pip);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--pip) * 0.5);
  line-height: 1;
  color: #fff;
  pointer-events: none;
}
.cards-root:not([data-face="full"]) .card .court {
  display: none;
}
/* Face down (Klondike): an original back, no face showing. */
.cards-root .card.down {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.09) 0 3px,
      transparent 3px 7px
    ),
    linear-gradient(160deg, var(--card-back-1), var(--card-back-2));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.45),
    0 1px 2px rgba(0, 0, 0, 0.45);
}
.cards-root .card.down > * {
  display: none;
}

/* Picked up: lifted AND ringed (two cues, not colour alone). */
.cards-root .card.sel {
  top: -4px;
  box-shadow:
    inset 0 0 0 2px var(--card-sel),
    0 5px 10px rgba(0, 0, 0, 0.5);
}
/* The card a picked-up run would land on (helpers on). */
.cards-root .card.target-top {
  box-shadow:
    inset 0 0 0 2px var(--card-target),
    0 1px 2px rgba(0, 0, 0, 0.45);
}
.cards-root .card.hint {
  box-shadow:
    inset 0 0 0 3px var(--card-target),
    0 0 0 0 rgba(25, 195, 178, 0.7);
  animation: cards-pulse 0.85s ease-in-out 3;
}
@keyframes cards-pulse {
  50% {
    box-shadow:
      inset 0 0 0 3px var(--card-target),
      0 0 12px 4px rgba(25, 195, 178, 0.75);
  }
}
@keyframes cards-pulse-lane {
  50% {
    background: rgba(25, 195, 178, 0.32);
  }
}

/* Keyboard focus: drawn over the cards (the pile's own outline would sit
   under them), inset so it never spills onto a neighbouring column. */
.cards-root .cards-focus {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  pointer-events: none;
  z-index: 900;
  border-radius: calc(var(--cr) + 2px);
  box-shadow:
    inset 0 0 0 3px var(--card-focus),
    inset 0 0 0 4px rgba(0, 0, 0, 0.55);
}

/* Read by screen readers, not shown. */
.cards-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .cards-root .card {
    transition: none;
  }
  .cards-root .card.hint,
  .cards-root .lane.hint {
    animation: none;
  }
}
