/* ============ 答案之书 · THE ORACLE ============ */
:root {
  --ink: #1a0f08;          /* 背景深棕黑 */
  --leather: #4a2e15;      /* 皮革棕 */
  --leather-deep: #2c1a0a; /* 深皮革 */
  --gold: #d4af37;         /* 主金 */
  --gold-bright: #f4cf6e;  /* 亮金 */
  --gold-deep: #8b6914;    /* 深金 */
  --parchment: #ecdcb0;    /* 羊皮纸 */
  --parchment-deep: #c4a878; /* 深羊皮纸 */
  --ember: #ff9a3c;        /* 烛光橙 */
  --ash: #8a7355;          /* 灰 */
  --text: #2c1a0a;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--ink);
  overflow: hidden;
  font-family: "Noto Serif SC", "Cormorant Garamond", serif;
  color: var(--parchment);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  height: 100dvh;
}

#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  height: 100dvh;
  display: block;
}

/* ---------- 氛围层 ---------- */
#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 48%,
      transparent 28%,
      rgba(20, 8, 0, 0.55) 70%,
      rgba(10, 4, 0, 0.92) 100%);
  z-index: 3;
}

#grain {
  position: fixed; inset: -100px;
  pointer-events: none;
  z-index: 4;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-jitter 0.42s steps(4) infinite;
}
@keyframes grain-jitter {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-32px, 18px); }
  50%  { transform: translate(22px, -26px); }
  75%  { transform: translate(-14px, -30px); }
  100% { transform: translate(0, 0); }
}

#flash {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse at 50% 50%,
    rgba(255, 215, 130, 1) 0%,
    rgba(255, 175, 70, 0.4) 30%,
    transparent 70%);
  opacity: 0;
}
#flash.reveal {
  animation: reveal-flash 1.6s ease-out;
}
@keyframes reveal-flash {
  0%   { opacity: 0; }
  18%  { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ---------- 加载层 ---------- */
#loading {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--gold);
  font-family: "Cinzel", serif;
  letter-spacing: 0.4em;
  transition: opacity 1s ease;
}
#loading.hide { opacity: 0; pointer-events: none; }
#loading .loader {
  width: 38px; height: 38px;
  border: 2px solid rgba(212, 175, 55, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
  margin-bottom: 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { font-size: 13px; }

/* ---------- 顶部条 ---------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  opacity: 0;
  animation: fade-down 2.4s ease 0.6s forwards;
}
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.title-block {
  pointer-events: auto;
  text-align: left;
}
.title-block .en {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.55em;
  color: var(--gold-deep);
  margin-bottom: 6px;
}
.title-block h1 {
  font-family: "Noto Serif SC", serif;
  font-weight: 900;
  font-size: clamp(24px, 5vw, 40px);
  letter-spacing: 0.4em;
  color: var(--gold);
  text-shadow:
    0 0 20px rgba(212, 175, 55, 0.35),
    0 0 4px rgba(0, 0, 0, 0.6);
  margin-left: 0.4em;
}
.title-block .sub {
  margin-top: 8px;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: clamp(11px, 2vw, 14px);
  letter-spacing: 0.25em;
  color: var(--ash);
}

/* 音乐按钮 */
.music-toggle {
  pointer-events: auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.4);
  background: rgba(20, 8, 0, 0.5);
  color: var(--gold);
  display: grid; place-items: center;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: all 0.35s ease;
}
.music-toggle:hover {
  border-color: var(--gold);
  background: rgba(74, 46, 21, 0.6);
  box-shadow: 0 0 18px rgba(212, 175, 55, 0.35);
}
.music-toggle.off {
  opacity: 0.4;
  border-color: rgba(138, 115, 85, 0.4);
}
.music-toggle.off svg { display: none; }
.music-toggle.off::after {
  content: "‖";
  font-size: 14px;
  color: var(--ash);
}

/* ---------- 底部 dock ---------- */
#dock {
  position: fixed;
  bottom: 7%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: min(92vw, 720px);
  display: grid;
  place-items: end center;
}
#dock .stage {
  grid-area: 1 / 1;
  width: 100%;
  text-align: center;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#dock .stage.show {
  opacity: 1;
  transform: translateY(0);
}
#dock .stage.hidden { display: none; }

.lead {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: clamp(14px, 2.4vw, 18px);
  letter-spacing: 0.18em;
  color: var(--ash);
  margin-bottom: 18px;
}

/* 输入框 */
#questionInput {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 0 auto 20px;
  padding: 14px 18px;
  background: rgba(20, 8, 0, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 2px;
  color: var(--parchment);
  font-family: "Noto Serif SC", serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-align: center;
  outline: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}
#questionInput::placeholder {
  color: rgba(138, 115, 85, 0.7);
  font-style: italic;
}
#questionInput:focus {
  border-color: var(--gold);
  background: rgba(40, 20, 8, 0.7);
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.18);
}

