/* The Palindrome — the web page.
   The book is a palindrome grid: 841 cells, every reading path load-bearing,
   the center left empty on purpose. The page is built the same way — hairline
   warp and weft, each section a cell of the lattice, the interludes the parts
   no record holds (their cells left empty), and the exact middle of the book
   marked with the empty center. */

:root {
  /* the second purple — the dye the record does not have and the novel invents */
  --pd-purple: #7A5FA8;
  --pd-purple-soft: color-mix(in srgb, var(--pd-purple) 30%, var(--mo-bg));
}

/* ── nav — the seal is inverted ink; the glyph must invert with it.
   Mono's own template leaves .mo-nav__brand-mark an empty decorative
   square: background: var(--mo-ink) and no colour at all. A glyph left
   to inherit --mo-fg sits on the same value and vanishes — dark-on-dark
   in light mode, white-on-white in dark — while the 0.4s theme
   transitions and the nav's backdrop blur make it flicker through the
   change. The fix is the Yellow Immortal's: set the glyph to --mo-bg so
   it inverts with the mark in both themes. */
.mo-nav__brand-mark {
  display: grid;
  place-items: center;
  font-family: "Noto Serif SC", "Noto Serif CJK SC", serif;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  color: var(--mo-bg);
}

/* ── hero ──────────────────────────────────────────────────────────── */

.pd-hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(3.5rem, 8vw, 6.5rem) 1.5rem clamp(2.5rem, 6vw, 4rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.pd-hero__text { min-width: 0; }

.pd-title {
  font-family: 'Inter', sans-serif;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 1.2rem;
}

.pd-lede {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--mo-fg-muted);
  max-width: 56ch;
  margin: 0 0 1.6rem;
}

.pd-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2.2rem;
  margin: 0 0 1.8rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--mo-line);
  border-bottom: 1px solid var(--mo-line);
}
.pd-facts div { display: flex; gap: .5rem; align-items: baseline; }
.pd-facts dt {
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--mo-fg-muted);
}
.pd-facts dd { margin: 0; font-size: .85rem; font-weight: 500; }

.pd-take { display: flex; flex-wrap: wrap; gap: .6rem; }

.pd-plate {
  margin: 0;
  padding: .5rem;
  border: 1px solid var(--mo-line);
  background: var(--mo-surface);
  box-shadow: var(--mo-shadow-card);
}
.pd-plate img {
  display: block;
  width: 15rem;
  max-width: 100%;
  height: auto;
}

/* ── section headers ───────────────────────────────────────────────── */

.pd-head { max-width: 56rem; margin-bottom: 2.2rem; }
.pd-h2 {
  font-size: clamp(1.4rem, 3.4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: .4rem 0 .9rem;
}
.pd-head__note {
  font-size: .95rem;
  line-height: 1.7;
  color: var(--mo-fg-muted);
  margin: 0;
}

/* ── the web — contents as a lattice ───────────────────────────────── */
/* Weft: the hairline between rows. Warp: faint verticals behind the list,
   so the rows read as cells on a loom. */

.pd-web {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  border-top: 1px solid var(--mo-line-strong);
  background-image:
    repeating-linear-gradient(to right,
      transparent 0, transparent calc(25% - 1px),
      var(--mo-line-soft) calc(25% - 1px), var(--mo-line-soft) 25%);
}

.pd-web .entry { border-bottom: 1px solid var(--mo-line); }

.pd-web .entry__link {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto;
  grid-template-areas:
    "no title words"
    "no open  words";
  column-gap: 1rem;
  align-items: baseline;
  padding: .78rem .6rem;
  text-decoration: none;
  color: var(--mo-fg);
  transition: background-color .15s ease;
}
.pd-web .entry__link:hover { background: var(--mo-subtle); }

/* every row's number sits in a bordered cell of the grid */
.pd-web .entry__no {
  grid-area: no;
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-top: .1rem;
  border: 1px solid var(--mo-border-strong);
  font-size: .7rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--mo-fg-muted);
}

.pd-web .entry__title {
  grid-area: title;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.pd-web .entry__open {
  grid-area: open;
  font-size: .85rem;
  line-height: 1.55;
  color: var(--mo-fg-muted);
  margin-top: .15rem;
}
.pd-web .entry__words {
  grid-area: words;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  color: var(--mo-fg-muted);
  justify-self: end;
}

/* the interludes are the parts no record holds — their cells left empty.
   (href suffix match: interlude slugs are i1..i8; chapters are numeric.) */
.pd-web .entry__link[href*="/read/i"] .entry__no { visibility: hidden; }
.pd-web .entry__link[href*="/read/i"] .entry__title { font-style: italic; }

/* the exact middle of the book — the center cell, left empty */
.pd-web .entry:nth-child(40) { border-top: none; position: relative; }
.pd-web .entry:nth-child(40)::before {
  content: "the center cell is left empty";
  display: block;
  padding: 1.5rem 0;
  text-align: center;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mo-fg-muted);
  position: relative;
}
.pd-web .entry:nth-child(40)::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.45rem;
  width: .9rem;
  height: .9rem;
  transform: translateX(-50%) rotate(45deg);
  border: 1px solid var(--pd-purple);
  background: var(--mo-bg);
}

/* ── su hui — provenance ───────────────────────────────────────────── */

.pd-place { border-top: 1px solid var(--mo-line); }
.pd-place__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.pd-prose {
  font-size: .98rem;
  line-height: 1.75;
  color: var(--mo-fg);
  margin: 0 0 1.4rem;
}

.pd-quote-note {
  font-family: "Noto Serif SC", serif;
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--pd-purple);
  margin: 1.6rem 0 .3rem;
}
.pd-quote-gloss {
  font-size: .85rem;
  line-height: 1.6;
  color: var(--mo-fg-muted);
  margin: 0;
}

/* the web's own numbers */
.pd-figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--mo-line);
  border: 1px solid var(--mo-line);
}
.pd-figure {
  background: var(--mo-bg);
  padding: 1.2rem 1rem 1.1rem;
}
.pd-figure__value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 .4rem;
  font-variant-numeric: tabular-nums;
}
.pd-figure__label {
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--mo-fg-muted);
  margin: 0;
  line-height: 1.5;
}

/* the empty center: a bordered cell with nothing in it */
.pd-empty-cell {
  display: inline-block;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--pd-purple);
  background: transparent;
}

/* ── footer extras ─────────────────────────────────────────────────── */

.pd-foot {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2rem;
}
.pd-foot__name {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 .3rem;
}
.pd-foot__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

/* ── small screens ─────────────────────────────────────────────────── */

@media (max-width: 880px) {
  .pd-hero { grid-template-columns: 1fr; }
  .pd-plate { width: max-content; }
  .pd-place__grid { grid-template-columns: 1fr; }
  .pd-foot { grid-template-columns: 1fr; gap: 1.4rem; }
}

@media (max-width: 560px) {
  .pd-web .entry__link {
    grid-template-columns: 2.3rem minmax(0, 1fr);
    grid-template-areas:
      "no title"
      "no open"
      "no words";
  }
  .pd-web .entry__words { justify-self: start; }
  .pd-web {
    background-image: none;
  }
  .pd-figures { grid-template-columns: 1fr; }
}
