/* ==========================================================================
   ApexCMS — Tarot Reading Tool (vratfestivals.com)
   Indian celestial miniature style: deep maroon, antique gold, cream
   Pure CSS, responsive, no horizontal scrollbar, prefers-reduced-motion safe
   ========================================================================== */

.tarot-shell {
  --tarot-maroon: #7a1f1f;
  --tarot-maroon-dark: #5a1515;
  --tarot-gold: #c9a227;
  --tarot-gold-light: #e8d49b;
  --tarot-cream: #faf6ec;
  --tarot-ink: #3b1f1a;

  --tarot-card-w: 120px;
  --tarot-card-h: 210px; /* 4:7 ratio */
  --tarot-gap: 12px;
}

.tarot-shell * { box-sizing: border-box; }

/* Intro copy */
.tarot-intro p {
  margin: 0 0 14px;
  line-height: 1.7;
  color: var(--ink-soft);
  font-size: clamp(13.5px, 1.1vw, 15px);
}
.tarot-intro strong { color: var(--tarot-maroon); }

/* ---------- Card (3D flip) ---------- */
.tarot-card-wrap {
  position: relative;
  width: var(--tarot-card-w);
  height: var(--tarot-card-h);
  perspective: 1000px;
  cursor: pointer;
  user-select: none;
}

.tarot-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.0, 0.2, 1);
  transform-origin: center;
}

.tarot-card.flipped { transform: rotateY(180deg); }

.tarot-card-face {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 10px;
  border: 3px solid var(--tarot-gold);
  background: var(--tarot-cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(122, 31, 31, 0.18);
}

.tarot-card-face.back {
  background: var(--tarot-maroon);
  background-image: radial-gradient(circle at center, rgba(201, 162, 39, 0.12) 0%, transparent 70%),
                    conic-gradient(from 90deg, transparent 0%, rgba(201, 162, 39, 0.06) 25%, transparent 25%, rgba(201, 162, 39, 0.06) 50%, transparent 50%, rgba(201, 162, 39, 0.06) 75%, transparent 75%);
  border: 3px solid var(--tarot-gold);
}

.tarot-card-face.back::after {
  content: "";
  position: absolute;
  top: 14px; right: 14px; bottom: 14px; left: 14px;
  border: 2px solid rgba(201, 162, 39, 0.5);
  border-radius: 6px;
}

.tarot-card-face.front img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 7px;
  display: block;
}

/* Card is reversed (upside down) */
.tarot-card.reversed .tarot-card-face.front {
  transform: rotateX(180deg);
}

/* Reversed badge */
.tarot-reversed-badge {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--tarot-gold-light);
  background: rgba(122, 31, 31, 0.75);
  padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--tarot-gold);
  pointer-events: none;
  z-index: 5;
  text-transform: uppercase;
}

/* Card overlay info (below image) */
.tarot-card-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  color: #fff;
  padding: 10px 8px 8px;
  font-size: 11.5px;
  line-height: 1.3;
  border-radius: 0 0 7px 7px;
  text-align: center;
}
.tarot-card-name {
  font-weight: 700; font-size: 12px; margin-bottom: 2px; letter-spacing: 0.02em;
  font-family: var(--font-serif);
}
.tarot-card-orient {
  font-size: 9.5px; letter-spacing: 0.1em; opacity: 0.9;
}

/* ---------- Spread layouts ---------- */
.tarot-spread {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tarot-gap);
  justify-content: center;
  align-items: flex-start;
  margin: 0 calc(-1 * var(--tarot-gap) / 2);
  padding: 0 calc(var(--tarot-gap) / 2);
}
.tarot-spread > * { margin: calc(var(--tarot-gap) / 2); }

/* One card — larger */
.tarot-spread.one-card .tarot-card-wrap {
  width: 170px; height: 297px; /* same 4:7 ratio */
}

/* Three cards */
.tarot-spread.three-cards .tarot-card-wrap {
  width: 120px; height: 210px;
}

/* Celtic cross — positions laid out in a grid-ish pattern */
.tarot-spread.celtic-cross {
  justify-content: center;
}
.tarot-spread.celtic-cross .tarot-card-wrap {
  width: 100px; height: 175px;
}

