/* ═══════════════════════════════════════════
   TarotManager - 타로카드 리딩 스타일
   ═══════════════════════════════════════════ */

/* ── 오버레이 ── */
.tarot-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: rgba(10, 5, 30, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.tarot-deck-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 700px;
  padding: 20px;
}

.tarot-deck-title {
  font-size: 1.3rem;
  color: #e0d0ff;
  text-align: center;
  text-shadow: 0 0 10px rgba(180, 130, 255, 0.5);
  font-weight: 500;
  letter-spacing: 1px;
}

.tarot-deck-counter {
  font-size: 1rem;
  color: #a08cc0;
  letter-spacing: 2px;
}

/* ── 카드 팬 레이아웃 (78장 그리드) ── */
.tarot-fan {
  position: relative;
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 10px;
  perspective: 1000px;
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(130, 80, 255, 0.3) transparent;
}

.tarot-fan::-webkit-scrollbar {
  width: 4px;
}
.tarot-fan::-webkit-scrollbar-thumb {
  background: rgba(130, 80, 255, 0.3);
  border-radius: 4px;
}

/* ── 개별 카드 (78장 그리드) ── */
.tarot-card {
  position: relative;
  width: 52px;
  height: 78px;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  animation: cardDealIn 0.3s ease-out forwards;
  opacity: 0;
  flex-shrink: 0;
}

@keyframes cardDealIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tarot-card:hover:not(.flipped):not(.disabled) {
  transform: translateY(-8px) scale(1.12);
  z-index: 10;
  box-shadow: 0 8px 20px rgba(130, 80, 255, 0.4);
}

.tarot-card.disabled {
  opacity: 0.3;
  pointer-events: none;
  filter: grayscale(0.5);
}

/* ── 카드 내부 (3D 플립) ── */
.tarot-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

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

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

/* ── 카드 앞면 / 뒷면 공통 ── */
.tarot-card-front,
.tarot-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
}

/* ── 카드 뒷면 ── */
.tarot-card-back {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(60, 30, 120, 0.4) 0%, transparent 70%),
    linear-gradient(145deg, #241452, #150c38);
  border: 2px solid #7a5ec8;
  box-shadow:
    inset 0 0 20px rgba(100, 60, 200, 0.15),
    0 0 12px rgba(130, 80, 255, 0.3);
}

.card-back-pattern {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  background-image:
    repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(120, 80, 220, 0.04) 8px, rgba(120, 80, 220, 0.04) 9px),
    repeating-linear-gradient(-45deg, transparent, transparent 8px, rgba(120, 80, 220, 0.04) 8px, rgba(120, 80, 220, 0.04) 9px);
}

/* 뒷면 코너 장식 */
.card-back-corner {
  position: absolute;
  font-size: 0.5rem;
  color: rgba(180, 150, 255, 0.5);
  line-height: 1;
}
.card-back-corner.tl { top: 5px; left: 6px; }
.card-back-corner.tr { top: 5px; right: 6px; transform: rotate(90deg); }
.card-back-corner.bl { bottom: 5px; left: 6px; transform: rotate(-90deg); }
.card-back-corner.br { bottom: 5px; right: 6px; transform: rotate(180deg); }

/* 뒷면 중앙 메달리온 */
.card-back-medallion {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.medallion-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1.5px solid rgba(180, 150, 255, 0.35);
  border-radius: 50%;
  animation: medallionSpin 20s linear infinite;
  box-shadow: 0 0 12px rgba(150, 100, 255, 0.15);
}

.medallion-ring::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(160, 130, 255, 0.2);
  border-radius: 50%;
}

.medallion-symbol {
  font-size: 1rem;
  color: #b8a0ff;
  text-shadow: 0 0 18px rgba(180, 140, 255, 0.7);
  animation: shimmer 3s ease-in-out infinite;
  z-index: 1;
}

@keyframes medallionSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0%, 100% { opacity: 0.7; text-shadow: 0 0 15px rgba(180, 130, 255, 0.4); }
  50% { opacity: 1; text-shadow: 0 0 25px rgba(180, 130, 255, 0.8); }
}

.card-back-border {
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(160, 120, 255, 0.2);
  border-radius: 5px;
  pointer-events: none;
}

.card-back-border::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(140, 100, 230, 0.1);
  border-radius: 4px;
}

/* ── 카드 앞면 ── */
.tarot-card-front {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 248, 230, 0.6) 0%, transparent 60%),
    linear-gradient(180deg, #faf5e8, #e8dcc4);
  border: 2px solid #b89a52;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  position: relative;
  box-shadow: inset 0 0 30px rgba(180, 150, 80, 0.08);
}

/* 앞면 이중 테두리 */
.tarot-card-front::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(160, 130, 60, 0.3);
  border-radius: 5px;
  pointer-events: none;
}

.tarot-card-front::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(160, 130, 60, 0.15);
  border-radius: 4px;
  pointer-events: none;
}

/* 앞면 코너 장식 */
.card-front-corner {
  position: absolute;
  font-size: 0.3rem;
  color: rgba(140, 110, 50, 0.4);
  line-height: 1;
}
.card-front-corner.tl { top: 4px; left: 4px; }
.card-front-corner.br { bottom: 4px; right: 4px; transform: rotate(180deg); }

/* 카드 구분선 */
.card-divider {
  width: 40%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(140, 110, 50, 0.35), transparent);
}

