/* Ritual pages — Liu Yao coin toss + Tarot shuffle/pick.
   Extends oracle.css mystic theme with 3D coin + card flip animations. */

.ritual-body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.ritual-wrap {
  position: relative; z-index: 2;
  max-width: 940px; margin: 0 auto;
  padding: 40px 24px 100px;
  text-align: center;
}

.ritual-title {
  font-family: var(--oracle-serif);
  font-size: clamp(30px, 4vw, 44px);
  color: #fff8e6; font-weight: 400; margin: 0 0 8px;
  letter-spacing: .02em;
}
.ritual-sub {
  color: var(--oracle-ink-dim); font-size: 15px; line-height: 1.75;
  margin: 0 auto 24px; max-width: 620px;
}
.ritual-progress {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  background: rgba(212,162,76,.08);
  border: 1px solid rgba(212,162,76,.3);
  border-radius: 999px;
  color: var(--oracle-gold-bright);
  font-size: 14px; letter-spacing: .06em;
  margin-bottom: 30px;
}
.ritual-progress .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(212,162,76,.25); }
.ritual-progress .dot.on { background: var(--oracle-gold-bright); box-shadow: 0 0 8px var(--oracle-gold-bright); }

/* -------- Liu Yao: coins + yao board -------- */
.coins-stage {
  position: relative; height: 240px; margin: 0 auto 24px;
  max-width: 560px;
  perspective: 900px;
  background: radial-gradient(ellipse at center, rgba(42,20,68,.6), transparent 70%);
}
.coin {
  position: absolute; width: 90px; height: 90px;
  top: 70px;
  transform-style: preserve-3d;
  transition: transform .35s cubic-bezier(.3,1.4,.5,1);
}
.coin.c1 { left: 30%; margin-left: -45px; }
.coin.c2 { left: 50%; margin-left: -45px; }
.coin.c3 { left: 70%; margin-left: -45px; }
.coin-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
}
.coin-face {
  position: absolute; inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--oracle-serif);
  color: #2b1a05;
}
.coin-yang {
  background: radial-gradient(circle at 30% 30%, #f3cd7a 0%, #b08334 60%, #6a4a18 100%);
  box-shadow: inset 0 -6px 12px rgba(0,0,0,.3), inset 0 4px 8px rgba(255,255,255,.15), 0 6px 20px -6px rgba(243,205,122,.4);
  transform: rotateY(0deg);
}
.coin-yin {
  background: radial-gradient(circle at 30% 30%, #a67729 0%, #6a4a18 60%, #2b1a05 100%);
  box-shadow: inset 0 -6px 12px rgba(0,0,0,.4), 0 6px 20px -6px rgba(0,0,0,.6);
  transform: rotateY(180deg);
}
/* square hole */
.coin-face::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 26px; height: 26px;
  transform: translate(-50%,-50%);
  background: #0a0620;
  border: 1px solid rgba(0,0,0,.6);
  box-shadow: inset 0 0 4px rgba(0,0,0,.8);
}
.coin-yang::after {
  content: ''; position: absolute; inset: 12px;
  border: 1px solid rgba(43,26,5,.5);
  border-radius: 50%;
  pointer-events: none;
}
.coin-face .coin-char {
  position: absolute; top: 6px; left: 50%;
  transform: translateX(-50%);
  font-size: 15px; color: rgba(43,26,5,.9); letter-spacing: .02em;
}
.coin-yin .coin-char { top: auto; bottom: 6px; color: rgba(243,205,122,.7); font-size: 11px; letter-spacing: .1em; }

/* shaking */
.coins-stage.shaking .coin-inner {
  animation: coinShake 900ms cubic-bezier(.36, .07, .19, .97);
}
@keyframes coinShake {
  0%   { transform: translateY(0)    rotateZ(0);     }
  15%  { transform: translateY(-60px) rotateZ(140deg); }
  30%  { transform: translateY(-90px) rotateZ(320deg); }
  45%  { transform: translateY(-70px) rotateZ(540deg); }
  60%  { transform: translateY(-95px) rotateZ(720deg); }
  75%  { transform: translateY(-50px) rotateZ(900deg); }
  85%  { transform: translateY(-20px) rotateZ(1020deg); }
  100% { transform: translateY(0) rotateZ(1080deg); }
}
.coin.settled-yang .coin-inner { transform: rotateY(0deg); }
.coin.settled-yin  .coin-inner { transform: rotateY(180deg); }

/* cast button */
.btn-cast {
  padding: 16px 42px;
  font-size: 20px; letter-spacing: .12em;
  background: linear-gradient(135deg, #f3cd7a 0%, #d4a24c 50%, #a67729 100%);
  color: #1a0f00; border: none; border-radius: 999px; cursor: pointer;
  font-family: var(--oracle-serif); font-weight: 500;
  box-shadow: 0 14px 40px -14px rgba(243,205,122,.7);
  transition: all .2s;
}
.btn-cast:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); box-shadow: 0 18px 50px -14px rgba(243,205,122,.85); }
.btn-cast:disabled { opacity: .4; cursor: not-allowed; }
.btn-cast .shake-icon { display: inline-block; animation: iconShake 1.5s ease-in-out infinite; }
@keyframes iconShake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-15deg); } 75% { transform: rotate(15deg); } }

