/* yveltal — in memoriam */

:root {
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.08);
  --glass-border: 1px solid rgba(255, 255, 255, 0.09);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.58);
  --faint: rgba(255, 255, 255, 0.38);
  --warm: 255, 208, 160;
  --card-w: 400px;
  --radius: 20px;
  --pad: 14px 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: #000;
  color: var(--text);
  font-family: "Outfit", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

svg[hidden] {
  display: none !important;
}

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

/* —— Background —— */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #000;
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.04);
  /* Drained of colour — the page is a wake, not a party */
  filter: saturate(0.28) brightness(0.46) contrast(1.06);
  pointer-events: none;
}

.bg-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(var(--warm), 0.05), transparent 46%),
    radial-gradient(ellipse at 50% 50%, transparent 32%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.76));
}

.dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.55;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  pointer-events: none;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* —— Enter —— */
.enter {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #000;
  cursor: pointer;
}

.enter .grain {
  opacity: 0.14;
}

.enter p {
  position: relative;
  z-index: 1;
  font-family: "Lora", Georgia, serif;
  font-size: 15px;
  font-weight: 400;
  font-style: italic;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.04em;
  animation: enterPulse 2.6s ease-in-out infinite;
}

.enter.fade {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

@keyframes enterPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* —— Mute —— */
.mute {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 40;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.68);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.mute:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.36);
  border-color: rgba(255, 255, 255, 0.12);
}

/* —— Layout —— */
.profile {
  position: relative;
  z-index: 10;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 88px 16px 64px;
  font-family: "Lora", Georgia, serif;
}

.profile[hidden],
.mute[hidden] {
  display: none !important;
}

.stack {
  width: min(100%, var(--card-w));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  animation: rise 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.memorial {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* —— Avatar —— */
.avatar-wrap {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.halo {
  position: absolute;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(var(--warm), 0.16), rgba(var(--warm), 0.05) 42%, transparent 68%);
  animation: breathe 7s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.07); }
}

.avatar-ring {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.06));
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  /* Faded, like a photograph left in the sun */
  filter: grayscale(0.82) brightness(0.86) contrast(1.04);
  transition: filter 1.4s ease;
  user-select: none;
  -webkit-user-drag: none;
}

/* Seal 1 — held long enough for the photo to develop */
.avatar-ring.developed .avatar {
  filter: grayscale(0) brightness(1.04) contrast(1.02);
}

.hold-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  background: conic-gradient(rgba(var(--warm), 0.85) calc(var(--hold, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent calc(50% - 2px), #000 calc(50% - 2px));
  mask: radial-gradient(circle, transparent calc(50% - 2px), #000 calc(50% - 2px));
}

.avatar-ring.holding .hold-ring {
  opacity: 1;
}

/* —— Identity —— */
.identity {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 0 6px;
}

.kicker {
  font-family: "Outfit", sans-serif;
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: rgba(var(--warm), 0.62);
  line-height: 1;
}

.display-name {
  font-family: "Lora", Georgia, serif;
  font-size: 34px;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.13em;
  text-indent: 0.13em;
  line-height: 1.1;
  text-shadow: 0 0 26px rgba(var(--warm), 0.18);
}

.dates {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Outfit", sans-serif;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--faint);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dates .dash {
  letter-spacing: 0;
  text-indent: 0;
  opacity: 0.7;
}

.rule {
  width: 64px;
  height: 1px;
  margin: 4px 0 2px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.32), transparent);
}

.epitaph {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: clamp(12px, 3.2vw, 14.5px);
  color: rgba(255, 255, 255, 0.82);
  min-height: 1.5em;
  width: 100%;
  text-align: center;
  white-space: nowrap;
  line-height: 1.5;
  overflow: hidden;
}

#epitaphText {
  display: inline;
  font: inherit;
  white-space: nowrap;
  vertical-align: baseline;
}

.caret {
  display: inline-block;
  width: 1.5px;
  height: 0.9em;
  margin-left: 2px;
  background: currentColor;
  vertical-align: -0.1em;
  border-radius: 1px;
  opacity: 0.8;
  animation: blink 0.95s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0; }
}

/* —— Cards —— */
.glass-card {
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--glass-border);
  border-radius: var(--radius);
}

.music-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--pad);
}

.music-top {
  width: 100%;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
}

.cover-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.cover-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(10px) brightness(0.6) saturate(0.5);
  transform: scale(1.25);
}

.cover {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  filter: grayscale(0.55) brightness(0.9);
}

.track-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  font-family: "Outfit", sans-serif;
  text-align: left;
}

.track-meta strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-meta span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.play:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.24);
}

.play:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.seek-row {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 10px;
  align-items: center;
  font-family: "Outfit", sans-serif;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.66);
  font-variant-numeric: tabular-nums;
}

.wave {
  position: relative;
  z-index: 1;
  height: 26px;
  cursor: pointer;
  touch-action: none;
}

#waveCanvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

#seek {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  /* Wave owns pointer seeking — unstyled range maps every click to 0 */
  pointer-events: none;
  accent-color: #fff;
  -webkit-appearance: none;
  appearance: none;
}

#seek::-webkit-slider-runnable-track,
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
}

/* No audio file present yet */
.music-card.is-missing {
  opacity: 0.62;
}

/* Still clickable with no audio — the third seal lives in the waveform. */
.music-card.is-missing .wave {
  cursor: default;
}

.footnote {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  margin-top: 2px;
}

