@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/caveat.woff2") format("woff2");
}

@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/fredoka.woff2") format("woff2");
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/nunito.woff2") format("woff2");
}

:root {
  --paper: #fbf1e0;
  --card: #fffdf7;
  --ink: #3a2a22;
  --muted: #6e5c4e;
  --accent: #d94f72;
  --accent-ink: #b23a5b;
  --line: rgba(58, 42, 34, 0.16);
  --hand: "Caveat", "Comic Sans MS", cursive;
  --round: "Fredoka", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100svh;
  background-color: var(--paper);
  background-image:
    radial-gradient(115% 55% at 50% -6%, rgba(217, 79, 114, 0.07), transparent 62%),
    radial-gradient(110% 50% at 50% 106%, rgba(217, 79, 114, 0.05), transparent 62%),
    radial-gradient(80% 45% at 6% 42%, rgba(217, 79, 114, 0.04), transparent 60%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: clip;
}

/* Serat kertas tipis di seluruh latar, supaya halaman tidak terasa kosong. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: var(--grain);
  background-size: 220px 220px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.crayon {
  font-family: var(--hand);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.crayon.medium {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  margin: 0;
}

/* ---------- doodle hati ---------- */
.doodles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.heart {
  display: block;
  line-height: 1;
  color: rgba(217, 79, 114, 0.22);
}

.heart svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.heart.doodle {
  position: absolute;
  animation: drift 11s ease-in-out infinite;
}

.heart.pop {
  position: fixed;
  z-index: 5;
  color: rgba(217, 79, 114, 0.7);
  transform: translate(-50%, -50%);
  animation: floatUp 0.9s ease-out forwards;
}

@keyframes drift {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-18px) rotate(6deg); }
}

@keyframes floatUp {
  from { opacity: 0.9; transform: translate(-50%, -50%) scale(0.5); }
  to { opacity: 0; transform: translate(-50%, -170%) scale(1.15); }
}

/* ---------- page ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(2.2rem, 7vw, 4rem) clamp(1.1rem, 4vw, 1.6rem) clamp(2rem, 6vw, 3rem);
}

/* ---------- surat ---------- */
.letter {
  position: relative;
  padding: clamp(1.8rem, 6vw, 2.8rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow:
    0 18px 38px rgba(58, 42, 34, 0.16),
    inset 0 0 0 1px rgba(58, 42, 34, 0.04),
    inset 0 0 46px rgba(58, 42, 34, 0.06);
  text-align: center;
}

/* Serat kertas: noise halus supaya kartu terasa kertas sungguhan, bukan blok rata. */
.letter::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: var(--grain);
  background-size: 220px 220px;
}

.letter h1,
.letter-body {
  position: relative;
  z-index: 1;
}

.seal {
  position: absolute;
  top: -18px;
  left: 50%;
  z-index: 2;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(58, 42, 34, 0.25);
  transform-origin: 50% 0%;
  animation: sealWobble 3.6s ease-in-out infinite;
}

@keyframes sealWobble {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.letter h1 {
  margin: 0.4rem 0 1.3rem;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1;
}

/* huruf judul muncul satu per satu seperti digoyang pensil */
.letter h1 .ltr {
  display: inline-block;
  white-space: pre;
  animation: letterPop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
  animation-delay: calc(var(--i) * 42ms);
}

@keyframes letterPop {
  0% { opacity: 0; transform: translateY(-0.45em) rotate(-10deg) scale(0.6); }
  100% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

.letter-body {
  text-align: left;
}

.letter-body p {
  margin: 0 0 1rem;
}

.letter-body .sign {
  margin: 1.3rem 0 0;
  text-align: right;
  font-size: 1.6rem;
  color: var(--accent-ink);
}

/* paragraf muncul saat masuk layar, seperti surat dibuka pelan-pelan */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--d, 0ms);
}

.js .reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------- petunjuk scroll ---------- */
.scrollcue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin: 1.6rem 0 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--muted);
}

.scrollcue .chev {
  animation: bob 1.7s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ---------- divider ---------- */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: clamp(2rem, 6vw, 3.2rem) 0;
  color: rgba(217, 79, 114, 0.55);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.divider svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
  flex: none;
  transform-origin: 50% 50%;
  animation: beat 2.6s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  10% { transform: scale(1.24); }
  20% { transform: scale(1); }
  30% { transform: scale(1.16); }
  40% { transform: scale(1); }
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--round);
  font-weight: 600;
  font-size: 1.2rem;
  min-height: 52px;
  padding: 0.85rem 1.9rem;
  border: none;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(58, 42, 34, 0.22), 0 12px 22px rgba(58, 42, 34, 0.12);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.18s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(58, 42, 34, 0.22), 0 16px 26px rgba(58, 42, 34, 0.15);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(58, 42, 34, 0.22);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--accent-ink), 0 12px 24px rgba(217, 79, 114, 0.32);
}

