:root {
  --red: #b83229;
  --paper-bright: #fff7e6;
  --bg: #060504;
  --font-heading: "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
  --font-body: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--paper-bright);
  font-family: var(--font-body);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a,
button,
input,
textarea,
select,
[role="button"],
[tabindex]:not([tabindex="-1"]) {
  cursor: pointer !important;
}

.top-nav {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  height: 76px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  padding-left: clamp(22px, 3vw, 42px);
  color: #fff6e8;
  background: rgba(8, 8, 8, 0.88);
  backdrop-filter: blur(10px);
  font-family: var(--font-heading);
}

.top-nav__brand {
  display: flex;
  align-items: center;
  color: #fff6e8;
  font-size: clamp(22px, 2.4vw, 38px);
  font-weight: 800;
  text-decoration: none;
  transition: color 0.3s;
}

.top-nav__brand:hover {
  color: var(--red);
}

.top-nav__links {
  display: flex;
  align-items: stretch;
  height: 100%;
}

.top-nav__links a {
  position: relative;
  display: flex;
  min-width: clamp(82px, 8vw, 128px);
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  color: rgba(255, 246, 232, 0.86);
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.3s ease, background 0.3s ease;
}

.top-nav__links a:hover {
  color: #fff6e8;
}

.top-nav__links a.is-active {
  color: #fff;
  background: #e9283e;
}

.top-nav__links a:not(.is-active)::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: 0;
  left: 24px;
  height: 5px;
  background: #e9283e;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease;
}

.top-nav__links a:not(.is-active):hover::after {
  transform: scaleX(1);
}

.works-wrapper {
  --wash: #060504;
  position: relative;
  height: calc(100vh - 76px);
  margin-top: 76px;
  overflow: hidden;
}

.works-wash {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: var(--wash);
  opacity: 0;
  transition:
    opacity 620ms cubic-bezier(0.2, 0.78, 0.22, 1),
    background-color 620ms cubic-bezier(0.2, 0.78, 0.22, 1);
  pointer-events: none;
}

.works-wrapper.is-washed .works-wash {
  opacity: 1;
}

.works-gallery {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
}

.works-gallery::-webkit-scrollbar {
  display: none;
}

.works-scroll-container {
  display: flex;
  align-items: stretch;
  width: max-content;
  min-width: 100%;
  height: 100%;
  padding: clamp(42px, 6vh, 70px) clamp(48px, 6vw, 104px);
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

.works-intro {
  position: relative;
  display: flex;
  flex: 0 0 clamp(390px, 34vw, 560px);
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-inline: clamp(24px, 4vw, 72px);
  background: transparent;
  animation: introRise 820ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.works-intro__portrait {
  display: block;
  width: clamp(130px, 11vw, 188px);
  height: clamp(130px, 11vw, 188px);
  margin-bottom: clamp(28px, 4vh, 46px);
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 16%;
  opacity: 0.88;
  filter: grayscale(100%) contrast(1.08) brightness(0.92);
}

.works-intro__title {
  margin: 0;
  color: rgba(255, 246, 232, 0.9);
  font-family: "Source Han Serif CN", "思源宋体 CN", Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(26px, 2.1vw, 40px);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-align: center;
}

.works-shelf {
  position: relative;
  display: flex;
  min-width: calc(100vw - clamp(96px, 12vw, 208px));
  min-height: 100%;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(8px, 0.9vw, 16px);
  padding-block: clamp(28px, 5vh, 58px);
  padding-inline: clamp(48px, 6vw, 104px);
  perspective: 1250px;
  perspective-origin: 50% 44%;
}

.work-book {
  --group-shift: 0px;
  --back-offset: clamp(4px, calc(var(--visible-depth) - 8px), 8px);
  --bottom-line: clamp(2px, calc(var(--visible-depth) - 10px), 4px);
  --hardcover-lip: clamp(2px, calc(var(--visible-depth) * 0.22), 4px);
  --cover-lip: clamp(1px, calc(var(--visible-depth) * 0.08), 2px);
  --cover-edge: color-mix(in srgb, var(--book-accent) 58%, #090705);
  --cover-edge-deep: color-mix(in srgb, var(--book-accent) 42%, #030201);
  --page-depth: clamp(8px, calc(var(--visible-depth) * 0.62), 12px);
  --page-bottom: 3px;
  --cover-lift: 2px;
  --page-inset: 3px;
  --cover-overhang: 1px;
  --page-corner-overlap: 1px;
  position: relative;
  z-index: 2;
  flex: 0 0 calc(var(--spine-w) + 6px);
  width: calc(var(--spine-w) + 6px);
  height: min(var(--book-h), calc(100vh - 220px));
  overflow: visible;
  isolation: isolate;
  outline: none;
  transform: translateX(var(--group-shift)) rotateZ(var(--lean));
  transform-origin: 50% 100%;
  transition:
    transform 330ms cubic-bezier(0.22, 0.72, 0.24, 1),
    filter 300ms ease,
    opacity 300ms ease;
  transition-delay: 0ms, 0ms, 0ms;
}

.works-shelf.is-flip-measuring .work-book {
  transition: none !important;
}

.work-book::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 12px;
  right: -5px;
  bottom: 4px;
  width: 10px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.26), transparent 82%);
  filter: blur(1px);
  opacity: 0.52;
  transform: scaleY(0.96);
  transform-origin: left center;
  pointer-events: none;
}

.work-book::after {
  content: "";
  position: absolute;
  z-index: 0;
  right: 7px;
  bottom: -3px;
  left: 7px;
  height: 8px;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.42) 0%,
    rgba(0, 0, 0, 0.18) 44%,
    transparent 80%
  );
  filter: blur(1px);
  opacity: 0.48;
  transform: scaleX(0.76);
  transform-origin: center;
  pointer-events: none;
}

