:root {
  --paper: #f7f4ef;
  --page: #fffcf7;
  --ink: #1a1512;
  --muted: #6b6158;
  --line: rgba(26, 21, 18, 0.14);
  --cloth: #3d2140;
  --cloth-deep: #2a1530;
  --gilt: #b8952c;
  --rule: #1a1512;
  --display: "EB Garamond", Georgia, serif;
  --sans: "Figtree", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.7;
}

.paper-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.running-head,
main,
.footer { position: relative; z-index: 1; }

a { color: var(--cloth); }

.running-head {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem clamp(1.2rem, 4vw, 3rem);
  background: rgba(247, 244, 239, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.folio {
  font-variant-numeric: oldstyle-nums;
  color: var(--muted);
}

.cover {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(2rem, 6vh, 4rem) clamp(1.2rem, 4vw, 3rem);
}

.cover-board {
  width: min(100%, 560px);
  min-height: min(80vh, 720px);
  background:
    linear-gradient(145deg, rgba(184, 149, 44, 0.12), transparent 40%),
    linear-gradient(180deg, var(--cloth) 0%, var(--cloth-deep) 100%);
  color: var(--page);
  padding: clamp(2rem, 5vw, 3rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow:
    12px 16px 0 rgba(26, 21, 18, 0.08),
    0 30px 60px rgba(26, 21, 18, 0.25);
  border: 1px solid rgba(184, 149, 44, 0.35);
  animation: open-cover 1s ease both;
}

@keyframes open-cover {
  from { opacity: 0; transform: rotateY(8deg) translateY(20px); }
  to { opacity: 1; transform: none; }
}

.imprint-line {
  margin: 0 0 1.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gilt);
  font-weight: 600;
}

.brand {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  margin: 0 0 1.5rem;
  font-weight: 700;
}

.cover h1 {
  font-family: var(--display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  line-height: 1.25;
  margin: 0 0 1rem;
  max-width: 16ch;
}

.deck {
  margin: 0 0 1.8rem;
  color: rgba(255, 252, 247, 0.75);
  max-width: 36ch;
  font-weight: 400;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.btn {
  display: inline-flex;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.85rem 1.15rem;
  transition: transform 0.2s ease;
}

.btn:hover { transform: translateY(-2px); }

.btn.cloth {
  background: var(--gilt);
  color: var(--ink);
}

.btn.ghost {
  color: var(--page);
  border-bottom: 1px solid var(--gilt);
  padding-left: 0;
  padding-right: 0;
}

.cover-address {
  margin: auto 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: rgba(255, 252, 247, 0.55);
}

section {
  padding: clamp(3.5rem, 8vh, 5.5rem) clamp(1.2rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
}

.chap-label {
  margin: 0 0 0.6rem;
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--cloth);
}

h2 {
  font-family: var(--display);
  font-size: clamp(1.9rem, 3.5vw, 2.9rem);
  line-height: 1.15;
  font-weight: 600;
  margin: 0 0 1.5rem;
  max-width: 18ch;
}

.toc {
  max-width: 720px;
  margin: 0 auto;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list a {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.25rem;
}

.toc-list .dots {
  border-bottom: 1px dotted var(--muted);
  height: 0.85em;
}

.toc-list a:hover { color: var(--cloth); }

.preface-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
  max-width: 1000px;
}

.preface-grid p {
  color: var(--muted);
  font-size: 1.05rem;
}

.preface-aside {
  background: var(--page);
  border: 1px solid var(--line);
  padding: 1.5rem;
  align-self: start;
}

.pull {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.3;
  margin: 0 0 1.5rem;
  color: var(--cloth);
}

.preface-aside ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
}

.preface-aside li {
  color: var(--muted);
  font-size: 0.95rem;
}

.preface-aside strong {
  display: block;
  font-family: var(--display);
  font-size: 1.8rem;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.list-strip {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 1.25rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
  max-width: 900px;
}

.list-strip:last-of-type { border-bottom: 1px solid var(--line); }

.list-strip.reverse { direction: rtl; }
.list-strip.reverse > * { direction: ltr; }

.spine-tag {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--cloth);
  color: var(--gilt);
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 700;
}

.list-strip h3 {
  font-family: var(--display);
  font-size: 1.8rem;
  margin: 0 0 0.7rem;
  font-weight: 600;
}

.list-strip > div > p {
  color: var(--muted);
  max-width: 62ch;
}

.list-strip ul {
  columns: 2;
  gap: 1.5rem;
  margin: 1rem 0 0;
  padding-left: 1.1rem;
}

.spreads {
  background: var(--page);
}

.spread {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 960px;
  margin: 0 auto 1.5rem;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 40px rgba(26, 21, 18, 0.05);
}

.verso,
.recto {
  padding: 1.6rem 1.5rem 1.8rem;
  min-height: 220px;
}

.verso {
  border-right: 1px solid var(--line);
  background: linear-gradient(90deg, #f3efe8, #fff);
}

.page-num {
  margin: 0 0 0.8rem;
  font-family: var(--display);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--muted);
}

.spread h3 {
  font-family: var(--display);
  font-size: 1.5rem;
  margin: 0 0 0.55rem;
}

.spread p {
  margin: 0;
  color: var(--muted);
}

.shelf-lead {
  color: var(--muted);
  max-width: 50ch;
  margin: -0.5rem 0 1.5rem;
}

.bookshelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 140px;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 1rem 0 1.5rem;
  scroll-snap-type: x mandatory;
  align-items: end;
}

.book {
  scroll-snap-align: start;
  height: 220px;
  padding: 1rem 0.75rem;
  writing-mode: horizontal-tb;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: var(--page);
  border-radius: 2px 6px 6px 2px;
  box-shadow: 3px 4px 0 rgba(26, 21, 18, 0.15);
  transition: transform 0.25s ease;
}

.book:hover { transform: translateY(-8px); }

.book span {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: auto;
}

.book strong {
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1.15;
  margin-bottom: 0.35rem;
}

.book em {
  font-size: 0.8rem;
  opacity: 0.8;
  font-style: italic;
}

.book.c1 { background: #3d2140; height: 240px; }
.book.c2 { background: #1f3d36; height: 210px; }
.book.c3 { background: #4a2c1a; height: 230px; }
.book.c4 { background: #1a2a4a; height: 200px; }
.book.c5 { background: #3d2140; height: 250px; }
.book.c6 { background: #2c3d1f; height: 215px; }
.book.c7 { background: #4a1a2a; height: 235px; }
.book.c8 { background: #1f3340; height: 205px; }

.author-dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 960px;
}

.author-dl > div {
  padding: 1.2rem 0;
  border-top: 1px solid var(--line);
}

.author-dl dt {
  font-family: var(--display);
  font-size: 1.35rem;
  margin-bottom: 0.4rem;
}

.author-dl dd {
  margin: 0;
  color: var(--muted);
}

.statutes {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 800px;
  counter-reset: none;
}

.statutes li {
  padding: 1.3rem 0;
  border-top: 1px solid var(--line);
}

.statutes li:last-child { border-bottom: 1px solid var(--line); }

.statutes h3 {
  margin: 0 0 0.45rem;
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--cloth);
}

.statutes p {
  margin: 0;
  color: var(--muted);
  max-width: 65ch;
}

.voices blockquote {
  margin: 0 0 1.25rem;
  padding: 1.25rem 0 1.25rem 1.25rem;
  border-left: 3px solid var(--gilt);
  max-width: 640px;
}

.voices p {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.35;
  margin: 0 0 0.6rem;
}

.voices cite {
  font-style: normal;
  font-size: 0.9rem;
  color: var(--muted);
}

.colophon {
  background: var(--cloth-deep);
  color: var(--page);
  border-top: 0;
}

.colophon .chap-label { color: var(--gilt); }
.colophon h2 { color: #fff; }
.colophon a { color: var(--gilt); }

.colo-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 2rem;
  max-width: 1000px;
}

.colo-grid > div > p {
  color: rgba(255, 252, 247, 0.72);
}

.colo-grid address {
  font-style: normal;
  margin: 1.4rem 0 0.8rem;
  line-height: 1.85;
  font-family: var(--display);
  font-size: 1.15rem;
}

.mail { font-weight: 600; }

.colo-note {
  font-size: 0.9rem;
  opacity: 0.75;
}

.colophon form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  background: rgba(255, 252, 247, 0.04);
  border: 1px solid rgba(184, 149, 44, 0.3);
  padding: 1.3rem;
}

.form-title {
  grid-column: 1 / -1;
  font-family: var(--display);
  font-size: 1.3rem;
  margin: 0 0 0.3rem;
  color: var(--gilt);
}

.colophon label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 252, 247, 0.65);
}

.colophon .full { grid-column: 1 / -1; }

.colophon input,
.colophon select,
.colophon textarea {
  width: 100%;
  border: 1px solid rgba(255, 252, 247, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: var(--page);
  padding: 0.8rem;
  font: inherit;
}

.colophon button {
  grid-column: 1 / -1;
  justify-self: start;
  border: 0;
  background: var(--gilt);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
}

.form-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--gilt);
}

.footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 2.4rem clamp(1.2rem, 4vw, 3rem) 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer strong {
  font-family: var(--display);
  color: var(--ink);
  font-size: 1.1rem;
}

.footer p:last-child { grid-column: 1 / -1; }

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.in {
  opacity: 1;
  transform: none;
}

@media (max-width: 900px) {
  .preface-grid,
  .spread,
  .author-dl,
  .colo-grid {
    grid-template-columns: 1fr;
  }

  .list-strip,
  .list-strip.reverse {
    grid-template-columns: 1fr;
    direction: ltr;
  }

  .list-strip ul { columns: 1; }

  .verso { border-right: 0; border-bottom: 1px solid var(--line); }

  .colophon form { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .footer { grid-template-columns: 1fr; }
  .cover-board { min-height: auto; padding: 1.8rem 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cover-board { animation: none; }
  .book:hover { transform: none; }
}
