/* ═══════════════════════════════════════════
   大学四年宿命模拟器 — 暗色文学风格
   ═══════════════════════════════════════════ */

:root {
  --bg-deep: #f7f5f0;
  --bg-scene: #f0ede7;
  --bg-card: rgba(0, 0, 0, 0.04);
  --bg-card-hover: rgba(0, 0, 0, 0.08);
  --text-primary: #1c1a17;
  --text-secondary: rgba(28, 26, 23, 0.70);
  --text-muted: rgba(28, 26, 23, 0.42);
  --accent: #7a5c1e;
  --accent-dim: rgba(122, 92, 30, 0.10);
  --accent-glow: rgba(122, 92, 30, 0.25);
  --danger: #b83030;
  --border: rgba(0, 0, 0, 0.10);
  --font-serif: 'Noto Serif SC', 'Songti SC', Georgia, serif;
  --font-sans: 'Noto Sans SC', -apple-system, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ── Scene System ── */

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0.8s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.scene.active {
  opacity: 1;
  visibility: visible;
}

/* 封面、学年过渡、计算中：内容较短，垂直居中 */
#cover,
#year-transition,
#calculating {
  align-items: center;
}

.scene-inner {
  width: 100%;
  max-width: 560px;
  padding: 40px 28px;
  position: relative;
}

/* ── Cover ── */

#cover {
  background: var(--bg-deep);
}

#cover .scene-inner {
  text-align: center;
}

.cover-decoration {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  pointer-events: none;
}

.orbit {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.orbit-1 {
  inset: 0;
  animation: spin 40s linear infinite;
}

.orbit-2 {
  inset: 40px;
  border-color: rgba(201, 169, 110, 0.08);
  animation: spin 30s linear infinite reverse;
}

.orbit-3 {
  inset: 80px;
  border-color: rgba(201, 169, 110, 0.12);
  animation: spin 20s linear infinite;
}

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

.cover-epigraph {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 2;
  margin-bottom: 48px;
  letter-spacing: 1px;
  position: relative;
}

.cover-title {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 900;
  line-height: 1.4;
  letter-spacing: 4px;
  margin-bottom: 16px;
  position: relative;
}

.cover-title .accent {
  color: var(--accent);
  display: block;
  font-size: 42px;
  letter-spacing: 8px;
}

.cover-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 6px;
  margin-bottom: 56px;
  text-transform: uppercase;
}

.cover-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 24px;
  letter-spacing: 1px;
}

/* ── Buttons ── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: #faf7f0;
  border: none;
  padding: 16px 48px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.btn-primary:hover::before {
  transform: translateX(100%);
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 14px 36px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Year Transition ── */

#year-transition {
  background: var(--bg-deep);
}

#year-transition .scene-inner {
  text-align: center;
}

.year-label {
  font-family: var(--font-serif);
  font-size: 72px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 12px;
  opacity: 0;
  transform: scale(0.8);
  animation: yearReveal 1.5s ease forwards;
}

.year-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 16px;
  letter-spacing: 4px;
  opacity: 0;
  animation: fadeUp 0.8s ease 0.5s forwards;
}

@keyframes yearReveal {
  0% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}

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

/* ── Question ── */

#question {
  background: var(--bg-scene);
  align-items: flex-start;
}

#question .scene-inner {
  margin: auto;
  padding-top: 48px;
  padding-bottom: 48px;
}

.q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.q-year {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 2px;
  padding: 4px 12px;
  border: 1px solid var(--accent-dim);
  border-radius: 2px;
}

.q-progress {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  width: 100%;
  height: 2px;
  background: var(--border);
  margin-bottom: 40px;
  border-radius: 1px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.5s ease;
  width: 0%;
}

.q-scenario {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 20px;
  padding-left: 16px;
  border-left: 2px solid var(--accent-dim);
  min-height: 0;
}

.q-scenario:empty {
  display: none;
}

.q-text {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.7;
  margin-bottom: 36px;
  letter-spacing: 0.5px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 20px 24px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.6;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.option-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

.option-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-dim);
}

.option-btn:hover::before {
  width: 3px;
}

.option-btn:active {
  transform: scale(0.99);
}

.option-btn.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.option-btn.selected::before {
  width: 3px;
}

.btn-back {
  display: block;
  margin-top: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 0;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

.btn-back:hover {
  color: var(--text-secondary);
}

.btn-back[hidden] {
  display: none;
}

/* ── Calculating ── */

#calculating {
  background: var(--bg-deep);
}

#calculating .scene-inner {
  text-align: center;
}

.calc-text {
  margin-bottom: 40px;
}

.calc-line {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 2.2;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
}

.calc-line:nth-child(2) { animation-delay: 0.8s; }
.calc-line:nth-child(3) { animation-delay: 1.6s; }

.calc-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.calc-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.calc-dots span:nth-child(2) { animation-delay: 0.2s; }
.calc-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ── Result ── */

#result {
  background: var(--bg-deep);
}

#result .scene-inner {
  text-align: center;
  padding-top: 64px;
  padding-bottom: 80px;
}

#result .scene-inner {
  text-align: center;
  padding-top: 60px;
  padding-bottom: 80px;
}

.result-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 4px;
  text-transform: uppercase;
  padding: 6px 20px;
  border: 1px solid var(--accent-dim);
  border-radius: 2px;
  margin-bottom: 24px;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.3s forwards;
}

.result-title {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 6px;
  margin-bottom: 32px;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.6s forwards;
}

