/* ═══════════════════════════════════════
   愈见自己 OH卡AI助手 — 样式表
   ═══════════════════════════════════════ */

/* ====== 基础重置与全局 ====== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&display=swap');

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

:root {
  --bg-deep: #080812;
  --bg-dark: #0e0e1e;
  --bg-card: #12122a;
  --gold: #d4b896;
  --gold-light: #e8d5b7;
  --gold-dim: #a08a6c;
  --text-primary: #e8e4df;
  --text-secondary: #9a96a6;
  --text-muted: #5e5a6e;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --chat-ai-bg: rgba(212, 184, 150, 0.06);
  --chat-user-bg: rgba(100, 120, 180, 0.12);
  --shadow-glow: rgba(212, 184, 150, 0.08);
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Noto Serif SC', 'Georgia', 'Songti SC', serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ====== 星空粒子背景 ====== */
.stars-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(232, 213, 183, 0.6);
  border-radius: 50%;
  animation: twinkle var(--duration, 3s) infinite alternate ease-in-out;
  animation-delay: var(--delay, 0s);
}

@keyframes twinkle {
  0% { opacity: 0.1; transform: scale(0.8); }
  100% { opacity: 0.9; transform: scale(1.2); }
}

/* ====== 页面状态容器 ====== */
.page {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.page.active {
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════
   第一屏：口令验证页
   ═══════════════════════════════════════ */
#page-verify {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 30px;
}

.verify-container {
  max-width: 360px;
  width: 100%;
}

.verify-logo {
  font-size: 3rem;
  margin-bottom: 20px;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.verify-title {
  font-size: 1.6rem;
  color: var(--gold-light);
  letter-spacing: 6px;
  margin-bottom: 8px;
  font-weight: 700;
}

.verify-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-bottom: 40px;
}

.verify-input-group {
  position: relative;
  margin-bottom: 20px;
}

.verify-input {
  width: 100%;
  padding: 14px 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 2px;
  text-align: center;
  transition: all 0.3s var(--transition-smooth);
  outline: none;
}

.verify-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 1px;
}

.verify-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 20px var(--shadow-glow);
}

.verify-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, rgba(212, 184, 150, 0.15), rgba(212, 184, 150, 0.08));
  border: 1px solid rgba(212, 184, 150, 0.3);
  border-radius: 12px;
  color: var(--gold-light);
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.3s var(--transition-smooth);
}

.verify-btn:hover {
  background: linear-gradient(135deg, rgba(212, 184, 150, 0.25), rgba(212, 184, 150, 0.15));
  border-color: rgba(212, 184, 150, 0.5);
  box-shadow: 0 4px 20px var(--shadow-glow);
}

.verify-btn:active {
  transform: scale(0.98);
}

.verify-error {
  margin-top: 15px;
  color: #e8a0a0;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s;
}

.verify-error.show {
  opacity: 1;
}

.verify-contact {
  margin-top: 30px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.verify-contact a {
  color: var(--gold-dim);
  text-decoration: none;
}

/* ═══════════════════════════════════════
   第二屏：抽卡页
   ═══════════════════════════════════════ */
#page-draw {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 30px;
}

.draw-welcome {
  max-width: 400px;
  margin-bottom: 50px;
}

.draw-welcome h2 {
  font-size: 1.4rem;
  color: var(--gold-light);
  letter-spacing: 4px;
  margin-bottom: 20px;
  font-weight: 600;
}

.draw-welcome p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
  letter-spacing: 1px;
}

.draw-btn-container {
  position: relative;
}

.draw-btn {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%,
    rgba(212, 184, 150, 0.12) 0%,
    rgba(212, 184, 150, 0.04) 60%,
    transparent 100%);
  border: 1.5px solid rgba(212, 184, 150, 0.3);
  color: var(--gold-light);
  font-family: inherit;
  font-size: 1.3rem;
  letter-spacing: 6px;
  cursor: pointer;
  transition: all 0.4s var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.draw-btn::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent,
    rgba(212, 184, 150, 0.1),
    transparent,
    rgba(212, 184, 150, 0.05),
    transparent
  );
  animation: rotate-glow 6s linear infinite;
  z-index: -1;
}

@keyframes rotate-glow {
  to { transform: rotate(360deg); }
}

.draw-btn:hover {
  border-color: rgba(212, 184, 150, 0.6);
  box-shadow: 0 0 40px rgba(212, 184, 150, 0.12), 0 0 80px rgba(212, 184, 150, 0.05);
  transform: scale(1.06);
}

