:root {
  --ink: #0d0f10;
  --ink-raised: #14181a;
  --paper: #e8e2d6;
  --paper-dim: #9a968c;
  --rule: #23292c;
  --accent: #b3893f;
  --measure: 33rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: Newsreader, Georgia, serif;
  font-optical-sizing: auto;
  font-size: clamp(1.125rem, 0.95rem + 0.6vw, 1.4rem);
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ---------- shared chrome ---------- */

.masthead {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1.5rem;
  padding: 2.5rem 1.5rem 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.masthead a { text-decoration: none; }
.masthead a:hover { color: var(--accent); }

.colophon {
  border-top: 1px solid var(--rule);
  margin-top: 5rem;
  padding: 2rem 1.5rem 4rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  line-height: 2;
  letter-spacing: 0.06em;
  color: var(--paper-dim);
  text-align: center;
}

.colophon a { color: var(--paper-dim); }

/* ---------- chapter ---------- */

.chapter {
  display: grid;
  justify-items: center;
  padding: 0 1.5rem;
}

.numeral {
  font-size: clamp(4rem, 3rem + 8vw, 9rem);
  line-height: 1;
  font-weight: 400;
  color: var(--rule);
  margin: 3.5rem 0 0;
  user-select: none;
}

.verses {
  max-width: var(--measure);
  width: 100%;
  margin: 2.5rem 0 0;
}

.verses p {
  margin: 0 0 1.6em;
  hanging-punctuation: first;
}

.verses .verse {
  margin: 2.2em 0;
  padding-left: 1.4em;
  border-left: 1px solid var(--rule);
  font-style: italic;
  color: #d9d2c4;
  white-space: pre-line;
  line-height: 1.9;
}

/* ---------- pager ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--measure);
  margin: 4.5rem 0 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.pager a, .pager span { text-decoration: none; color: var(--paper-dim); }
.pager a:hover { color: var(--accent); }
.pager span { opacity: 0.3; }

/* ---------- index ---------- */

.title {
  text-align: center;
  padding: 5rem 1.5rem 0;
}

.title h1 {
  font-size: clamp(2.6rem, 2rem + 4vw, 4.6rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}

.title p {
  max-width: 30rem;
  margin: 1.5rem auto 0;
  color: var(--paper-dim);
  font-size: 1rem;
  line-height: 1.7;
}

.grid {
  display: grid;
  /* 81 chapters divide as 9 x 9 exactly, so the grid never ends on a ragged row. */
  grid-template-columns: repeat(9, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  max-width: 42rem;
  margin: 4rem auto 0;
}

.grid a {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--ink);
  text-decoration: none;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--paper-dim);
  transition: background 120ms ease, color 120ms ease;
}

.grid a:hover { background: var(--ink-raised); color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .grid a { transition: none; }
}