.result-quote {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 2;
  margin: 0 auto 40px;
  max-width: 420px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-style: italic;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.9s forwards;
}

.result-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 2;
  margin-bottom: 40px;
  text-align: left;
  opacity: 0;
  animation: fadeUp 0.6s ease 1.2s forwards;
}

.result-theory {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px 24px;
  margin-bottom: 32px;
  text-align: left;
  opacity: 0;
  animation: fadeUp 0.6s ease 1.4s forwards;
}

.theory-label {
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.theory-text {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.result-dims {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 40px;
  opacity: 0;
  animation: fadeUp 0.6s ease 1.6s forwards;
}

.dim-item {
  text-align: center;
  padding: 12px 4px;
}

.dim-bar-wrap {
  width: 4px;
  height: 60px;
  background: var(--border);
  margin: 0 auto 8px;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.dim-bar-fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: height 1s ease 2s;
}

.dim-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.dim-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
  opacity: 0;
  animation: fadeUp 0.6s ease 1.8s forwards;
}

.result-footer {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 2;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.author-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 48px;
}

.author-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.2s;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.author-link:hover {
  color: var(--accent);
}

.author-sep {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 12px;
}

/* ── Responsive ── */

@media (max-width: 480px) {
  .scene-inner {
    padding: 32px 20px;
  }

  .cover-title {
    font-size: 28px;
  }

  .cover-title .accent {
    font-size: 34px;
    letter-spacing: 6px;
  }

  .year-label {
    font-size: 56px;
  }

  .q-text {
    font-size: 18px;
  }

  .result-title {
    font-size: 28px;
    letter-spacing: 4px;
  }

  .result-dims {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .btn-primary {
    padding: 14px 32px;
    width: 100%;
  }

  .btn-secondary {
    width: 100%;
  }
}

/* ── 阅读原文按钮 ── */

@keyframes shimmer-border {
  0%   { box-shadow: 0 0 0px 0px rgba(122, 92, 30, 0); border-color: rgba(122,92,30,0.25); }
  50%  { box-shadow: 0 0 10px 2px rgba(122, 92, 30, 0.25); border-color: rgba(122,92,30,0.7); }
  100% { box-shadow: 0 0 0px 0px rgba(122, 92, 30, 0); border-color: rgba(122,92,30,0.25); }
}

.btn-essay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(122,92,30,0.25);
  padding: 14px 24px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 32px;
  width: 100%;
  animation: shimmer-border 2.4s ease-in-out infinite;
}

.btn-essay:hover {
  background: var(--accent-dim);
  color: var(--accent);
  animation: none;
  box-shadow: 0 0 12px 2px rgba(122,92,30,0.2);
}

/* ── Essay scene ── */

.essay-scene {
  display: block !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-deep);
  padding: 0;
}

.essay-scene:not(.active) {
  display: none !important;
}

/* 返回按钮固定 */
.essay-back-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 245, 240, 0.95);
  backdrop-filter: blur(8px);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.essay-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 20px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s;
}

.essay-back-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.essay-title-small {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

/* 原文章节通用样式 */
.essay-chapter {
  padding: 64px 28px;
  max-width: 680px;
  margin: 0 auto;
}

.essay-chapter + .essay-chapter {
  border-top: 1px solid var(--border);
}

.essay-chapter-num {
  font-family: var(--font-sans);
  font-size: 11px;
  color: #c9a96e;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.essay-chapter-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.essay-p {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 2;
  margin-bottom: 24px;
}

.essay-p strong {
  color: var(--text-primary);
  font-weight: 700;
}

.essay-highlight {
  border-left: 3px solid var(--accent);
  padding: 20px 24px;
  margin: 32px 0;
  background: var(--accent-dim);
  border-radius: 0 4px 4px 0;
}

.essay-highlight-title {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.essay-highlight-body {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.9;
}

.essay-big {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.7;
  margin: 36px 0;
  text-align: center;
}

.essay-quote {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--text-muted);
  line-height: 2;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 24px 0;
  margin: 36px 0;
  font-style: italic;
  text-align: center;
}

.essay-quote footer {
  display: block;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 3px;
  margin-top: 12px;
  font-style: normal;
}

.essay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 32px 0;
}

@media (max-width: 480px) {
  .essay-grid {
    grid-template-columns: 1fr;
  }
}

.essay-card {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.essay-card-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.essay-card-body {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.9;
}

.essay-layer {
  border: 1px solid var(--border);
  padding: 28px;
  margin: 20px 0;
  position: relative;
}

.essay-layer-tag {
  position: absolute;
  top: -1px;
  left: -1px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
  padding: 3px 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.essay-layer-title {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 12px;
}

.essay-center-big {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.6;
  letter-spacing: 2px;
  margin: 48px 0;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* 色调微变 — 每章，浅色主题，章间用细微暖色变化区分 */
.essay-ch-1 { background: #f7f5f0; }
.essay-ch-2 { background: #f4f2ed; }
.essay-ch-3 { background: #f6f4ef; }
.essay-ch-4 { background: #f5f3ee; }
.essay-ch-5 { background: #f7f5f1; }
.essay-ch-6 { background: #f4f2ee; }
.essay-ch-7 { background: #f6f4f0; }
.essay-ch-8 { background: #f5f3ef; }
.essay-ch-9 { background: #f7f5f0; }

/* ── Scene transition ── */

.scene.fade-out { opacity: 0; transition: opacity 0.5s ease; }
.scene.fade-in { opacity: 0; visibility: visible; }
.scene.fade-in.active { opacity: 1; }
