/* ==========================================================================
   TAROT PAGE STYLES (tarot.html)
   ========================================================================== */

.tarot-intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ==========================================================================
   TAROT TABLE
   ========================================================================== */

.tarot-table {
  --card-w: clamp(120px, 30vw, 170px);

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 32px 16px 24px;
  background: #08070d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.tarot-table [hidden] {
  display: none !important;
}

.tarot-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.tarot-spot-label {
  font-family: var(--font-pixel);
  font-size: 1.15rem;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.tarot-status {
  margin-top: 14px;
  min-height: 1.6em;
  text-align: center;
  font-family: var(--font-typewriter);
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ==========================================================================
   CARD BACK
   ========================================================================== */

.tarot-back {
  display: block;
  position: relative;
  background-color: #1a1226;
  background-image:
    repeating-linear-gradient(45deg, rgba(218, 65, 103, 0.24) 0 2px, transparent 2px 10px),
    repeating-linear-gradient(-45deg, rgba(139, 92, 246, 0.24) 0 2px, transparent 2px 10px);
  border: 2px solid var(--accent-pink);
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 5px #1a1226,
    inset 0 0 0 6px rgba(244, 114, 182, 0.6),
    2px 3px 0 rgba(0, 0, 0, 0.55);
}

.tarot-back::after {
  content: "\2726";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  background: #1a1226;
  border: 1px solid var(--accent-pink-soft);
  border-radius: 50%;
  color: var(--accent-pink-soft);
  font-family: var(--font-pixel);
  font-size: var(--emblem, 2.2rem);
  line-height: 1;
}

/* ==========================================================================
   STAGE: DECK AND CUT HALVES
   ========================================================================== */

.tarot-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

.tarot-deck,
.tarot-half {
  position: relative;
  width: var(--card-w);
  aspect-ratio: 2 / 3.5;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s ease;
}

.tarot-deck:not(:disabled):hover,
.tarot-half:not(:disabled):hover {
  transform: translateY(-3px) rotate(-1deg);
}

.tarot-deck:disabled,
.tarot-half:disabled {
  cursor: default;
}

.deck-layer {
  position: absolute;
  inset: 0;
  transform: translate(calc(var(--i) * -1px), calc(var(--i) * -1.5px));
}

.deck-layer:nth-child(odd) {
  --dir: -1;
}

.deck-layer:nth-child(even) {
  --dir: 1;
}

.tarot-deck.is-shuffling .deck-layer {
  animation: tarot-riffle 0.45s ease-in-out 3;
  animation-delay: calc(var(--i) * 0.06s);
}

@keyframes tarot-riffle {
  0%,
  100% {
    transform: translate(calc(var(--i) * -1px), calc(var(--i) * -1.5px)) rotate(0deg);
  }
  50% {
    transform: translate(calc(var(--dir) * 40px + var(--i) * -1px), calc(var(--i) * -1.5px - 6px)) rotate(calc(var(--dir) * 5deg));
  }
}

.tarot-cut {
  --cut-gap: clamp(28px, 12vw, 96px);

  display: flex;
  justify-content: center;
  gap: var(--cut-gap);
}

.tarot-cut.is-cutting .tarot-half-spot:first-child .tarot-half {
  animation: tarot-cut-left 0.7s cubic-bezier(0.3, 0.7, 0.3, 1) both;
}

.tarot-cut.is-cutting .tarot-half-spot:last-child .tarot-half {
  animation: tarot-cut-right 0.7s cubic-bezier(0.3, 0.7, 0.3, 1) both;
}

.tarot-cut.is-cutting .tarot-spot-label {
  animation: tarot-fade-in 0.7s ease both;
}

@keyframes tarot-cut-left {
  from {
    transform: translateX(calc((var(--card-w) + var(--cut-gap)) / 2));
  }
  to {
    transform: translateX(0);
  }
}

@keyframes tarot-cut-right {
  from {
    transform: translateX(calc((var(--card-w) + var(--cut-gap)) / -2));
  }
  to {
    transform: translateX(0);
  }
}

.tarot-half-spot.is-rejected {
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* ==========================================================================
   SPREAD: TEN FACE-DOWN CARDS IN AN OVERLAPPING ROW
   ========================================================================== */

.tarot-spread {
  --n: 10;
  --ov: 0.5;

  --slot-w: calc(100% / (1 + (var(--n) - 1) * (1 - var(--ov))));
  --emblem: clamp(1rem, 3.2vw, 1.9rem);

  display: flex;
  align-items: flex-start;
  width: 100%;
  max-width: 760px;
  padding-top: 16px;
}

@media (max-width: 600px) {
  .tarot-spread {
    --ov: 0.62;
  }
}

.tarot-spread-slot {
  position: relative;
  flex: 0 0 var(--slot-w);
  width: var(--slot-w);
  aspect-ratio: 2 / 3.5;
}

.tarot-spread-slot + .tarot-spread-slot {
  margin-left: calc(var(--ov) * var(--slot-w) * -1);
}

.tarot-spread-slot:nth-child(odd) {
  transform: rotate(-0.8deg);
}

.tarot-spread-slot:nth-child(even) {
  transform: rotate(0.8deg);
}

.tarot-spread:not(.is-full) .tarot-card:not(:disabled):hover,
.tarot-spread .tarot-card.is-picked,
.tarot-spread .tarot-card.is-picked:not(:disabled):hover {
  transform: translateY(-14px);
}

.tarot-spread.is-full .tarot-card:not(.is-picked):not(:disabled) {
  cursor: not-allowed;
}

.tarot-spread.is-full .tarot-card:not(.is-picked):not(:disabled):hover {
  transform: none;
}

.tarot-card.is-picked .tarot-back {
  border-color: var(--accent-pink-soft);
  box-shadow:
    inset 0 0 0 5px #1a1226,
    inset 0 0 0 6px rgba(244, 114, 182, 0.9),
    0 0 14px rgba(244, 114, 182, 0.65),
    2px 3px 0 rgba(0, 0, 0, 0.55);
}

.tarot-pick-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--accent-pink);
  border-radius: 50%;
  color: #ffffff;
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.tarot-controls {
  display: flex;
  justify-content: center;
}

.tarot-reveal-btn {
  color: var(--accent-pink);
  border-color: var(--accent-pink);
}

/* ==========================================================================
   CARDS
   ========================================================================== */

.tarot-pick-row {
  --pick-w: clamp(84px, 15vw, 140px);

  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px 16px;
}

.tarot-pick-row[data-count="1"] {
  --pick-w: var(--card-w);
}

.tarot-slot {
  position: relative;
  width: var(--pick-w, var(--card-w));
  aspect-ratio: 2 / 3.5;
  border: 2px dashed var(--border-card);
  border-radius: 4px;
}

.tarot-card {
  position: absolute;
  inset: 0;
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  perspective: 900px;
  transition: transform 0.15s ease, opacity 0.5s ease;
}

.tarot-card:not(.is-flipped):not(:disabled):hover {
  transform: translateY(-6px) rotate(1deg);
}

.tarot-card:disabled {
  cursor: default;
}

.tarot-card.is-dimmed {
  opacity: 0;
  pointer-events: none;
}

.tarot-card.is-dealing {
  animation: tarot-deal 0.6s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}

@keyframes tarot-deal {
  from {
    transform: translate(var(--from-x), var(--from-y)) scale(var(--from-scale, 1)) rotate(-6deg);
  }
  to {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
}

.tarot-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.tarot-card.is-flipped .tarot-card-inner {
  transform: rotateY(180deg);
}

.tarot-face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* ==========================================================================
   CARD FRONT
   ========================================================================== */

.tarot-front {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 14px;
  background: #e8e2f0;
  color: #2d2640;
  border: 2px solid var(--accent-purple);
  border-radius: 4px;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.55);
  text-align: center;
}

.tarot-front::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(45, 38, 64, 0.4);
  pointer-events: none;
}

.tarot-front-numeral {
  font-family: var(--font-pixel);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent-pink);
}

