:root {
  --ink: #24211f;
  --ink-soft: #6f6964;
  --paper: #fffaf3;
  --paper-soft: #f8efe7;
  --line: rgba(36, 33, 31, 0.13);
  --rose: #b66f7c;
  --rose-soft: #e9c7c4;
  --gold: #e5c37a;
  --night: #0b0d18;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.28);

  /* alias biar class lama/baru tetap aman */
  --accent-strong: var(--rose);
  --muted: var(--ink-soft);

  --envelope-width: min(380px, 82vw);
  --envelope-height: calc(var(--envelope-width) * 0.66);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 14% 12%, rgba(204, 151, 158, 0.22), transparent 28rem),
    radial-gradient(circle at 88% 8%, rgba(229, 195, 122, 0.12), transparent 25rem),
    linear-gradient(135deg, #080912 0%, #101426 48%, #211520 100%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, black 0%, transparent 76%);
  pointer-events: none;
}

button {
  font: inherit;
}

/* =========================
   Background ambience
========================= */

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.13;
  background-image: radial-gradient(rgba(255, 255, 255, 0.5) 0.6px, transparent 0.7px);
  background-size: 18px 18px;
}

.orb {
  position: absolute;
  width: 26rem;
  height: 26rem;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.22;
}

.orb-1 {
  top: 12%;
  left: -8rem;
  background: rgba(214, 153, 171, 0.62);
}

.orb-2 {
  right: -10rem;
  bottom: 10%;
  background: rgba(229, 195, 122, 0.34);
}

.star {
  position: absolute;
  width: 4px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 248, 227, 0.9);
  box-shadow: 0 0 18px rgba(255, 248, 227, 0.75);
  animation: twinkle 4s ease-in-out infinite;
}

.star-1 {
  top: 18%;
  left: 14%;
  animation-delay: 0.4s;
}

.star-2 {
  top: 31%;
  left: 78%;
  animation-delay: 1.6s;
}

.star-3 {
  top: 69%;
  left: 87%;
  animation-delay: 2.2s;
}

.star-4 {
  top: 82%;
  left: 27%;
  animation-delay: 0.9s;
}

/* =========================
   Page / hero
========================= */

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 96px;
}

.hero {
  display: grid;
  min-height: 100svh;
  place-content: center;
  padding: 64px 0 86px;
  text-align: center;
}

.eyebrow,
.letter-kicker {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Source Serif 4", Georgia, Cambria, "Times New Roman", serif;
  line-height: 0.96;
}

h1 {
  font-size: clamp(3.2rem, 9vw, 7rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.hero-copy {
  width: min(610px, 100%);
  margin: 24px auto 0;
  color: rgba(255, 250, 243, 0.72);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.8;
  text-wrap: balance;
}

/* =========================
   Envelope
========================= */

.envelope-scene {
  display: grid;
  place-items: center;
  margin-top: 3.2rem;
}

.envelope-button {
  position: relative;
  display: inline-grid;
  justify-items: center;
  gap: 18px;
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
  cursor: pointer;
}

.envelope-button:focus-visible,
.voice-play:focus-visible,
.voice-skip:focus-visible,
.voice-seek:focus-visible,
.close-letter:focus-visible,
.to-top:focus-visible {
  outline: 3px solid rgba(229, 195, 122, 0.82);
  outline-offset: 4px;
}

.envelope-shadow {
  position: absolute;
  bottom: 3.3rem;
  width: calc(var(--envelope-width) * 0.8);
  height: 2.4rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  filter: blur(18px);
  transform: translateY(8px);
}

.envelope {
  position: relative;
  width: var(--envelope-width);
  height: var(--envelope-height);
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.32));
  perspective: 900px;
  transform-origin: center;
  transition: transform 700ms ease;
}

.envelope-button:hover .envelope {
  transform: translateY(-4px);
}

.envelope-back,
.envelope-front,
.envelope-flap,
.letter-preview {
  position: absolute;
  inset: 0;
  border-radius: 0 0 22px 22px;
}

