/* =========================================================
   Kartu Ucapan Ulang Tahun — style.css
   ========================================================= */

:root {
  --bg-1: #ffe4ec;
  --bg-2: #fff4d6;

  --pink: #ff7aa2;
  --pink-dark: #e0567f;
  --ink: #4a3b47;
  --ink-soft: #7a6472;
  --paper: #fffdf7;

  --env: #f4b3c2;        /* warna amplop */
  --env-dark: #e895ab;   /* bagian belakang amplop */
  --env-inner: #fbe1e8;  /* bagian dalam penutup amplop */

  --env-w: min(340px, 86vw);
  --env-h: calc(var(--env-w) * 0.66);

  --font-ui: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-hand: 'Caveat', 'Segoe Script', 'Comic Sans MS', cursive;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Blob dekorasi latar */
body::before,
body::after {
  content: '';
  position: fixed;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body::before {
  top: -22vmax; left: -22vmax;
  background: radial-gradient(circle, rgba(255, 122, 162, .28), transparent 62%);
}
body::after {
  bottom: -26vmax; right: -22vmax;
  background: radial-gradient(circle, rgba(255, 209, 102, .32), transparent 62%);
}

.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;
}

@keyframes float {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, -12px); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@keyframes wiggle {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(-2.5deg); }
  90% { transform: rotate(2.5deg); }
  94% { transform: rotate(-1.5deg); }
  97% { transform: rotate(1deg); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   1. GERBANG PASSWORD
   ========================================================= */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.gate__card {
  width: min(380px, 100%);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
  border-radius: 24px;
  padding: 32px 28px 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(224, 86, 127, .18);
}

.gate__icon {
  display: inline-block;
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 12px;
  animation: bob 2.2s ease-in-out infinite;
}

.gate h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 700;
}

.gate p {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: .95rem;
  line-height: 1.5;
}

.gate input {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  font: inherit;
  font-size: 18px;               /* >=16px: cegah auto-zoom di iOS */
  letter-spacing: .35em;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 2px solid #ffd0dd;
  border-radius: 14px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.gate input::placeholder {
  color: #c9b3bd;
  letter-spacing: .35em;
  font-weight: 700;
}
.gate input:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 122, 162, .22);
}

.gate button {
  margin-top: 12px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--pink);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.gate button:hover  { background: var(--pink-dark); }
.gate button:active { transform: scale(.97); }

.gate .gate__error {
  margin: 12px 0 0;
  color: #d9534f;
  font-size: .875rem;
}

/* =========================================================
   2. SCENE
   ========================================================= */
.scene {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
}

/* ---------- Amplop ---------- */
.envelope-wrap {
  position: relative;
  z-index: 3;
}

.hint {
  position: absolute;
  bottom: calc(100% + 22px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-hand);
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 700;
  color: var(--pink-dark);
  white-space: nowrap;
  text-shadow: 0 2px 0 #fff;
  animation: float 1.6s ease-in-out infinite;
  opacity: 0;
  pointer-events: none;
}

.envelope {
  position: relative;
  width: var(--env-w);
  height: var(--env-h);
  cursor: pointer;
  perspective: 1200px;
  filter: drop-shadow(0 18px 28px rgba(224, 86, 127, .28));
  outline: none;
}
.envelope.is-ready { animation: wiggle 3.2s ease-in-out infinite; }
.envelope.is-ready:focus-visible .envelope__back {
  box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--pink);
}

.envelope__back {
  position: absolute;
  inset: 0;
  background: var(--env-dark);
  border-radius: 10px;
  z-index: 1;
}

.envelope__paper {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 6%;
  height: 92%;
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .10);
  z-index: 2;
  padding: 12% 10%;
  display: flex;
  flex-direction: column;
  gap: 10%;
}
.envelope__line {
  display: block;
  height: 4px;
  border-radius: 4px;
  background: #f0d3db;
}
.envelope__line--short { width: 60%; }
.envelope__heart {
  margin-top: auto;
  align-self: flex-end;
  color: var(--pink);
  font-size: 1.2rem;
  line-height: 1;
}

.envelope__front {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #f8c3cf 0%, var(--env) 45%, var(--env-dark) 100%);
  clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
  border-radius: 10px;
  z-index: 3;
}

.envelope__flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60%;
  transform-origin: top center;
  transform-style: preserve-3d;
  z-index: 4;
}
.envelope__flap::before,
.envelope__flap::after {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  backface-visibility: hidden;
}
.envelope__flap::before {
  background: linear-gradient(180deg, #f9c9d5 0%, var(--env) 100%);
  border-radius: 10px 10px 0 0;
}
.envelope__flap::after {
  background: var(--env-inner);
  transform: rotateX(180deg);
}

.envelope__seal {
  position: absolute;
  left: 50%;
  top: 82%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  line-height: 1;
  backface-visibility: hidden;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .18));
}

