/* ===== 六爻占卜 样式 ===== */
/* 配色：白色 / 银色 / 米色 / 灰色 */

:root {
  --bg: #f4f1ea;            /* 米色背景 */
  --bg-grad-1: #f7f4ed;
  --bg-grad-2: #ece8df;
  --card: #ffffff;           /* 白色卡片 */
  --card-2: #fbfaf7;
  --silver: #c9c9ce;         /* 银色 */
  --silver-light: #e6e6ea;
  --silver-dark: #9b9ba1;
  --beige: #efeae0;          /* 米色 */
  --beige-deep: #e2dccf;
  --text: #2c2c31;           /* 深灰文字 */
  --text-2: #5e5e66;         /* 中灰 */
  --text-3: #9a9aa2;         /* 浅灰 */
  --line: #34343a;           /* 爻线 */
  --line-soft: #4a4a52;
  --border: #e4dfd5;         /* 边框 */
  --border-2: #d8d3c8;
  --accent: #8a8a92;         /* 强调银灰 */
  --shadow-sm: 0 2px 10px rgba(120, 110, 90, 0.06);
  --shadow-md: 0 8px 28px rgba(120, 110, 90, 0.09);
  --shadow-lg: 0 14px 44px rgba(120, 110, 90, 0.12);
  --ease: cubic-bezier(0.4, 0.15, 0.2, 1);
  --ease-soft: cubic-bezier(0.32, 0.12, 0.24, 1);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  min-height: 100%;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-grad-1), transparent 70%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  min-height: 100vh;
}

/* 微妙的纹理底纹 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(200,195,180,0.10), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(180,180,190,0.08), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 18px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== 顶部标题 ===== */
.header {
  text-align: center;
  margin-bottom: 22px;
  animation: fadeDown 0.7s var(--ease) both;
}
.logo {
  display: inline-flex;
  width: 56px; height: 56px;
  color: var(--silver-dark);
  margin-bottom: 10px;
  animation: spinSlow 24s linear infinite;
}
.logo-svg { width: 100%; height: 100%; }
.title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 8px;
  color: var(--text);
  margin-right: -8px; /* 抵消末字间距 */
}
.subtitle {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 4px;
  margin-top: 6px;
}

/* ===== 主区域 ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 通用卡片 */
.hexagram-card,
.cast-card,
.reading {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

/* ===== 卦象显示卡片 ===== */
.hexagram-card {
  padding: 20px 22px 22px;
  animation: fadeUp 0.7s 0.1s var(--ease) both;
}
.hexagram-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.hex-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text);
}
.hex-progress {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 1px;
  background: var(--beige);
  padding: 4px 10px;
  border-radius: 10px;
}

/* 爻象舞台：纵向排列，上爻在顶，初爻在底（column-reverse 使 append 即初爻在底） */
.yao-stage {
  display: flex;
  flex-direction: column-reverse;
  gap: 14px;
  align-items: center;
  padding: 18px 0 14px;
  min-height: 240px;
  justify-content: flex-start;
}

.yao-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 320px;
  opacity: 0;
  transform: scale(0.88);
  animation: yaoIn 0.5s var(--ease) forwards;
}
.yao-pos {
  width: 26px;
  flex-shrink: 0;
  text-align: center;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--text-3);
  letter-spacing: 1px;
}
.yao-bar {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 22px;
  position: relative;
}
.yao-bar .seg {
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--line), var(--line-soft));
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
/* 阳爻：一整条 */
.yao-bar.yang .seg { width: 80%; }
/* 阴爻：两段，中间留空 */
.yao-bar.yin .seg { width: 36%; }
.yao-bar.yin .seg.left { margin-right: 8%; }