.envelope-back {
  background: linear-gradient(180deg, #f8ebe6, #e8c7c0);
}

.letter-preview {
  inset: 10% 11% 18%;
  padding: 1rem 1.2rem;
  border-radius: 16px;
  color: #4f4047;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 250, 243, 0.98));
  box-shadow: inset 0 0 0 1px rgba(182, 111, 124, 0.12);
  transform: translateY(18%);
  transition:
    transform 900ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 400ms ease;
}

.letter-preview__title {
  display: block;
  margin-bottom: 0.8rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.letter-preview__line {
  display: block;
  width: 100%;
  height: 1px;
  margin-top: 0.75rem;
  background: rgba(79, 64, 71, 0.14);
}

.letter-preview__line.short {
  width: 72%;
}

.envelope-front {
  z-index: 4;
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, #efdad4, #d8aca9);
}

.envelope-front::before,
.envelope-front::after {
  position: absolute;
  inset: 0;
  content: "";
}

.envelope-front::before {
  clip-path: polygon(0 0, 0 100%, 50% 56%);
  background: linear-gradient(180deg, #f7e7e1, #d8b3ae);
}

.envelope-front::after {
  clip-path: polygon(100% 0, 100% 100%, 50% 56%);
  background: linear-gradient(180deg, #edd7d1, #cf9b99);
}

.envelope-flap {
  z-index: 6;
  clip-path: polygon(0 0, 100% 0, 50% 72%);
  transform-origin: top;
  background: linear-gradient(180deg, #fbeee7, #e8c1bc);
  border-radius: 22px 22px 0 0;
  transition:
    transform 900ms cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 820ms ease;
}

.wax-seal {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 7;
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 2px solid rgba(255, 248, 238, 0.34);
  border-radius: 50%;
  color: #fff3e7;
  background: radial-gradient(circle at 35% 30%, #da91a0, #9f5d6e 70%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  transition:
    transform 380ms ease,
    opacity 380ms ease;
}

.envelope-button__label {
  padding: 15px 22px;
  border: 1px solid rgba(255, 248, 238, 0.22);
  border-radius: 999px;
  color: #241c22;
  background: linear-gradient(135deg, #fff8ee, #e8bfc0);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    opacity 260ms ease;
}

.envelope-button:hover .envelope-button__label {
  transform: translateY(-2px);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.28);
}

/* =========================
   Letter sheet
========================= */

.letter-sheet {
  position: relative;
  width: min(960px, calc(100vw - 28px));
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px) clamp(24px, 6vw, 76px);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(255, 248, 238, 0.58);
  border-radius: 30px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(80px) scale(0.94);
  transform-origin: top center;
  pointer-events: none;
  transition:
    opacity 700ms ease,
    transform 1000ms cubic-bezier(0.19, 1, 0.22, 1);
}

.letter-sheet.is-visible {
  opacity: 1;
  transform: translateY(-58px) scale(1);
  pointer-events: auto;
}

/* =========================
   Butterfly tattoo
========================= */

.letter-tattoo {
  position: absolute;
  top: 42px;
  right: 84px;
  z-index: 1;
  width: 270px;
  height: 152px;
  color: rgba(19, 17, 18, 0.82);
  opacity: 0.82;
  pointer-events: none;
}

.letter-tattoo-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Biar konten tetap di atas tattoo */
.letter-header,
.voice-note,
.letter-body,
.letter-footer,
.close-letter {
  position: relative;
  z-index: 2;
}

/* Biar judul nggak nabrak tattoo, tapi voice player tetap bisa full width */
.letter-header > .letter-kicker,
.letter-header > h2,
.letter-header > .letter-subtitle {
  max-width: calc(100% - 330px);
}

/* =========================
   Letter header
========================= */

.letter-header {
  padding-bottom: 28px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.letter-header h2 {
  color: var(--ink);
  font-size: clamp(3.2rem, 9vw, 6.2rem);
  font-weight: 700;
  letter-spacing: -0.06em;
}

.letter-subtitle {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* =========================
   Voice note
========================= */

.voice-note {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  margin-top: 1.35rem;
  border: 1px solid rgba(182, 111, 124, 0.16);
  border-radius: 18px;
  background: rgba(255, 248, 238, 0.58);
}

.voice-play {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  width: fit-content;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.voice-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.voice-skip {
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(182, 111, 124, 0.18);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 248, 238, 0.68);
  cursor: pointer;
}

.voice-skip:hover,
.voice-play:hover {
  opacity: 0.78;
}

.voice-seek {
  width: 100%;
  accent-color: #1a73e8;
  cursor: pointer;
}

.voice-time {
  display: flex;
  justify-content: space-between;
  color: var(--ink);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

/* =========================
   Close button
========================= */

.close-letter {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 5;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(182, 111, 124, 0.16);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 248, 238, 0.78);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.close-letter:hover {
  background: rgba(255, 248, 238, 0.96);
}

/* =========================
   Letter body
========================= */

.letter-body {
  display: grid;
  gap: 1.18em;
  font-family: "Source Serif 4", Georgia, Cambria, "Times New Roman", serif;
  font-size: clamp(1.05rem, 1.6vw, 1.28rem);
  line-height: 1.78;
  letter-spacing: -0.006em;
}

.letter-body p {
  margin: 0;
}

.letter-body p:first-child {
  color: var(--rose);
  font-weight: 400;
}

.letter-body em {
  font-style: italic;
}

.letter-body strong {
  font-weight: 700;
}

/* =========================
   Footer
========================= */

.letter-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  padding-top: 34px;
  margin-top: 38px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.letter-footer strong {
  color: var(--rose);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.35rem;
}

/* =========================
   Back to top
========================= */

.to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 248, 238, 0.25);
  border-radius: 999px;
  color: #fff8ee;
  background: rgba(18, 22, 42, 0.72);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================
   Open states
========================= */

body.is-opening .envelope-button,
body.is-opened .envelope-button {
  pointer-events: none;
}

body.is-opening .envelope-flap,
body.is-opened .envelope-flap {
  transform: rotateX(180deg);
  filter: brightness(0.98);
}

body.is-opening .letter-preview,
body.is-opened .letter-preview {
  transform: translateY(-42%);
}

body.is-opening .wax-seal,
body.is-opened .wax-seal {
  transform: translate(-50%, -92%);
  opacity: 0;
}

body.is-opened .envelope-button {
  opacity: 0.22;
  transform: translateY(80px) scale(0.78);
}

body.is-opened .envelope-button__label {
  opacity: 0;
}

body.is-opened .hero {
  min-height: 82svh;
}

/* =========================
   Animations
========================= */

@keyframes twinkle {
  0%,
  100% {
    transform: scale(0.85);
    opacity: 0.35;
  }

  50% {
    transform: scale(1.3);
    opacity: 1;
  }
}

/* =========================
   Responsive
========================= */

@media (max-width: 900px) {
  .letter-tattoo {
    top: 44px;
    right: 58px;
    width: 220px;
    height: 124px;
    opacity: 0.72;
  }

  .letter-header > .letter-kicker,
  .letter-header > h2,
  .letter-header > .letter-subtitle {
    max-width: calc(100% - 250px);
  }
}

@media (max-width: 720px) {
  :root {
    --envelope-width: min(326px, 86vw);
  }

  .page-shell {
    width: min(100% - 22px, 1120px);
  }

  .hero {
    padding-top: 52px;
    padding-bottom: 62px;
  }

  h1 {
    font-size: clamp(4rem, 21vw, 6.2rem);
  }

  .envelope-scene {
    margin-top: 2.5rem;
  }

  .letter-sheet {
    width: 100%;
    border-radius: 24px;
  }

  .letter-sheet.is-visible {
    transform: translateY(-32px) scale(1);
  }

  .letter-tattoo {
    position: relative;
    top: auto;
    right: auto;
    width: 190px;
    height: 108px;
    margin: -6px 0 10px auto;
    opacity: 0.62;
  }

  .letter-header > .letter-kicker,
  .letter-header > h2,
  .letter-header > .letter-subtitle {
    max-width: none;
  }

  .voice-controls {
    grid-template-columns: 1fr;
  }

  .voice-skip {
    width: fit-content;
  }

  .voice-skip[data-skip-forward] {
    justify-self: end;
  }

  .close-letter {
    top: 16px;
    right: 16px;
  }

  .letter-footer {
    display: block;
  }

  .letter-footer strong {
    display: block;
    margin-top: 6px;
  }
}

@media (max-width: 420px) {
  .letter-header h2 {
    font-size: clamp(3rem, 18vw, 4.6rem);
  }

  .letter-body {
    font-size: 1.04rem;
    line-height: 1.76;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