.btn.primary:hover {
  background: #e2607f;
  box-shadow: 0 6px 0 var(--accent-ink), 0 16px 28px rgba(217, 79, 114, 0.38);
  animation: btnWiggle 0.5s ease-in-out;
}

@keyframes btnWiggle {
  0%, 100% { transform: translateY(-2px) rotate(0); }
  25% { transform: translateY(-2px) rotate(-3.5deg); }
  75% { transform: translateY(-2px) rotate(3.5deg); }
}

#treat.pop {
  animation: btnPop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.5);
}

@keyframes btnPop {
  0% { transform: scale(1); }
  40% { transform: scale(0.9) rotate(-2deg); }
  70% { transform: scale(1.05) rotate(1.5deg); }
  100% { transform: scale(1); }
}

.btn.primary:active {
  box-shadow: 0 1px 0 var(--accent-ink);
}

/* ---------- kejutan kata manis ---------- */
.treat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  text-align: center;
}

.treat-out {
  position: relative;
  max-width: 30ch;
  margin: 0;
  padding: 1rem 1.3rem;
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 16px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(1.35rem, 4vw, 1.8rem);
  color: var(--accent-ink);
  box-shadow: 0 10px 22px rgba(58, 42, 34, 0.12);
}

.treat-out::after {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  margin-left: -9px;
  border: 9px solid transparent;
  border-bottom-color: var(--accent);
}

