:root {
  --lacquer: #fefcf8;
  --ink: #1a1a1a;
  --muted: #7a6a5d;
  --crimson: #c21807;
  --crimson-deep: #8f1204;
  --gold: #c5a059;
  --spine: #1c1412;
  --spine-fg: rgba(252, 248, 242, 0.72);
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --display: "Palatino Linotype", "Palatino", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--lacquer);
  color: var(--ink);
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cg fill='none' stroke='%23c21807' stroke-width='0.6' opacity='0.07'%3E%3Cpath d='M28 0 L56 16 L56 48 L28 64 L0 48 L0 16 Z'/%3E%3Cpath d='M28 16 L42 24 L42 40 L28 48 L14 40 L14 24 Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 56px 97px;
}

.book {
  display: flex;
  min-height: 100vh;
}

.spine {
  flex: 0 0 84px;
  background: var(--spine);
  color: var(--spine-fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 32px;
  position: relative;
}

.spine::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(197, 160, 89, 0.55) 18%, rgba(197, 160, 89, 0.55) 82%, transparent);
}

.spine-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(197, 160, 89, 0.55);
  color: #f7efe2;
  font-family: var(--serif);
  font-size: 16px;
}

.spine-title {
  writing-mode: vertical-rl;
  font-family: var(--serif);
  letter-spacing: 0.42em;
  font-size: 15px;
}

main {
  flex: 1;
  max-width: 860px;
  padding: 72px 64px 56px;
}

.kicker {
  margin: 0;
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--crimson);
}

h1 {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(40px, 6vw, 64px);
  letter-spacing: 0.18em;
  line-height: 1.15;
}

.couplet {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 26px 0 0;
  max-width: 16em;
  font-family: var(--serif);
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.45;
  letter-spacing: 0.06em;
}

.couplet span:last-child {
  color: var(--crimson-deep);
}

.obtain {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 22px;
  margin: 28px 0 0;
  max-width: 38em;
}

.obtain-link {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.14em;
  color: var(--crimson);
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 3px;
}

.obtain-link:hover,
.obtain-link:focus-visible {
  color: var(--crimson-deep);
  border-bottom-color: var(--crimson);
}

.obtain span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.story {
  margin-top: 56px;
  max-width: 40em;
}

.story p {
  margin: 0 0 1.05em;
}

.story .turn {
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.08em;
  line-height: 1.5;
}

.traits {
  margin-top: 40px;
}

.traits h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--crimson);
}

.traits table {
  width: 100%;
  border-collapse: collapse;
}

.traits th,
.traits td {
  padding: 16px 20px 16px 0;
  border-bottom: 1px solid rgba(197, 160, 89, 0.45);
  text-align: left;
  vertical-align: top;
  line-height: 1.65;
}

.traits thead th {
  padding-top: 0;
  padding-bottom: 10px;
  border-bottom-color: var(--gold);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--crimson);
}

.traits tbody th {
  width: 14em;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.traits td {
  color: var(--muted);
  padding-right: 0;
  font-size: 15px;
  text-wrap: pretty;
}

.strip {
  display: flex;
  gap: 16px;
  margin-top: 22px;
  padding-bottom: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  cursor: grab;
  scrollbar-color: var(--crimson) rgba(197, 160, 89, 0.28);
  scrollbar-width: thin;
}

.strip.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.strip::-webkit-scrollbar {
  height: 8px;
}

.strip::-webkit-scrollbar-track {
  background: rgba(197, 160, 89, 0.28);
}

.strip::-webkit-scrollbar-thumb {
  background: var(--crimson);
}

.strip figure {
  flex: 0 0 340px;
  margin: 0;
  scroll-snap-align: start;
  cursor: pointer;
}

.strip img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--gold);
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(197, 160, 89, 0.28);
  pointer-events: none;
}

.strip figcaption {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.12em;
}

body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 64px 18px 36px;
  background: rgba(28, 20, 18, 0.9);
}

.viewer-prev { grid-column: 1; grid-row: 1; }
.viewer figure { grid-column: 2; grid-row: 1; }
.viewer-next { grid-column: 3; grid-row: 1; }

.viewer[hidden] { display: none; }

.viewer figure {
  margin: 0;
  min-width: 0;
  justify-self: center;
  max-width: min(1100px, 100%);
}

.viewer img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  border: 1px solid var(--gold);
  background: #fff;
}

.viewer figcaption {
  margin-top: 12px;
  text-align: center;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.16em;
  color: #f7efe2;
}

.viewer button {
  justify-self: center;
  border: 1px solid rgba(197, 160, 89, 0.7);
  background: transparent;
  color: #f7efe2;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.12em;
  padding: 8px 12px;
  cursor: pointer;
}

.viewer button:hover,
.viewer button:focus-visible {
  color: #fff;
  border-color: var(--gold);
}

.viewer-close {
  position: absolute;
  top: 18px;
  right: 18px;
}

.closing {
  margin: 36px 0 0;
  max-width: 40em;
  padding-top: 28px;
  border-top: 1px solid rgba(197, 160, 89, 0.45);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: 0.03em;
}

.colophon {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  color: var(--muted);
  font-size: 13px;
}

.beian {
  color: var(--muted);
  text-underline-offset: 3px;
}

.beian:hover,
.beian:focus-visible {
  color: var(--crimson-deep);
}

a:focus-visible {
  outline: 2px solid var(--crimson);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .book { flex-direction: column; }

  .spine {
    flex-basis: auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    padding: 16px 20px;
  }

  .spine::after {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(197, 160, 89, 0.55), transparent);
  }

  .spine-title {
    writing-mode: horizontal-tb;
    letter-spacing: 0.28em;
  }

  main { padding: 36px 22px 40px; }

  .couplet {
    max-width: none;
    font-size: 20px;
    letter-spacing: 0.02em;
  }

  .strip figure {
    flex-basis: 78vw;
  }

  .viewer {
    grid-template-columns: 1fr 1fr;
  }

  .viewer figure { grid-column: 1 / -1; grid-row: 1; }
  .viewer-prev { grid-column: 1; grid-row: 2; }
  .viewer-next { grid-column: 2; grid-row: 2; }

  .traits thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .traits tr,
  .traits tbody th,
  .traits td {
    display: block;
    width: auto;
  }

  .traits tbody th {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .traits td {
    padding-top: 4px;
  }

  .colophon { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