.work-book__object {
  position: absolute;
  bottom: 0;
  left: 3px;
  width: var(--spine-w);
  height: 100%;
  transform: none;
  transform-origin: center bottom;
  transform-style: preserve-3d;
  transition:
    width 560ms cubic-bezier(0.16, 1, 0.3, 1),
    left 560ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 560ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: width, left, transform;
}

.work-book__back,
.work-book__fore-edge,
.work-book__bottom-edge,
.work-book__cover,
.work-book__spine {
  position: absolute;
  backface-visibility: hidden;
}

.work-book__object :is(.work-book__back, .work-book__fore-edge, .work-book__bottom-edge) {
  opacity: 0;
  transition: opacity 240ms ease 0ms;
}

.work-book__back {
  z-index: 0;
  top: 3px;
  right: calc(0px - var(--back-offset));
  bottom: calc(0px - var(--bottom-line));
  left: 4px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--book-accent) 48%, #080706) 0%,
    color-mix(in srgb, var(--book-accent) 62%, #0d0907) 58%,
    color-mix(in srgb, var(--book-accent) 38%, #030201) 100%
  );
  border: 0;
  border-radius: 0 3px 3px 0;
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.24);
  transform: none;
}

.work-book__fore-edge {
  z-index: 2;
  top: 4px;
  right: calc(0px - var(--hardcover-lip));
  bottom: 5px;
  width: var(--hardcover-lip);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--book-accent) 78%, #15110d),
    color-mix(in srgb, var(--book-accent) 54%, #050403)
  );
  border-right: 1px solid rgba(0, 0, 0, 0.42);
  box-shadow: inset 1px 0 rgba(255, 244, 222, 0.07);
  transform: none;
}

.work-book__bottom-edge {
  z-index: 3;
  right: calc(0px - var(--visible-depth));
  bottom: 0;
  left: 5px;
  height: var(--bottom-line);
  background: linear-gradient(90deg, rgba(85, 69, 48, 0.42), rgba(217, 206, 185, 0.8) 18%, rgba(150, 136, 113, 0.7));
  border-bottom: 1px solid rgba(61, 49, 35, 0.36);
  transform: none;
}

