/* =========================================================
 * enhance.css — 视觉升级层（附加于 app.css / pages.css 之后）
 * 目标：不改动既有样式，通过更高优先级 / 新类名叠加优化
 *   1. 配色降饱和（朱砂 + 墨玉 + 绢帛）
 *   2. 命主速览 Hero 卡（一屏结论）
 *   3. 紫微 4×4 传统盘布局
 *   4. 深度解读章节 chip 目录
 *   5. 起卦 loading 动画
 *   6. 卡片主次分级
 * ========================================================= */

:root {
  /* 宣纸屏幕 · Paper & Pixel — 令牌收敛为焦墨 + 朱砂 */
  --ll-ink:      #1A1613;              /* 焦墨主色 */
  --ll-green:    #1A1613;              /* 原“主绿” → 焦墨 */
  --ll-green-2:  #2A2420;
  --ll-cinnabar: #8B2323;              /* 朱砂（印章级 <3%） */
  --ll-cinnabar-2: #A03535;
  --ll-silk:     #F8F5EE;              /* 宣纸 */
  --ll-silk-2:   #FBF9F3;
  --ll-gold-2:   #1A1613;              /* 金 → 焦墨 */
  --ll-brown:    rgba(26,22,19,.55);
  --ll-brown-2:  rgba(26,22,19,.40);

  --ll-shadow-hero: 0 10px 30px rgba(26,22,19,.14), 0 2px 6px rgba(26,22,19,.06);
  --ll-shadow-soft: 0 4px 16px rgba(26,22,19,.08);
}

/* ============ 1. Hero 命主速览卡 ============ */
.ll-hero {
  position: relative;
  background:
    radial-gradient(1200px 200px at 100% 0%, rgba(184,134,11,.10), transparent 60%),
    linear-gradient(135deg, #ffffff 0%, #fbf6ea 100%);
  border: 1px solid rgba(184,134,11,.28);
  border-radius: 18px;
  padding: 18px 18px 14px;
  margin: 12px 0 16px;
  box-shadow: var(--ll-shadow-hero);
  overflow: hidden;
}

.ll-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ll-cinnabar), var(--ll-gold-2), var(--ll-green));
  opacity: .8;
}

.ll-hero-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 6px;
}

.ll-hero-title {
  font-family: var(--font-song), serif;
  font-size: 15px;
  color: var(--ll-brown);
  letter-spacing: 3px;
}

.ll-hero-title::before {
  content: '❖ ';
  color: var(--ll-cinnabar);
  margin-right: 2px;
}

.ll-hero-sub {
  font-size: 12px;
  color: var(--ll-brown-2);
  letter-spacing: 1px;
}

.ll-hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.ll-hero-cell {
  position: relative;
  background: linear-gradient(180deg, #fffdf6 0%, #f7ecd6 100%);
  border: 1px solid rgba(184,134,11,.22);
  border-radius: 12px;
  padding: 12px 6px 10px;
  text-align: center;
  transition: transform .2s, box-shadow .2s;
}

.ll-hero-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(94,71,51,.10);
}

.ll-hero-cell-label {
  font-size: 11px;
  color: var(--ll-brown-2);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.ll-hero-cell-value {
  font-family: var(--font-kai), serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ll-ink);
  line-height: 1.15;
  min-height: 24px;
}

.ll-hero-cell-hint {
  font-size: 11px;
  color: var(--ll-brown);
  margin-top: 4px;
  min-height: 16px;
}