.yao-mark {
  width: 24px;
  flex-shrink: 0;
  text-align: center;
  font-size: 14px;
  font-family: var(--serif);
  color: var(--silver-dark);
}
.yao-row.changing .yao-mark { color: #a07b5c; }
.yao-row.changing .seg {
  background: linear-gradient(180deg, #5a5a62, #6a6a72);
  animation: pulseLine 1.8s var(--ease) infinite;
}

.yao-empty {
  color: var(--silver-light);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 40px 0;
}

.hex-symbol {
  text-align: center;
  font-size: 22px;
  color: var(--silver-dark);
  letter-spacing: 2px;
  margin-top: 8px;
  min-height: 22px;
  font-family: var(--serif);
}

/* ===== 掷爻卡片 ===== */
.cast-card {
  padding: 26px 22px 24px;
  text-align: center;
  animation: fadeUp 0.7s 0.2s var(--ease) both;
}
.coins {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-bottom: 18px;
  min-height: 76px;
  align-items: center;
}

/* 硬币 */
.coin {
  width: 68px; height: 68px;
  perspective: 240px;
}
.coin-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 1.5s var(--ease);
}
.coin.flipping .coin-inner {
  transition: none;
}
.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.6),
    inset 0 -2px 6px rgba(120,110,90,0.18),
    0 4px 10px rgba(120,110,90,0.15);
}
/* 阳面（正面/字） */
.coin-front {
  background: radial-gradient(circle at 35% 30%, #f3efe6, #e0d9cb 70%, #cfc7b6);
  border: 1.5px solid #b8ad97;
}
.coin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6a6356, #34302a);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
/* 阴面（反面/背） */
.coin-back {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 35% 30%, #e8e6e0, #cfcdc6 70%, #b6b4ad);
  border: 1.5px solid #9a988f;
}
.coin-ring {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2.5px solid #5a584f;
  background: transparent;
}

.coin.shaking { animation: shake 0.3s var(--ease); }

.cast-tip {
  font-size: 13px;
  color: var(--text-2);
  letter-spacing: 1px;
  margin-bottom: 18px;
  min-height: 18px;
  transition: opacity 0.3s;
}
.cast-tip.result { color: var(--text); font-family: var(--serif); }

.cast-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.btn {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 3px;
  padding: 12px 32px;
  border: none;
  border-radius: 28px;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  font-weight: 500;
}
.btn-primary {
  background: linear-gradient(180deg, #4a4a52, #34343a);
  color: #f4f1ea;
  box-shadow: 0 6px 16px rgba(60,55,45,0.22), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(60,55,45,0.28); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: linear-gradient(180deg, #c9c9ce, #b6b6bb);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--beige); }

/* ===== 解读区 ===== */
.reading {
  padding: 22px;
  animation: fadeUp 0.7s 0.3s var(--ease) both;
}
.reading-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.reading-block {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}
.reading-block.reading-bian {
  border-color: var(--beige-deep);
  background: linear-gradient(180deg, #fbf9f3, #f5f1e8);
}
.rb-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.rb-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text);
  margin-bottom: 4px;
}
.rb-symbol {
  font-size: 18px;
  color: var(--silver-dark);
  letter-spacing: 2px;
  margin-bottom: 10px;
  font-family: var(--serif);
}
.rb-judge {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-2);
  letter-spacing: 0.5px;
}

.reading-yao {
  margin-top: 18px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #f7f3ea, #f1ece0);
  border: 1px solid var(--beige-deep);
  border-radius: 14px;
}
.ry-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: #9a7b5c;
  margin-bottom: 8px;
}
.ry-name {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.ry-text {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.9;
  color: var(--text-2);
  letter-spacing: 0.5px;
}

.reading-image {
  margin-top: 18px;
  padding: 16px 18px;
  border-top: 1px dashed var(--border-2);
}
.ri-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.ri-text {
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--text-3);
  letter-spacing: 0.5px;
}

/* ===== 页脚 ===== */
.footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 3px;
  opacity: 0.7;
}

/* ===== 动画 ===== */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes yaoIn {
  from { opacity: 0; transform: scale(0.88); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes spinSlow {
  to { transform: rotate(360deg); }
}
@keyframes pulseLine {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(2deg); }
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .app { padding: 22px 14px 32px; }
  .title { font-size: 22px; letter-spacing: 6px; }
  .hexagram-card, .cast-card, .reading { padding: 18px 16px; border-radius: 16px; }
  .coin { width: 60px; height: 60px; }
  .coins { gap: 18px; }
  .yao-row { gap: 10px; }
  .yao-bar.yang .seg { width: 84%; }
  .yao-bar.yin .seg { width: 38%; }
  .btn { padding: 11px 26px; font-size: 14px; letter-spacing: 2px; }
  .rb-name { font-size: 17px; }
}

@media (max-width: 360px) {
  .coin { width: 54px; height: 54px; }
  .coins { gap: 14px; }
  .title { font-size: 20px; letter-spacing: 5px; }
}

/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
