:root {
  /* palette: Gochujang Red #780001, Crimson Blaze #C1121F, Varden #FEF0D5, Cosmos Blue #242653 */
  --night: #0b0c1d;
  --ink: #fef0d5;
  --ink-soft: rgba(254, 240, 213, 0.66);
  --ink-faint: rgba(254, 240, 213, 0.3);
  --moon: 236, 98, 84; /* rgb: the red moon's coral, for lines and glows */
  --crimson: 193, 18, 31;
  --serif: "Cormorant Garamond", "Cormorant", Garamond, Georgia, serif;
}

/* The font ships with the site (latin subset), so it shows up even where Google Fonts doesn't load. */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 300 400;
  font-display: swap;
  src: url("fonts/cormorant-garamond-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/cormorant-garamond.woff2") format("woff2");
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Screens: stacked, one fades in at a time ─────────────────────────────── */

main {
  position: fixed;
  inset: 0;
  display: grid;
}

.screen {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* sit a little below the middle, leaving the sky to the moon */
  padding: 16vh 16px 0;
  padding-top: 16dvh;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 1.2s ease, transform 1.2s ease, visibility 0s linear 1.2s;
}

.screen.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 1.4s ease 0.3s, transform 1.4s ease 0.3s, visibility 0s;
}

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

button {
  font: inherit;
  color: inherit;
}

button:focus-visible {
  outline: 1px solid rgba(var(--moon), 0.7);
  outline-offset: 4px;
}

/* ── Lock ─────────────────────────────────────────────────────────────────── */

.unlock {
  width: min(88vw, 340px);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--ink-faint);
  transition: border-color 0.4s, box-shadow 0.4s;
}

.unlock:focus-within {
  border-color: rgba(var(--moon), 0.8);
  box-shadow: 0 12px 18px -14px rgba(var(--moon), 0.9);
}

.unlock input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0 0.55rem 44px; /* balances the button, so the text sits centred */
  background: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: 400 1.25rem/1.2 var(--serif);
  letter-spacing: 0.12em;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.unlock input::placeholder {
  color: var(--ink-soft);
  font-style: italic;
  letter-spacing: 0.04em;
}

.icon-button {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.3s, transform 0.3s, border-color 0.3s;
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

.unlock button:hover { transform: translateX(3px); }

.unlock.is-busy button {
  opacity: 0.35;
  animation: pulse 1.4s ease-in-out infinite;
}

.status {
  min-height: 1.5em;
  margin: 1.1rem 0 0;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.shake { animation: shake 0.5s ease; }

@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@keyframes pulse {
  50% { opacity: 0.8; }
}

/* ── Ready ────────────────────────────────────────────────────────────────── */

.play {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(var(--moon), 0.7);
  background: radial-gradient(circle, rgba(var(--crimson), 0.3), rgba(var(--crimson), 0.05) 70%);
  box-shadow: 0 0 36px rgba(var(--crimson), 0.5), inset 0 0 18px rgba(var(--moon), 0.18);
  cursor: pointer;
  animation: breathe 4.5s ease-in-out infinite;
  transition: transform 0.4s ease;
}

.play svg {
  width: 30px;
  height: 30px;
  margin-left: 4px;
}

.play:hover { transform: scale(1.05); }

@keyframes breathe {
  50% { box-shadow: 0 0 60px rgba(var(--crimson), 0.75), inset 0 0 24px rgba(var(--moon), 0.3); }
}

.hint {
  margin: 1.6rem 0 0;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

/* ── End ──────────────────────────────────────────────────────────────────── */

.heart {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1;
  color: rgb(var(--moon));
  text-shadow: 0 0 22px rgba(var(--crimson), 0.9);
}

.signature {
  margin: 0.9rem 0 0;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.3rem, 5.4vw, 1.6rem);
  letter-spacing: 0.03em;
  text-shadow: 0 0 24px rgba(var(--crimson), 0.7);
}

.text-button {
  margin-top: 2.2rem;
  padding: 0.25rem 0.1rem;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--ink-faint);
  font-style: italic;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.4s;
}

.text-button:hover { border-color: rgba(var(--moon), 0.8); }

/* ── Playback controls ────────────────────────────────────────────────────── */

.controls {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 440px);
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.controls.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.controls .icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--ink-faint);
}

.controls .icon-button:hover { border-color: rgba(var(--moon), 0.8); }

.controls .icon-button svg {
  width: 16px;
  height: 16px;
}

#toggle .icon-play,
#toggle.is-paused .icon-pause { display: none; }

#toggle.is-paused .icon-play { display: block; }

.track {
  position: relative;
  flex: 1;
  height: 28px;
  cursor: pointer;
  touch-action: none;
}

.track::before,
.fill {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
}

.track::before {
  right: 0;
  background: var(--ink-faint);
}

.fill {
  width: 0;
  background: var(--ink);
  box-shadow: 0 0 8px rgba(var(--moon), 0.8);
}

.time {
  min-width: 3em;
  text-align: right;
  font-size: 1.05rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .play { animation: none; }
}
