/*
 * apps/fortune.css
 * "🔮 오늘의 운세" (타로 22장) 디자인 시스템
 * - 딥 네이비 + 골드 라인 팔레트 (토스 스타일의 화이트/블루 톤과 구분되는 별도 무드)
 * - 카드 앞/뒷면 + 3D 플립 애니메이션
 * - 골드 라인 아이콘은 js/tarot-data.js 에서 stroke 전용으로 정의됨
 */

#fortuneApp {
  --tarot-navy: #14152b;
  --tarot-navy-2: #262a52;
  --tarot-gold: #c9a961;
  --tarot-gold-soft: rgba(201, 169, 97, 0.16);
  --tarot-gold-line: rgba(201, 169, 97, 0.45);
  --tarot-cream: #faf7f0;
  position: relative;
  overflow: hidden;
}

.tarot-stage {
  position: relative;
  min-height: 280px;
}

.tarot-step[hidden],
.tarot-result[hidden] {
  display: none !important;
}

/* ── STEP1: 오늘의 질문 ─────────────────────────── */
.tarot-intro-lead {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.55;
  color: var(--color-text);
  text-align: center;
  margin: 4px 0 8px;
  letter-spacing: -0.02em;
}

.tarot-intro-hint {
  font-size: 14px;
  color: var(--color-text-sub);
  text-align: center;
  margin: 0 0 18px;
}

.tarot-question-box {
  background: linear-gradient(155deg, rgba(20, 21, 43, 0.04) 0%, rgba(38, 42, 82, 0.08) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  margin: 0 0 16px;
  text-align: center;
}

.tarot-question-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--tarot-gold);
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}

.tarot-question-text {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.55;
  color: var(--color-text);
  margin: 0;
  letter-spacing: -0.02em;
}

.tarot-intro-ready {
  text-align: center;
  margin-bottom: 16px;
}

.tarot-spread-btn {
  width: 100%;
  min-height: 52px;
}

/* ── 배경 파티클 ───────────────────────────────── */
.tarot-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.tarot-particle {
  position: absolute;
  font-size: 11px;
  line-height: 1;
  opacity: 0;
  animation: tarot-particle-float linear infinite;
}

@keyframes tarot-particle-float {
  0% {
    transform: translateY(12px);
    opacity: 0;
  }
  12% {
    opacity: 0.45;
  }
  88% {
    opacity: 0.35;
  }
  100% {
    transform: translateY(-48px);
    opacity: 0;
  }
}

.tarot-step,
.tarot-result {
  position: relative;
  z-index: 1;
}

.tarot-spread {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 8px 0 22px;
}

.tarot-card-slot {
  width: 96px;
  aspect-ratio: 5 / 8;
  perspective: 1000px;
  cursor: pointer;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tarot-card-slot.is-entering {
  animation: tarot-card-enter 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.tarot-card-slot.is-entering:nth-child(1) { animation-delay: 0.05s; }
.tarot-card-slot.is-entering:nth-child(2) { animation-delay: 0.15s; }
.tarot-card-slot.is-entering:nth-child(3) { animation-delay: 0.25s; }

@keyframes tarot-card-enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tarot-card-slot.is-selected {
  z-index: 2;
  transform: scale(1.12);
}

.tarot-card-slot.is-glowing .tarot-card-back,
.tarot-card-slot.is-glowing .tarot-card-front {
  box-shadow: 0 0 22px rgba(201, 169, 97, 0.45);
}

/* aspect-ratio 미지원 구형 브라우저 대비 폴백 */
@supports not (aspect-ratio: 5 / 8) {
  .tarot-card-slot {
    height: 154px;
  }
}

.tarot-card-slot.is-dim {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

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

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

.tarot-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tarot-card-back {
  background: linear-gradient(155deg, var(--tarot-navy) 0%, var(--tarot-navy-2) 100%);
  border: 1px solid var(--tarot-gold-line);
}

.tarot-card-back::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--tarot-gold-line);
  border-radius: 8px;
}

.tarot-back-emblem {
  color: var(--tarot-gold);
  opacity: 0.9;
}

.tarot-card-front {
  background: var(--tarot-cream);
  border: 1px solid var(--tarot-gold-line);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.6);
  transform: rotateY(180deg);
  padding: 8px 4px;
  box-sizing: border-box;
}

.tarot-card-front.tarot-tier-rare {
  border: 2px solid #d4b978;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.55), 0 0 10px rgba(201, 169, 97, 0.28);
}

.tarot-card-front.tarot-tier-epic {
  border: 2px solid #e8cc8a;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 16px rgba(201, 169, 97, 0.4);
}

.tarot-card-front.tarot-tier-legendary {
  border: 2px solid #f5dfa0;
  box-shadow:
    inset 0 0 0 3px rgba(255, 248, 230, 0.45),
    0 0 22px rgba(245, 223, 160, 0.5),
    inset 0 0 14px rgba(201, 169, 97, 0.12);
}