/* Position label under each card */
.tarot-position-label {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--tarot-maroon);
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Reading result card ---------- */
.tarot-result-card {
  width: 100%;
  max-width: 320px;
  margin: 0 auto 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.tarot-result-card .tarot-thumb {
  width: 70px; height: 122px; /* 4:7 */
  flex-shrink: 0;
  border-radius: 6px;
  border: 2px solid var(--tarot-gold);
  background: var(--tarot-cream);
}
.tarot-result-card .tarot-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.tarot-result-card .tarot-thumb.missing {
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--muted); font-family: var(--font-mono);
}
.tarot-result-info { flex: 1; min-width: 0; }
.tarot-result-name {
  font-family: var(--font-serif); font-weight: 700; font-size: 15px;
  color: var(--tarot-maroon-dark); margin: 0 0 2px;
}
.tarot-result-orient {
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--tarot-maroon); font-weight: 700; margin: 0 0 6px;
}
.tarot-result-keywords {
  font-size: 12px; color: var(--ink-soft); margin: 0 0 8px;
}
.tarot-result-keywords b { color: var(--ink); }
.tarot-result-position {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--tarot-maroon); margin: 0 0 4px;
}
.tarot-result-meaning {
  font-size: 13px; line-height: 1.55; color: var(--ink-soft); margin: 0;
}

/* ---------- Summary ---------- */
.tarot-summary {
  max-width: 700px;
  margin: 26px auto 0;
  background: var(--tarot-cream);
  border: 1px solid var(--tarot-gold);
  border-left: 4px solid var(--tarot-gold);
  border-radius: 10px;
  padding: 16px 18px;
}
.tarot-summary h3 {
  margin: 0 0 8px; font-family: var(--font-serif); font-size: 17px;
  color: var(--tarot-maroon-dark);
}
.tarot-summary p {
  margin: 0; line-height: 1.65; color: var(--ink-soft); font-size: 14px;
}
.tarot-disclaimer {
  font-size: 11.5px; color: var(--muted); text-align: center;
  margin-top: 10px; font-style: italic;
}

/* ---------- Controls ---------- */
.tarot-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-top: 24px;
}
.tarot-controls.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.tarot-controls button {
  appearance: none; border: 1px solid var(--tarot-maroon);
  background: var(--tarot-maroon); color: #fff;
  font-size: 14px; font-weight: 600; padding: 10px 20px;
  border-radius: 8px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
}
.tarot-controls button:hover { background: var(--tarot-maroon-dark); }
.tarot-controls button:disabled { opacity: 0.55; cursor: not-allowed; }
.tarot-controls button.outline {
  background: transparent; color: var(--tarot-maroon);
}
.tarot-controls button.outline:hover { background: rgba(122,31,31,0.08); }

/* ---------- Shuffle / draw state ---------- */
.tarot-deck-view {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; margin: 26px 0;
}
.tarot-deck-stack {
  position: relative; width: var(--tarot-card-w); height: var(--tarot-card-h);
}
.tarot-shake {
  animation: tarotShake 0.6s ease-in-out infinite;
}
@keyframes tarotShake {
  0%, 100% { transform: rotate(-1deg); }
  25% { transform: rotate(2deg); }
  75% { transform: rotate(-2deg); }
}
.tarot-draw-btn {
  background: var(--tarot-gold); color: var(--tarot-maroon-dark);
  border: 1px solid var(--tarot-gold);
}
.tarot-draw-btn:hover { background: #d9b64e; }

/* Draw stage — cards laid out in a centered wrapping row */
.tarot-draw-stage {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tarot-gap);
  justify-content: center;
  margin: 16px 0;
}

/* Flip stagger for multiple cards */
.tarot-draw-stage .tarot-card {
  transition-delay: 0s;
}

