*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans:  'Inter', system-ui, sans-serif;
  --gold:       #C9A97A;
  --cream:      #D8CEB8;
  --dark:       #080808;
  --panel-bg:   rgba(21,14,1,0.85);
}

html, body { width: 100%; height: 100%; background: var(--dark); overflow: hidden; }

.home-nav {
  position: fixed; top: 1.25rem; left: 1.5rem; z-index: 150;
  font-family: var(--font-sans); font-size: 0.55rem;
  text-transform: uppercase; letter-spacing: 0.2em;
  color: rgba(216,206,184,0.45); text-decoration: none;
  transition: color 0.2s ease;
}
.home-nav:hover { color: var(--gold); }

/* ── Background ── */
#reading-bg {
  position: fixed; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
}
#reading-bg-tint {
  position: fixed; inset: 0; z-index: 1;
  background: rgba(8,8,8,0.72);
}

/* ── Gate overlay ── */
#gate-overlay {
  position: fixed; inset: 0; z-index: 100;
  background-image:
    linear-gradient(rgba(10,5,2,0.78), rgba(10,5,2,0.78)),
    url('/images/backgrounds/reading-background.webp');
  background-size: cover;
  background-position: center;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
  overflow-y: auto;
}

.gate-step {
  width: 100%; max-width: 480px;
  background: rgba(21, 14, 1, 0.65);
  border: 0.25px solid rgba(118, 88, 19, 0.4);
  padding: 2.5rem 3rem;
  display: flex; flex-direction: column;
  align-items: center; gap: 1.5rem;
  animation: gFadeUp 0.4s ease forwards;
}

.gate-eyebrow {
  font-family: var(--font-sans);
  font-size: 0.55rem; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--gold);
}

.gate-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 300;
  color: var(--cream); text-align: center; line-height: 1.2;
}

.gate-body {
  font-family: var(--font-serif);
  font-size: clamp(0.95rem, 2.5vw, 1.1rem); color: rgba(216,206,184,0.9);
  text-align: center; line-height: 1.7; max-width: 380px;
}

/* ── Gate form elements ── */
.gate-field {
  width: 100%; display: flex; flex-direction: column; gap: 0.4rem;
}

.gate-label {
  font-family: var(--font-sans); font-size: 0.6rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(201,169,122,0.9);
}

.gate-input, .gate-select, .gate-textarea {
  width: 100%; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(201,169,122,0.4);
  color: var(--cream); font-family: var(--font-serif); font-size: 1rem;
  padding: 0.75rem 0.9rem; outline: none;
  transition: border-color 0.2s ease;
}
.gate-input::placeholder, .gate-textarea::placeholder {
  color: rgba(216,206,184,0.4);
}
.gate-input:focus, .gate-select:focus, .gate-textarea:focus {
  border-color: var(--gold);
}
.gate-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%23C9A97A'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.9rem center; }
.gate-select option { background: #150e06; color: var(--cream); }
.gate-textarea { resize: vertical; min-height: 100px; }

/* ── Gate buttons ── */
.gate-btn-primary {
  width: 100%; padding: 0.9rem 1rem;
  background: var(--cream); color: var(--dark); border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.2em; font-weight: 500;
  transition: opacity 0.2s ease;
}
.gate-btn-primary:hover { opacity: 0.82; }
.gate-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.gate-btn-secondary {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 0.6rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(216,206,184,0.4); transition: color 0.2s ease;
}
.gate-btn-secondary:hover { color: var(--gold); }

/* ── Progress dots ── */
.gate-dots {
  display: flex; gap: 0.5rem; align-items: center;
}
.gate-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(201,169,122,0.25); transition: background 0.25s ease;
}
.gate-dot.active { background: var(--gold); }

/* ── OTP input ── */
.otp-input {
  width: 180px; text-align: center; letter-spacing: 0.4em;
  font-size: 1.8rem; padding: 0.6rem 0.9rem;
}

/* ── Gate error ── */
.gate-error {
  font-family: var(--font-sans); font-size: 0.7rem;
  color: #e07070; text-align: center;
}

/* ── Stripe element wrapper ── */
#stripe-element {
  width: 100%; padding: 0.75rem 0.9rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(201,169,122,0.25);
}

