/* css/style.css — Mucha Tarot
 * 深黑暖调 + 香槟金 + 象牙白的奢侈品配色，全部走 CSS 变量。
 * 3D 画布固定在 z-index 0，内容层在其上；牌位标签是 fixed 浮层，按投影对齐。
 * 页面上不出现说明性文字：只有标题、占位提示、提示句、按钮、牌义与结果。
 */

/* ============================================================
   设计令牌
   ============================================================ */
:root {
  /* 底色：深黑带暖调 */
  --ink: #0A0908;
  --ink-2: #12100E;
  --ink-3: #17140F;

  /* 文字 */
  --ivory: #EDE8E0;          /* 主文字：米白 / 象牙 */
  --muted: #8A8278;          /* 次要文字：灰米 */
  --faint: #5F594F;

  /* 强调 */
  --gold: #C9A961;           /* 香槟金，低饱和 */
  --gold-dim: rgba(201, 169, 97, 0.55);
  --line: rgba(201, 169, 97, 0.2);
  --line-soft: rgba(237, 232, 224, 0.08);
  --panel: rgba(18, 16, 14, 0.88);

  /* 字体 */
  --font-wordmark: 'Cinzel Decorative', 'Cormorant Garamond', Georgia, serif;
  --font-display: 'Cormorant Garamond', 'Songti SC', 'STSong', 'SimSun', Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;

  /* 节奏 */
  --gap-section: 104px;
  --gap-section-sm: 76px;
  --page-max: 1120px;
  --pad-x: 24px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============================================================
   Layer 0：WebGL 画布
   ============================================================ */
.gl-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.gl-layer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 画布四角压暗，保证长文区域的可读性 */
.gl-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 55% at 50% 42%, transparent 30%, rgba(10, 9, 8, 0.55) 100%),
    linear-gradient(180deg, rgba(10, 9, 8, 0.2) 0%, rgba(10, 9, 8, 0.62) 100%);
}

.gl-notice {
  position: relative;
  z-index: 3;
  max-width: 560px;
  margin: 28px auto 0;
  padding: 20px 22px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.gl-notice-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.gl-notice-text {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* ============================================================
   牌位标签浮层（fixed，按 3D 投影对齐）
   ============================================================ */
.stage-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;              /* 由 JS 按滚动位置控制 */
}

body:not(.has-draw) .stage-overlay { display: none; }

.slot-label {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  text-align: center;
}

.slot-pos {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--gold-dim);
}

.slot-name {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.1em;
  color: var(--ivory);
}

.slot-badge {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

/* ============================================================
   首屏
   ============================================================ */
.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px var(--pad-x) 72px;
  text-align: center;
}

/* 花体英文标题（Cinzel Decorative） */
.hero-title {
  margin: 0;
  font-family: var(--font-wordmark);
  font-size: clamp(32px, 7.4vw, 58px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ivory);
}

