/* ==========================================================
   Dua Puluh — untuk Elizabeth
   Arah visual: surat cinta di kertas merah muda pucat,
   tinta merah anggur. Sedikit tulisan tangan, banyak ruang.
   ========================================================== */

:root {
  --paper: #f5e6e1;
  --paper-deep: #ecd6cf;
  --sheet: #fbf4f1;
  --wine: #6b1d2c;
  --wine-deep: #2a0f16;
  --ink: #33161c;
  --muted: #8b6068;
  --flame: #ffb347;

  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Hanken Grotesk', system-ui, sans-serif;
  --hand: 'Nothing You Could Do', cursive;

  --gutter: clamp(1.25rem, 5vw, 4rem);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }
html.is-sealed, html.is-sealed body { overflow: hidden; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

.kicker {
  font: 500 0.8125rem/1.3 var(--sans);
  letter-spacing: 0.08em;
  text-transform: lowercase;
  font-variant: small-caps;
  color: var(--wine);
}

/* ================= PEMBUKA ================= */
.seal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.75rem;
  padding: 1.5rem;
  background: var(--wine-deep);
  transition: opacity 0.7s ease 0.5s, visibility 0s linear 1.2s;
}
.seal.is-open { opacity: 0; visibility: hidden; pointer-events: none; }

.note {
  position: relative;
  width: min(300px, 78vw);
  aspect-ratio: 4 / 3;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
}
.note-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1.75rem;
  background: var(--sheet);
  text-align: left;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.note-to {
  font: 400 1.9rem/1.1 var(--hand);
  color: var(--wine);
}
.note-from {
  font: 400 0.8125rem/1.4 var(--sans);
  color: var(--muted);
}
/* dua lipatan kertas yang terbuka ke atas & ke bawah */
.note-flap {
  position: absolute;
  left: 0; right: 0;
  height: 50%;
  background: var(--paper-deep);
  z-index: 2;
  transition: transform 0.9s cubic-bezier(.6, 0, .2, 1);
  backface-visibility: hidden;
}
.note-flap--top { top: 0; transform-origin: top; border-bottom: 1px solid rgba(107, 29, 44, 0.12); }
.note-flap--bottom { bottom: 0; transform-origin: bottom; }
.note-flap--top::after {
  /* sedikit bekas lipatan supaya terasa kertas, bukan kotak */
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 30%;
  background: linear-gradient(to top, rgba(107, 29, 44, 0.08), transparent);
}
.note-address {
  position: absolute;
  inset: auto 0 0.9rem;
  text-align: center;
  font: 400 1.7rem/1 var(--hand);
  color: var(--wine);
}
.note:hover .note-flap--top { transform: rotateX(8deg); }
.seal.is-open .note-flap--top { transform: rotateX(-178deg); }
.seal.is-open .note-flap--bottom { transform: rotateX(178deg); transition-delay: 0.12s; }

.note:focus-visible { outline: 2px solid var(--flame); outline-offset: 8px; }

.seal-hint {
  font: 400 1.35rem/1 var(--hand);
  color: #d9a8b1;
}

/* ================= SAMPUL ================= */
.cover {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  padding: clamp(3rem, 8vh, 6rem) var(--gutter);
  overflow: hidden;
}
.cover-text { position: relative; z-index: 2; max-width: 34rem; }
.cover-date {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.cover-title { font-weight: 400; }
.cover-small {
  display: block;
  font: italic 400 clamp(1.5rem, 3vw, 2.1rem)/1.1 var(--serif);
  color: var(--wine);
}
.cover-name {
  display: block;
  font: 400 clamp(3.6rem, 11vw, 8.5rem)/0.9 var(--serif);
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: 0.1em;
}
.cover-lead {
  margin-top: 1.75rem;
  max-width: 30ch;
  font-size: 1.125rem;
  color: #5a2d35;
}

.cover-photo {
  position: relative;
  z-index: 2;
  justify-self: end;
  width: min(100%, 360px);
  rotate: 2deg;
}
.cover-photo img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--paper-deep);
  box-shadow: 0 1px 2px rgba(51, 22, 28, 0.08), 0 24px 50px -20px rgba(51, 22, 28, 0.45);
}
.cover-photo figcaption {
  position: absolute;
  left: -2.5rem;
  bottom: -1.4rem;
  font: 400 1.4rem/1 var(--hand);
  color: var(--wine);
  rotate: -6deg;
}