/* ---------- Input form ---------- */
.tarot-setup {
  max-width: 640px; margin: 0 auto 26px;
  display: flex; flex-direction: column; gap: 12px;
}
.tarot-field {
  display: flex; flex-direction: column; gap: 6px;
}
.tarot-field label {
  font-size: 13px; font-weight: 700; color: var(--ink-strong);
  letter-spacing: 0.02em;
}
.tarot-field input,
.tarot-field select {
  appearance: none; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--input-fg);
  font-size: 14px; padding: 10px 12px; border-radius: 8px;
  font-family: inherit;
}
.tarot-spread-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.tarot-spread-options button {
  appearance: none; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
  font-size: 13px; padding: 10px; border-radius: 8px; cursor: pointer;
  transition: all 0.2s;
}
.tarot-spread-options button.active {
  border-color: var(--tarot-maroon); background: var(--tarot-cream); color: var(--tarot-maroon);
}
.tarot-spread-options button:hover { border-color: var(--tarot-maroon); }

/* ---------- Empty / error states ---------- */
.tarot-empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
}
.tarot-error {
  text-align: center; color: var(--err-fg); padding: 24px 16px;
  background: var(--err-bg); border: 1px solid var(--err-border);
  border-radius: 10px; margin: 16px;
}

/* ---------- Responsive: no horizontal scroll anywhere ---------- */
.tarot-shell, .tarot-page, .cms-container {
  overflow-x: hidden;
}
.tarot-shell { max-width: 100%; }

@media (max-width: 480px) {
  .tarot-shell { --tarot-card-w: 95px; --tarot-card-h: 166px; --tarot-gap: 8px; }
  .tarot-spread.one-card .tarot-card-wrap { width: 130px; height: 227px; }
  .tarot-spread.celtic-cross .tarot-card-wrap { width: 78px; height: 136px; }
  .tarot-result-card { max-width: 100%; flex-direction: column; align-items: center; text-align: center; }
  .tarot-result-card .tarot-thumb { width: 60px; height: 105px; }
  .tarot-setup { max-width: 100%; }
  .tarot-controls.row { flex-direction: column; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .tarot-card { transition: none; }
  .tarot-shake { animation: none; }
  .tarot-card.flipped { transform: rotateY(180deg); } /* instant */
}

/* ---------- Print view ---------- */
@media print {
  .tarot-shell * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff !important; color: #1a1a1a !important; }
  .cms-header, .cms-navbar-wrap, .cms-admin-shortcut-bar, .cms-cookie-banner,
  .tarot-controls, .tarot-setup, .tarot-deck-view, .tarot-intro, .tarot-related,
  .cms-faq-section, header, footer, nav, .cms-topbar, .cms-masthead { display: none !important; }
  .tarot-shell { margin-top: 0 !important; padding-top: 0 !important; }
  .cms-container { max-width: 100% !important; padding: 0 !important; }
  .tarot-spread { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; justify-content: center !important; margin: 0 !important; padding: 0 !important; }
  .tarot-card-wrap { width: 95px !important; height: 166px !important; }
  .tarot-spread.one-card .tarot-card-wrap,
  .tarot-spread.three-cards .tarot-card-wrap,
  .tarot-spread.celtic-cross .tarot-card-wrap { width: 95px !important; height: 166px !important; }
  .tarot-result-card { break-inside: avoid; page-break-inside: avoid; border: 1px solid #999; background: #fff; padding: 12px; margin: 0 0 10px; display: flex; gap: 10px; align-items: flex-start; }
  .tarot-result-card .tarot-thumb { width: 55px; height: 96px; border: 1px solid #999; }
  .tarot-result-name { font-size: 13px; color: #000; }
  .tarot-result-orient { font-size: 9px; color: #000; }
  .tarot-result-keywords { font-size: 11px; }
  .tarot-result-meaning { font-size: 11.5px; line-height: 1.45; }
  .tarot-position-label { font-size: 10px; color: #000; }
  .tarot-summary { break-inside: avoid; page-break-inside: avoid; background: #faf6ec !important; border: 1px solid #999; margin: 14px 0; padding: 12px; }
  .tarot-summary h3 { font-size: 15px; color: #000; }
  .tarot-summary p { font-size: 12.5px; color: #1a1a1a; }
  .tarot-disclaimer { font-size: 9.5px; color: #555; }
  .tarot-print-header {
    text-align: center; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 16px;
  }
  @page { size: A4; margin: 15mm; }
}
