/* ============================================
   塔罗牌占卜 - 主样式表
   温暖简约风 + 响应式设计
   ============================================ */

:root {
  --bg: #faf6f0;
  --bg-warm: #f7f1e8;
  --panel: #fffbf6;
  --text: #3e2d25;
  --text-secondary: #6b5a4e;
  --muted: #9b897a;
  --accent: #c49a72;
  --accent-strong: #ad7a49;
  --accent-deep: #8b5e34;
  --accent-light: #e8d5c0;
  --border: rgba(62, 45, 37, 0.1);
  --shadow-sm: 0 2px 8px rgba(88, 62, 48, 0.06);
  --shadow: 0 8px 30px rgba(88, 62, 48, 0.08);
  --shadow-lg: 0 18px 50px rgba(88, 62, 48, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: linear-gradient(175deg, #faf6f0 0%, #f5ede0 40%, #f0e5d5 100%);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  width: min(720px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

/* ---------- 头部 ---------- */
.app-header { text-align: center; padding: 2rem 0 1.5rem; }
.app-title { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: 0.06em; }
.app-subtitle { margin-top: 0.4rem; font-size: 0.95rem; color: var(--muted); letter-spacing: 0.1em; }

/* ---------- 步骤指示器 ---------- */
.steps-indicator { display: flex; align-items: center; justify-content: center; padding: 0.5rem 0 2rem; }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-light); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600; transition: all var(--transition);
}
.step-dot.active { background: var(--accent-strong); color: #fff; box-shadow: 0 4px 12px rgba(173,122,73,0.3); }
.step-dot.done { background: var(--accent); color: #fff; }
.step-line { width: 36px; height: 2px; background: var(--accent-light); transition: background var(--transition); }
.step-line.done { background: var(--accent); }

/* ---------- 步骤面板 ---------- */
.step { display: none; animation: fadeSlideIn 0.4s ease; }
.step.active { display: block; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.step-title { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: 0.3rem; }
.step-desc { text-align: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 1.8rem; }

/* ---------- 牌阵卡片 ---------- */
.spread-cards { display: flex; flex-direction: column; gap: 0.7rem; }

.spread-card {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.8rem 1rem;
  box-shadow: var(--shadow-sm); cursor: pointer; transition: all var(--transition);
}
.spread-card:hover { box-shadow: var(--shadow); border-color: var(--accent); transform: translateY(-1px); }
.spread-card.selected { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(173,122,73,0.15); background: #fefaf5; }
.spread-preview { flex-shrink: 0; }
.spread-preview svg { display: block; max-height: 55px; width: auto; }
.spread-info { flex: 1; min-width: 0; }
.spread-name { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.15rem; }
.spread-desc-text { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.4; margin-bottom: 0.35rem; }
.spread-rule {
  font-size: 0.73rem; color: var(--muted); line-height: 1.4;
  padding: 0.35rem 0.5rem; background: rgba(196,154,114,0.08); border-radius: 6px;
}
.spread-rule strong { color: var(--accent-strong); }

/* ---------- 抽牌方式选择 ---------- */
.draw-mode-section {
  margin-top: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
}

.draw-mode-title {
  font-size: 0.95rem; font-weight: 600; margin-bottom: 1rem; text-align: center;
}

.draw-mode-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}

.draw-mode-card { cursor: pointer; }
.draw-mode-card input { display: none; }

.mode-content {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 1rem 0.8rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); text-align: center;
  background: #fefbf8; transition: all var(--transition);
}
.mode-content:hover { border-color: var(--accent); }

.draw-mode-card input:checked + .mode-content {
  border-color: var(--accent-strong);
  background: #fef8f2;
  box-shadow: 0 2px 8px rgba(173,122,73,0.15);
}

.mode-icon { color: var(--accent-strong); }
.mode-label { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.mode-desc { font-size: 0.75rem; color: var(--muted); line-height: 1.4; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
  padding: 0.75rem 1.5rem; border-radius: 50px; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; border: none; transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--accent-strong); color: #fff; box-shadow: 0 4px 14px rgba(173,122,73,0.25); }
.btn-primary:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(173,122,73,0.35); }
.btn-outline { background: transparent; color: var(--accent-strong); border: 1.5px solid var(--accent-strong); padding: 0.5rem 1.2rem; font-size: 0.85rem; flex-shrink: 0; }
.btn-outline:hover { background: var(--accent-strong); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); padding: 0.6rem 1rem; font-size: 0.9rem; }
.btn-ghost:hover { color: var(--text); background: rgba(62,45,37,0.04); }

/* ---------- 步骤2 ---------- */
.category-label, .question-label {
  display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.7rem; color: var(--text);
}
.category-chips { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.category-chip { cursor: pointer; }
.category-chip input { display: none; }
.chip-content {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1.3rem; border: 1.5px solid var(--border);
  border-radius: 50px; background: var(--panel); color: var(--text-secondary);
  transition: all var(--transition); font-weight: 500; font-size: 0.9rem;
}
.category-chip input:checked + .chip-content {
  border-color: var(--accent-strong); background: #fef8f2;
  color: var(--accent-strong); box-shadow: 0 2px 8px rgba(173,122,73,0.15);
}
.chip-icon { display: flex; align-items: center; color: inherit; }

.question-group { margin-top: 1.5rem; }
.question-hint { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }
.question-input {
  width: 100%; padding: 0.9rem 1rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font: inherit; font-size: 0.9rem;
  background: var(--panel); color: var(--text); resize: vertical;
  min-height: 80px; transition: border-color var(--transition);
}
.question-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,154,114,0.1); }
.question-input::placeholder { color: #c4b5a5; }
.question-count { display: block; text-align: right; font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }
.step-actions { display: flex; justify-content: center; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }

/* ---------- 步骤3：抽牌 ---------- */
.draw-grid { display: grid; gap: 1.2rem; justify-content: center; padding: 0.5rem 0; }

/* 随机模式 - 单张 */
.draw-grid.single { grid-template-columns: min(220px, 60vw); }
/* 随机模式 - 三张 */
.draw-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 500px; margin: 0 auto; }
/* 自选模式 - 6张牌 */
.draw-grid.selfpick {
  grid-template-columns: repeat(3, 1fr);
  max-width: 520px; margin: 0 auto; gap: 1rem;
}

/* 自选模式 - 牌面正面展示 */
.tarot-card.face-up {
  cursor: pointer; transition: all var(--transition);
}
.tarot-card.face-up:hover {
  transform: translateY(-3px);
}

.tarot-card-front-visible {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(88,62,48,0.12);
  transition: all var(--transition);
}
.tarot-card-front-visible img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.tarot-card-front-visible .card-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #fef9f3, #fdf5ec);
  font-size: 0.9rem; font-weight: 600; color: var(--accent-strong);
}

