/* The card room's own parts: cards, piles, the hand, and the bits of the
   sheets that show cards. Drawn from the card tokens in themes.css, on
   top of the room's structure (games/static/games/room/room.css). A card
   game adds its own panels in its own stylesheet. */

body {
  /* (big screens get big cards: about 76px at 1280×800, 103 at 1920×1080) */
  --cw: clamp(48px, min(6.4vw, 9.5vh), 112px);
  --cw-small: clamp(34px, 3.6vw, 44px);
}

/* The room's one focus style (room.css), on the card room's own parts. */
:is(.card, .meld, .pile, .swatch):focus-visible {
  outline: 2px solid var(--focus, var(--ink)); outline-offset: 3px; box-shadow: 0 0 0 5px var(--room);
}

/* ── cards ──────────────────────────────────────────────────────────── */
.card {
  --h: calc(var(--cw) * 1.4);
  position: relative; flex: none; width: var(--cw); height: var(--h);
  background: var(--card); border: var(--card-edge); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  font-family: var(--card-font); font-weight: var(--card-weight); user-select: none; -webkit-user-select: none;
  font-variant-numeric: lining-nums; transition: transform .14s ease, box-shadow .14s ease; touch-action: manipulation;
}
.card.small { --cw: var(--cw-small); }
.card .ix { position: absolute; left: 7%; top: 4%; font-size: max(12px, calc(var(--cw) * .3)); line-height: .95; text-align: center; letter-spacing: -.04em; }
.card .ix i { display: block; font-style: normal; font-size: max(12px, .9em); }
.card.small .ix { font-weight: 700; }
.card .pip { position: absolute; right: 8%; bottom: 5%; font-size: calc(var(--cw) * .52); line-height: 1; }
.card.small .pip { font-size: calc(var(--cw) * .42); }
.card.s { color: var(--suit-s); } .card.c { color: var(--suit-c); }
.card.h { color: var(--suit-h); } .card.d { color: var(--suit-d); }
.card.joker { color: var(--joker); }
.card.joker .ix i { font-size: .62em; letter-spacing: .02em; }
.card.joker .ix i.asis { font-size: .8em; letter-spacing: -.02em; }
.card.back { background: var(--back-pattern), var(--back); border: var(--back-edge); }
.card.sel { transform: var(--lift); box-shadow: var(--select); z-index: 2; }
/* In a fanned hand a picked card lifts straight up and stays in its place in
   the stack, so the card after it keeps its corner showing and can be picked. */
.hand .card.sel { z-index: auto; }
.hand.fanned .card.sel { transform: translateY(-14px); }
/* Overlapped cards keep a visible edge, even where the card and its border
   are the same color. */
:is(.cards, .hand.fanned) .card + .card { box-shadow: var(--card-shadow), -2px 0 3px -1px rgba(0, 0, 0, .35); }
:is(.cards, .hand.fanned) .card.sel + .card { box-shadow: var(--card-shadow), -2px 0 3px -1px rgba(0, 0, 0, .35); }
.card.pick { cursor: pointer; }
/* While picking is off, a card can only be dragged: say so with the cursor. */
.hand.locked .card.pick { cursor: grab; }
body.handdrag, body.handdrag * { cursor: grabbing !important; }
.card.arrive { animation: arrive var(--m-arrive, 350ms) ease-out; }
@keyframes arrive { from { transform: translateY(-24px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
/* Overlapped cards hide their big pip: only the corner shows, as on a real fan. */
.hand.fanned .card:not(:last-child) .pip,
.cards .card:not(:last-child) .pip { visibility: hidden; }
.cards { display: flex; align-items: flex-start; }
.cards .card + .card { margin-left: calc(var(--cw-small) * -0.42); }
/* Something on its way across the table (room/kit/motion.js): a card too. */
.card.flying { position: fixed; z-index: 40; pointer-events: none; margin: 0; }

/* ── piles and the table's middle ───────────────────────────────────── */
.middle { display: flex; gap: 14px; align-items: flex-start; }
.piles { display: flex; gap: 12px; align-items: flex-start; flex: none; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--soft); background: none; border: 0; padding: 0; position: relative; }
.pile.live { cursor: pointer; }
.pile.live .card { box-shadow: var(--select); outline: 3px solid var(--turn); outline-offset: 2px; }
.pile .count { font-variant-numeric: tabular-nums; max-width: 11em; text-align: center; }
.empty-slot { width: var(--cw); height: calc(var(--cw) * 1.4); border: 1.5px dashed color-mix(in srgb, var(--ink) 35%, transparent); border-radius: var(--card-radius); }

/* ── your hand ──────────────────────────────────────────────────────── */
.hand {
  display: flex; align-items: flex-end; min-height: calc(var(--cw) * 1.4 + 22px); padding: 18px 4px 4px;
  overflow-x: auto; overflow-y: visible; scrollbar-width: thin; touch-action: pan-x;
}
/* more cards past an edge (a long hand on a phone): that edge fades */
.hand.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.hand.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); }
.hand.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); }
/* Snapped together in one fan, centered along the bottom (kit/hand.js sets
   the overlap); a hand too long to show whole starts at the left and scrolls
   (auto margins give way to the overflow). */
