:root {
  --ink: #2c251c;
  --ink-soft: #736759;
  --gold: #c3a170;
  --gold-deep: #9a7746;
  --paper-hi: #faf6ec;
  --paper-lo: #eee4d1;
  --night: #101214;
  --flip-duration: 1180ms;
  --book-w: min(88vw, calc(88vh * 1.778));
}

/* ------------------------------------------------------------------- book */
.book-shell {
  position: relative;
  width: var(--book-w);
  aspect-ratio: 1200 / 675;
  /* 顶部与 .little-nav 拉开间距，避免区域重叠 */
  margin-top: clamp(40px, 6vh, 96px);
  /* 与页脚之间留出足量空隙，避免底部投影阴影压到 .footer-widget-area */
  margin-bottom: clamp(72px, 10vh, 140px);
  animation: fadeUp 1s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.book-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='180' viewBox='0 0 320 180'><text x='50%25' y='50%25' text-anchor='middle' dominant-baseline='middle' font-family='PingFang SC, Hiragino Sans GB, SimSun, serif' font-size='22' font-weight='500' fill='%238b7355' fill-opacity='0.1' transform='rotate(-30 160 90)'>杭州华黎泵业有限公司</text></svg>");
  background-repeat: repeat;
}

.book-shell::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 3%;
  right: 3%;
  bottom: -5.5%;
  height: 16%;
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0) 70%);
  filter: blur(18px);
}

.book {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 2500px;
  perspective-origin: 50% 46%;
  transform-style: preserve-3d;
}

.book::before {
  content: "";
  position: absolute;
  inset: -11px -13px -15px;
  z-index: 0;
  border-radius: 18px;
  background: linear-gradient(150deg, #4b3929 0%, #37281a 46%, #1e1711 100%);
  box-shadow:
    0 38px 62px -28px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.book::after {
  content: "";
  position: absolute;
  inset: 2px -7px -9px;
  z-index: 0;
}

table { border-collapse: collapse; width: 100%; margin: 15px 0; }
table, th,  tr, td { border: 1px solid #333; padding: 6px 10px; text-align: center; }

/* page paper ------------------------------------------------------------- */
.page,
.sheet-face {
  background-color: var(--paper-hi);
  background-image:
    radial-gradient(120% 92% at 78% 4%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 58%),
    radial-gradient(100% 96% at 2% 100%, rgba(164, 125, 74, 0.14), rgba(164, 125, 74, 0) 62%),
    linear-gradient(92deg, #f7f1e5 0%, #faf6ec 46%, #f1e8d7 100%);
}

.page {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
}

/* Size containment lives here rather than on .page / .sheet-face, so cqw/cqh
   still scale with the page while the faces keep working backface culling. */
.page-clip {
  position: absolute;
  inset: 0;
  container-type: size;
  overflow: hidden;
}

.page--left {
  left: 0;
  border-radius: 12px 3px 3px 12px;
  box-shadow:
    inset -28px 0 36px -26px rgba(76, 52, 26, 0.6),
    0 26px 46px -24px rgba(0, 0, 0, 0.62),
    2px 0 0 rgba(255, 255, 255, 0.35);
}

.page--right {
  right: 0;
  border-radius: 3px 12px 12px 3px;
  box-shadow:
    inset 28px 0 36px -26px rgba(76, 52, 26, 0.6),
    0 26px 46px -24px rgba(0, 0, 0, 0.62),
    -2px 0 0 rgba(255, 255, 255, 0.35);
}

/* the turning sheet ------------------------------------------------------ */
.flipper {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  z-index: 20;
  display: none;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration) cubic-bezier(0.46, 0.03, 0.3, 1);
  will-change: transform;
}

.flipper.is-active {
  display: block;
}

.flipper.is-flipped {
  transform: rotateY(-180deg);
}

.sheet-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0.02px);
}

.face-front {
  border-radius: 3px 12px 12px 3px;
  box-shadow:
    inset 28px 0 36px -26px rgba(76, 52, 26, 0.6),
    0 26px 46px -24px rgba(0, 0, 0, 0.62);
}

.face-front .page-inner {
  background: linear-gradient(92deg, #f7f1e5 0%, #faf6ec 46%, #f1e8d7 100%);
}

.face-back {
  transform: rotateY(180deg);
  border-radius: 12px 3px 3px 12px;
  box-shadow:
    inset -28px 0 36px -26px rgba(76, 52, 26, 0.6),
    0 26px 46px -24px rgba(0, 0, 0, 0.62);
}

.face-back .page-inner {
  background: linear-gradient(88deg, #f1e8d7 0%, #faf6ec 54%, #f7f1e5 100%);
}

.sheet-face::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: #2a1c0c;
  opacity: 0;
  mix-blend-mode: multiply;
}

.is-turning .sheet-face::before {
  animation: surfaceShade var(--flip-duration) ease-in-out both;
}

@keyframes surfaceShade {
  0% { opacity: 0; }
  38% { opacity: 0.3; }
  55% { opacity: 0.16; }
  100% { opacity: 0; }
}

/* --------------------------------------------------------------- page body */
.page-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 4.7cqh, 38px) clamp(26px, 5.3cqw, 52px);
  color: var(--ink);
  overflow: hidden;
}