/* ————————————————————————————————
   The parts that aren't a memorial
   ———————————————————————————————— */

/* Seal 2 — the end date, if you think to touch it */
.date-end {
  cursor: pointer;
  border-radius: 3px;
  outline: none;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.date-end:hover,
.date-end:focus-visible {
  color: rgba(255, 255, 255, 0.72);
}

.date-end:focus-visible {
  box-shadow: 0 0 0 1px rgba(var(--warm), 0.5);
}

.date-end.scrambling {
  color: rgba(var(--warm), 0.92);
  text-shadow: 0 0 12px rgba(var(--warm), 0.5);
}

.dates.tampered .date-end {
  color: rgba(var(--warm), 0.78);
  text-shadow: 0 0 10px rgba(var(--warm), 0.32);
}

/* Three seals */
.seals {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: -6px;
}

.seal {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.5s ease, box-shadow 0.5s ease, transform 0.5s ease;
}

.seal.lit {
  background: rgba(var(--warm), 0.95);
  box-shadow: 0 0 10px rgba(var(--warm), 0.7), 0 0 22px rgba(var(--warm), 0.3);
  transform: scale(1.25);
}

/* All three lit — the page stops pretending */
.epitaph.final {
  color: rgba(var(--warm), 0.92);
  text-shadow: 0 0 14px rgba(var(--warm), 0.28);
}

.profile.armed .display-name {
  animation: unsettle 5.5s ease-in-out infinite;
}

@keyframes unsettle {
  0%, 92%, 100% { transform: none; opacity: 1; }
  94% { transform: translateX(-1px) skewX(-0.6deg); opacity: 0.86; }
  96% { transform: translateX(1.5px) skewX(0.5deg); opacity: 1; }
}

/* The word — only after three seals */
.key-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.key-form[hidden] {
  display: none !important;
}

.key-form.show {
  opacity: 1;
  transform: none;
}

#keyInput {
  width: min(100%, 240px);
  padding: 6px 4px;
  text-align: center;
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: rgba(var(--warm), 0.95);
  background: none;
  border: none;
  border-bottom: 1px solid rgba(var(--warm), 0.28);
  border-radius: 0;
  outline: none;
  caret-color: rgba(var(--warm), 0.9);
  transition: border-color 0.2s ease;
}

#keyInput:focus {
  border-bottom-color: rgba(var(--warm), 0.7);
}

.key-form.busy #keyInput {
  opacity: 0.5;
}

.key-form.refused #keyInput {
  animation: refuse 0.5s ease;
  border-bottom-color: rgba(255, 120, 120, 0.6);
}

@keyframes refuse {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.key-note {
  font-family: "Outfit", sans-serif;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.34);
  min-height: 1em;
}

/* —— Reveal —— */
.unlock {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 0.9s ease;
}

.unlock[hidden] {
  display: none !important;
}

.unlock.show {
  opacity: 1;
}

.unlock-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  font-family: "Lora", Georgia, serif;
}

.unlock-kicker {
  font-family: "Outfit", sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: rgba(var(--warm), 0.6);
}

.unlock-alias {
  font-family: "Lora", Georgia, serif;
  font-size: clamp(34px, 11vw, 56px);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: #fff;
  text-shadow: 0 0 34px rgba(var(--warm), 0.34);
  animation: surface 1.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes surface {
  from { opacity: 0; filter: blur(14px); transform: translateY(10px); }
  to { opacity: 1; filter: none; transform: none; }
}

.unlock-alias.is-link,
.unlock-alias {
  cursor: pointer;
  word-break: break-all;
}

.unlock-alias.is-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 8px;
  text-decoration-color: rgba(var(--warm), 0.4);
}

.unlock-line {
  font-style: italic;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.68);
  max-width: 30ch;
  line-height: 1.6;
}

.unlock-close {
  margin-top: 10px;
  font-family: "Outfit", sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: color 0.15s, border-color 0.15s;
}

.unlock-close:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* —— Small screens —— */
@media (max-width: 420px) {
  .profile {
    padding: 72px 14px 56px;
  }

  .stack {
    gap: 18px;
  }

  .memorial {
    gap: 16px;
  }

  .halo {
    width: 190px;
    height: 190px;
  }

  .avatar-ring {
    width: 108px;
    height: 108px;
  }

  .display-name {
    font-size: 28px;
    letter-spacing: 0.11em;
    text-indent: 0.11em;
  }

  .kicker {
    font-size: 9px;
    letter-spacing: 0.36em;
    text-indent: 0.36em;
  }

  .dates {
    font-size: 10px;
    letter-spacing: 0.26em;
    text-indent: 0.26em;
  }

  .glass-card {
    border-radius: 16px;
  }

  .music-card {
    padding: 12px 14px;
  }

  .music-top {
    grid-template-columns: 44px 1fr auto;
    gap: 10px;
  }

  .cover-wrap {
    width: 44px;
    height: 44px;
    border-radius: 9px;
  }

  .cover {
    border-radius: 9px;
  }

  .play {
    width: 32px;
    height: 32px;
  }

  .seek-row {
    grid-template-columns: 32px 1fr 32px;
    gap: 8px;
  }

  .mute {
    top: 12px;
    left: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .enter p,
  .halo,
  .caret,
  .profile.armed .display-name {
    animation: none;
  }

  .unlock-alias {
    animation-duration: 0.01ms;
  }

  .stack {
    animation-duration: 0.01ms;
  }

  .dust {
    display: none;
  }
}