.hand .card { margin-left: var(--overlap, -18px); }
.hand .card:first-child { margin-left: auto; }
.hand .card:last-child { margin-right: auto; }
/* A card being dragged: its place stays, marked with a dashed outline, while
   a lifted copy follows the pointer and a bar shows where it will land. */
.hand .card.placeholder { background: color-mix(in srgb, var(--card) 30%, transparent); border: 2px dashed var(--ink); box-shadow: none; }
.hand .card.placeholder > * { visibility: hidden; }
.card.handghost { position: fixed; left: 0; top: 0; z-index: 70; margin: 0; pointer-events: none; transition: none; will-change: transform; box-shadow: 0 16px 30px rgba(0, 0, 0, .45); }
.card.handghost .pip { visibility: visible; }
.handghost .ghostcount { position: absolute; top: -9px; right: -9px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--btn); color: var(--btn-ink); font: 800 13px/24px var(--ui-font); text-align: center; box-shadow: 0 0 0 2px var(--card); }
.handghost .ghostnote { display: none; position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 4px 10px; border-radius: 99px; background: var(--sheet); color: var(--ink); border: 1px solid var(--ink); font: 700 12px/1.2 var(--ui-font); }
.card.handghost.cancel { background: color-mix(in srgb, var(--card) 55%, transparent); }
.handghost.cancel > :is(.ix, .pip, .ghostcount) { opacity: .45; }
.handghost.cancel .ghostnote { display: block; }
.dropbar { position: fixed; left: 0; top: 0; z-index: 71; width: 3px; border-radius: 2px; background: var(--turn); box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 0 8px var(--turn); pointer-events: none; }
/* Cards you've just picked up wear a small tag above their corner until you
   next act; it sits in the hand's spare top margin, so nothing moves. */
.hand .card.fresh::after {
  content: 'New'; position: absolute; left: 2px; bottom: calc(100% + 3px); padding: 1px 5px; border-radius: 6px;
  font: 800 9px/1.3 var(--ui-font); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  background: var(--card); color: var(--suit-s); border: 1px solid var(--suit-s); pointer-events: none;
}
.handbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.handbar .sorters { gap: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-left: auto; }
.say { font-size: 15px; min-height: 1.45em; }
.say b { color: var(--turn); }

/* the card room's "Table style" picker in Options (kit/looks.js) */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.swatch { cursor: pointer; border-radius: 12px; padding: 10px; border: 2px solid transparent; text-align: left; display: flex; flex-direction: column; gap: 8px; min-height: 92px; }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--ink); }
.swatch .mini { display: flex; gap: 4px; }
.swatch .mini span { width: 20px; height: 28px; border-radius: 4px; }
.swatch b { font: 700 14px var(--ui-font); }
.swatch small { font-size: var(--t-note); }
.swatch .inuse { display: block; font-weight: 800; }
.swatch .inuse.unseen { visibility: hidden; }

/* a card still needed: a dashed outline with what would go there (on the
   sheet's own color, so the card it overlaps doesn't show through) */
.card.ghost, .cards .card.small.ghost {
  background: var(--sheet); border: 1.5px dashed color-mix(in srgb, var(--ink) 60%, transparent);
  box-shadow: none; color: var(--ink); font-weight: 700;
}

/* cards and melds named in the game log */
.logcard { font-weight: 700; white-space: nowrap; }
.logmeld { display: inline-flex; gap: .3em; padding: 0 5px; margin: 0 2px; border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); border-radius: 5px; white-space: nowrap; }

@media (max-width: 640px) {
  body { --cw: clamp(44px, 12.5vw, 58px); --cw-small: clamp(34px, 9vw, 40px); }
  .felt.rummy .bar .tools { display: none; }
  .felt.rummy .bar .more { display: inline-flex; min-width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .card.arrive { transition: none; animation: none; }
}
