:root {
  --bg-top: #141c2b;
  --bg-bot: #070a11;
  --ink: #cdd8e6;
  --ink-dim: #7d8aa0;
  --accent: #bfdbfe;
  --accent-soft: rgba(191, 219, 254, 0.14);
  --ring: rgba(191, 219, 254, 0.28);
  /* How strongly the background painting shows through (0 = hidden, 1 = full).
     Lower it if the poem gets hard to read over a bright image. */
  --bg-image-opacity: 0.45;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  background-color: var(--bg-bot);
  color: var(--ink);
  font-family: "Cormorant Garamond", ui-serif, Georgia, "Times New Roman", serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Background painting — its own dimmed layer over a solid dark fallback.
   Fading toward the dark body colour quietens a bright image so the poem reads.
   If the image is missing, this layer is simply empty and the dark base shows. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url("../assets/background.jpg") center / cover no-repeat;
  opacity: var(--bg-image-opacity);
}
/* Darkening scrim tied to the poem: a touch stronger through the upper half
   where the text sits, so words stay legible over clouds and water. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(90% 55% at 50% 34%, rgba(4, 7, 12, 0.62) 0%, rgba(4, 7, 12, 0.28) 60%, transparent 100%),
    linear-gradient(180deg, rgba(5, 8, 13, 0.42) 0%, rgba(5, 8, 13, 0.30) 45%, rgba(4, 7, 12, 0.6) 100%);
}

#rain-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5vh, 52px);
  padding: max(28px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  text-align: center;
}

/* ---- poem ---- */
.poem {
  max-width: min(34ch, 90vw);
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: #eaf1fb;
  font-weight: 500;
  font-size: clamp(1.35rem, 1.15rem + 1.1vw, 1.9rem);
  opacity: 0.95;
  text-shadow: 0 1px 16px rgba(4, 8, 14, 0.7), 0 0 2px rgba(4, 8, 14, 0.5);
  animation: fade-up 1.4s ease both;
}
.poem p { margin: 0 0 0.7em; }
.poem p:last-child { margin-bottom: 0; }
.poem__ar {
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  font-weight: 300;
  margin-top: 1.1em;
  color: #cdd8e6;
  font-size: 0.72em;
  line-height: 1.9;
  letter-spacing: 0;
  opacity: 0.9;
}

/* ---- play button ---- */
.play {
  position: relative;
  width: clamp(96px, 26vw, 128px);
  height: clamp(96px, 26vw, 128px);
  border-radius: 50%;
  border: 1px solid var(--ring);
  background: radial-gradient(circle at 50% 35%, rgba(191, 219, 254, 0.10), rgba(191, 219, 254, 0.02) 60%, transparent 72%);
  color: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.5s cubic-bezier(.2,.7,.2,1), border-color 0.5s ease, box-shadow 0.6s ease;
  -webkit-tap-highlight-color: transparent;
  animation: fade-up 1.4s ease 0.15s both;
}
.play:hover { border-color: rgba(191, 219, 254, 0.5); transform: translateY(-2px); }
.play:active { transform: scale(0.97); }
.play:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

.play__glow {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  box-shadow: 0 0 0 0 var(--accent-soft);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.play.is-playing .play__glow {
  opacity: 1;
  animation: breathe 4.5s ease-in-out infinite;
}

.play__icon {
  position: absolute;
  width: 42%;
  height: 42%;
  fill: currentColor;
  stroke: currentColor;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.play__icon--pause { opacity: 0; transform: scale(0.85); }
.play.is-playing .play__icon--play { opacity: 0; transform: scale(0.85); }
.play.is-playing .play__icon--pause { opacity: 1; transform: scale(1); }
.play__icon--play { transform: translateX(2px); } /* optical centering */
.play.is-playing .play__icon--play { transform: translateX(2px) scale(0.85); }

/* ---- volume ---- */
.volume {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(320px, 78vw);
  color: var(--ink-dim);
  animation: fade-up 1.4s ease 0.3s both;
}
.volume__icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: currentColor;
  stroke: currentColor;
}
.volume__wave { transition: opacity 0.3s ease; }

.volume__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.volume__slider::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0 var(--fill, 70%), rgba(205,216,230,0.16) var(--fill, 70%) 100%);
}
.volume__slider::-moz-range-track {
  height: 2px;
  border-radius: 2px;
  background: rgba(205,216,230,0.16);
}
.volume__slider::-moz-range-progress {
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.volume__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(191,219,254,0.5);
  transition: transform 0.2s ease;
}
.volume__slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(191,219,254,0.5);
}
.volume__slider:active::-webkit-slider-thumb { transform: scale(1.25); }
.volume__slider:focus-visible { outline: none; }
.volume__slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---- hint ---- */
.hint {
  margin: 0;
  min-height: 1em;
  font-style: italic;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  text-shadow: 0 1px 10px rgba(4, 8, 14, 0.6);
  opacity: 0.8;
  transition: opacity 0.6s ease;
  animation: fade-up 1.4s ease 0.45s both;
}
.hint.is-hidden { opacity: 0; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 34px 2px rgba(191,219,254,0.10); }
  50%      { box-shadow: 0 0 60px 8px rgba(191,219,254,0.22); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  #rain-canvas { display: none; }
}
