/* 故人镜 — 宣纸档案 / 册页 */
@font-face {
  font-family: "GurenJing Song";
  src: url("../fonts/NotoSerifCJKsc-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GurenJing Song";
  src: url("../fonts/NotoSerifCJKsc-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #F1E6D4;
  --paper-deep: #E8DCC6;
  --ink: #2A241C;
  --ink-soft: rgba(42, 36, 28, 0.72);
  --ink-faint: rgba(42, 36, 28, 0.45);
  --sand: #9B2D2D;
  --sand-soft: rgba(155, 45, 45, 0.12);
  --gold: #B08A5B;
  --pine: #4E5A4A;
  --desk: #C9B498;
  --page-max: 440px;
  --line: 1.85;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "GurenJing Song", "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
  color: var(--ink);
  background-color: #C4B191;
  background-image: radial-gradient(ellipse at 50% 28%, #D2C2A4 0%, #C4B191 58%, #B8A685 100%);
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: break-word;
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
}

.desk {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
}

@media (min-width: 720px) {
  .desk {
    align-items: flex-start;
    padding: 36px 24px 64px;
  }
}

.page {
  width: 100%;
  max-width: var(--page-max);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  background-color: var(--paper);
  background-image: url("../assets/paper.png");
  background-repeat: repeat;
  box-shadow: 0 0 0 1px rgba(42, 36, 28, 0.06),
              0 18px 50px rgba(42, 36, 28, 0.16);
  overflow: hidden;
}

@media (min-width: 720px) {
  .page {
    min-height: calc(100vh - 72px);
    border-radius: 0;
  }
}

/* double 栏框 */
.page::before,
.page::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(42, 36, 28, 0.18);
  z-index: 2;
}
.page::after {
  inset: 18px;
  border-color: rgba(176, 138, 91, 0.45);
}

.sheet {
  position: relative;
  z-index: 3;
  padding: 36px 32px 48px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 720px) {
  .sheet { min-height: calc(100vh - 72px); }
}

.typo-unit, .typo-lock {
  white-space: nowrap;
}
.typo-line {
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: break-word;
}

/* —— 封面 —— */
.view-intro {
  text-align: center;
  justify-content: space-between;
}

.intro-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 12px;
}

.title-block {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin: 8px 0 28px;
  min-height: 280px;
}

.title-vertical {
  writing-mode: vertical-rl;
  font-weight: 700;
  font-size: 78px;
  letter-spacing: 0.32em;
  line-height: 1;
  color: var(--ink);
  margin: 0;
  padding-right: 0.08em;
}

.title-block .seal-float {
  position: absolute;
  right: -28px;
  bottom: 18px;
  transform: rotate(11deg);
  filter: drop-shadow(0 1px 0 rgba(155, 45, 45, 0.08));
}

.invitation {
  max-width: 16em;
  margin: 0 auto 36px;
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.85;
}

.btn-primary {
  display: inline-block;
  min-width: 168px;
  padding: 10px 28px 11px;
  border: 1px solid var(--sand);
  color: var(--sand);
  background: transparent;
  font-size: 17px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--sand);
  color: var(--paper);
  outline: none;
}
.btn-primary:active { transform: translateY(1px); }

.footer-note {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.85;
  text-align: center;
  margin-top: auto;
  padding-top: 28px;
}

.gate-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 220px;
}
.gate-input {
  width: 100%;
  margin: 0 0 22px;
  padding: 8px 4px 10px;
  border: 0;
  border-bottom: 1px solid rgba(42, 36, 28, 0.28);
  background: transparent;
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  outline: none;
}
.gate-input::placeholder {
  letter-spacing: 0.12em;
  text-indent: 0;
  color: var(--ink-faint);
  font-size: 14px;
}
.gate-input:focus {
  border-bottom-color: var(--sand);
}
.gate-err {
  margin: -10px 0 16px;
  font-size: 13px;
  color: var(--sand);
  line-height: 1.6;
}

/* —— 选择方向 —— */
.view-pref .pref-prompt {
  font-size: 20px;
  font-weight: 700;
  margin: 36px 0 28px;
  text-align: center;
  letter-spacing: 0.06em;
}

.pref-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pref-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 18px 20px 18px;
  border: 1px solid rgba(42, 36, 28, 0.22);
  background: rgba(241, 230, 212, 0.3);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.pref-btn:hover,
.pref-btn:focus-visible {
  border-color: var(--sand);
  background: var(--sand-soft);
  outline: none;
}
.pref-btn .pref-title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.pref-btn .pref-sub {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.85;
  white-space: normal;
  overflow: visible;
  height: auto;
  max-height: none;
}

