.spread-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.spread-preview__slot {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 64px;
  text-align: center;
}
.spread-preview__slot span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 60px;
  border: 1px solid var(--color-gold);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-gold-light);
}
.spread-preview__slot small {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.spread-stage {
  position: relative;
  width: 100%;
  min-height: 60vh;
  z-index: var(--z-reading-board);
}

.spread-stage__slot {
  position: absolute;
  width: clamp(120px, 14vw, 150px);
}

/* Stable per-card wrapper (SRS Phase 4 §2/§6): the slot position never
   changes; only its inner state (locked / active / revealed) is swapped,
   so revealing a card never shifts layout or duplicates a container. */
.reading-card-slot {
  perspective: 900px;
  min-height: 100%;
}
.reading-card-slot[data-state="active"] { z-index: var(--z-card-active); position: relative; }

.reading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.8rem;
  min-height: 44px;
  transform-style: preserve-3d;
}

.reading-card strong,
.reading-card span {
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.reading-card--facedown {
  cursor: default;
  color: var(--color-text-muted);
}
.reading-card--facedown img { width: 90px; border-radius: 6px; }

.reading-card--active {
  cursor: pointer;
  border-color: var(--color-gold);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-standard), box-shadow var(--transition-standard);
  animation: reading-card-glow 3.6s ease-in-out infinite;
}
.reading-card--active:hover,
.reading-card--active:focus-visible { transform: scale(1.04); }
.reading-card--active:disabled,
.reading-card--active[aria-busy="true"] {
  cursor: wait;
  opacity: 0.7;
  animation: none;
}

@keyframes reading-card-glow {
  0%, 100% { box-shadow: var(--shadow-soft); }
  50% { box-shadow: 0 0 0 6px rgba(216, 181, 107, 0.18), var(--shadow-soft); }
}

.reading-card--locked { opacity: 0.55; }

.reading-card--revealed {
  cursor: pointer;
  transition: transform var(--transition-standard), box-shadow var(--transition-standard);
}
.reading-card--revealed:hover,
.reading-card--revealed:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-soft);
  border-color: var(--color-gold);
}
.reading-card--revealed:focus-visible { outline: 2px solid var(--color-gold-light); outline-offset: 2px; }
.reading-card--revealed .card-thumb { width: 110px; }

/* Reveal-order card-flip (SRS Phase 4 §4–5): plays only after the server
   confirms the reveal — this class is added by JS just before the DOM swap,
   never before the response succeeds. */
@media (prefers-reduced-motion: no-preference) {
  .is-flipping-out > * { animation: card-flip-out 260ms ease forwards; pointer-events: none; }
  .is-flipping-in > * { animation: card-flip-in 260ms ease forwards; }
}
@keyframes card-flip-out {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(90deg); }
}
@keyframes card-flip-in {
  from { transform: rotateY(-90deg); }
  to { transform: rotateY(0deg); }
}

.reading-board--leaving {
  transition: opacity 380ms ease;
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .reading-board--leaving { transition: none; }
}

.reading-card__deep {
  text-align: left;
  white-space: pre-line;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 0.4rem;
}

.purpose-card { display: block; text-align: center; padding: 1.5rem 1rem; }

.purpose-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.purpose-card-full { justify-content: space-between; }

.spread-preview--small {
  aspect-ratio: 16 / 7;
  margin-block: 0.4rem;
}
.spread-preview--small .spread-preview__slot span {
  width: 20px;
  height: 30px;
}

.spread-card--suggested { border-color: var(--color-gold); }

@media (max-width: 768px) {
  /* A vertical, staged flow (SRS Phase 4 §6/§3) — every spread shape (1, 3,
     4, or 5 cards) collapses to the same predictable single-column list, so
     five-card crosses and conversations never have to shrink illegibly. */
  .spread-stage__slot {
    position: static !important;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 1rem;
    transform: none !important;
  }
  .spread-stage { display: flex; flex-direction: column; align-items: stretch; min-height: 0; }
  .reading-card { padding: 1rem; }
  .reading-card--facedown img,
  .reading-card--revealed .card-thumb { width: 110px; }
}

@media print {
  .no-print,
  .site-header,
  .site-footer,
  .card-popup,
  .card-popup::backdrop,
  .toast-region {
    display: none !important;
  }
  body { background: #fff; color: #000; }
}