.work-book__cover {
  z-index: 4;
  inset: 0 0 var(--bottom-line) 0;
  overflow: hidden;
  padding: 0;
  background: color-mix(in srgb, var(--book-accent) 78%, #0b0807);
  border: 0;
  border-radius: 4px 4px 3px 3px;
  opacity: 0;
  box-shadow:
    inset 3px 0 0 rgba(0, 0, 0, 0.28),
    inset 6px 0 9px rgba(0, 0, 0, 0.18),
    12px 18px 36px rgba(0, 0, 0, 0.5);
  transform: none;
  transform-origin: center center;
  transition:
    opacity 380ms cubic-bezier(0.2, 0.78, 0.22, 1) 80ms,
    filter 380ms ease,
    box-shadow 380ms ease,
    transform 560ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.work-book__cover::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: 0;
  width: 5px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.28) 0%,
    rgba(0, 0, 0, 0.1) 42%,
    transparent 100%
  );
  transition: width 560ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.work-book__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow:
    inset 1px 0 0 rgba(0, 0, 0, 0.28),
    inset -1px 0 0 var(--cover-edge),
    inset 0 -1px 0 var(--cover-edge-deep),
    inset 0 1px 0 rgba(0, 0, 0, 0.08),
    inset 4px 0 8px rgba(0, 0, 0, 0.07);
  pointer-events: none;
}

.work-book__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  box-shadow: none;
  transition: filter 460ms ease, transform 780ms cubic-bezier(0.16, 1, 0.3, 1);
}

.work-book:not(.is-open) .work-book__cover img {
  filter: grayscale(42%) saturate(0.62) brightness(0.72);
  transform: scale(1.035);
}

.work-book__spine {
  z-index: 5;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--spine-w);
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: rgba(239, 228, 207, 0.9);
  border-radius: 4px 2px 2px 4px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.5), transparent 18%, rgba(255, 255, 255, 0.1) 46%, transparent 68%, rgba(0, 0, 0, 0.38)),
    var(--book-accent);
  box-shadow:
    inset 3px 0 5px rgba(0, 0, 0, 0.28),
    inset -2px 0 4px rgba(0, 0, 0, 0.22),
    2px 4px 7px rgba(0, 0, 0, 0.22);
  transform: translateZ(1px);
  transform-origin: left center;
  transition: opacity 260ms ease, filter 260ms ease, box-shadow 260ms ease;
}

.work-book__spine::before,
.work-book__spine::after {
  content: "";
  position: absolute;
  right: 6px;
  left: 6px;
  height: 1px;
  background: rgba(231, 216, 190, 0.20);
  box-shadow: 0 1px rgba(0, 0, 0, 0.25);
}

.work-book__spine::before {
  top: 24px;
}

.work-book__spine::after {
  bottom: 24px;
}

.work-book__spine-title {
  overflow: hidden;
  max-height: calc(100% - 104px);
  font-family: "Source Han Serif CN", "思源宋体 CN", "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: clamp(14px, 1vw, 18px);
  letter-spacing: 0.13em;
  line-height: 1;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  writing-mode: vertical-rl;
}

.work-book__spine-fr {
  position: absolute;
  top: 20px;
  left: 50%;
  overflow: hidden;
  max-height: 38%;
  color: rgba(255, 247, 234, 0.6);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(9px, 0.66vw, 11px);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: translateX(-50%);
}

.work-book[data-light="true"] .work-book__spine-title {
  color: #1c1712;
  text-shadow: none;
}

.work-book[data-light="true"] .work-book__spine-fr {
  color: rgba(28, 23, 18, 0.55);
  text-shadow: none;
}

.work-book.is-peeking:not(.is-open) {
  z-index: 7;
  transform: translateX(var(--group-shift)) rotateZ(0deg) scale(1.055);
  transition-duration: 190ms, 190ms, 190ms;
}

.work-book.is-peeking:not(.is-open) .work-book__spine {
  filter: brightness(1.12) saturate(1.08);
  box-shadow:
    inset 3px 0 5px rgba(0, 0, 0, 0.24),
    inset -2px 0 4px rgba(0, 0, 0, 0.18),
    3px 6px 9px rgba(0, 0, 0, 0.26);
  transition-duration: 190ms;
}