.tarot-front-glyph {
  font-family: var(--font-typewriter);
  font-size: clamp(2.6rem, 9vw, 3.8rem);
  line-height: 1;
  color: #5b2a86;
}

.tarot-front-glyph svg {
  display: block;
  width: 1em;
  height: 1em;
}

.tarot-pick-row:not([data-count="1"]) .tarot-front-glyph {
  font-size: 2.3rem;
}

.tarot-front-keywords {
  position: absolute;
  inset: 5px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  padding: 6px;
  background: rgba(45, 38, 64, 0.95);
  color: #e8e2f0;
  font-family: var(--font-typewriter);
  font-style: italic;
  font-size: clamp(0.62rem, calc(var(--pick-w, var(--card-w)) * 0.085), 0.95rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.tarot-card.is-flipped:hover .tarot-front-keywords {
  opacity: 1;
}

.tarot-pick-row .tarot-card.is-flipped {
  cursor: pointer;
}

.tarot-pick-row .tarot-card.is-flipped:hover,
.tarot-pick-row .tarot-card.is-open {
  transform: translateY(-6px);
}

.tarot-pick-row .tarot-card.is-open .tarot-front {
  border-color: var(--accent-pink);
  box-shadow: 0 0 14px rgba(218, 65, 103, 0.6), 2px 3px 0 rgba(0, 0, 0, 0.55);
}

.tarot-front-name {
  font-family: var(--font-typewriter);
  font-size: clamp(0.8rem, 2.4vw, 0.95rem);
  line-height: 1.2;
}

/* ==========================================================================
   DESCRIPTION
   ========================================================================== */

.tarot-description {
  width: 100%;
  max-width: 640px;
  padding: 16px 20px 18px;
  background: #110f18;
  border: 1px dashed var(--border-card);
  border-left: 3px solid var(--accent-pink);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.5);
}

.tarot-description.is-showing {
  animation: tarot-fade-in 0.4s ease both;
}

@keyframes tarot-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tarot-reading-heading {
  flex-wrap: wrap;
  gap: 4px 16px;
}

.tarot-numeral {
  font-family: var(--font-pixel);
  font-size: 1.15rem;
  color: var(--accent-mint);
}

.tarot-keywords {
  margin-bottom: 12px;
  font-family: var(--font-typewriter);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--accent-pink-soft);
}

.tarot-reading-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

.tarot-btn {
  padding: 8px 14px;
  background: #110f18;
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tarot-btn:hover:not(:disabled) {
  background: #201a2f;
  color: var(--accent-teal);
  border-color: var(--accent-teal);
  transform: translateY(-2px);
}

.tarot-btn:active:not(:disabled) {
  color: var(--accent-pink);
  border-color: var(--accent-pink);
  transform: translateY(0);
}

.tarot-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--text-dim);
  border-color: var(--border-card);
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .tarot-deck.is-shuffling .deck-layer,
  .tarot-cut.is-cutting .tarot-half,
  .tarot-cut.is-cutting .tarot-spot-label,
  .tarot-card.is-dealing,
  .tarot-description.is-showing {
    animation-duration: 0.01s;
    animation-iteration-count: 1;
    animation-delay: 0s;
  }

  .tarot-card-inner,
  .tarot-card,
  .tarot-half-spot.is-rejected {
    transition-duration: 0.01s;
  }
}