.card-numeral {
  font-size: 0.45rem;
  color: #7a5c2e;
  font-weight: 700;
  letter-spacing: 1px;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.card-symbol {
  font-size: 1.1rem;
  line-height: 1;
  color: #4a3218;
  font-family: 'Georgia', 'Times New Roman', serif;
  text-shadow: 0 1px 3px rgba(74, 50, 24, 0.12);
  padding: 1px 0;
}

.card-name {
  font-size: 0.35rem;
  color: #6a5430;
  text-align: center;
  line-height: 1.1;
  font-weight: 600;
  word-break: keep-all;
  letter-spacing: 0;
  font-family: 'Georgia', 'Times New Roman', serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 90%;
}

/* ── 스프레드 선택 UI ── */
.tarot-spread-selector {
  background: linear-gradient(135deg, rgba(30, 15, 60, 0.95), rgba(20, 10, 45, 0.95));
  border: 1px solid rgba(160, 120, 255, 0.3);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  backdrop-filter: blur(4px);
}

.tarot-spread-title {
  text-align: center;
  font-size: 1.1rem;
  color: #d0c0f0;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.tarot-spread-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tarot-spread-btn {
  background: linear-gradient(135deg, rgba(60, 30, 120, 0.6), rgba(40, 20, 90, 0.6));
  border: 1px solid rgba(140, 100, 230, 0.35);
  border-radius: 12px;
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.3s ease;
  color: inherit;
}

.tarot-spread-btn:hover {
  background: linear-gradient(135deg, rgba(80, 40, 160, 0.7), rgba(60, 30, 120, 0.7));
  border-color: rgba(180, 140, 255, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(130, 80, 255, 0.3);
}

.spread-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.spread-name {
  font-size: 0.85rem;
  color: #e0d0ff;
  font-weight: 500;
  white-space: nowrap;
}

.spread-desc {
  font-size: 0.65rem;
  color: #a090c0;
  white-space: nowrap;
}

/* ── 결과 카드 (채팅 내 표시) ── */
.tarot-result-cards {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 18px 8px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.tarot-result-card {
  width: 95px;
  text-align: center;
}

.result-card-face {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 248, 230, 0.5) 0%, transparent 60%),
    linear-gradient(180deg, #faf5e8, #e8dcc4);
  border: 2px solid #b89a52;
  border-radius: 8px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 12px rgba(160, 120, 50, 0.2);
  transition: box-shadow 0.3s, transform 0.3s;
  position: relative;
}

/* 결과 카드 이중 테두리 */
.result-card-face::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(160, 130, 60, 0.25);
  border-radius: 5px;
  pointer-events: none;
}

/* 결과 카드 코너 장식 */
.result-corner {
  position: absolute;
  font-size: 0.4rem;
  color: rgba(140, 110, 50, 0.35);
  line-height: 1;
}
.result-corner.tl { top: 7px; left: 7px; }
.result-corner.br { bottom: 7px; right: 7px; transform: rotate(180deg); }

/* 결과 카드 구분선 */
.result-divider {
  width: 45%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(140, 110, 50, 0.3), transparent);
}

.tarot-result-card.reversed .result-card-face {
  transform: rotate(180deg);
  border-color: #8a5a6e;
}

.result-card-face:hover {
  box-shadow: 0 6px 22px rgba(160, 120, 50, 0.35);
  transform: translateY(-2px);
}

.tarot-result-card.reversed .result-card-face:hover {
  transform: rotate(180deg) translateY(2px);
}

.result-numeral {
  font-size: 0.55rem;
  color: #7a5c2e;
  font-weight: 700;
  font-family: 'Georgia', 'Times New Roman', serif;
  letter-spacing: 1.5px;
}

.result-symbol {
  font-size: 1.4rem;
  color: #4a3218;
  font-family: 'Georgia', 'Times New Roman', serif;
  text-shadow: 0 1px 2px rgba(74, 50, 24, 0.1);
  padding: 1px 0;
}

.result-name {
  font-size: 0.6rem;
  color: #6a5430;
  font-weight: 600;
  line-height: 1.2;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.result-orient {
  font-size: 0.5rem;
  color: #9a7a4a;
  margin-top: 2px;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.result-position {
  font-size: 0.7rem;
  color: #a090c0;
  margin-top: 6px;
  word-break: keep-all;
}

/* ── 반응형 ── */
@media (max-width: 600px) {
  .tarot-fan {
    gap: 4px;
    padding: 8px;
    max-height: 55vh;
  }

  .tarot-card {
    width: 42px;
    height: 63px;
  }

  .card-symbol {
    font-size: 0.9rem;
  }

  .card-name {
    font-size: 0.35rem;
  }

  .card-numeral {
    font-size: 0.4rem;
  }

  .card-divider {
    width: 35%;
  }

  .card-front-corner {
    font-size: 0.3rem;
  }
  .card-front-corner.tl { top: 3px; left: 3px; }
  .card-front-corner.br { bottom: 3px; right: 3px; }

  .medallion-symbol {
    font-size: 0.85rem;
  }

  .card-back-medallion {
    width: 22px;
    height: 22px;
  }

  .card-back-corner {
    font-size: 0.3rem;
  }

  .tarot-spread-options {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .tarot-spread-btn {
    padding: 8px 6px;
    gap: 3px;
  }

  .tarot-result-card {
    width: 80px;
  }

  .tarot-deck-title {
    font-size: 1.1rem;
  }
}

@media (max-width: 380px) {
  .tarot-fan {
    gap: 3px;
    padding: 6px;
  }

  .tarot-card {
    width: 36px;
    height: 54px;
  }

  .card-back-corner {
    font-size: 0.25rem;
  }

  .medallion-symbol {
    font-size: 0.7rem;
  }

  .card-back-medallion {
    width: 18px;
    height: 18px;
  }

  .card-symbol {
    font-size: 0.75rem;
  }

  .card-divider {
    width: 30%;
  }

  .card-front-corner {
    display: none;
  }

  .card-name {
    display: none;
  }
}