.work-book.is-opening {
  z-index: 20;
}

.work-book.is-closing {
  z-index: 18;
}

.work-book.is-closing .work-book__object {
  transition-duration: 520ms;
}

.work-book.is-closing .work-book__cover {
  opacity: 0;
  transition-duration: 300ms;
  transition-delay: 0ms;
}

.work-book.is-open {
  z-index: 20;
  transform: translateX(var(--group-shift)) rotateZ(0deg);
}

.work-book.is-open::before {
  opacity: 0;
}

.work-book.is-open::after {
  right: auto;
  bottom: -10px;
  left: calc(3px + (var(--spine-w) - var(--book-w)) / 2 + 8px);
  width: calc(var(--book-w) - 10px);
  height: 22px;
  background: radial-gradient(
    ellipse at 54% 42%,
    rgba(0, 0, 0, 0.48) 0%,
    rgba(0, 0, 0, 0.24) 42%,
    transparent 76%
  );
  filter: blur(5px);
  opacity: 0.58;
  transform: translateX(12px) scaleX(0.94) skewX(-5deg);
}

.work-book.is-open .work-book__object {
  left: calc(3px + (var(--spine-w) - var(--book-w)) / 2);
  width: var(--book-w);
  transform: translateY(-2px) rotateY(-4deg) translateZ(6px);
  transform-origin: 28% 54%;
}

.work-book.is-open .work-book__back {
  top: calc(var(--page-inset) - var(--cover-overhang));
  right: calc(0px - var(--page-depth) - 2px);
  bottom: calc(0px - var(--page-bottom) - var(--cover-overhang));
  left: 1px;
  opacity: 1;
  transition-delay: 70ms;
  box-shadow: 3px 4px 8px rgba(0, 0, 0, 0.18);
  transform: translateZ(-2px);
}

.work-book.is-open .work-book__fore-edge {
  top: var(--page-inset);
  right: calc(0px - var(--page-depth));
  bottom: 1px;
  width: var(--page-depth);
  opacity: 1;
  background:
    linear-gradient(90deg, rgba(31, 26, 21, 0.3) 0, rgba(31, 26, 21, 0.08) 1.5px, transparent 3px),
    repeating-linear-gradient(0deg, transparent 0 2.5px, rgba(58, 50, 41, 0.08) 2.5px 3px, transparent 3px 5.5px),
    repeating-linear-gradient(0deg, rgba(241, 232, 211, 0.05) 0 0.5px, transparent 0.5px 3.5px),
    radial-gradient(ellipse at 72% 50%, rgba(235, 224, 201, 0.12), transparent 62%),
    linear-gradient(180deg, #766d60 0%, #a99e8a 12%, #b4a995 50%, #978d7b 88%, #6c6357 100%);
  border-right: 1px solid rgba(45, 38, 31, 0.28);
  box-shadow: inset 1px 0 rgba(255, 247, 226, 0.05);
  clip-path: polygon(0 0, 100% 3px, 100% calc(100% - 3px), 0 100%);
  transform: translateZ(-1px);
}

.work-book.is-open .work-book__fore-edge::after {
  content: "";
  display: none;
  position: absolute;
  right: -1px;
  bottom: calc(0px - var(--page-inset) - var(--page-corner-overlap));
  left: 0;
  height: calc(var(--page-inset) + var(--page-corner-overlap));
  background:
    linear-gradient(90deg, rgba(31, 26, 21, 0.24), transparent 2px),
    linear-gradient(180deg, #978d7b, #7e7466 72%, #6a6155);
  border-right: 1px solid rgba(45, 38, 31, 0.28);
  pointer-events: none;
}

.work-book.is-open .work-book__bottom-edge {
  right: calc(0px - var(--page-depth));
  bottom: calc(0px - var(--page-bottom));
  left: 12%;
  height: var(--page-bottom);
  opacity: 0;
  background:
    linear-gradient(180deg, rgba(38, 32, 26, 0.3), transparent 1px),
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(58, 50, 41, 0.07) 3px 3.5px, transparent 3.5px 7px),
    linear-gradient(90deg, #756c5f, #a69b87 20%, #9b917f 78%, #6a6155);
  border-bottom: 1px solid rgba(39, 33, 27, 0.24);
  clip-path: polygon(0 0, calc(100% - 3px) 0, 100% 100%, 3px 100%);
  filter: brightness(0.72);
  transform: translateZ(-0.5px);
}

.work-book.is-open .work-book__cover {
  inset: 0;
  padding: 0;
  border-radius: 2px;
  opacity: 1;
  transform: translateZ(var(--cover-lift));
  box-shadow:
    inset 5px 0 10px rgba(0, 0, 0, 0.16),
    3px 6px 10px rgba(0, 0, 0, 0.18),
    14px 20px 30px rgba(0, 0, 0, 0.2);
}

.work-book.is-open .work-book__cover::before {
  width: 12px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.13) 34%,
    rgba(255, 246, 224, 0.04) 66%,
    transparent 100%
  );
}