.back-quiet {
  display: inline-block;
  margin-top: 28px;
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  border-bottom: 1px solid transparent;
}
.back-quiet:hover,
.back-quiet:focus-visible {
  color: var(--ink-soft);
  border-bottom-color: var(--gold);
  outline: none;
}

/* —— 题目 —— */
.quiz-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.chapter {
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--sand);
  font-weight: 700;
}
.progress-frac {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.progress-ink {
  height: 2px;
  background: rgba(42, 36, 28, 0.1);
  margin: 0 0 28px;
  position: relative;
}
.progress-ink > span {
  display: block;
  height: 2px;
  background: var(--ink);
  opacity: 0.55;
  width: 0;
  transition: width 0.35s ease;
}

.q-stem {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.7;
  margin: 0 0 28px;
}

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

.opt-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 14px 14px 12px;
  border: 1px solid rgba(42, 36, 28, 0.18);
  background: rgba(255, 250, 240, 0.18);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.opt-btn:hover,
.opt-btn:focus-visible {
  border-color: rgba(42, 36, 28, 0.45);
  background: rgba(232, 220, 198, 0.55);
  outline: none;
}
.opt-btn.is-on {
  border-color: var(--sand);
  background: var(--sand-soft);
}
.opt-mark {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border: 1px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: var(--ink);
  background: transparent;
}
.opt-btn.is-on .opt-mark {
  border-color: var(--sand);
  color: var(--sand);
  background: rgba(155, 45, 45, 0.06);
}
.opt-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.85;
  padding-top: 1px;
}

.quiz-nav {
  margin-top: 26px;
  min-height: 28px;
}

/* —— 结果 —— */
.view-result { padding-bottom: 56px; }

.result-cover {
  text-align: center;
  padding: 12px 0 8px;
}

.cover-kicker {
  font-size: 12px;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: var(--gold);
  margin-bottom: 18px;
}

.medallion-wrap {
  width: 168px;
  height: 168px;
  margin: 0 auto 22px;
}
.medallion-svg { width: 100%; height: 100%; display: block; }

.figure-name {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  line-height: 1.2;
  margin: 0 0 8px;
  white-space: nowrap;
}
.figure-role {
  font-size: 15px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin: 0 0 16px;
}
.result-cover .seal-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 18px;
}
.result-cover .seal-wrap .seal-svg {
  transform: rotate(8deg);
}

.match-line {
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin: 0 0 4px;
}
.seen-as {
  font-size: 13px;
  color: var(--ink-faint);
  margin: 0 0 8px;
}
.close-gap {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 0;
}

.section {
  margin-top: 28px;
  padding-top: 4px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  margin: 0 0 12px;
  color: var(--ink);
}
.section-title::before {
  content: "";
  width: 2px;
  height: 1em;
  background: var(--sand);
  display: inline-block;
}

.ruled {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1em * 1.85 - 1px),
    rgba(155, 45, 45, 0.13) calc(1em * 1.85 - 1px),
    rgba(155, 45, 45, 0.13) calc(1em * 1.85)
  );
  background-attachment: local;
  padding-bottom: 2px;
}
.section-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink);
  margin: 0;
}

.bar-legend {
  font-size: 12px;
  color: var(--ink-faint);
  margin: -4px 0 12px;
}

.bars { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 3em 1fr;
  gap: 10px;
  align-items: center;
}
.bar-label {
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.bar-cell {
  position: relative;
  height: 14px;
}
.bar-track {
  position: absolute;
  left: 0; right: 0;
  top: 2px;
  height: 10px;
  background: rgba(42, 36, 28, 0.08);
  overflow: hidden;
}
.bar-ink {
  display: block;
  height: 100%;
  background: var(--ink);
  opacity: 0.72;
  max-width: 100%;
}
.bar-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--sand);
  transform: translateX(-1px);
  z-index: 1;
}

.verse {
  margin: 0;
  padding: 0;
  list-style: none;
}
.verse li {
  position: relative;
  padding: 8px 0 8px 2.2em;
  font-size: 15px;
  line-height: 1.85;
  border-bottom: 1px solid rgba(42, 36, 28, 0.08);
}
.verse li:last-child { border-bottom: 0; }
.verse li::before {
  position: absolute;
  left: 0;
  top: 8px;
  color: var(--sand);
  font-size: 12px;
  letter-spacing: 0;
  content: attr(data-n);
}

.lines-note {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 0 0 8px;
}

.runners {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.runner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(42, 36, 28, 0.12);
}
.runner:last-child { border-bottom: 1px solid rgba(42, 36, 28, 0.12); }
.runner-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.runner-role {
  font-size: 13px;
  color: var(--ink-faint);
  text-align: right;
}

.result-actions {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.cover-extra {
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