.cover-numeral {
  position: absolute;
  right: -0.08em;
  bottom: -0.28em;
  font: italic 400 clamp(16rem, 42vw, 34rem)/1 var(--serif);
  color: var(--paper-deep);
  z-index: 1;
  pointer-events: none;
  user-select: none;
}

/* ================= DUA PULUH HAL ================= */
.twenty {
  padding: clamp(5rem, 12vh, 8rem) var(--gutter);
  background: var(--sheet);
}
.twenty .kicker { margin-bottom: 2rem; }
.twenty-text {
  max-width: 62rem;
  font: 400 clamp(1.55rem, 3.2vw, 2.6rem)/1.35 var(--serif);
  color: var(--ink);
  text-wrap: pretty;
}
.twenty-text sup {
  font: italic 400 0.5em/1 var(--serif);
  color: var(--wine);
  vertical-align: 0.9em;
  margin-right: 0.15em;
}

/* ================= MEJA FOTO ================= */
.table {
  padding: clamp(5rem, 12vh, 8rem) var(--gutter) clamp(4rem, 10vh, 6rem);
}
.table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  max-width: 1100px;
  margin: 0 auto 2rem;
}
.table-hint {
  font: 400 1.25rem/1 var(--hand);
  color: var(--muted);
}
.table-surface {
  position: relative;
  max-width: 1100px;
  height: clamp(460px, 62vw, 640px);
  margin: 0 auto;
  touch-action: pan-y;
}
.print {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: clamp(170px, 30%, 300px);
  padding: 10px 10px 0;
  background: #fffdfb;
  rotate: var(--r);
  box-shadow: 0 1px 2px rgba(51, 22, 28, 0.1), 0 14px 30px -12px rgba(51, 22, 28, 0.35);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.2s ease, scale 0.2s ease;
}
.print img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--paper-deep);
  pointer-events: none;
}
.print figcaption {
  padding: 0.7rem 0.2rem 0.9rem;
  font: 400 1.05rem/1.2 var(--hand);
  color: var(--ink);
}
.print.is-dragging {
  cursor: grabbing;
  scale: 1.03;
  box-shadow: 0 2px 4px rgba(51, 22, 28, 0.1), 0 30px 50px -16px rgba(51, 22, 28, 0.45);
}

/* ================= SURAT ================= */
.letter {
  padding: clamp(4rem, 10vh, 7rem) var(--gutter);
  background: var(--wine);
}
.letter-paper {
  max-width: 40rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem);
  background: var(--sheet);
  font: 400 clamp(1.2rem, 2vw, 1.4rem)/1.6 var(--serif);
  color: var(--ink);
}
.letter-paper p + p { margin-top: 1.1em; }
.letter-hello {
  font: 400 2rem/1 var(--hand);
  color: var(--wine);
  margin-bottom: 1.6rem;
}
.letter-paper .letter-sign {
  margin-top: 2.2rem;
  text-align: right;
  font: 400 1.6rem/1 var(--hand);
  color: var(--wine);
}