.work-book.is-open .work-book__cover img {
  filter: grayscale(0%) saturate(1) brightness(1);
  transform: scale(1);
}

.work-book.is-open .work-book__spine {
  opacity: 0;
}

.works-shelf.has-open-book .work-book:not(.is-open) {
  filter: brightness(0.72) saturate(0.68);
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .work-book:not(.is-open):hover {
    filter: brightness(1.12);
  }
}

@keyframes introRise {
  from {
    opacity: 0;
    transform: translate3d(-18px, 14px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 768px) {
  .top-nav {
    height: 64px;
    padding-left: 16px;
  }

  .top-nav__brand {
    font-size: 20px;
  }

  .top-nav__links a {
    min-width: 70px;
    padding: 0 12px;
    font-size: 14px;
  }

  .works-wrapper {
    height: calc(100vh - 64px);
    margin-top: 64px;
  }

  .works-scroll-container {
    padding: 24px 16px 42px;
  }

  .works-intro {
    flex-basis: min(54vw, 220px);
    padding-inline: 12px 18px;
  }

  .works-intro__title {
    font-size: 24px;
  }

  .works-intro__portrait {
    width: 88px;
    height: 88px;
    margin-bottom: 20px;
  }

  .works-shelf {
    gap: 7px;
    padding-block: 28px 42px;
    padding-inline: 14px 28px;
  }

  .work-book {
    --page-depth: clamp(6px, calc(var(--visible-depth) * 0.45), 9px);
    --page-bottom: 3px;
    flex-basis: calc(var(--spine-w) * 0.78 + 4px);
    width: calc(var(--spine-w) * 0.78 + 4px);
    height: min(calc(var(--book-h) * 0.78), calc(100vh - 190px));
  }

  .work-book__object {
    width: calc(var(--spine-w) * 0.78);
  }

  .work-book__spine {
    width: calc(var(--spine-w) * 0.78);
  }

  .work-book.is-open .work-book__object {
    left: calc(3px + (var(--spine-w) * 0.78 - var(--book-w) * 0.78) / 2);
    width: calc(var(--book-w) * 0.78);
    transform: translateY(-1px) rotateY(-3deg) translateZ(4px);
  }

}

@media (prefers-reduced-motion: reduce) {
  html,
  .works-gallery,
  .works-scroll-container {
    scroll-behavior: auto;
  }

  .works-intro {
    animation: none;
  }

  .work-book,
  .works-wash,
  .work-book__cover,
  .work-book__object,
  .work-book__back,
  .work-book__fore-edge,
  .work-book__bottom-edge {
    animation: none !important;
    transition-duration: 120ms !important;
  }

  .work-book.is-open .work-book__object {
    transform: translateY(-2px) rotateY(-4deg) translateZ(6px);
  }

  .work-book.is-peeking:not(.is-open) {
    transform: translateX(var(--group-shift)) rotateZ(var(--lean));
  }

  .work-book.is-peeking:not(.is-open) .work-book__spine {
    filter: none;
  }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .work-book.is-open .work-book__object {
    transform: translateY(-1px) rotateY(-3deg) translateZ(4px);
  }
}
