/* ── Sets ─────────────────────────────────────────────────────────────────────
   A jeweller's tray: item cards laid three to a row, each showing its gem
   pendants (rendered as inline SVG by src/games/sets/jewel.js). The outer game
   screen is the shared shell; this file is the tray and the slot row — there is
   no footer: the third pick evaluates itself. It borrows the play chrome
   (.q-chrome / .q-stage) from queens.css and adds only Sets's own board. All
   colours come from the --sx-* tokens in tokens.css.                           */

.sets-play {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* the tray scrolls if a big deal outgrows the stage; slots sit above it */
.sets-play .q-stage {
  position: relative;   /* anchors the sets-found counter */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  place-items: stretch;
  padding: var(--space-5);
  overflow-x: hidden;   /* never scroll sideways — the tray always fits the width */
  overflow-y: auto;
}

/* the win condition, always in view: "K / M SETS" — dim mono, no pill */
.sx-count {
  position: absolute;
  top: var(--space-4);
  right: var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--dim);
  pointer-events: none;
}

.sx-wrap {
  width: 100%;
  /* wide-strip cards keep the deal short — a simple width cap is enough, and
     margin:auto centres the whole ensemble */
  max-width: min(520px, 100%);
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ── the slot row: `slots` placeholders that fill left-to-right ───────────── */

.sx-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}

.sx-slot {
  flex: 0 0 auto;
  width: 64px;
  min-height: 84px;
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--sx-slot);
  background: transparent;
}
.sx-slot.filled {
  border-style: solid;
  border-color: var(--sx-line);
  background: var(--sx-paper);
}
.sx-slot.pop { animation: sx-pop var(--duration-2) var(--ease) both; }
@keyframes sx-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sx-dash {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--sx-slot);
}

/* the three stacked items inside a filled slot */
.sx-tile { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.sx-tile-row { display: flex; align-items: center; justify-content: center; gap: 1px; }
.sx-tile-row .sx-pendant { height: 23px; width: auto; }

/* ── the deal: item cards — WIDE strips, 3 per row (the original look, just a
   touch taller so cards stay tap-safe and the gems read) ─────────────────── */

.sx-deal {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.sx-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;         /* let the column shrink; a fixed-size gem must not floor the width */
  overflow: hidden;
  aspect-ratio: 5 / 2;
  min-height: 44px;     /* tap floor even at 280px */
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--sx-paper);
  border: 1.5px solid var(--sx-line);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--duration-1) var(--ease), box-shadow var(--duration-1) var(--ease), border-color var(--duration-1) var(--ease);
}
.sx-card:hover { border-color: var(--sx-sel); }
.sx-card:active { transform: scale(0.97); }
/* 280px-class: the ratio + tap floor would force 110px columns (3 don't fit) —
   fixed-height strips instead */
@media (max-width: 340px) {
  .sx-card { aspect-ratio: auto; height: 46px; min-height: 0; }
}
/* pendants are height-driven on the strip — the same size on every card,
   whatever its count, so colour · cut · count · chain compare at a glance */
.sx-card .sx-pendant {
  flex: none;
  height: 78%;
  width: auto;
  max-width: calc((100% - 8px) / 3);
}

/* selected: a coloured ring, and the card lifts a touch */
.sx-card.sel {
  border-color: var(--sx-sel);
  background-color: var(--sx-paper-2);
  box-shadow: 0 0 0 3px var(--sx-sel), var(--shadow-2, 0 4px 14px rgba(0, 0, 0, 0.18));
  transform: translateY(-2px);
}

/* invalid submit — a short shake on the three cards */
.sx-card.shake { animation: sx-shake 0.42s var(--ease); }
@keyframes sx-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* the hint pulse — a set the solver surfaced */
.sx-card.hinted { animation: sx-hint 0.8s var(--ease) 2; z-index: 1; }
@keyframes sx-hint {
  0%, 100% { box-shadow: 0 0 0 0 var(--sx-good); }
  50% { box-shadow: 0 0 0 4px var(--sx-good); }
}

/* review banner reuses .pz-review (puzzle.css); keep it centred here */
.sets-play .pz-review { margin: var(--space-4) auto 0; }

/* ── landscape phone: slots stand LEFT of the deal, cards sized by height ── */
@media (orientation: landscape) and (max-height: 700px) {
  .sets-play .sx-wrap {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: none;
    gap: var(--space-7);
  }
  .sets-play .sx-slots {
    flex-direction: column;
    align-self: stretch;
    justify-content: center;
  }
  /* height budgets the card: rows × card-height must fit the short viewport,
     and the 5/2 strip ratio turns that height into the column track width */
  .sets-play .sx-deal {
    grid-template-columns: repeat(3, calc((100dvh - 90px) / var(--sx-rows, 3) * 2.2));
  }
}

/* ── level-card thumbnail ─────────────────────────────────────────────────── */

.sx-mini {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6%;
  padding: 6%;
  border-radius: var(--radius-sm);
  background: var(--sx-paper);
  border: 1.5px solid var(--sx-line);
}
.sx-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 5%;
  flex: 1;
  min-height: 0;
}
.sx-mcard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 4px;
  background: var(--sx-paper-2);
  border: 1px solid var(--sx-line);
  overflow: hidden;
  transition: box-shadow var(--duration-1) var(--ease);
}
.sx-mcard.on { box-shadow: inset 0 0 0 2px var(--sx-sel); }
.sx-mcard .sx-pendant { height: 88%; width: auto; }
.sx-mini-pips { display: flex; justify-content: center; gap: 4px; }
.sx-mpip { width: 12px; height: 3px; border-radius: 2px; background: var(--sx-slot); }
.sx-mpip.on { background: var(--sx-good); }
