/* Layout: one raw column of type on a hard grid, thick rules between sections,
   instruments in mono at the edges. Black and white only. */
:root {
  --bg: #fff;
  --fg: #000;
  --faint: rgba(0, 0, 0, 0.16);
  --muted: #5c5c5c;
  --rule: 2px solid var(--fg);
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --fg: #fff;
    --faint: rgba(255, 255, 255, 0.2);
    --muted: #a3a3a3;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
::selection { background: var(--fg); color: var(--bg); }

.wrap {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 720px) {
  .wrap { padding-left: 40px; padding-right: 40px; }
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

/* Top bar */
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: calc(14px + env(safe-area-inset-top, 0px)) 14px;
  border-bottom: var(--rule);
}

/* Hero */
.hero {
  padding-block: 8vh 6vh;
  border-bottom: var(--rule);
}
.display {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 62%;
  font-size: clamp(6rem, 30vw, 22rem);
  line-height: 0.78;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.lede {
  margin: 3.5rem 0 0;
  max-width: 34ch;
  font-size: 13px;
  line-height: 1.6;
  text-transform: uppercase;
}

/* Poem page title: smaller than the home hero so long titles still fit */
.kicker { margin: 0 0 1.5rem; }
.title {
  font-size: clamp(3.5rem, 13vw, 11rem);
  line-height: 0.85;
}

/* Collection index: one hard-ruled row per poem, inverts on hover */
.index {
  margin: 0;
  padding: 0;
  list-style: none;
}
.row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1rem;
  padding-block: 1.4rem;
  border-bottom: var(--rule);
}
.row:hover, .row:focus-visible {
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  outline: none;
}
.row-title {
  min-width: 0;
  font-weight: 900;
  font-stretch: 62%;
  font-size: clamp(2.4rem, 9vw, 6.5rem);
  line-height: 0.9;
  letter-spacing: -0.01em;
}
.row-meta { white-space: nowrap; }
@media (max-width: 520px) {
  .row { grid-template-columns: 2.25rem minmax(0, 1fr); }
  .row-meta { grid-column: 2; }
}

/* Next poem link at the end of each poem */
.next {
  display: grid;
  gap: 0.75rem;
  padding-block: 2rem 2.5rem;
  border-top: var(--rule);
}
.next:hover, .next:focus-visible {
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  outline: none;
}
.next-title {
  font-weight: 900;
  font-stretch: 62%;
  font-size: clamp(2.4rem, 9vw, 6.5rem);
  line-height: 0.9;
}
.next-title::after { content: " →"; }

/* Stanzas: numeral in a narrow column, lines in the wide one */
.stanza {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  min-height: 92vh;
  align-content: center;
  padding-block: 18vh;
  border-bottom: var(--rule);
}
@media (min-width: 720px) {
  .stanza { grid-template-columns: 6rem minmax(0, 1fr); }
  .stanza .num { padding-top: 0.9em; }
}
.lines {
  display: grid;
  gap: 0.55em;
  min-width: 0;
  font-size: clamp(1.6rem, 4.4vw, 3.1rem);
}
.line {
  margin: 0;
  max-width: 24em;
  font-weight: 500;
  font-stretch: 100%;
  line-height: 1.22;
  letter-spacing: -0.01em;
}

/* Words that wait. Hidden words keep their space and leave a blank to fill. */
.w { position: relative; }
.w[data-l] {
  color: transparent;
  transition: color 0.3s ease;
}
.w[data-l]::after {
  content: "";
  position: absolute;
  left: 0.04em;
  right: 0.04em;
  bottom: 0.08em;
  height: 1px;
  background: var(--faint);
  transition: opacity 0.3s ease;
}
.line[data-level="1"] .w[data-l="1"],
.line[data-level="2"] .w[data-l] {
  color: var(--fg);
  transition: color 1.8s ease var(--d, 0s);
}
.line[data-level="1"] .w[data-l="1"]::after,
.line[data-level="2"] .w[data-l]::after {
  opacity: 0;
  transition: opacity 1.8s ease var(--d, 0s);
}

.end {
  margin: 0;
  padding-block: 20vh;
  color: var(--muted);
}

/* Footer */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  padding-block: 20px calc(64px + env(safe-area-inset-bottom, 0px));
  border-top: var(--rule);
}

/* Speed meter and the one-time whisper */
.meter {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  padding: 6px 9px;
  background: var(--bg);
  border: 1px solid var(--fg);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.whisper {
  position: fixed;
  left: 50%;
  bottom: calc(18vh + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: 0.2em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}
.whisper.on { opacity: 1; transition-duration: 0.4s; }

/* About page */
.about {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding-block: 7vh;
  border-bottom: var(--rule);
}
@media (min-width: 720px) {
  .about { grid-template-columns: 12rem minmax(0, 1fr); gap: 2rem; }
  .about .label { padding-top: 0.35em; }
}
.prose {
  min-width: 0;
  max-width: 62ch;
  font-size: 1.15rem;
  line-height: 1.6;
  font-weight: 400;
}
.prose p { margin: 0 0 1.1em; }
.prose p:last-child { margin-bottom: 0; }
.readings {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1.1rem;
}
.readings li {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  gap: 1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--fg);
}
.readings li:first-child { padding-top: 0; border-top: 0; }
.readings .mono { padding-top: 0.3em; }
.sample { color: var(--muted); font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  .w[data-l], .w[data-l]::after,
  .line[data-level] .w[data-l], .line[data-level] .w[data-l]::after,
  .whisper { transition-duration: 0.01s !important; }
}