.ll-hero-cell.ll-cell-accent {
  background: linear-gradient(180deg, #fff6ec 0%, #f9dfc2 100%);
  border-color: rgba(184,68,46,.35);
}

.ll-hero-cell.ll-cell-accent .ll-hero-cell-value {
  color: var(--ll-cinnabar);
}

/* 五行色继承 pages.css 已有 wx-* 颜色 */
.ll-hero-cell-value.wx-mu   { color: #2E7D32; }
.ll-hero-cell-value.wx-huo  { color: #C62828; }
.ll-hero-cell-value.wx-tu   { color: #6D4C41; }
.ll-hero-cell-value.wx-jin  { color: #b8860b; }
.ll-hero-cell-value.wx-shui { color: #1565C0; }

@media (max-width: 480px) {
  .ll-hero-grid { grid-template-columns: repeat(2, 1fr); }
  .ll-hero-cell-value { font-size: 18px; }
}

/* Hero 底部一句话总评 */
.ll-hero-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(94,71,51,.18);
  font-size: 13px;
  line-height: 1.75;
  color: var(--ll-brown);
  font-family: var(--font-song), serif;
}

.ll-hero-footer::before {
  content: '「 ';
  color: var(--ll-cinnabar);
  font-weight: 700;
}

.ll-hero-footer::after {
  content: ' 」';
  color: var(--ll-cinnabar);
  font-weight: 700;
}

/* ============ 2. 章节 chip 导航（深度解读 TOC） ============ */
.ll-toc {
  position: sticky;
  top: 100px;
  z-index: 8;
  margin: -4px -16px 12px -16px;
  padding: 10px 12px 8px;
  background: rgba(253,248,238,.94);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid rgba(209,195,168,.55);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.ll-toc::-webkit-scrollbar { display: none; }

.ll-toc-chip {
  display: inline-block;
  padding: 6px 12px;
  margin-right: 6px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(46,90,60,.20);
  color: var(--ll-green);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all .2s;
  user-select: none;
}

.ll-toc-chip:hover {
  background: rgba(46,90,60,.06);
}

.ll-toc-chip.active {
  background: linear-gradient(135deg, var(--ll-green-2), var(--ll-green));
  color: #fff;
  border-color: var(--ll-green);
  box-shadow: 0 2px 8px rgba(46,90,60,.28);
}

/* 章节锚点补偿 sticky 高度 */
[id^="ll-sec-"] {
  scroll-margin-top: 156px;
}

/* ============ 3. 紫微 4×4 传统盘布局 ============ */
/* 覆盖原 zw-grid 结构；启用新类 zw-board 时激活 */
.zw-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, minmax(90px, auto));
  gap: 3px;
  background: linear-gradient(135deg, #efe4c9, #e2d3b2);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid rgba(184,134,11,.35);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
}

.zw-board .zw-gong {
  background: linear-gradient(180deg, #fffdf6 0%, #fbf3de 100%);
  border-radius: 8px;
  padding: 8px 5px 6px;
  text-align: left;
  min-height: 0;
  border: 1px solid rgba(184,134,11,.22);
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}

.zw-board .zw-gong:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(94,71,51,.12);
  z-index: 2;
}

.zw-board .zw-gong-name {
  font-family: var(--font-song), serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--ll-brown);
  letter-spacing: 1px;
  margin-bottom: 3px;
  border-bottom: 1px dashed rgba(94,71,51,.18);
  padding-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.zw-board .zw-gong-pos {
  font-size: 10px;
  color: var(--ll-brown-2);
  margin-left: auto;
  font-family: var(--font-kai), serif;
}

.zw-board .zw-gong-stars {
  font-family: var(--font-kai), serif;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ll-ink);
  font-weight: 500;
  word-break: break-all;
  min-height: 30px;
}

.zw-board .zw-gong-daxian,
.zw-board .zw-gong-natal {
  font-size: 10px;
  color: var(--ll-brown-2);
  margin-top: 3px;
  padding-top: 3px;
  border-top: 1px dashed rgba(94,71,51,.15);
}

.zw-board .zw-gong-ming {
  background: linear-gradient(180deg, #fff6ec 0%, #f9dfc2 100%);
  border-color: rgba(184,68,46,.45);
  box-shadow: 0 0 0 2px rgba(184,68,46,.15) inset;
}

.zw-board .zw-gong-ming .zw-gong-name {
  color: var(--ll-cinnabar);
}

.zw-board .zw-gong-shen {
  background: linear-gradient(180deg, #f2f7f0 0%, #dfe9dc 100%);
  border-color: rgba(46,90,60,.35);
}

/* 中央信息区：跨 4 格（col 2-3, row 2-3） */
.zw-board-center {
  grid-column: 2 / span 2;
  grid-row: 2 / span 2;
  background:
    radial-gradient(circle at center, #fff9ea 0%, #f3e6c5 60%, #e5d4a6 100%);
  border-radius: 10px;
  border: 1px solid rgba(184,134,11,.40);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.zw-board-center::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(184,68,46,.28);
  border-radius: 6px;
  pointer-events: none;
}

.zw-board-center-title {
  font-family: var(--font-song), serif;
  font-size: 13px;
  color: var(--ll-cinnabar);
  letter-spacing: 4px;
  margin-bottom: 8px;
  font-weight: 600;
}

.zw-board-center-line {
  font-size: 12px;
  color: var(--ll-brown);
  line-height: 1.9;
  font-family: var(--font-kai), serif;
}

.zw-board-center-line strong {
  color: var(--ll-ink);
  font-weight: 700;
}

@media (max-width: 480px) {
  .zw-board {
    grid-template-rows: repeat(4, minmax(78px, auto));
  }
  .zw-board .zw-gong-stars { font-size: 11px; min-height: 24px; }
  .zw-board-center-title { font-size: 12px; letter-spacing: 2px; }
  .zw-board-center-line { font-size: 11px; }
}

/* ============ 4. 起卦 loading 动画 ============ */
.ll-loading .loading-box {
  padding: 20px 32px 22px !important;
  background: linear-gradient(180deg, #fffdf6, #f6ead0) !important;
  border: 1px solid rgba(184,134,11,.30);
  min-width: 200px;
}

.ll-qigua {
  width: 68px;
  height: 68px;
  margin: 0 auto 12px;
  position: relative;
  animation: llQiguaRotate 3s linear infinite;
}

.ll-qigua-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--ll-cinnabar);
  border-right-color: var(--ll-gold-2);
  border-bottom-color: var(--ll-green);
  border-left-color: transparent;
  animation: llQiguaSpin 1.2s cubic-bezier(.4,.1,.6,.9) infinite;
}

.ll-qigua-ring.r2 {
  inset: 10px;
  border-top-color: var(--ll-green);
  border-right-color: transparent;
  border-bottom-color: var(--ll-cinnabar);
  border-left-color: var(--ll-gold-2);
  animation-duration: 1.6s;
  animation-direction: reverse;
}

.ll-qigua-core {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffe28a, #b8860b 65%);
  box-shadow: 0 0 12px rgba(184,134,11,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a2e08;
  font-family: var(--font-kai), serif;
  font-size: 13px;
  font-weight: 800;
  animation: llQiguaPulse 1.4s ease-in-out infinite;
}

.ll-loading .loading-text {
  font-family: var(--font-song), serif;
  letter-spacing: 3px;
  color: var(--ll-brown) !important;
}

@keyframes llQiguaSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes llQiguaRotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes llQiguaPulse {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 12px rgba(184,134,11,.55); }
  50%      { transform: scale(.90); box-shadow: 0 0 20px rgba(184,68,46,.55); }
}

/* ============ 5. 卡片主次分级 ============ */
.ll-card-primary {
  border-left: 3px solid var(--ll-cinnabar) !important;
}
.ll-card-secondary {
  border-left: 3px solid var(--ll-green) !important;
}
.ll-card-tertiary {
  background: rgba(255,253,248,.75) !important;
  border-left: 3px solid rgba(94,71,51,.25) !important;
}

/* ============ 6. 深度解读章节容器 ============ */
.ll-section {
  scroll-margin-top: 160px;
}

.ll-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 10px;
  padding: 0 2px;
}

.ll-section-head::before {
  content: '';
  width: 3px;
  height: 16px;
  background: linear-gradient(180deg, var(--ll-cinnabar), var(--ll-gold-2));
  border-radius: 2px;
}

.ll-section-title {
  font-family: var(--font-song), serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ll-ink);
  letter-spacing: 2px;
}

.ll-section-sub {
  font-size: 11px;
  color: var(--ll-brown-2);
  letter-spacing: 1px;
  margin-left: auto;
}

/* ============ 7. 通用视觉微调 ============ */
/* 深度块的古籍引用字体更"帖"感 */
.deep-classical {
  font-family: var(--font-kai), "STKaiti", "KaiTi", serif !important;
  letter-spacing: 1px;
}

/* Tag 更秀气 */
.tag {
  border-radius: 999px !important;
  padding: 3px 12px !important;
  letter-spacing: 1px;
}

/* result-tabs sticky 高度补偿（配合 hero 之后仍能贴顶） */
.result-tabs { top: 56px !important; }

/* ============ 8. 全局字体（宋楷偏向古籍质感） ============ */
/* 正文改为宋体，标题与关键词沿用楷体 */
body,
#app,
.page,
.card-body,
.form-item,
.form-item input,
.form-item select,
.form-item textarea,
.btn-primary,
.tabbar-item {
  font-family: var(--font-song), "STSong", "SimSun", "Songti SC", "Noto Serif SC", serif;
}

/* 卡片标题、导航、Hero 副题：宋体 + 疏朗字距 */
.card-title,
.navbar-title,
.greeting,
.ll-hero-title,
.ll-hero-sub,
.ll-section-title,
.ll-toc-chip {
  font-family: var(--font-song), "STSong", "SimSun", "Songti SC", "Noto Serif SC", serif;
}

/* 命盘、结论、数字类：楷体强化"手书感" */
.zw-board .zw-gong-stars,
.zw-board-center-line,
.ll-hero-cell-value,
.bazi-chart-cell,
.bazi-gan, .bazi-zhi,
.result-value,
.deep-quote,
.deep-classical {
  font-family: var(--font-kai), "STKaiti", "KaiTi", "楷体", "Noto Serif SC", serif;
}

/* 代码/数字维持等宽（不覆盖） */
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }

/* ============ 9. 命盘导出 PNG 按钮 ============ */
.ll-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff6ec 0%, #f9dfc2 100%);
  border: 1px solid rgba(184,68,46,.35);
  color: var(--ll-cinnabar);
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font-song), serif;
}
.ll-export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(184,68,46,.20);
}
.ll-export-btn:active { transform: translateY(0); }
.ll-export-btn::before {
  content: '⤓';
  font-size: 14px;
  color: var(--ll-gold-2);
}
.ll-export-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 4px 0 8px;
}