.treat-out.pop {
  animation: pop 0.36s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- galeri ---------- */
.galeri {
  text-align: center;
}

.status {
  margin: 0;
  padding: 1.6rem 0.5rem;
  color: var(--muted);
  text-align: center;
}

.status button {
  margin-left: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  background: var(--ink);
  color: var(--card);
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.marquee {
  display: grid;
  gap: 1rem;
  padding: 1.4rem 0 0.4rem;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.lane {
  overflow: hidden;
  padding: 16px 0 10px;
}

.track {
  display: flex;
  gap: 1.1rem;
  width: max-content;
  animation: slide 52s linear infinite;
}

.lane.rev .track {
  animation-direction: reverse;
}

@keyframes slide {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.marquee:hover .track,
.marquee:focus-within .track {
  animation-play-state: paused;
}

.tile {
  position: relative;
  display: block;
  flex: none;
  width: 200px;
  padding: 9px 9px 38px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 10px 20px rgba(58, 42, 34, 0.14);
  cursor: pointer;
  text-align: center;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.tile:nth-child(3n + 1) { --tilt: -1.6deg; }
.tile:nth-child(3n + 2) { --tilt: 1.4deg; }
.tile:nth-child(3n) { --tilt: -0.7deg; }

.tile:hover,
.tile:focus-visible {
  transform: translateY(-4px) rotate(0deg) scale(1.04);
  box-shadow: 0 18px 32px rgba(58, 42, 34, 0.2);
  z-index: 2;
  animation: tileHop 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes tileHop {
  0% { transform: translateY(0) rotate(var(--tilt, 0deg)) scale(1); }
  55% { transform: translateY(-11px) rotate(calc(var(--tilt, 0deg) * -1)) scale(1.06); }
  100% { transform: translateY(-4px) rotate(0deg) scale(1.04); }
}

.tile img,
.tile video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center top;
  border-radius: 2px;
  background: #000;
}

.tile .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9px;
  padding: 0 0.5rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile .tape {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 76px;
  height: 24px;
  background: rgba(217, 79, 114, 0.3);
  box-shadow: 0 2px 4px rgba(58, 42, 34, 0.12);
  transform: translateX(-50%) rotate(-3deg);
  pointer-events: none;
}

.tile.soon {
  display: grid;
  place-content: center;
  gap: 0.3rem;
  width: min(280px, 100%);
  min-height: 150px;
  margin: 1.8rem auto 0;
  padding: 1.2rem;
  cursor: default;
  transform: none;
  border: 3px dashed var(--line);
  box-shadow: none;
  background: repeating-linear-gradient(45deg, rgba(58, 42, 34, 0.03) 0 14px, transparent 14px 28px);
}

.tile.soon .cap {
  position: static;
  font-size: 1.15rem;
  color: var(--muted);
  white-space: normal;
}

.tile.soon .soonmark {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- footer ---------- */
.foot {
  margin: 0;
  text-align: center;
  font-size: 1.3rem;
  color: var(--muted);
}

/* ---------- viewer ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 5vw, 2.5rem);
  background: rgba(58, 42, 34, 0.62);
  backdrop-filter: blur(3px);
  animation: fade 0.25s ease both;
}

.modal[hidden] {
  display: none;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.stage {
  position: relative;
  margin: 0;
  width: min(92vw, 900px);
  max-height: 90svh;
  padding: 14px 14px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  animation: rise 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

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

.stage img,
.stage video {
  display: block;
  margin: 0 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 62svh;
  border-radius: 10px;
  background: #000;
}

.stage figcaption {
  padding: 0.9rem 0.4rem 0.4rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  text-align: center;
}

.stage figcaption .meta {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
}

.download {
  display: inline-block;
  margin: 0.9rem auto 1.1rem;
  min-height: 44px;
  padding: 0.55rem 1.3rem;
  background: var(--ink);
  color: var(--card);
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
}

.download:hover {
  background: var(--accent-ink);
}

.controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.ctl {
  position: absolute;
  display: grid;
  place-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 10px 20px rgba(58, 42, 34, 0.25);
  transition: transform 0.18s, background 0.18s, color 0.18s;
}

.ctl:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.1);
}

.ctl:active {
  transform: scale(0.94);
}

.ctl.close {
  top: 1.2rem;
  right: 1.2rem;
}

.ctl#prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.ctl#next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.ctl#prev:hover { transform: translateY(-50%) scale(1.1); }
.ctl#next:hover { transform: translateY(-50%) scale(1.1); }

@media (max-width: 640px) {
  body { font-size: 16px; }

  .tile { width: 150px; padding: 8px 8px 32px; }
  .tile .cap { bottom: 7px; font-size: 0.85rem; }
  .track { animation-duration: 40s; }

  .stage img,
  .stage video { max-height: 56svh; }
  .ctl#prev { left: 0.3rem; }
  .ctl#next { right: 0.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .modal,
  .stage,
  .treat-out.pop,
  .scrollcue .chev,
  .heart.doodle,
  .heart.pop,
  .letter h1 .ltr,
  .seal,
  .divider svg,
  .tile:hover,
  .tile:focus-visible,
  .btn.primary:hover,
  #treat.pop { animation: none !important; }
  .track { animation: none; }
  .lane { overflow-x: auto; }
  .heart.doodle,
  .heart.pop { display: none; }
  .btn,
  .tile,
  .ctl { transition: none; }
  .tile:hover,
  .tile:focus-visible { transform: rotate(var(--tilt, 0deg)); }
  .ctl:hover { transform: none; }
  .ctl#prev:hover { transform: translateY(-50%); }
  .ctl#next:hover { transform: translateY(-50%); }
}

/* ---------- intro bunga ---------- */
html.intro-lock,
html.intro-lock body {
  overflow: hidden;
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: var(--paper);
  overflow: hidden;
  transition: opacity 1.1s ease, visibility 0s linear 1.1s;
}

.intro.done {
  opacity: 0;
  visibility: hidden;
}

.intro-canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.intro-word {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0 1.2rem;
  max-width: 90vw;
  text-align: center;
  font-family: var(--hand);
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent-ink);
  font-size: clamp(2.4rem, 11vw, 5rem);
  text-shadow: 0 0 10px var(--paper), 0 0 4px var(--paper);
}

.iw-word {
  display: inline-block;
  white-space: nowrap;
}

.iw-ltr {
  display: inline-block;
}

.intro-word.show .iw-ltr {
  animation: wordLetter 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 65ms);
}

@keyframes wordLetter {
  from { opacity: 0; transform: translateY(0.55em) scale(0.7) rotate(-8deg); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .intro { transition: none; }
  .intro-word.show .iw-ltr { animation: none; }
}

/* ---------- tombol musik ---------- */
.music-btn {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0 1rem;
  max-width: calc(100vw - 2rem);
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent-ink);
  font-family: var(--round);
  font-size: 0.95rem;
  box-shadow: 0 3px 0 rgba(58, 42, 34, 0.22);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.music-btn svg { flex: none; }

/* Saat lagu jalan, tombol mengecil jadi ikon saja supaya tidak menutupi konten di mobile. */
.music-btn.playing {
  width: 3rem;
  padding: 0;
  justify-content: center;
}

.music-btn.playing .music-label {
  display: none;
}

/* Denyut cincin saat musik belum jalan: penanda jelas kalau tinggal diketuk. */
.music-btn:not(.playing) {
  animation: musicPulse 2.4s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { box-shadow: 0 3px 0 rgba(58, 42, 34, 0.22), 0 0 0 0 rgba(217, 79, 114, 0.4); }
  50% { box-shadow: 0 3px 0 rgba(58, 42, 34, 0.22), 0 0 0 9px rgba(217, 79, 114, 0); }
}

.music-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(58, 42, 34, 0.22);
}

.music-btn .wave,
.music-btn .slash {
  transition: opacity 0.2s ease;
}

.music-btn .wave { opacity: 0.25; }
.music-btn.playing .wave { opacity: 1; }
.music-btn .slash { opacity: 1; }
.music-btn.playing .slash { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .music-btn:not(.playing) { animation: none; }
}
