:root {
  /* Lamplit umber paper with warm cream ink. */
  --paper: #2a1f15;
  --paper-edge: #1b140c;
  --ink: #ead8b6;
  --faded: #b39873;
  --rule: #52402c;
  /* Gilt on the tome's cover and page edges. */
  --orpiment: #e2b651;
  --grain: 0.28;
  color-scheme: dark;
}

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

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Paper that darkens toward the edges, like an old photograph. */
  background: radial-gradient(ellipse 90% 80% at 50% 38%, var(--paper) 50%, var(--paper-edge) 100%) fixed;
  color: var(--ink);
  font-family: "IM Fell English", "Iowan Old Style", Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Contour lines of Mt. Elbrus pressed into the paper. topo.mjs draws them in
   line by line; with reduced motion they simply fade in. */
.topo {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 5s ease-out 0.15s;
}

.topo canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.topo.is-shown { opacity: 1; }
.topo.is-drawing { transition: none; }

.page, .imprint {
  position: relative;
  z-index: 1;
}

/* Paper grain, over everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .23 0 0 0 0 .15 0 0 0 0 .07 0 0 0 .5 -.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  flex: 1;
  width: min(100% - 32px, 58rem);
  margin-inline: auto;
  padding-block: clamp(0.75rem, 4vh, 3rem) 1rem;
}

.title-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stage {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stage:focus-visible {
  outline: 1px dashed var(--faded);
  outline-offset: 8px;
  border-radius: 2px;
}

.stage canvas { display: block; }

.caption {
  margin: 0.35rem 0 0;
  min-height: 1.5em;
  font-style: italic;
  font-size: 1.3rem;
  color: var(--accent, var(--faded));
  transition: opacity 0.8s ease;
}

.caption.is-idle { opacity: 0; }

h1 {
  margin: clamp(1.25rem, 4.5vh, 2.75rem) 0 0;
  font-family: "IM Fell English SC", "IM Fell English", Georgia, serif;
  font-weight: normal;
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0.16em;
  /* Balance the trailing letter-space so the name sits on the centre line. */
  padding-left: 0.16em;
}

.subtitle {
  margin: 0.85rem 0 0;
  font-style: italic;
  font-size: clamp(1.2rem, 2.6vw, 1.45rem);
  color: var(--faded);
}

/* Contents and poems appear once poems.js has entries. */

.contents {
  width: min(100%, 30rem);
  margin: 2.5rem auto 0;
}

.contents ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contents a {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0;
  color: inherit;
  text-decoration: none;
}

.contents .leader {
  flex: 1;
  border-bottom: 1px dotted var(--rule);
  transform: translateY(-0.3em);
}

.contents .year { color: var(--faded); font-variant-numeric: oldstyle-nums; }
.contents a:hover .title, .contents a:focus-visible .title { text-decoration: underline; text-underline-offset: 0.2em; }

.poem {
  width: min(100%, 34rem);
  margin: 3rem auto 0;
  scroll-margin-top: 2rem;
}

.poem h2 {
  margin: 0;
  font-weight: normal;
  font-size: 2rem;
  line-height: 1.2;
  outline: none;
}

.poem .year {
  margin: 0.25rem 0 2rem;
  color: var(--faded);
  font-style: italic;
}

.poem .stanza {
  margin: 0 0 1.4em;
  white-space: pre-wrap;
  font-size: 1.25rem;
  line-height: 1.6;
}

.poem nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-style: italic;
}

.poem nav a { color: var(--faded); }
.poem nav a:hover, .poem nav a:focus-visible { color: var(--ink); }

a:focus-visible {
  outline: 1px dashed var(--faded);
  outline-offset: 3px;
}

.imprint {
  padding: 1.5rem 0 2rem;
  text-align: center;
  font-family: "IM Fell English SC", "IM Fell English", Georgia, serif;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  color: var(--faded);
  font-size: 0.95rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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