/* 《余烬》在线阅读版 — 谷雾余烬 */
:root {
  --mist: #e7eef1;
  --paper: #f3f6f5;
  --ink: #1f2a26;
  --ink-soft: #3a4742;
  --ash: #7d8a84;
  --moss: #4a6356;
  --ember: #c45c26;
  --ember-soft: rgba(196, 92, 38, 0.14);
  --line: rgba(36, 48, 44, 0.12);
  --shadow: 0 18px 50px rgba(30, 40, 38, 0.12);
  --page-w: min(720px, 92vw);
  --page-h: min(860px, calc(100vh - 140px));
  --serif: "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "SimSun", serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}

@font-face {
  font-family: "Noto Serif SC";
  src: url("../fonts/noto-serif-sc-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Serif SC";
  src: url("../fonts/noto-serif-sc-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans SC";
  src: url("../fonts/noto-sans-sc-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--serif);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(196, 92, 38, 0.08), transparent 55%),
    linear-gradient(180deg, #cfd9df 0%, var(--mist) 38%, #dfe7ea 100%);
}

body {
  overflow: hidden;
}

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 36px);
  font-family: var(--sans);
  color: var(--ink-soft);
}

.brand {
  font-size: 15px;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: var(--ink);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.12em;
  padding: 8px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  border-color: rgba(196, 92, 38, 0.35);
  outline: none;
}

.icon-btn:active { transform: translateY(1px); }

/* stage */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0 16px 8px;
  min-height: 0;
}

.page {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55), transparent 28%),
    var(--paper);
  border: 1px solid rgba(36, 48, 44, 0.08);
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
  overflow-x: hidden;
  position: relative;
  transform-origin: left center;
  transition: transform .55s cubic-bezier(.22, .8, .28, 1), opacity .4s ease;
}

.book-frame {
  width: var(--page-w);
  height: var(--page-h);
  position: relative;
  perspective: 1600px;
  max-width: 100%;
  overflow: hidden;
}

.measure-page {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
  box-shadow: none;
  transform: none !important;
  opacity: 1 !important;
  animation: none !important;
}

.page.is-exit-next {
  transform: rotateY(-14deg) translateX(-18px);
  opacity: 0;
}
.page.is-exit-prev {
  transform: rotateY(14deg) translateX(18px);
  opacity: 0;
}
.page.is-enter {
  animation: pageIn .5s cubic-bezier(.22, .8, .28, 1);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.page-inner {
  height: 100%;
  padding: clamp(28px, 5vw, 48px) clamp(26px, 5vw, 52px) 36px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden;
  max-width: 100%;
}

.page-kicker {
  margin-bottom: 14px;
  flex-shrink: 0;
}

.book-card-title {
  letter-spacing: 0.28em;
  text-indent: 0.28em;
}

/* cover */
.cover {
  height: 100%;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-rows: minmax(140px, 1.05fr) auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.cover-art {
  margin: -8px 0 0;
  min-height: 140px;
  width: 100%;
  background: center/cover no-repeat url("../images/cover-yujin.png");
  border-bottom: 1px solid var(--line);
  position: relative;
}

.cover-art::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(transparent, var(--paper));
}

.cover-title {
  margin: 0;
  font-size: clamp(42px, 8vw, 64px);
  font-weight: 600;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  /* letter-spacing 会在末字后多出一段空白，抵消以免撑出横向滚动条 */
  margin-right: -0.42em;
  max-width: 100%;
}

.cover-body {
  padding-top: 8px;
  text-align: center;
  max-width: 100%;
  overflow-x: hidden;
}

.cover-blurb {
  margin: 18px auto 0;
  max-width: min(28em, 100%);
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.9;
  text-align: left;
  text-indent: 2em;
  box-sizing: border-box;
  padding: 0 4px;
}

.cover-meta {
  margin-top: 28px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ash);
}

.ember-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ember);
  margin: 0 10px 1px;
  box-shadow: 0 0 12px rgba(196, 92, 38, 0.55);
}