.pick-check-mark {
  display: none; position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  background: var(--accent-strong); color: #fff;
  border-radius: 50%; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pick-order-badge {
  position: absolute; top: 8px; left: 8px;
  width: 26px; height: 26px;
  background: var(--accent-deep); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pick-card-name {
  text-align: center; font-size: 0.78rem; color: var(--muted);
  margin-top: 0.4rem; font-weight: 500;
}

/* 选中状态 */
.tarot-card.picked .tarot-card-front-visible {
  box-shadow: 0 0 0 3px var(--accent-strong), 0 12px 30px rgba(173,122,73,0.25);
}
.tarot-card.picked .pick-check-mark {
  display: flex;
}
.tarot-card.picked .pick-card-name {
  color: var(--accent-strong); font-weight: 600;
}
  perspective: 800px; cursor: pointer;
}

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

.tarot-card-front, .tarot-card-back {
  position: absolute; inset: 0;
  backface-visibility: hidden; border-radius: 12px; overflow: hidden;
}

/* 牌背 */
.tarot-card-back {
  background: linear-gradient(145deg, #c9a87c 0%, #b8915e 30%, #a67c4a 60%, #8b6534 100%);
  border: 4px solid #7a5528;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 25px rgba(88,62,48,0.15);
}
.tarot-card-back-inner {
  width: calc(100% - 20px); height: calc(100% - 20px);
  border: 2px solid rgba(255,255,255,0.2); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
}
.card-back-star { font-size: 2rem; color: rgba(255,255,255,0.5); }
.card-back-text { font-size: 0.8rem; color: rgba(255,255,255,0.55); letter-spacing: 0.15em; }

/* 牌面 */
.tarot-card-front {
  background: #fff; transform: rotateY(180deg);
  box-shadow: 0 8px 25px rgba(88,62,48,0.15);
  display: flex; align-items: center; justify-content: center;
}
.tarot-card-front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tarot-card-front .card-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 1rem; text-align: center; font-size: 1rem; font-weight: 600;
  color: var(--accent-strong); background: linear-gradient(180deg, #fef9f3, #fdf5ec);
}

/* 抽牌位置标签 */
.draw-position-label { text-align: center; font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; font-weight: 500; }

/* 确认按钮脉冲动画 */
#pick-confirm-btn { animation: pulse 1.5s ease infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(173,122,73,0.25); }
  50% { box-shadow: 0 8px 30px rgba(173,122,73,0.45); }
}

/* ---------- 步骤4：结果 ---------- */

/* 综合解读 */
.result-summary {
  background: linear-gradient(135deg, #fef8f2, #fdf3e8);
  border: 1.5px solid var(--accent-light);
  border-radius: var(--radius);
  padding: 1.5rem; margin-bottom: 1.5rem;
}
.result-summary h3 {
  font-size: 1.05rem; color: var(--accent-strong); margin-bottom: 0.8rem;
  text-align: center;
}
.result-summary p {
  font-size: 0.9rem; color: var(--text-secondary); line-height: 1.9;
}

/* 单张牌结果 */
.result-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 1.2rem; box-shadow: var(--shadow-sm);
}
.result-card-img-large {
  width: 100%; border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden; cursor: pointer; background: #fdf5ec;
}
.result-card-img-large img {
  width: 100%; max-height: 220px; object-fit: contain; display: block;
}
.result-card-img-large:hover img {
  transform: scale(1.02); transition: transform 0.3s ease;
}

.result-card-header {
  display: flex; align-items: flex-start; gap: 1.2rem;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
}
.result-card-img {
  width: 100px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  box-shadow: 0 4px 12px rgba(88,62,48,0.12);
  cursor: pointer; transition: transform var(--transition);
}
.result-card-img:hover { transform: scale(1.05); }
.result-card-img img { width: 100%; display: block; }
.result-card-title { flex: 1; }
.result-position {
  display: inline-block; font-size: 0.75rem; font-weight: 600;
  color: var(--accent-strong); background: rgba(196,154,114,0.12);
  padding: 0.2rem 0.7rem; border-radius: 50px; margin-bottom: 0.4rem;
}
.result-card-name { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.2rem; }
.result-card-keywords { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.keyword-tag {
  font-size: 0.75rem; color: var(--text-secondary);
  background: rgba(196,154,114,0.08); padding: 0.15rem 0.6rem; border-radius: 50px;
}
.result-card-body { padding: 1.2rem; }
.result-card-body h4 {
  font-size: 0.9rem; font-weight: 600; color: var(--accent-strong); margin: 1.1rem 0 0.4rem;
}
.result-card-body h4:first-child { margin-top: 0; }
.result-card-body p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.8; }

/* 针对问题的建议区块 */
.advice-box {
  background: linear-gradient(135deg, rgba(196,154,114,0.08), rgba(196,154,114,0.03));
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  padding: 1rem 1.2rem; margin-top: 1rem;
}
.advice-box h4 { color: var(--accent-deep); margin-top: 0 !important; }
.advice-box p { font-size: 0.9rem; line-height: 1.8; }

/* ---------- 弹窗 ---------- */
.modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  align-items: center; justify-content: center;
}
.modal.active { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(30,18,8,0.7); }
.modal-content { position: relative; z-index: 1; max-width: 90vw; max-height: 90vh; }
.modal-content img { max-width: 100%; max-height: 85vh; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-close {
  position: absolute; top: -40px; right: 0; background: none;
  border: none; color: #fff; font-size: 2rem; cursor: pointer; line-height: 1;
}

/* ---------- 响应式 ---------- */
@media (max-width: 520px) {
  .app-container { padding: 1rem 0.75rem 3rem; }
  .app-header { padding: 1rem 0; }

  .spread-card { flex-direction: column; align-items: stretch; text-align: center; gap: 0.4rem; padding: 0.7rem; }
  .spread-preview { display: flex; justify-content: center; }
  .spread-preview svg { max-width: 80px; height: auto; }
  .btn-outline { align-self: center; }

  .draw-mode-options { grid-template-columns: 1fr; }

  .draw-grid.three { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .draw-grid.selfpick { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }

  .result-card-header { flex-direction: column; align-items: center; text-align: center; }
  .result-card-img-large img { max-height: 180px; }
  .result-card-keywords { justify-content: center; }
  .step-actions { flex-direction: column; align-items: center; }
}

@media (min-width: 521px) and (max-width: 768px) {
  .draw-grid.selfpick { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 动画 ---------- */
@keyframes cardReveal {
  from { opacity: 0; transform: scale(0.9) rotateY(90deg); }
  to { opacity: 1; transform: scale(1) rotateY(0deg); }
}
.tarot-card.flipped .tarot-card-front { animation: cardReveal 0.5s ease backwards; }