.draw-btn:active {
  transform: scale(0.97);
}

.draw-btn.loading {
  pointer-events: none;
  animation: pulse-draw 1.5s ease-in-out infinite;
}

@keyframes pulse-draw {
  0%, 100% { box-shadow: 0 0 20px rgba(212, 184, 150, 0.1); }
  50% { box-shadow: 0 0 50px rgba(212, 184, 150, 0.2); }
}

.draw-hint {
  margin-top: 30px;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ═══════════════════════════════════════
   第三屏：主页面（卡牌 + 对话 分屏）
   ═══════════════════════════════════════ */
#page-main {
  height: 100%;
  overflow: hidden;
}

/* — 卡牌展示区（固定顶部） — */
.card-display {
  width: 100%;
  height: 38vh;
  min-height: 200px;
  max-height: 340px;
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-card) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  flex-shrink: 0;
  border-bottom: 1px solid var(--glass-border);
  overflow: hidden;
}

/* 卡牌区的微光效果 */
.card-display::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(212, 184, 150, 0.06), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.card-image-wrapper {
  position: relative;
  height: 85%;
  max-width: 85%;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: card-appear 1s var(--transition-smooth) forwards;
  opacity: 0;
}

@keyframes card-appear {
  from {
    opacity: 0;
    transform: scale(0.8) rotateY(30deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotateY(0deg);
  }
}

.card-image {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(212, 184, 150, 0.06);
}

.card-number {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: 10px;
}

/* 卡牌区折叠/展开控制 */
.card-toggle {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(50%);
  width: 36px;
  height: 20px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: 0 0 10px 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 5;
  color: var(--text-muted);
  font-size: 0.6rem;
  transition: all 0.3s;
}

.card-toggle:hover {
  color: var(--gold-dim);
  border-color: var(--gold-dim);
}

.card-display.collapsed {
  height: 60px;
  min-height: 60px;
}

.card-display.collapsed .card-image-wrapper {
  height: 50px;
}

.card-display.collapsed .card-image {
  max-height: 50px;
  border-radius: 6px;
}

/* — 对话区域 — */
.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  padding-bottom: 90px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* 滚动条美化 */
.chat-area::-webkit-scrollbar {
  width: 3px;
}

.chat-area::-webkit-scrollbar-thumb {
  background: rgba(212, 184, 150, 0.15);
  border-radius: 3px;
}

/* 消息气泡 */
.message {
  margin-bottom: 16px;
  animation: msg-appear 0.5s var(--transition-smooth) forwards;
  opacity: 0;
}

@keyframes msg-appear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-ai {
  padding: 16px 18px;
  background: var(--chat-ai-bg);
  border-radius: 4px 16px 16px 16px;
  border: 1px solid rgba(212, 184, 150, 0.06);
  max-width: 88%;
}

.message-ai .message-label {
  font-size: 0.7rem;
  color: var(--gold-dim);
  letter-spacing: 2px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.message-ai .message-text {
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.message-user {
  padding: 14px 18px;
  background: var(--chat-user-bg);
  border-radius: 16px 4px 16px 16px;
  max-width: 80%;
  margin-left: auto;
}

.message-user .message-text {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-primary);
}

/* AI 打字中动画 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 16px 18px;
  background: var(--chat-ai-bg);
  border-radius: 4px 16px 16px 16px;
  border: 1px solid rgba(212, 184, 150, 0.06);
  max-width: 100px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--gold-dim);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-6px); opacity: 0.8; }
}

/* — 底部输入栏 — */
.input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent 0%, var(--bg-dark) 20%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  gap: 10px;
  z-index: 20;
}

.input-field {
  flex: 1;
  padding: 12px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.3s;
  min-height: 44px;
  resize: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-field:focus {
  border-color: var(--gold-dim);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(212, 184, 150, 0.2), rgba(212, 184, 150, 0.1));
  border: 1px solid rgba(212, 184, 150, 0.3);
  color: var(--gold-light);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.send-btn:hover {
  background: linear-gradient(135deg, rgba(212, 184, 150, 0.3), rgba(212, 184, 150, 0.15));
  box-shadow: 0 2px 12px var(--shadow-glow);
}

.send-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.send-btn:active {
  transform: scale(0.92);
}


/* ====== Toast 提示 ====== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(20, 20, 40, 0.9);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  padding: 10px 24px;
  border-radius: 24px;
  color: var(--gold-light);
  font-size: 0.82rem;
  letter-spacing: 1px;
  transition: transform 0.4s var(--transition-smooth);
  z-index: 999;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ====== 全局响应式 ====== */
@media (max-width: 380px) {
  .verify-title { font-size: 1.3rem; letter-spacing: 4px; }
  .draw-btn { width: 150px; height: 150px; font-size: 1.1rem; }
  .card-display { height: 34vh; }
}

@media (min-width: 768px) {
  /* 平板/桌面端：限制最大宽度 */
  #page-main {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
  }

  .input-bar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ====== 页面切换动画 ====== */
.page.fade-in {
  animation: page-fade-in 0.6s var(--transition-smooth) forwards;
}

@keyframes page-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ═══════════════════════════════════════
   翻牌仪式动画
   ═══════════════════════════════════════ */
.flip-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 4, 14, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  animation: overlay-in 0.6s var(--transition-smooth) forwards;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.flip-overlay.out {
  animation: overlay-out 0.8s var(--transition-smooth) forwards;
}

@keyframes overlay-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.flip-card-container {
  width: 220px;
  height: 320px;
  perspective: 1200px;
}

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

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

.flip-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 80px rgba(212, 184, 150, 0.08);
}

.flip-back {
  background: linear-gradient(145deg, #1a1540, #0e1a35);
  border: 2px solid rgba(212, 184, 150, 0.25);
  display: flex;
  justify-content: center;
  align-items: center;
}

.flip-back-inner {
  width: 180px;
  height: 280px;
  border: 1px solid rgba(212, 184, 150, 0.15);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.2rem;
  letter-spacing: 6px;
  color: var(--gold);
  font-family: inherit;
}

.flip-front {
  transform: rotateY(180deg);
  background: #0a0a18;
  border: 2px solid rgba(212, 184, 150, 0.2);
}

.flip-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

/* 翻牌光芒 */
.flip-glow {
  position: absolute;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(212, 184, 150, 0.15), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s;
}

.flip-glow.active {
  opacity: 1;
  animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
}

/* ═══════════════════════════════════════
   七步进度条
   ═══════════════════════════════════════ */
.step-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--bg-card), transparent);
  position: sticky;
  top: 0;
  z-index: 10;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(212, 184, 150, 0.12);
  border: 1px solid rgba(212, 184, 150, 0.15);
  transition: all 0.5s var(--transition-smooth);
  position: relative;
}