.tarot-front-icon {
  color: var(--tarot-gold);
}

.tarot-front-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  line-height: 1.3;
}

/* ── 결과 패널 ──────────────────────────────────── */
.tarot-result {
  text-align: center;
  background: linear-gradient(155deg, var(--tarot-navy) 0%, var(--tarot-navy-2) 100%);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  margin-top: 4px;
  animation: tarot-result-reveal 0.6s ease both;
}

.tarot-result.tarot-tier-rare {
  box-shadow: 0 0 0 1px rgba(212, 185, 120, 0.35), 0 8px 28px rgba(201, 169, 97, 0.12);
}

.tarot-result.tarot-tier-epic {
  box-shadow: 0 0 0 1px rgba(232, 204, 138, 0.45), 0 8px 32px rgba(201, 169, 97, 0.18);
}

.tarot-result.tarot-tier-legendary {
  box-shadow:
    0 0 0 1px rgba(245, 223, 160, 0.55),
    0 0 32px rgba(245, 223, 160, 0.15),
    0 8px 36px rgba(201, 169, 97, 0.22);
}

@keyframes tarot-result-reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tarot-result-question-label,
.tarot-message-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--tarot-gold);
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}

.tarot-result-question {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.82);
  margin: 0 0 18px;
}

.tarot-result-divider {
  height: 1px;
  background: var(--tarot-gold-line);
  margin: 0 0 18px;
  opacity: 0.55;
}

.tarot-message-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.45;
  color: #ffffff;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}

.tarot-message-body {
  font-size: 15px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.88);
  margin: 0 0 14px;
  white-space: pre-line;
}

.tarot-message-closing {
  font-size: 13.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.62);
  margin: 0 0 22px;
}

.tarot-result-card-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding-top: 4px;
}

.tarot-result-icon {
  color: var(--tarot-gold);
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.tarot-result-name {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: -0.01em;
  margin: 0;
}

.tarot-result-keyword,
.tarot-result-fortune {
  display: none;
}

.tarot-lucky-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tarot-lucky-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--tarot-gold-line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 84px;
}

.tarot-lucky-label {
  display: block;
  font-size: 10.5px;
  color: var(--tarot-gold);
  font-weight: 700;
  margin-bottom: 3px;
}

.tarot-lucky-value {
  display: block;
  font-size: 12.5px;
  color: #ffffff;
  font-weight: 700;
}

/* ── 22장 갤러리 (하단 소개 섹션) ──────────────── */
.tarot-gallery {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.tarot-gallery-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
}

.tarot-gallery-icon {
  color: #b8935a;
}

.tarot-gallery-name {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text-sub);
  text-align: center;
  line-height: 1.3;
}

@media (max-width: 560px) {
  .tarot-card-slot {
    width: 80px;
  }

  .tarot-card-slot.is-selected {
    transform: scale(1.08);
  }

  .tarot-gallery {
    grid-template-columns: repeat(4, 1fr);
  }

  .tarot-message-title {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tarot-card-slot.is-entering,
  .tarot-result,
  .tarot-particle {
    animation: none !important;
  }

  .tarot-card-slot.is-entering {
    opacity: 1;
    transform: none;
  }
}

/* ── 섹션 제목 행 - 정보 모달 여는 햄버거 버튼 ──────── */
.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-row .card-title {
  margin: 0;
  flex: 1 1 auto;
}

.card-title--with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tarot-section-icon {
  flex-shrink: 0;
  display: block;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(15, 26, 51, 0.12);
}

.quote-cookie-reset--with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.section-info-toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.section-info-toggle:active {
  transform: scale(0.96);
}

/* ── 정보 모달 (메이저 아르카나 22장 + 안내) ─────────
   모바일: 화면 하단에서 올라오는 시트. 데스크톱(561px~): 가운데 다이얼로그.
   본문(.info-modal-body)만 스크롤되고 헤더는 항상 보여서 닫기 버튼이 절대
   화면 밖으로 밀려나거나 잘리지 않는다. */
.info-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.info-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.info-modal-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-height: 85vh;
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card-hover);
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
  flex: 0 0 auto;
}

.info-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.info-modal-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text-sub);
  font-size: 15px;
  cursor: pointer;
}

.info-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

.info-modal-section + .info-modal-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

@media (min-width: 561px) {
  .info-modal-panel {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100% - 40px));
    max-height: 80vh;
    border-radius: var(--radius-lg);
  }
}

/* ── 결과 하단 툴바(이미지 저장/공유) ─────────────────
   .lotto-toolbar는 다른 페이지(css/apps/lotto-picker.css)에서 정의된
   클래스인데 이 페이지는 그 파일을 불러오지 않으므로 여기에도 동일하게
   정의해서 항상 스타일이 적용되게 한다. */
.lotto-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  flex-wrap: wrap;
}

.lotto-toolbar .btn {
  flex: 1 1 auto;
  min-width: 120px;
}

#fortuneCanvas {
  display: none;
}