/* Yao board — 6 rows from bottom (yao 1) to top (yao 6) */
.yao-board {
  display: inline-flex; flex-direction: column-reverse;
  gap: 14px;
  padding: 26px 36px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(212,162,76,.25);
  border-radius: 14px;
  margin: 20px auto 24px;
  min-width: 380px;
  position: relative;
}
.yao-board::before {
  content: ''; position: absolute; inset: -6px;
  border: 1px dashed rgba(212,162,76,.2);
  border-radius: 18px; pointer-events: none;
}
.yao-row {
  display: grid; grid-template-columns: 40px 1fr 100px; align-items: center; gap: 16px;
  color: var(--oracle-ink-dim); font-size: 13px;
  min-height: 22px;
}
.yao-row .yao-pos { text-align: left; color: var(--oracle-gold); font-family: var(--oracle-serif); }
.yao-row .yao-line {
  height: 22px; position: relative;
}
.yao-row .yao-line .bar {
  position: absolute; top: 8px; left: 0; right: 0; height: 6px;
  background: linear-gradient(90deg, #f3cd7a, #d4a24c);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(243,205,122,.5);
}
.yao-row.yin .yao-line .bar { display: none; }
.yao-row.yin .yao-line::before,
.yao-row.yin .yao-line::after {
  content: ''; position: absolute; top: 8px; height: 6px; width: 44%;
  background: linear-gradient(90deg, #f3cd7a, #d4a24c);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(243,205,122,.5);
}
.yao-row.yin .yao-line::before { left: 0; }
.yao-row.yin .yao-line::after  { right: 0; }

.yao-row.changing .yao-line { animation: changePulse 2s ease-in-out infinite; }
@keyframes changePulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.yao-row .yao-tag { text-align: right; font-size: 12px; color: var(--oracle-ink-dim); }
.yao-row.changing .yao-tag::after { content: ' ⚡ moving'; color: var(--oracle-gold-bright); }

/* Result panel */
.ritual-result {
  margin: 30px auto; max-width: 720px;
  padding: 26px 32px;
  background: linear-gradient(180deg, rgba(42,20,68,.6), rgba(10,6,32,.85));
  border: 1px solid rgba(212,162,76,.35);
  border-radius: 18px;
  text-align: left;
}
.ritual-result h3 { color: var(--oracle-gold-bright); margin: 0 0 12px; font-size: 22px; font-weight: 500; }
.ritual-result .result-diagram {
  display: flex; gap: 30px; align-items: center; justify-content: center;
  margin: 20px 0;
}
.ritual-result .hexagram-block {
  display: flex; flex-direction: column; align-items: center;
}
.hexagram-block .hb-trig {
  font-size: 36px; color: var(--oracle-gold-bright); line-height: 1;
  margin-bottom: 6px;
}
.hexagram-block .hb-name {
  font-family: var(--oracle-serif);
  font-size: 20px; color: #fff8e6;
  margin-bottom: 4px;
}
.hexagram-block .hb-sub { font-size: 12px; color: var(--oracle-ink-dim); }
.hex-arrow { font-size: 24px; color: var(--oracle-gold); }

.ritual-result pre.context-preview {
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(212,162,76,.2);
  padding: 14px 18px;
  border-radius: 8px;
  color: var(--oracle-ink);
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 220px; overflow-y: auto;
  margin: 20px 0;
}
.ritual-actions {
  display: flex; gap: 14px; justify-content: center; margin-top: 20px; flex-wrap: wrap;
}

/* -------- Tarot: card + fan -------- */
.tarot-stage {
  position: relative; min-height: 380px; margin: 30px auto;
  perspective: 1400px;
}
.tarot-deck {
  position: relative; width: 100%; height: 340px;
  display: flex; align-items: center; justify-content: center;
}
.tarot-card {
  position: absolute;
  width: 130px; height: 200px;
  border-radius: 12px;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.4, 1.3, .5, 1), top .5s, left .5s;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  left: 50%; top: 50%; margin-left: -65px; margin-top: -100px;
}
.tarot-card:hover { filter: brightness(1.15); }
.card-face {
  position: absolute; inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 12px 10px;
  border: 2px solid rgba(212,162,76,.5);
  box-shadow: 0 12px 32px -8px rgba(0,0,0,.7);
}
.card-back {
  background:
    radial-gradient(circle at 50% 30%, rgba(243,205,122,.18), transparent 50%),
    linear-gradient(145deg, #2a1444 0%, #0f0724 100%);
  color: var(--oracle-gold-bright);
  transform: rotateY(0deg);
}
.card-back::before {
  content: ''; position: absolute; inset: 12px;
  border: 1px dashed rgba(212,162,76,.4);
  border-radius: 8px;
}
.card-back::after {
  content: '✶'; position: absolute;
  left: 50%; top: 50%; transform: translate(-50%,-50%);
  font-size: 48px; color: rgba(212,162,76,.55);
}
.card-front {
  background: linear-gradient(180deg, #f5eddc 0%, #e5d9b8 100%);
  color: #2a1444;
  transform: rotateY(180deg);
  padding: 14px 12px;
}
.card-front .cf-num {
  font-family: var(--oracle-serif);
  font-size: 14px; letter-spacing: .1em;
  color: #4a3418;
}
.card-front .cf-symbol {
  font-size: 46px; line-height: 1; color: #2a1444;
  margin: 6px 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.2));
}
.card-front .cf-name {
  font-family: var(--oracle-serif);
  font-size: 13px; text-align: center; color: #2a1444; font-weight: 600;
  line-height: 1.2;
}
.card-front .cf-en {
  font-size: 10px; text-align: center; color: #4a3418;
  font-style: italic; letter-spacing: .05em; margin-top: 4px;
}
.card-front .cf-frame {
  position: absolute; inset: 8px;
  border: 1px solid rgba(74,52,24,.35);
  border-radius: 6px; pointer-events: none;
}
.tarot-card.flipped { transform: rotateY(180deg); }
.tarot-card.reversed .card-front .cf-symbol,
.tarot-card.reversed .card-front .cf-name,
.tarot-card.reversed .card-front .cf-num,
.tarot-card.reversed .card-front .cf-en { transform: rotate(180deg); }

.tarot-card.selected { cursor: default; }
.tarot-card.selected:not(.flipped) { animation: cardPulse .8s ease; }
@keyframes cardPulse {
  0%,100% { box-shadow: 0 12px 32px -8px rgba(0,0,0,.7); }
  50%     { box-shadow: 0 0 60px rgba(243,205,122,.9); }
}

/* Shuffling animation */
.tarot-deck.shuffling .tarot-card {
  animation: shuffle 1.4s cubic-bezier(.4,.1,.6,.9);
}
@keyframes shuffle {
  0%   { transform: translate(-120px, 0) rotate(-8deg); }
  25%  { transform: translate(120px,  -20px) rotate(8deg); }
  50%  { transform: translate(-80px,  15px) rotate(-5deg); }
  75%  { transform: translate(90px,   -10px) rotate(5deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

/* Slot row for picked 3 cards */
.tarot-spread {
  display: grid; grid-template-columns: repeat(3, 130px); gap: 24px;
  justify-content: center; margin: 40px auto;
  min-height: 240px;
}
.spread-slot {
  position: relative;
  border: 1px dashed rgba(212,162,76,.25);
  border-radius: 14px;
  min-height: 200px;
  display: flex; align-items: center; justify-content: center;
  padding-top: 12px;
}
.spread-slot::before {
  content: attr(data-label);
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--oracle-gold); letter-spacing: .12em; text-transform: uppercase;
}
.spread-slot .tarot-card {
  position: absolute;
  left: 0; top: 0; margin: 0;
}

.tarot-picker-hint {
  color: var(--oracle-ink-dim); font-size: 14px; margin: 20px 0 8px;
  font-style: italic;
}

/* -------- shared -------- */
.ritual-nav-back {
  position: absolute; top: 20px; left: 20px; z-index: 3;
  color: var(--oracle-gold); text-decoration: none;
  font-size: 15px; letter-spacing: .05em;
}
.ritual-nav-back:hover { color: var(--oracle-gold-bright); }

@media (max-width: 640px) {
  .coins-stage { height: 200px; }
  .coin { width: 70px; height: 70px; }
  .coin.c1 { left: 25%; margin-left: -35px; }
  .coin.c3 { left: 75%; margin-left: -35px; }
  .yao-board { min-width: auto; padding: 20px; }
  .tarot-card { width: 100px; height: 155px; margin-left: -50px; margin-top: -77px; }
  .card-front .cf-symbol { font-size: 32px; }
  .tarot-spread { grid-template-columns: repeat(3, 100px); gap: 12px; }
  .spread-slot { min-height: 155px; }
}