/* ---------- Surat ---------- */
.letter-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
  z-index: 5;
}

.letter {
  position: relative;
  width: min(440px, 100%);
  max-height: min(72vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 18px;
  padding: 28px 24px 20px;
  box-shadow: 0 24px 60px rgba(74, 59, 71, .20);
  pointer-events: auto;
  visibility: hidden;          /* dimunculkan lewat JS (autoAlpha) */
}
/* "selotip" di atas surat */
.letter::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  width: 110px;
  height: 28px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(255, 209, 102, .6);
  border-radius: 3px;
}

.letter h2 {
  margin: 0 0 12px;
  font-family: var(--font-hand);
  font-size: 2.3rem;
  line-height: 1.1;
  text-align: center;
  color: var(--pink-dark);
}

.letter__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 32px;
  background-image: repeating-linear-gradient(
    transparent 0 31px,
    rgba(224, 86, 127, .16) 31px 32px
  );
  background-attachment: local;
}
.letter__body p { margin: 0 0 32px; }
.letter__body p:last-child { margin-bottom: 0; }

.letter footer {
  margin-top: 14px;
  text-align: right;
  font-family: var(--font-hand);
  font-size: 1.35rem;
  color: var(--pink-dark);
}

/* ---------- Karakter (duo Judy & Nick) ---------- */
.character {
  position: absolute;
  left: 2vw;
  bottom: 0;
  width: clamp(240px, 32vw, 430px);
  display: flex;
  align-items: flex-end;
  z-index: 4;
  pointer-events: none;
  visibility: hidden;
}
.character__img {
  display: block;
  height: auto;
}
.character__img--judy {
  width: 58%;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 6px 10px rgba(74, 59, 71, .22));
  transform-origin: 50% 100%;
  animation: swayJudy 3.4s ease-in-out infinite;
}
.character__img--nick {
  width: 60%;
  margin-left: -18%;
  filter: drop-shadow(0 6px 10px rgba(74, 59, 71, .18));
  transform-origin: 50% 100%;
  animation: swayNick 4.1s ease-in-out infinite;
}

/* berayun pelan dengan poros di kaki; fase Judy & Nick berlawanan */
@keyframes swayJudy {
  0%, 100% { transform: rotate(-2.4deg); }
  50%      { transform: rotate(2.4deg); }
}
@keyframes swayNick {
  0%, 100% { transform: rotate(4.6deg); }   /* berayun di sekitar kemiringan dasarnya (2deg) */
  50%      { transform: rotate(-0.6deg); }
}

/* ---------- Music player (kartu pastel + daftar lagu) ---------- */
.player {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 15;
  visibility: hidden;
}

.player__card {
  width: min(320px, calc(100vw - 24px));
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 122, 162, .25);
  color: var(--ink);
  box-shadow: 0 24px 50px rgba(224, 86, 127, .25);
}