/* toc */
.toc {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.toc h2 {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.toc-list li {
  border-top: 1px solid var(--line);
}

.toc-list li.toc-book {
  border-top-color: rgba(36, 48, 44, 0.18);
  margin-top: 6px;
}

.toc-list li.toc-book:first-child {
  margin-top: 0;
}

.toc-list li.toc-chapter {
  border-top-color: rgba(36, 48, 44, 0.06);
}

.toc-list button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 14px 4px;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.toc-list .toc-book button {
  font-weight: 600;
  letter-spacing: 0.06em;
  padding-top: 16px;
  padding-bottom: 12px;
}

.toc-list .toc-chapter button {
  font-size: 14px;
  padding: 10px 4px 10px 18px;
  color: var(--ink-soft);
}

.toc-list .toc-chapter.is-volume button {
  font-style: italic;
  color: var(--ash);
}

.toc-list button:hover,
.toc-list button:focus-visible {
  color: var(--ember);
  outline: none;
}

.toc-list .is-current button {
  color: var(--ember);
}

.toc-list .idx {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ash);
  letter-spacing: 0.12em;
  flex-shrink: 0;
}

/* chapter / volume */
.kicker {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--ash);
  margin-bottom: 10px;
}

.chapter-title {
  margin: 0 0 22px;
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.35;
}

.volume-card {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 14px;
}

.volume-card .mark {
  width: 48px;
  height: 2px;
  margin: 0 auto;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
}

/* illustration page */
.illus-page {
  height: 100%;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  overflow-x: hidden;
}

.illus-page img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 62%;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: #dfe7ea;
}

.illus-caption {
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  letter-spacing: 0.06em;
  max-width: 100%;
  padding: 0 4px;
  box-sizing: border-box;
}

.end-page .end-meta {
  margin-top: 36px;
  max-width: 28em;
  text-align: center;
}

.end-page .end-contact {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.end-page .end-contact a {
  color: var(--ember);
  text-decoration: none;
  border-bottom: 1px solid rgba(196, 92, 38, 0.35);
}

.end-page .end-contact a:hover,
.end-page .end-contact a:focus-visible {
  border-bottom-color: var(--ember);
  outline: none;
}

.end-page .end-copy {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

.end-page .end-copy-note {
  margin: 0;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ash);
  letter-spacing: 0.04em;
}

/* prose */
.prose {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  font-size: clamp(16px, 2.1vw, 18px);
  line-height: 1.95;
  color: var(--ink);
}

.prose p {
  margin: 0 0 1.05em;
  text-indent: 2em;
  text-align: justify;
  hyphens: auto;
}

.prose p:last-child { margin-bottom: 0; }

.chapter-head-mini {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.chapter-head-mini .chapter-title {
  margin: 0;
  font-size: 20px;
}

/* footer nav */
.bottombar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px clamp(16px, 4vw, 36px) 18px;
  font-family: var(--sans);
}

.nav-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.12em;
  padding: 12px 18px;
  border-radius: 2px;
  cursor: pointer;
  transition: all .2s;
  min-width: 108px;
}

.nav-btn:hover:not(:disabled),
.nav-btn:focus-visible:not(:disabled) {
  background: var(--ink);
  color: #f3f6f5;
  border-color: var(--ink);
  outline: none;
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-btn.prev { justify-self: start; }
.nav-btn.next { justify-self: end; }

.pager {
  text-align: center;
  color: var(--ash);
  font-size: 13px;
  letter-spacing: 0.16em;
}

.pager strong {
  color: var(--ink-soft);
  font-weight: 500;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(36, 48, 44, 0.06);
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--moss), var(--ember));
  transition: width .35s ease;
}

/* overlay toc */
.drawer {
  position: fixed;
  inset: 0;
  background: rgba(24, 32, 30, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 20;
}

.drawer.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(400px, 92vw);
  height: 100%;
  background: var(--paper);
  box-shadow: -12px 0 40px rgba(0,0,0,.12);
  padding: 28px 22px;
  transform: translateX(12px);
  transition: transform .3s ease;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.drawer.open .drawer-panel { transform: none; }

.drawer-panel h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2em;
}

.drawer-panel .toc-list {
  margin-top: 8px;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ash);
  letter-spacing: 0.12em;
  opacity: 0;
  transition: opacity .4s;
  pointer-events: none;
}

.hint.show { opacity: 1; }

@media (max-width: 640px) {
  .brand { letter-spacing: 0.22em; text-indent: 0.22em; }
  .cover-title { letter-spacing: 0.28em; text-indent: 0.28em; font-size: 40px; }
  .cover-blurb { font-size: 14px; margin-top: 12px; }
  .cover-meta { margin-top: 16px; }
  .nav-btn { min-width: 88px; padding: 11px 12px; font-size: 13px; }
  .page-inner { padding: 22px 18px 26px; }
  .illus-page img { max-height: 52%; }
}

@media (prefers-reduced-motion: reduce) {
  .page, .page.is-enter, .nav-btn, .icon-btn { transition: none !important; animation: none !important; }
}
