:root {
  --paper: #f5f0e6;
  --ink: #303b31;
  --muted: #777b6c;
  --line: #d7d7c7;
  --accent: #8c4f32;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'DM Sans', Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-padding-bottom: 120px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath filter='url(%23n)' opacity='.8' d='M0 0h160v160H0z'/%3E%3C/svg%3E");
}
::selection { background: #a9ae87; color: #1e291f; }
[hidden] { display: none !important; }
button, input { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.poem-layout { width: min(100%, 650px); margin-inline: auto; padding: 20px 24px 72px; }
.cover { margin-bottom: 27px; }
.cover-image {
  margin: 0; aspect-ratio: 1.95; overflow: hidden; position: relative; background: #eae5d9;
  clip-path: polygon(0 0, 96% 0, 100% 8%, 100% 100%, 0 100%);
}
.cover-image::after { content: ''; position: absolute; inset: 7px; border: 1px solid #f5f0e666; pointer-events: none; }
.cover-image img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 52%; filter: saturate(.72); }
.book-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.poem-heading { min-width: 0; }
h1 { font: 500 clamp(50px, 13vw, 66px)/.95 var(--serif); letter-spacing: -2.5px; margin: 0 0 12px -2px; }
.author { margin: 0; font: 450 10px/1.6 var(--sans); letter-spacing: .25px; }
.author span { display: block; color: var(--muted); font-size: 9px; }

.poem-text { min-width: 0; font: 400 23px/1.62 var(--serif); letter-spacing: .02px; hyphens: none; }
.stanza { margin: 0 0 32px; }
.stanza:first-child { font-size: 24px; }
.stanza:last-child { margin-bottom: 0; }
.verse { display: block; padding-left: .85em; text-indent: -.85em; overflow-wrap: break-word; }

.audio-dock { flex-shrink: 0; }
.audio-toggle {
  display: grid; place-items: center; position: relative; flex-shrink: 0; width: 52px; height: 52px; padding: 0;
  border: 1px solid var(--ink); border-radius: 50%; background: var(--ink); color: var(--paper); transition: background .2s;
}
.audio-toggle:hover { background: var(--accent); border-color: var(--accent); }
.audio-toggle svg { width: 22px; height: 22px; }
#play-icon { fill: currentColor; transform: translateX(-1px); }
#pause-icon { fill: none; stroke: currentColor; stroke-width: 3; }
.audio-track, .audio-close { display: none; }
.audio-dock.is-expanded {
  position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  width: min(420px, calc(100% - 32px)); display: flex; align-items: center; gap: 14px; z-index: 20;
  padding: 11px 12px; background: var(--paper); border: 1px solid var(--line); box-shadow: 0 5px 30px #303b3126;
}
.audio-dock.is-expanded .audio-toggle { width: 44px; height: 44px; }
.audio-dock.is-expanded .audio-track { display: block; flex: 1; min-width: 0; }
.audio-dock.is-expanded .audio-close { display: grid; place-items: center; width: 36px; height: 44px; flex-shrink: 0; padding: 0; background: transparent; border: 0; }
.audio-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }
#audio-seek { display: block; width: 100%; min-height: 28px; margin: 0; padding: 0; accent-color: var(--ink); cursor: pointer; }
#audio-seek:disabled { cursor: default; opacity: .45; }
.audio-times { display: flex; align-items: center; gap: 6px; font: 10px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); }
.audio-times output:first-child { color: var(--ink); }
.audio-spinner { width: 20px; height: 20px; border: 2px solid #f5f0e655; border-top-color: var(--paper); border-radius: 50%; animation: spin 1s linear infinite; }
.audio-error { font: 12px/1.5 var(--sans); color: var(--accent); margin: 14px 0 0; }
body.has-audio .poem-layout { padding-bottom: 130px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 360px) {
  .poem-layout { padding-inline: 20px; padding-top: 16px; }
  .cover-image { aspect-ratio: 1.9; }
  .book-heading { margin-top: 19px; padding-bottom: 20px; }
  .poem-text { font-size: 22px; }
  .stanza:first-child { font-size: 23px; }
}
@media (min-width: 600px) {
  .poem-layout { padding-top: 32px; padding-inline: 36px; }
  .cover-image { aspect-ratio: 2.3; }
  h1 { font-size: 73px; }
  .poem-text { font-size: 25px; }
  .stanza:first-child { font-size: 27px; }
  .stanza { margin-bottom: 38px; }
}
@media (min-width: 980px) {
  .poem-layout { display: grid; grid-template-columns: 325px minmax(0, 1fr); align-items: start; gap: 70px; width: min(1190px, 100%); padding: 52px 46px 92px; }
  .cover { position: sticky; top: 42px; margin: 0; }
  .cover-image { aspect-ratio: 2/3; clip-path: polygon(0 0, 94% 0, 100% 4%, 100% 100%, 0 100%); }
  .cover-image img { object-position: center; }
  .cover-image::after { inset: 9px; }
  h1 { font-size: 65px; }
  .author { font-size: 11px; }
  .author span { font-size: 10px; }
  .poem-text { padding-top: 4px; font-size: 24px; line-height: 1.7; }
  .stanza:first-child { font-size: 27px; margin-bottom: 43px; }
  .audio-dock.is-expanded { left: auto; right: 24px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  body { background: white; color: black; }
  body::before, .cover-image, .audio-dock, .audio-error { display: none !important; }
  .poem-layout { display: block; width: 100%; padding: 0; }
  .cover { position: static; margin-bottom: 24pt; }
  .book-heading { margin-top: 0; padding-bottom: 16pt; }
  h1 { font-size: 32pt; }
  .poem-text, .stanza:first-child { font: 13pt/1.5 Georgia, serif; }
  .stanza { break-inside: avoid; margin-bottom: 18pt; }
}
