:root {
  --paper: #f7f2e8;
  --paper-card: #fffdf8;
  --ink: #2b2622;
  --ink-soft: #6d6459;
  --ink-faint: #a1968a;
  --accent: #a8501e;
  --accent-soft: #e9d9c6;
  --rule: #e3d9c9;
  --shadow: 0 1px 2px rgba(60, 45, 25, .06), 0 8px 24px rgba(60, 45, 25, .07);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171310;
    --paper-card: #221c17;
    --ink: #f0e7db;
    --ink-soft: #b0a493;
    --ink-faint: #7c7164;
    --accent: #e8a06a;
    --accent-soft: #3a2c20;
    --rule: #33291f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.15rem calc(3rem + env(safe-area-inset-bottom));
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.masthead {
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 9vw, 4.5rem) 0 1.75rem;
  text-align: center;
}

.masthead h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.1rem, 8.5vw, 3rem);
  letter-spacing: -.01em;
  margin: 0 0 .6rem;
}

.blurb {
  margin: 0 auto;
  max-width: 26rem;
  color: var(--ink-soft);
  font-size: .96rem;
  text-wrap: pretty;
}

main { max-width: 34rem; margin: 0 auto; }
.loading { color: var(--ink-faint); text-align: center; }

.poem {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  margin: 0 0 .8rem;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .25s;
}

.poem.is-open { border-color: var(--accent-soft); }

/* --- card header: play button + title ------------------------------ */

.poem-row { display: flex; align-items: center; }

.poem-head {
  display: flex;
  align-items: center;
  gap: .9rem;
  flex: 1;
  min-width: 0;
  padding: .95rem .4rem .95rem 1.1rem;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.play {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper-card);
  transition: transform .15s ease, filter .15s ease;
}

.poem-head:hover .play { filter: brightness(1.08); }
.poem-head:active .play { transform: scale(.94); }
.play svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.play .icon-pause { display: none; }
.poem.is-playing .play .icon-play { display: none; }
.poem.is-playing .play .icon-pause { display: block; }

.download {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 3rem;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color .15s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.download svg { width: 1.15rem; height: 1.15rem; }
.download:hover { color: var(--accent); background: var(--accent-soft); }
.download:active { color: var(--accent); }

.download:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-radius: 8px;
}

.poem-title {
  font-family: var(--serif);
  font-size: 1.28rem;
  line-height: 1.25;
  margin: 0;
  font-weight: 400;
}

.poem-meta {
  display: block;
  margin-top: .12rem;
  font-size: .8rem;
  color: var(--ink-faint);
}

.poem-meta .note { font-style: italic; }

/* --- the words ------------------------------------------------------ */

.poem-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .35s ease;
}

.poem.is-open .poem-body { grid-template-rows: 1fr; }
.poem-body > .inner { overflow: hidden; }

.lyrics {
  margin: 0;
  padding: .35rem 1.15rem 1.15rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.62;
}

.line {
  display: block;
  width: 100%;
  margin: 0;
  padding: .19rem .45rem;
  border: 0;
  border-radius: 7px;
  background: none;
  font: inherit;
  color: var(--ink-faint);
  text-align: left;
  cursor: pointer;
  transition: color .3s ease, background-color .3s ease;
  -webkit-tap-highlight-color: transparent;
}

.line:hover { color: var(--ink-soft); }

.line.is-past { color: var(--ink-soft); }

.line.is-live {
  color: var(--ink);
  background: var(--accent-soft);
}

.line.intro {
  font-family: var(--sans);
  font-size: .87rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-faint);
  opacity: .8;
}

.line.heading {
  margin-top: .7rem;
  font-size: 1.18rem;
  font-variant-caps: small-caps;
  letter-spacing: .02em;
}

/* The story track reads as prose, not verse. */
.lyrics.prose .line:not(.intro):not(.heading) {
  font-size: 1.02rem;
  line-height: 1.55;
  margin-bottom: .3rem;
}

.line .w { transition: color .12s linear; }
.line.is-live .w.is-said { color: var(--accent); }

/* --- scrubber ------------------------------------------------------- */

.transport {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 0 1.15rem 1.05rem;
  font-family: var(--sans);
  font-size: .74rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.scrub {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
  cursor: pointer;
}

.scrub .fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
}

.colophon {
  max-width: 34rem;
  margin: 2.5rem auto 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: .82rem;
  text-align: center;
}

.colophon p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