.wordmark-line {
  display: block;
  text-indent: 0.1em;     /* 抵消末字多出的字距，保证视觉居中 */
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero-title {
    background: linear-gradient(178deg, #F4F0E8 0%, #E4D8BC 52%, #C9A961 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}

.hero-rule {
  width: 84px;
  height: 1px;
  margin: 26px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ---------- 首屏提问 ---------- */

.hero-question {
  width: 100%;
  max-width: 460px;
  margin: 34px auto 0;
  text-align: left;
}

.hero-question .ai-input {
  min-height: 78px;
  margin-top: 0;
  font-size: 14px;
  /* 比内容面板更透，让身后的粒子雾气透出来 */
  background: rgba(10, 9, 8, 0.5);
  box-shadow: inset 0 0 26px rgba(201, 169, 97, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.question-hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: var(--faint);
}

.hero-actions { margin-top: 26px; }

/* 仅在异常时写入内容；为空时不占位 */
.hero-hint {
  margin: 18px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--faint);
}

.hero-hint:empty { display: none; }

/* ============================================================
   按钮
   ============================================================ */
.btn-primary,
.btn-secondary {
  font-family: var(--font-body);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.4s ease, border-color 0.4s ease, opacity 0.4s ease;
}

/* 抽牌按钮：形状不变，加入水晶球式的呼吸光晕 */
.btn-primary {
  position: relative;
  overflow: hidden;
  min-width: 216px;
  min-height: 56px;
  padding: 15px 40px;
  font-size: 13px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: var(--ivory);
  background: linear-gradient(180deg, rgba(201, 169, 97, 0.16), rgba(201, 169, 97, 0.05));
  border: 1px solid var(--gold-dim);
  border-radius: 1px;
  box-shadow:
    0 0 14px 0 rgba(201, 169, 97, 0.07),
    0 0 44px 0 rgba(201, 169, 97, 0.05),
    inset 0 0 18px rgba(201, 169, 97, 0.1),
    inset 0 1px 0 rgba(237, 232, 224, 0.16);
  animation: orbBreathe 7.2s ease-in-out infinite;
}

/* 缓慢呼吸：外层光晕胀缩 + 内层球体透光。两层关键帧的阴影层数/内外属性必须一致，才能平滑插值 */
@keyframes orbBreathe {
  0%, 100% {
    box-shadow:
      0 0 14px 0 rgba(201, 169, 97, 0.07),
      0 0 44px 0 rgba(201, 169, 97, 0.05),
      inset 0 0 18px rgba(201, 169, 97, 0.1),
      inset 0 1px 0 rgba(237, 232, 224, 0.16);
  }
  50% {
    box-shadow:
      0 0 30px 3px rgba(201, 169, 97, 0.3),
      0 0 82px 14px rgba(201, 169, 97, 0.15),
      inset 0 0 32px rgba(201, 169, 97, 0.24),
      inset 0 1px 0 rgba(237, 232, 224, 0.28);
  }
}

/* hover：金色微光流动（clipped 在按钮内，不影响点击区域） */
.btn-primary::after {
  content: '';
  position: absolute;
  inset: -1px;
  background: linear-gradient(115deg,
    transparent 32%,
    rgba(237, 232, 224, 0.34) 50%,
    transparent 68%);
  transform: translateX(-130%);
  transition: transform 0.85s cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

.btn-primary:hover::after { transform: translateX(130%); }
.btn-primary:hover { border-color: var(--gold); color: #fff; }

.btn-primary:disabled {
  opacity: 0.42;
  cursor: default;
  animation: none;
}

.btn-primary:disabled::after { transform: translateX(-130%); }

.btn-secondary {
  position: relative;
  overflow: hidden;
  min-height: 48px;
  padding: 11px 30px;
  font-size: 12.5px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--ivory);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 1px;
}

.btn-secondary::after {
  content: '';
  position: absolute;
  inset: -1px;
  background: linear-gradient(115deg, transparent 34%, rgba(201, 169, 97, 0.3) 50%, transparent 66%);
  transform: translateX(-130%);
  transition: transform 0.8s cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

.btn-secondary:hover::after { transform: translateX(130%); }
.btn-secondary:hover { border-color: var(--gold-dim); color: #fff; }

.btn-secondary:disabled {
  opacity: 0.38;
  cursor: default;
}

.btn-secondary:disabled::after { transform: translateX(-130%); }

/* ============================================================
   区块通用
   ============================================================ */
.stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100svh;
  min-height: 420px;
}

.stage-action {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 3;
}

.btn-compact {
  min-width: 176px;
  min-height: 48px;
  padding: 12px 30px;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.section-rule {
  height: 1px;
  margin-bottom: 34px;
  background: linear-gradient(90deg, var(--line), transparent 72%);
}

.reading,
.ai {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--gap-section) var(--pad-x) 0;
}

.ai { padding-bottom: var(--gap-section-sm); }

body:not(.has-draw) .stage,
body:not(.has-draw) .reading,
body:not(.has-draw) .ai { display: none; }

/* ============================================================
   牌义
   ============================================================ */
.reading-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.read-item {
  position: relative;
  padding: 28px 24px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.read-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.read-pos {
  margin: 0;
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--gold-dim);
}

.read-name {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: 25px;
  letter-spacing: 0.06em;
  color: var(--ivory);
}

.read-en {
  margin: 3px 0 0;
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.read-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 2px 12px;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 1px;
}

.read-badge.is-rev {
  color: #B9A6CE;
  border-color: rgba(185, 166, 206, 0.28);
}

/* 3D 模式下桌面端隐藏面板内的小图（3D 卡牌本身就够大）；降级模式常显 */
.read-thumb { display: none; }

body.no-3d .read-thumb {
  display: block;
  width: 100%;
  max-width: 190px;
  margin: 16px auto 0;
  border: 1px solid var(--line);
  border-radius: 1px;
}

/* 窄屏时 3D 卡牌必然偏小，面板里补一张可读的牌面 */
@media (max-width: 700px) {
  .read-thumb {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: 18px auto 0;
    border: 1px solid var(--line);
    border-radius: 1px;
  }
}

.read-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.read-keys li {
  padding: 2px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 1px;
}

.read-text {
  margin: 18px 0 0;
  padding-top: 16px;
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--ivory);
  border-top: 1px solid var(--line-soft);
}

.read-empty {
  grid-column: 1 / -1;
  padding: 64px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
  border: 1px dashed var(--line);
  border-radius: 2px;
}

/* ============================================================
   AI 解读
   ============================================================ */
.ai-card {
  position: relative;
  padding: 30px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.ai-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.8;
  color: var(--ivory);
  background: rgba(10, 9, 8, 0.62);
  border: 1px solid var(--line);
  border-radius: 1px;
  resize: vertical;
  min-height: 92px;
  outline: none;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.ai-input::placeholder { color: var(--faint); }

.ai-input:focus {
  border-color: var(--gold-dim);
  box-shadow: inset 0 0 26px rgba(201, 169, 97, 0.12), 0 0 24px -6px rgba(201, 169, 97, 0.34);
}

/* 回显将被使用的问题；未填时整行隐藏 */
.ai-question {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.ai-question[hidden] { display: none; }

.ai-question-text {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: var(--ivory);
}

.ai-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.ai-out {
  margin-top: 22px;
  font-size: 14px;
  line-height: 2.05;
  color: var(--ivory);
}

.ai-out:empty { margin-top: 0; }

.ai-out p { margin: 0 0 16px; }
.ai-out p:last-child { margin-bottom: 0; }

.ai-disclaimer {
  margin-top: 20px !important;
  padding-top: 16px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--faint);
  border-top: 1px solid var(--line-soft);
}

.ai-error {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.8;
  color: #E0C9A6;
  background: rgba(201, 169, 97, 0.07);
  border: 1px solid var(--line);
  border-radius: 1px;
}

/* 加载中：呼吸光晕，不用转圈 */
.ai-card.is-loading {
  animation: aiBreathe 2.1s ease-in-out infinite;
}

@keyframes aiBreathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 169, 97, 0); border-color: var(--line); }
  50%      { box-shadow: 0 0 36px -4px rgba(201, 169, 97, 0.28); border-color: var(--gold-dim); }
}

.ai-caret {
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.14em;
  background: var(--gold);
  animation: caret 1.05s step-end infinite;
}

@keyframes caret {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ============================================================
   页脚（只留极淡金分隔线，不放文字）
   ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--pad-x) 64px;
}

.footer-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  :root {
    --gap-section: var(--gap-section-sm);
    --pad-x: 20px;
  }

  .reading-grid { grid-template-columns: 1fr; gap: 18px; }

  .hero { padding: 48px 20px 56px; }

  .slot-name { font-size: 16px; }
  .slot-pos { font-size: 10.5px; letter-spacing: 0.3em; }
  .slot-badge { font-size: 10px; }

  .read-item { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .btn-primary { width: 100%; min-width: 0; }
  .btn-secondary { width: 100%; }
  .ai-meta { gap: 12px; }
}

/* 尊重系统的减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn-primary { animation: none; }
  .ai-card.is-loading { animation: none; border-color: var(--gold-dim); }
  .ai-caret { animation: none; }
}