/* --- lagu aktif: foto album + judul --- */
.player__head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.player__art-box {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  background: repeating-radial-gradient(circle, #3a2f36 0 2px, #514249 2px 4px);
  color: #fff;
  font-size: 1.4rem;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px rgba(74, 59, 71, .25);
}
.player__note { grid-area: 1 / 1; }
.player__art {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.player__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.player__title {
  font-weight: 700;
  font-size: .98rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.player__artist {
  font-size: .78rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player__chip {
  flex: none;
  align-self: flex-start;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #ffeef3;
  color: var(--pink-dark);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.player__chip:hover { background: #ffdfe9; }
.player__chip:active { transform: scale(.92); }
.player__chip svg { width: 17px; height: 17px; }

/* --- progress --- */
.player__seek {
  margin-top: 12px;
  padding: 5px 0;
  cursor: pointer;
  touch-action: none;
}
.player__seek:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
  border-radius: 6px;
}
.player__track {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: #ffe0e9;
}
.player__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--pink-dark));
}
.player__thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--pink);
  box-shadow: 0 2px 5px rgba(224, 86, 127, .35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.player__times {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* --- kontrol --- */
.player__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 12px;
}
.player__btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #ffeef3;
  color: var(--pink-dark);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.player__btn:hover { background: #ffdfe9; }
.player__btn:active { transform: scale(.92); }
.player__btn svg { width: 17px; height: 17px; }
.player__btn--play {
  width: 48px;
  height: 48px;
  background: var(--pink);
  color: #fff;
  box-shadow: 0 8px 18px rgba(224, 86, 127, .4);
}
.player__btn--play:hover { background: var(--pink-dark); }
.player__btn--play svg { width: 21px; height: 21px; }
.player__btn .icon-pause { display: none; }
.player.is-playing .player__btn .icon-play  { display: none; }
.player.is-playing .player__btn .icon-pause { display: block; }

/* --- volume --- */
.player__volume {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.player__mute {
  flex: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--pink-dark);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s;
}
.player__mute:hover { background: #ffeef3; }
.player__mute svg { width: 18px; height: 18px; }
.player__mute .icon-muted { display: none; }
.player.is-muted .player__mute .icon-vol   { display: none; }
.player.is-muted .player__mute .icon-muted { display: block; }
.player.is-muted .player__vol-slider .player__fill { opacity: .35; }

.player__vol-slider {
  flex: 1;
  padding: 5px 0;
  cursor: pointer;
  touch-action: none;
}
.player__vol-slider:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
  border-radius: 6px;
}
.player__thumb--small { width: 12px; height: 12px; }

/* --- daftar lagu (music selector) --- */
.player__list {
  margin: 0;
  padding: 6px 0 0;
  list-style: none;
  border-top: 1px dashed #ffd0dd;
  max-height: 168px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.player__row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.player__row:hover { background: #fff1f5; }
.player__row.is-active { background: #ffe9f0; }
.player__row-thumb {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  overflow: hidden;
  background: repeating-radial-gradient(circle, #3a2f36 0 2px, #514249 2px 4px);
  color: #fff;
  font-size: .8rem;
  display: grid;
  place-items: center;
}
.player__row-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.player__row-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.player__row-title {
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player__row.is-active .player__row-title { color: var(--pink-dark); }
.player__row-artist {
  font-size: .72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* indikator equalizer di baris yang sedang diputar */
@keyframes eq {
  0%, 100% { height: 30%; }
  50%      { height: 100%; }
}
.player__bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  flex: none;
}
.player__row.is-active .player__bars { display: flex; }
.player__bars i {
  width: 3px;
  height: 30%;
  border-radius: 2px;
  background: var(--pink-dark);
  animation: eq 1s ease-in-out infinite;
}
.player__bars i:nth-child(2) { animation-delay: .25s; }
.player__bars i:nth-child(3) { animation-delay: .5s; }
.player:not(.is-playing) .player__bars i { animation-play-state: paused; }

/* bentuk mini saat dikecilkan */
.player__mini {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  overflow: hidden;
  background: repeating-radial-gradient(circle, #3a2f36 0 2px, #514249 2px 4px);
  color: #fff;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 3px #fff, 0 12px 26px rgba(224, 86, 127, .35);
  margin-left: auto;
}
.player__mini img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* denyut halus saat musik berbunyi */
@keyframes miniPulse {
  0%, 100% { box-shadow: 0 0 0 3px #fff, 0 12px 26px rgba(224, 86, 127, .35); }
  50%      { box-shadow: 0 0 0 7px rgba(255, 122, 162, .5), 0 12px 26px rgba(224, 86, 127, .35); }
}
.player.is-playing .player__mini { animation: miniPulse 2s ease-in-out infinite; }

.player.is-unavailable .player__btn,
.player.is-unavailable .player__mute,
.player.is-unavailable .player__row { opacity: .45; cursor: not-allowed; }
.player.is-unavailable .player__seek,
.player.is-unavailable .player__vol-slider { pointer-events: none; }

/* =========================================================
   Responsif (HP)
   ========================================================= */
@media (max-width: 640px) {
  :root { --env-w: min(300px, 84vw); }

  .letter-layer {
    align-items: start;
    padding-top: max(20px, 7vh);
  }
  .letter { max-height: 64vh; }
  .letter__body { font-size: .95rem; }

  .character {
    left: 1vw;
    width: clamp(170px, 48vw, 235px);
  }

  .player { right: 12px; }
  .player__card { width: min(300px, calc(100vw - 24px)); }
  .player__list { max-height: 128px; }
}

@media (max-height: 560px) {
  .letter { max-height: 80vh; }
  .character { width: clamp(90px, 18vh, 150px); }
}

/* Hormati preferensi "kurangi gerakan" */
@media (prefers-reduced-motion: reduce) {
  .hint, .gate__icon, .envelope.is-ready, .player__bars i,
  .player.is-playing .player__mini, .character__img {
    animation: none;
  }
  .hint { opacity: 1; }
}