/* ── Reading shell (desktop) ── */
#reading-root {
  position: fixed; inset: 0; z-index: 2;
  display: flex; flex-direction: row;
}

.cards-panel {
  flex: 0 0 66%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem; position: relative; overflow: hidden;
}

.text-panel {
  flex: 0 0 34%;
  border-left: 1px solid rgba(201,169,122,0.15);
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 2rem 1.75rem; overflow-y: auto;
  background: var(--panel-bg);
}

.text-content { flex: 1; overflow-y: auto; padding-right: 0.5rem; }

.reading-dog-label {
  font-family: var(--font-sans); font-size: 0.55rem;
  text-transform: uppercase; letter-spacing: 0.25em;
  color: var(--gold); margin-bottom: 1.5rem; text-align: center;
}

/* ── Card slots ── */
.cards-row {
  display: flex; flex-direction: row;
  justify-content: center; align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
}

.card-slot-wrap { display: flex; flex-direction: column; align-items: center; }

.card-slot-label {
  font-family: var(--font-sans); font-size: 0.55rem;
  text-transform: uppercase; letter-spacing: 0.25em;
  color: rgba(201,169,122,0.4); margin-bottom: 0.75rem; text-align: center;
}

.card-wrap {
  width: 100%; height: 100%;
  perspective: 1200px; cursor: default;
}

.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.4,0,0.2,1);
}
.card-inner.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.card-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-face.front { transform: rotateY(180deg); }
.card-face.front img.reversed { transform: rotate(180deg); }

/* ── Text sections ── */
.text-section { margin-bottom: 1.5rem; }
.section-label {
  font-family: var(--font-sans); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.22em;
  color: var(--gold); margin-bottom: 0.75rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid rgba(201,169,122,0.12);
}
.section-para {
  font-family: var(--font-serif); font-size: clamp(1rem, 2.2vw, 1.2rem);
  color: var(--cream); line-height: 1.85; font-weight: 400;
  opacity: 0; animation: fadeUp 0.6s ease forwards;
}
.truth-btn-wrap { margin-top: 1.5rem; }

/* ── Synthesis overlay ── */
#synthesis-overlay {
  position: fixed; inset: 0; z-index: 50;
  background-image:
    linear-gradient(rgba(10,5,2,0.78), rgba(10,5,2,0.78)),
    url('/images/backgrounds/reading-background.webp');
  background-size: cover;
  background-position: center;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 4rem 2rem 2rem; overflow-y: auto;
}
.synthesis-inner {
  max-width: 680px; width: 100%;
  background: rgba(21, 14, 1, 0.65);
  border: 0.25px solid rgba(118, 88, 19, 0.4);
  padding: 2.5rem 3rem;
}
.synthesis-label {
  font-family: var(--font-sans); font-size: 0.55rem;
  text-transform: uppercase; letter-spacing: 0.3em;
  color: var(--gold); margin-bottom: 2rem;
}
.synthesis-text {
  font-family: var(--font-serif); font-size: clamp(1rem, 2.2vw, 1.2rem);
  color: var(--cream); line-height: 1.85; font-weight: 400;
}
.synthesis-text p { margin-bottom: 1rem; }
.synthesis-actions {
  margin-top: 3rem; display: flex; flex-direction: column;
  align-items: center; gap: 1rem;
}

/* ── Interstitial overlay ──
   Light cream / dark text, unlike the rest of this shared dark theme —
   this is the "walk through the positions" popup shown before a reading
   starts, and needs to match the dashboard's light readability fix. */
#interstitial {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(245,241,232,0.98);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.6s ease forwards;
}
#interstitial .gate-step { background: transparent; border: none; }
#interstitial .gate-btn-primary { background: #2A1A0E; color: var(--cream); }
.interstitial-eyebrow {
  font-family: var(--font-sans); font-size: 0.55rem;
  letter-spacing: 0.25em; text-transform: uppercase;
  color: #7a5a1e; margin-bottom: 1.5rem;
}
.interstitial-title {
  font-family: var(--font-serif); font-weight: 300;
  color: #2A1A0E; margin-bottom: 1.25rem;
}
.interstitial-body {
  font-family: var(--font-serif); color: rgba(30,15,5,0.75);
  max-width: 380px; line-height: 1.7; margin: 0 auto 2rem;
}
.interstitial-counter {
  font-family: var(--font-sans); font-size: 0.5rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(122,90,30,0.65); margin-bottom: 0.5rem;
}