/* 符文按钮 */
.rune-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 42px;
  background: linear-gradient(180deg,
    rgba(74, 46, 21, 0.85) 0%,
    rgba(44, 26, 10, 0.9) 100%);
  border: 1px solid var(--gold);
  border-radius: 2px;
  color: var(--gold-bright);
  font-family: "Noto Serif SC", serif;
  cursor: pointer;
  letter-spacing: 0.4em;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.15),
    0 0 24px rgba(212, 175, 55, 0.12),
    inset 0 0 24px rgba(212, 175, 55, 0.08);
}
.rune-btn::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  pointer-events: none;
}
.rune-btn:hover {
  background: linear-gradient(180deg,
    rgba(120, 70, 30, 0.95) 0%,
    rgba(60, 30, 10, 0.95) 100%);
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 32px rgba(255, 175, 70, 0.4),
    inset 0 0 32px rgba(255, 175, 70, 0.15);
  color: #fff5d0;
}
.rune-btn:active { transform: translateY(1px); }
.rune-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: saturate(0.6);
}
.rune-btn .rune { font-size: 15px; }
.rune-btn .en {
  font-family: "Cinzel", serif;
  font-size: 10px;
  letter-spacing: 0.3em;
  opacity: 0.7;
  font-weight: 400;
}

.hint {
  margin-top: 16px;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 12px;
  color: var(--ash);
  letter-spacing: 0.12em;
  opacity: 0.7;
}

/* ---------- 答案框 ---------- */
.answer-frame {
  position: relative;
  margin: 0 auto 22px;
  padding: 32px 36px 28px;
  background:
    radial-gradient(ellipse at center,
      rgba(236, 220, 176, 0.97) 0%,
      rgba(196, 168, 120, 0.95) 100%);
  border: 2px solid var(--gold);
  border-radius: 2px;
  box-shadow:
    0 0 0 4px rgba(20, 8, 0, 0.6),
    0 0 0 5px var(--gold),
    0 12px 48px rgba(0, 0, 0, 0.6),
    inset 0 0 32px rgba(139, 105, 20, 0.18);
  color: var(--text);
  max-width: 560px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.answer-frame::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(139, 105, 20, 0.45);
  pointer-events: none;
}

.corner {
  position: absolute;
  font-family: "Cinzel", serif;
  color: var(--gold-deep);
  font-size: 14px;
}
.corner.tl { top: 10px;    left: 14px; }
.corner.tr { top: 10px;    right: 14px; }
.corner.bl { bottom: 10px; left: 14px; }
.corner.br { bottom: 10px; right: 14px; }

.answer-cn {
  font-family: "Noto Serif SC", serif;
  font-weight: 900;
  font-size: clamp(28px, 5.5vw, 40px);
  letter-spacing: 0.25em;
  color: var(--text);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.9s ease 0.2s, transform 0.9s ease 0.2s;
}
.answer-cn.show {
  opacity: 1;
  transform: translateY(0);
}

.answer-label {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.6em;
  color: var(--gold-deep);
  margin-bottom: 18px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.answer-label.show { opacity: 1; }

.answer-divider {
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold-deep) 50%,
    transparent 100%);
  margin: 14px 0;
  opacity: 0;
  transform: scaleX(0);
  transition: opacity 0.6s ease 0.8s, transform 0.6s ease 0.8s;
}
.answer-divider.show {
  opacity: 1;
  transform: scaleX(1);
}

.answer-en {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: clamp(13px, 2.6vw, 17px);
  letter-spacing: 0.18em;
  color: var(--leather-deep);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.9s ease 1.0s, transform 0.9s ease 1.0s;
  margin-top: 4px;
}
.answer-en.show {
  opacity: 0.7;
  transform: translateY(0);
}

.answer-tag {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 14px;
  background: var(--gold-deep);
  color: var(--parchment);
  font-family: "Cinzel", serif;
  font-size: 9px;
  letter-spacing: 0.35em;
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.6s ease 1.4s;
}
.answer-tag.show { opacity: 1; }

/* ---------- 底部 ---------- */
#footer {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  font-family: "Cinzel", serif;
  font-size: 9px;
  letter-spacing: 0.35em;
  color: var(--gold-deep);
  opacity: 0.45;
  pointer-events: none;
  white-space: nowrap;
}
#footer .dot { margin: 0 10px; opacity: 0.5; }

/* 烛光闪烁效果（古书场景里的暖光） */
body.shake #scene { animation: cam-shake 0.5s linear; }
@keyframes cam-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); }
  40% { transform: translate(5px, -5px); }
  60% { transform: translate(-4px, -3px); }
  80% { transform: translate(3px, 3px); }
}

/* 移动端调整 */
@media (max-width: 640px) {
  #topbar { padding: 16px 18px; }
  #title-block h1 { letter-spacing: 0.3em; }
  .answer-frame { padding: 26px 22px 22px; }
  .rune-btn { padding: 12px 32px; }
  #footer { font-size: 8px; }
}