.step-dot.active {
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-color: var(--gold-light);
  box-shadow: 0 0 10px rgba(212, 184, 150, 0.4);
}

.step-dot.done {
  background: rgba(212, 184, 150, 0.4);
  border-color: var(--gold-dim);
}

.step-line {
  width: 16px;
  height: 1px;
  background: rgba(212, 184, 150, 0.1);
  transition: background 0.5s;
}

.step-line.done {
  background: rgba(212, 184, 150, 0.3);
}

.step-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-left: 8px;
}

/* ═══════════════════════════════════════
   打字光标效果
   ═══════════════════════════════════════ */
.typing-cursor::after {
  content: '▍';
  color: var(--gold-dim);
  animation: blink-cursor 0.8s infinite;
  margin-left: 1px;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ═══════════════════════════════════════
   引导完成总结卡片
   ═══════════════════════════════════════ */
.session-complete {
  text-align: center;
  padding: 24px 20px;
  margin-top: 16px;
  animation: msg-appear 0.8s var(--transition-smooth) forwards;
  opacity: 0;
}

.summary-card {
  background: linear-gradient(145deg, rgba(212, 184, 150, 0.06), rgba(212, 184, 150, 0.02));
  border: 1px solid rgba(212, 184, 150, 0.12);
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 20px;
  text-align: center;
}

.summary-card .summary-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.summary-card .summary-title {
  font-size: 0.95rem;
  color: var(--gold-light);
  letter-spacing: 3px;
  margin-bottom: 14px;
}

.summary-card .summary-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.summary-card .summary-divider {
  width: 40px;
  height: 1px;
  background: rgba(212, 184, 150, 0.2);
  margin: 16px auto;
}

.complete-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

/* ═══════════════════════════════════════
   卡牌区光晕动画
   ═══════════════════════════════════════ */
.card-display::after {
  content: '';
  position: absolute;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(212, 184, 150, 0.04), transparent 70%);
  border-radius: 50%;
  animation: ambient-glow 5s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes ambient-glow {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1.3); opacity: 1; }
}