/* ================= LILIN ================= */
.wish {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem var(--gutter);
  background: var(--wine-deep);
  color: #f3dfe2;
  text-align: center;
  transition: background 1.2s ease;
}
.wish.is-out { background: #160609; }
.wish-title {
  font: italic 400 clamp(2rem, 5vw, 3.4rem)/1.1 var(--serif);
  max-width: 16ch;
}
.wish-sub {
  margin-top: 1rem;
  color: #c79aa2;
  max-width: 34ch;
}

.candle {
  position: relative;
  width: 22px;
  height: 190px;
  margin: 4.5rem 0 3rem;
}
.stick {
  position: absolute;
  bottom: 0; left: 0;
  width: 22px; height: 140px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, #f1d9dc 0%, #fbeff0 45%, #d8b8bd 100%);
}
.wick {
  position: absolute;
  bottom: 140px; left: 50%;
  width: 2px; height: 10px;
  translate: -50% 0;
  background: #3b2a24;
}
.flame {
  position: absolute;
  bottom: 146px; left: 50%;
  width: 18px; height: 40px;
  translate: -50% 0;
  border-radius: 50% 50% 45% 45% / 70% 70% 30% 30%;
  background: radial-gradient(ellipse at 50% 78%, #fff8e0 0%, #ffd78a 35%, var(--flame) 65%, rgba(255, 120, 60, 0) 100%);
  box-shadow: 0 0 40px 14px rgba(255, 170, 80, 0.28);
  transform-origin: 50% 90%;
  transform: skewX(var(--lean, 0deg)) scaleY(var(--squash, 1));
  animation: flicker 2.4s ease-in-out infinite;
  transition: opacity 0.3s ease;
}
@keyframes flicker {
  0%, 100% { rotate: -1.5deg; }
  30% { rotate: 2deg; }
  60% { rotate: -2.5deg; }
}
.candle.is-out .flame { opacity: 0; }
.smoke {
  position: absolute;
  bottom: 150px; left: 50%;
  width: 6px; height: 30px;
  translate: -50% 0;
  border-radius: 50%;
  background: rgba(220, 200, 205, 0.35);
  filter: blur(4px);
  opacity: 0;
}
.candle.is-out .smoke { animation: smoke 2.6s ease-out forwards; }
@keyframes smoke {
  0% { opacity: 0.8; transform: translateY(0) scaleX(1); }
  100% { opacity: 0; transform: translateY(-90px) scaleX(3); }
}

.wish-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  transition: opacity 0.5s ease;
}
.btn-blow {
  position: relative;
  overflow: hidden;
  padding: 0.95rem 1.8rem;
  border: 1px solid rgba(243, 223, 226, 0.4);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.btn-blow-fill {
  position: absolute;
  inset: 0;
  background: #f3dfe2;
  transform-origin: left;
  transform: scaleX(var(--p, 0));
}
.btn-blow-label {
  position: relative;
  font-weight: 500;
  color: #f3dfe2;
  mix-blend-mode: difference;
}
.btn-mic {
  border: 0;
  background: none;
  padding: 0.25rem;
  font-size: 0.875rem;
  color: #b58891;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-blow:focus-visible, .btn-mic:focus-visible { outline: 2px solid var(--flame); outline-offset: 4px; }

.wish.is-out .wish-actions { opacity: 0; pointer-events: none; }
.wish-done {
  margin-top: -3rem;
  font: 400 clamp(1.5rem, 4vw, 2rem)/1.3 var(--hand);
  color: #f3dfe2;
  opacity: 0;
  transition: opacity 1.2s ease 0.6s;
}
.wish.is-out .wish-done { opacity: 1; }

/* ================= PENUTUP ================= */
.end {
  padding: 2.5rem var(--gutter);
  background: #160609;
  color: #7f5a61;
  font-size: 0.8125rem;
  text-align: center;
  letter-spacing: 0.04em;
}

/* ================= RESPONSIF ================= */
@media (max-width: 760px) {
  .cover {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 3rem;
  }
  .cover-photo { justify-self: center; width: min(78%, 300px); }
  .cover-photo figcaption { left: -1rem; }
  .cover-numeral { font-size: 62vw; bottom: auto; top: 18%; right: -0.12em; }

  /* di HP, foto disusun bertumpuk vertikal tapi tetap bisa digeser */
  .table-surface { height: 1080px; }
  .print { width: 62%; }
  .print:nth-child(1) { left: 2%;  top: 0; }
  .print:nth-child(2) { left: 34%; top: 32%; }
  .print:nth-child(3) { left: 6%;  top: 64%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
