/* One visual world: a dark velvet table the decks sit on. Picker on top, the deck in the middle, the drawn card lands over it. */
:root {
  --table: #160c0f;
  --table-2: #241318;
  --ink: #f5ede6;
  --muted: #b9a59c;
  --gold: #c9a030;
  --paper: #f7f0e8;
  --display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --body: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html {
  /* Clip sideways fly-offs so they don't create a horizontal gutter; allow vertical scroll on short screens */
  overflow-x: hidden;
  overflow-y: auto;
}
html, body { margin: 0; }
body {
  background: radial-gradient(120% 80% at 50% 30%, var(--table-2), var(--table) 70%);
  background-color: var(--table);
  color: var(--ink);
  font-family: var(--body);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 40px;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}
body.is-animating { pointer-events: none; }
header { text-align: center; display: grid; gap: 6px; }
.brand { font-size: 12px; letter-spacing: .32em; color: var(--gold); font-weight: 500; }
.brand .tm {
  letter-spacing: 0;
  font-size: .85em;
  vertical-align: super;
  margin-left: .1em;
}
.credit {
  display: grid; gap: 8px; justify-items: center;
  margin-top: 2px; margin-bottom: 4px;
}
.credit-by {
  font-size: 12px; letter-spacing: .06em; color: var(--muted);
  font-family: var(--display); font-style: italic;
}
.socials { display: flex; gap: 14px; align-items: center; }
.socials a {
  color: var(--muted); display: grid; place-items: center;
  transition: color .2s ease, transform .2s ease;
}
.socials a:hover,
.socials a:focus-visible { color: var(--gold); transform: translateY(-1px); }
.socials a:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }
h1 {
  font-family: var(--display); font-weight: 500; font-size: clamp(30px, 7vw, 42px);
  margin: 0; text-wrap: balance;
}
.sub { margin: 0; color: var(--muted); font-size: 14px; }

/* deck picker — gold ring is a shared element that GSAP tweens between minis */
.picker {
  position: relative;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px;
  width: 100%; max-width: 340px; margin: 14px 0 4px;
}
.picker-ring {
  position: absolute;
  top: 0; left: 0;
  border: 2px solid var(--gold);
  border-radius: 10px;
  pointer-events: none;
  z-index: 2;
  box-sizing: border-box;
  opacity: 0;
}
.pick {
  appearance: none; border: 0; cursor: pointer; padding: 0; background: none; color: inherit;
  display: grid; gap: 8px; justify-items: center; font-family: var(--body);
  position: relative; z-index: 1;
}
.pick .mini {
  position: relative;
  width: 100%; aspect-ratio: 5 / 7; border-radius: 6px;
  display: grid; place-items: center; text-align: center;
  font-family: var(--display); font-weight: 600; font-size: clamp(8px, 2vw, 11px); letter-spacing: .03em; padding: 0 3px;
  box-shadow: 0 5px 12px rgba(0,0,0,.4);
}
.pick .lbl { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pick[aria-pressed="true"] .lbl { color: var(--ink); }
.pick:focus-visible .mini { outline: 2px solid var(--ink); outline-offset: 3px; }

.tagline { min-height: 22px; margin: 14px 0 0; font-family: var(--display); font-style: italic; font-size: 20px; color: var(--gold); text-align: center; }

/* table — perspective on the parent so GSAP rotateY keeps backface-visibility working */
.table {
  position: relative; width: min(80vw, 300px); aspect-ratio: 5 / 7; margin: 22px 0 26px;
  perspective: 1400px; perspective-origin: 50% 50%;
  overflow: visible;
}
.stack {
  position: absolute; inset: 0; cursor: pointer; border: 0; padding: 0; background: none;
  z-index: 0;
}
/* Flat top copy hidden while a drawn face sits on the deck; angled cards stay for the stack illusion */
.stack.is-drawn .back:last-child { visibility: hidden; }
.stack:focus-visible .back:last-child { outline: 2px solid var(--ink); outline-offset: 4px; }
.back {
  position: absolute; inset: 0; border-radius: 16px;
  display: grid; grid-template-rows: auto 1fr auto; justify-items: center;
  padding: 26px 18px; text-align: center;
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
  /* Stable GPU layer so suit text doesn't reflow/jitter when the card starts moving */
  -webkit-font-smoothing: antialiased;
  transform: translateZ(0);
}
.back::after {
  content: ""; position: absolute; inset: 10px; border-radius: 10px;
  border: 1.5px solid var(--accent); pointer-events: none;
}
.back .b-brand {
  font-size: 10px; letter-spacing: .3em; font-weight: 500;
  line-height: 1; min-height: 1em;
}
.back .b-mid { align-self: center; display: grid; gap: 4px; }
.back .b-of { font-family: var(--display); font-style: italic; font-size: 22px; color: var(--accent); line-height: 1.1; }
.back .b-name { font-family: var(--display); font-weight: 600; letter-spacing: .06em; font-size: 40px; line-height: 1; }
.back .b-name.long { font-size: 30px; }
.back .b-tag {
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  line-height: 1.2; min-height: 1.2em;
}
.stack.empty .back:last-child { opacity: .25; }

/* drawn card — GSAP rotates the card; face/back swap at the edge-on midpoint */
.card {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none; opacity: 0;
  z-index: 1;
}
.card.drawn { pointer-events: auto; }
.card .back {
  /* Flat suit back on the flip card; keep translateZ for the same text rasterization as the stack */
  transform: translateZ(0);
  z-index: 1;
}
.face {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 16px;
  background: var(--paper);
  color: #2a1216;
  display: grid; grid-template-rows: auto 1fr auto; padding: 24px 22px;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
  visibility: hidden;
  z-index: 2;
}
.card.show-face .face { visibility: visible; opacity: 1; }
.card.show-face .back { visibility: hidden; opacity: 0; }
.card.show-back .face { visibility: hidden; opacity: 0; }
.card.show-back .back { visibility: visible; opacity: 1; }
.face .f-top { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--deck); font-weight: 600; }
.face .f-body { align-self: center; display: grid; gap: 14px; }
.face .kind { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #8a6f66; font-weight: 600; }
.face .text { font-family: var(--display); font-weight: 500; font-size: 27px; line-height: 1.15; margin: 0; text-wrap: balance; }
.face .he { font-family: var(--body); font-size: 14px; color: #6d5550; margin: 0; }
.face .he b { color: #2a1216; font-weight: 600; }
.face .f-foot { text-align: center; font-family: var(--display); font-style: italic; color: var(--deck); font-size: 18px; }

/* controls — fixed two-column grid so label changes ("Draw a card" ↔ "Draw another") don't shift layout */
.controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: min(100%, 420px); margin-top: 18px;
}
.btn {
  font-family: var(--body); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600;
  padding: 13px 16px; border-radius: 999px; cursor: pointer; border: 1.5px solid var(--gold);
  background: var(--gold); color: #1a0d10;
  width: 100%; text-align: center; white-space: nowrap;
  transition: opacity .35s ease;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.btn[disabled] { opacity: .4; cursor: default; }
.count {
  margin: 14px 0 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
  min-height: 1.25em; text-align: center; width: min(100%, 420px);
}
footer { margin-top: auto; padding-top: 28px; font-size: 12px; color: var(--muted); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .pick .mini { transition: none; }
  .btn { transition: none; }
  body.is-animating { pointer-events: auto; }
}