.page-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background-image: var(--noise);
  opacity: 0.05;
  mix-blend-mode: multiply;
}

.page-inner.side-left {
  padding-right: clamp(24px, 4.7cqw, 46px);
  padding-left: clamp(28px, 5.3cqw, 52px);
}

.page-inner.side-right {
  padding-left: clamp(24px, 4.7cqw, 46px);
  padding-right: clamp(28px, 5.3cqw, 52px);
}

.page-text {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: clamp(12px, 3.2cqw, 16px);
  line-height: 1.9;
  text-align: justify;
  color: #3b342a;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 100, 70, 0.35) transparent;
}

.page-text::-webkit-scrollbar {
  width: 6px;
}

.page-text::-webkit-scrollbar-thumb {
  background: rgba(120, 100, 70, 0.35);
  border-radius: 3px;
}

.page-text::-webkit-scrollbar-track {
  background: transparent;
}

.page-text p {
  margin-bottom: 0.55em;
  text-indent: 2em;
}

.page-text p:first-of-type::first-letter {
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 1.6em;
  font-weight: 600;
  color: var(--gold-deep);
}

.page-foot {
  display: flex;
  align-items: flex-end;
  margin-top: clamp(8px, 1.6cqh, 14px);
  white-space: nowrap;
}

.page-no {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(15px, 3.4cqw, 23px);
  line-height: 1;
  color: #7c674b;
  margin-left: auto;
}

.side-left .page-no {
  margin-left: 0;
  margin-right: auto;
}

/* --------------------------------------------------------------- skeleton */
.is-loading-face .page-inner {
  justify-content: center;
  align-items: center;
  gap: 14px;
  background: linear-gradient(92deg, #f7f1e5, #f3ebdc);
}

.skeleton-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0.55;
}

.skeleton-bar {
  height: 9px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(120, 100, 70, 0.14), rgba(120, 100, 70, 0.3), rgba(120, 100, 70, 0.14));
  background-size: 220% 100%;
  animation: shimmer 1.5s linear infinite;
}

.skeleton-bar.wide { height: 22px; width: 42%; }
.skeleton-bar.short { width: 62%; }

.loading-label {
  margin-top: 18px;
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(115, 103, 89, 0.7);
  display: flex;
  align-items: center;
  gap: 9px;
}

.mini-spin {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(115, 103, 89, 0.35);
  border-top-color: var(--gold-deep);
  animation: spin 0.9s linear infinite;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

/* ----------------------------------------------------------------- nav */
.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(195, 161, 112, 0.28);
  border-radius: 50%;
  background: rgba(20, 17, 13, 0.72);
  color: rgba(214, 183, 137, 0.85);
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.3s ease, color 0.3s ease, background 0.3s ease, transform 0.3s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.nav span {
  transform: translateY(-2px);
}

.nav--prev { left: -21px; }
.nav--next { right: -21px; }

.nav:hover,
.nav:focus-visible {
  opacity: 1;
  color: var(--gold);
  background: rgba(18, 15, 12, 0.82);
  outline: none;
}

.nav--prev:hover { transform: translate(-4px, -50%); }
.nav--next:hover { transform: translate(4px, -50%); }

.nav:disabled {
  opacity: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------- overlay */
.book-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 11, 0.42);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  border-radius: 12px;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.book-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.overlay-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(18, 16, 14, 0.62);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.8);
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid rgba(240, 232, 216, 0.28);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}

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

.overlay-text {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(244, 236, 220, 0.8);
}

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


@media (max-width: 1200px) {
  .nav {
    width: 36px;
    height: 36px;
    font-size: 21px;
    opacity: 0.5;
  }
  .nav--prev { left: -18px; }
  .nav--next { right: -18px; }
}

@media (max-width: 720px) {
  :root { --book-w: min(90vw, calc(90vh * 1.778)); }
  .nav { opacity: 0.4; }
}