/* ============ 10. AI 打字机 & 内容渲染 ============ */
.ll-ai-typing::after {
  content: '▍';
  color: var(--ll-cinnabar);
  animation: llBlink 1s steps(1) infinite;
  margin-left: 2px;
}
@keyframes llBlink {
  50% { opacity: 0; }
}

.ll-ai-body {
  font-family: var(--font-song), serif;
  line-height: 1.9;
  color: var(--ll-ink);
  letter-spacing: .5px;
}
.ll-ai-body h1, .ll-ai-body h2, .ll-ai-body h3, .ll-ai-body h4 {
  font-family: var(--font-song), serif;
  color: var(--ll-cinnabar);
  border-left: 3px solid var(--ll-gold-2);
  padding-left: 10px;
  margin: 14px 0 8px;
  letter-spacing: 2px;
}
.ll-ai-body h1 { font-size: 17px; }
.ll-ai-body h2 { font-size: 15px; }
.ll-ai-body h3 { font-size: 14px; }
.ll-ai-body p { margin: 6px 0; }
.ll-ai-body strong { color: var(--ll-cinnabar); }
.ll-ai-body em { color: var(--ll-green); font-style: normal; border-bottom: 1px dashed rgba(46,90,60,.35); }
.ll-ai-body blockquote {
  border-left: 3px solid var(--ll-gold-2);
  background: rgba(184,134,11,.06);
  padding: 8px 12px;
  margin: 8px 0;
  color: var(--ll-brown);
  font-family: var(--font-kai), serif;
}
.ll-ai-body ul, .ll-ai-body ol { padding-left: 22px; margin: 6px 0; }
.ll-ai-body li { margin: 3px 0; }
.ll-ai-body code {
  background: rgba(94,71,51,.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ============ 15. Emoji → SVG 图标（icons.js 运行时替换） ============
 * 出处：《周礼·考工记》"审曲面势，以饬五材，以辨民器"
 *   —— 图必以工整之形示人，故弃杂色 emoji 而用统一线描图标
 */
.ll-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.15em;
  width: 1em;
  height: 1em;
  line-height: 1;
  color: inherit;
}
.ll-icon svg {
  width: 1em;
  height: 1em;
  display: block;
  fill: none;
  stroke: currentColor;
}

/* 卡片标题图标：稍大且带主色 */
.card-title-icon .ll-icon,
.card-title .ll-icon {
  width: 1.15em;
  height: 1.15em;
  color: var(--ll-green-2);
}
.card-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 警示卡里的图标沿用朱砂 */
.warning-card .card-title .ll-icon,
.warning-card .card-title-icon .ll-icon {
  color: var(--ll-cinnabar);
}

/* Hero 单元格里图标承接文字颜色，不额外抢色 */
.ll-hero .ll-icon { color: currentColor; }

/* 深度解读章节 chip 内图标 */
.ll-toc .ll-icon { width: 1em; height: 1em; }

/* Tab 按钮里的图标略微紧凑 */
.result-tab-btn .ll-icon {
  width: 1.05em;
  height: 1.05em;
  margin-right: 4px;
  vertical-align: -0.18em;
}