/* ── Shuffle box ── */
#shuffle-box { position: fixed; z-index: 20; }
.deck-wrap { position: relative; }

/* ── Loading state ── */
#loading-state {
  position: fixed; inset: 0; z-index: 45;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
}

/* ── Mobile layout ── */
@media (max-width: 767px) {
  #reading-root { flex-direction: column; overflow-y: auto; }
  .cards-panel { flex: none; padding: 1.25rem 1rem; justify-content: flex-start; }
  .text-panel { flex: none; border-left: none; border-top: 1px solid rgba(201,169,122,0.15); padding: 1.25rem 1rem; }
  .cards-row { gap: clamp(0.5rem, 2vw, 1rem); }
  .card-slot-label { display: none; }
  #synthesis-overlay { padding: 2rem 1.25rem; }
  .gate-step { padding: 2rem 1.5rem; }
  #gate-overlay { padding: 1.25rem 1rem; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes gFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cardSettle {
  0%   { transform: scale(1.08) translateY(-6px); }
  65%  { transform: scale(0.97) translateY(1px); }
  100% { transform: scale(1) translateY(0); }
}
@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-18px); }
}
@keyframes shuffleCycle {
  0%   { transform: translate(0,0) rotate(0deg) scale(1); opacity: 1; }
  20%  { transform: translate(0,-55px) rotate(-8deg) scale(1.04); opacity: 0.9; }
  45%  { transform: translate(-50px,-40px) rotate(-18deg); opacity: 0.7; }
  65%  { transform: translate(-65px,18px) rotate(-10deg) scale(0.95); opacity: 0.4; }
  85%  { transform: translate(-18px,38px) rotate(-3deg) scale(0.92); opacity: 0.15; }
  100% { transform: translate(0,0) rotate(0deg) scale(1); opacity: 0; }
}
@keyframes charFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 0.9; } 50% { opacity: 0.35; }
}
/* ── Butterfly layout (new-puppy, rainbow-bridge) ── */
.cards-butterfly {
  display: flex; flex-direction: row;
  align-items: center; justify-content: center;
  gap: clamp(0.75rem, 2.5vw, 2rem);
}
.butterfly-col {
  display: flex; flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1.25rem);
}
.butterfly-center { display: flex; align-items: center; }

/* ── Two-row layout (past-life) ── */
.cards-two-rows {
  display: flex; flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1.25rem);
}

/* ── Rescue cross layout ── */
.cards-rescue-cross {
  display: flex; flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1.25rem);
}
.rescue-top { display: flex; justify-content: center; }

/* ── Cross pair (rescue dog + celtic center) ── */
.cross-pair { position: relative; }
.crossing-slot { position: absolute; inset: 0; }

/* ── Celtic Cross layout ── */
.cards-celtic-cross {
  display: flex; flex-direction: row;
  align-items: center; justify-content: center;
  gap: clamp(1rem, 3vw, 2.5rem);
}
.celtic-cross-grid {
  display: grid;
  /* grid-template-columns set inline in JS: CARD_W CARD_H CARD_W */
  gap: clamp(0.25rem, 0.75vw, 0.75rem);
  align-items: center;
  justify-items: center;
}
.celtic-cross-staff {
  display: grid;
  /* grid-template-columns set inline in JS: CARD_W CARD_W */
  gap: clamp(0.25rem, 0.75vw, 0.75rem);
  align-self: center;
}

/* Placed after the base .cards-celtic-cross rule (not in the earlier
   "Mobile layout" block) deliberately — a media-scoped rule doesn't win a
   specificity tie just by matching; source order still decides, and the
   base rule above is declared later in the file than that block. Grid +
   staff sitting side-by-side (row) never fits a phone width even at the
   card floor size, so this stacks them instead. */
@media (max-width: 767px) {
  .cards-celtic-cross { flex-direction: column; align-items: center; gap: 1rem; }
}
