/* =====================================================================
   Happy Birthday Husna  -  "soft garden"
   Fonts: Quicksand (display) + Nunito (body). Satu warna accent: rose.
   Semua text ada dalam index.html; file ni untuk rupa je.
   ===================================================================== */

:root {
  color-scheme: light;

  /* palette */
  --blush: #fff6f8;
  --blush-2: #ffe9ee;
  --pink: #f8cdd8;
  --pink-2: #f2aebe;
  --rose: #d9667e;
  --rose-deep: #b8465f;
  --rose-text: #a63d56; /* rose for small text: 4.5:1+ on every blush tone */
  --ink: #4a2f38;
  --ink-soft: #7d5a66;
  --white: #fffdfd;
  --tape: rgba(242, 174, 190, 0.6);

  /* type */
  --font-display: "Quicksand", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Nunito", "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* spacing scale */
  --s1: 0.5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2.5rem;
  --s5: 4rem;
  --gutter: clamp(16px, 5vw, 32px);
  /* viewport-fit=cover: in landscape on a notched phone the gutter grows past the notch */
  --gutter: max(clamp(16px, 5vw, 32px), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));

  /* radii + shadow */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --shadow: 0 12px 36px -14px rgba(184, 70, 95, 0.32);
  --shadow-soft: 0 6px 18px -8px rgba(184, 70, 95, 0.25);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background: linear-gradient(180deg, #fffafb 0%, #fff3f6 50%, #ffecf1 100%);
  background-color: #ffecf1; /* iOS overscroll area matches the page end */
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: transparent;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
h1, h2, h3, p, figure { margin: 0; }
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }

/* ---------- type helpers ---------- */
.eyebrow {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rose-text);
}

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-top: var(--s1);
}

.section-lead {
  margin-top: var(--s2);
  color: var(--ink-soft);
  max-width: 30rem;
  margin-inline: auto;
}

/* ---------- layout ---------- */
.section { padding-block: var(--s4) var(--s5); }

.wrap {
  max-width: 40rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--wide { max-width: 62rem; }

.section-head {
  text-align: center;
  margin-bottom: var(--s4);
  padding-block: var(--s2);
}

/* ---------- petals (script.js makes up to 17 in the hero + 1 the cat bats) ---------- */
.petal {
  position: absolute;
  top: 0;
  left: var(--x, 50%);
  width: var(--s, 14px);
  height: calc(var(--s, 14px) * 1.4);
  border-radius: 100% 0 100% 0;
  background: linear-gradient(150deg, #ffd8e1 0%, #f4a6b8 100%);
  opacity: 0;
  will-change: transform, opacity;
  animation: petal-fall var(--d, 14s) linear infinite;
  animation-delay: var(--t, 0s);
}

@keyframes petal-fall {
  0%   { transform: translate3d(0, -10vh, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: var(--o, 0.85); }
  85%  { opacity: var(--o, 0.85); }
  100% { transform: translate3d(var(--dx, 0px), 108vh, 0) rotate(var(--r, 480deg)); opacity: 0; }
}

/* script.js adds .is-paused to the hero while it is off-screen */
.hero.is-paused .petal,
.hero.is-paused .hero__cue span { animation-play-state: paused; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh; /* phones: always a full first screen (900px cap is desktop-only, below) */
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: var(--s5) var(--gutter) 8rem;
  text-align: center;
  background:
    radial-gradient(60% 45% at 14% 18%, rgba(255, 255, 255, 0.8), transparent 70%),
    radial-gradient(50% 40% at 88% 72%, rgba(242, 174, 190, 0.35), transparent 70%),
    linear-gradient(180deg, #fff7f9 0%, #ffe8ee 55%, #fbd8e1 100%);
  border-bottom-left-radius: 50% 2.75rem;
  border-bottom-right-radius: 50% 2.75rem;
}

.hero__petals {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero__inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 34rem;
  min-width: 0;
}

.hero__date { margin-bottom: var(--s2); }

.hero__title {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.015em;
  display: grid;
  gap: 0.35rem;
}

.hero__greeting {
  font-weight: 600;
  font-size: clamp(1.25rem, 5vw, 1.7rem);
  color: var(--rose-text);
  letter-spacing: 0;
}

.hero__name {
  font-size: clamp(2.3rem, 11.2vw, 4.8rem);
  color: var(--rose-deep);
  padding-bottom: 0.06em; /* room for the q descender */
  overflow-wrap: anywhere;
}

.hero__line {
  margin-top: var(--s3);
  font-size: clamp(1rem, 3.8vw, 1.15rem);
  line-height: 1.6;
  color: var(--ink);
  max-width: 26rem;
  margin-inline: auto;
}

.hero__meta {
  margin-top: var(--s3);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s1);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  min-height: 2rem;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--rose-deep);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-soft);
}

.chip--days { background: var(--rose-deep); color: #fff; }

.hero__cue {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: var(--s4);
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  color: var(--rose-text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.hero__cue:hover, .hero__cue:focus-visible { color: var(--rose-deep); }
.hero__cue span { display: inline-block; animation: cue-bob 1.8s ease-in-out infinite; }

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

/* flower bed in the bottom-left corner of the hero */
.hero__flowers {
  position: absolute;
  left: clamp(-10px, -1vw, 0px);
  bottom: 3rem;
  width: clamp(150px, 34vw, 260px);
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(184, 70, 95, 0.12));
}

/* cat in the bottom-right corner, batting a petal */
.hero__cat {
  position: absolute;
  right: clamp(8px, 4vw, 40px);
  bottom: 2.5rem;
  width: clamp(104px, 27vw, 150px);
  color: var(--rose-deep);
  pointer-events: none;
}

.hero__cat-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 6px rgba(184, 70, 95, 0.14));
}

.petal--bat {
  top: 24%;
  left: 3%;
  width: 15px;
  height: 21px;
  opacity: 0.95;
  transform-origin: 50% 100%;
  animation: petal-bat 2.4s ease-in-out infinite;
}

@keyframes petal-bat {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-18deg); }
  35%      { transform: translate3d(-6px, -10px, 0) rotate(22deg); }
  70%      { transform: translate3d(3px, -3px, 0) rotate(-6deg); }
}

/* ---------- floral divider ---------- */
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s3) var(--gutter) 0;
  max-width: 40rem;
  margin-inline: auto;
}

.divider__line {
  flex: 1 1 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--pink-2));
  min-width: 0;
}
.divider__line:last-child {
  background: linear-gradient(90deg, var(--pink-2), transparent);
}

.divider__art {
  width: clamp(150px, 46vw, 220px);
  height: auto;
  flex: 0 0 auto;
}

/* ---------- gallery (polaroids, 2 columns on phone, 3 on wide) ----------
   flex-wrap (bukan CSS columns): gambar ikut susunan dalam HTML, dan kalau
   bilangan ganjil, yang terakhir duduk tengah. */
.gallery__grid {
  --gap-x: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.6rem var(--gap-x);
  padding: var(--s2) 0.25rem var(--s1);
}

.polaroid {
  position: relative;
  width: calc(50% - var(--gap-x) / 2);
  padding: 8px 8px 10px;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, 0deg));
}

.polaroid:nth-child(odd)  { --tilt: -1.6deg; }
.polaroid:nth-child(even) { --tilt: 1.3deg; --i: 1; }

/* washi tape on some of them */
.polaroid:nth-child(3n + 1)::before,
.polaroid:nth-child(odd):last-child::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  z-index: 2;
  width: 70px;
  height: 20px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.4) 0 5px, rgba(255, 255, 255, 0) 5px 10px),
    var(--tape);
  transform: translateX(-50%) rotate(-4deg);
  box-shadow: 0 1px 2px rgba(74, 47, 56, 0.08);
}
.polaroid:nth-child(odd):last-child::before { transform: translateX(-50%) rotate(5deg); }

.polaroid img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 7px;
  background: var(--pink);
}

/* optional: class="polaroid polaroid--tall" keeps a 9:16 photo uncropped */
.polaroid.polaroid--tall img { aspect-ratio: 9 / 16; }

.polaroid figcaption {
  padding: 10px 2px 2px;
  min-height: 2.8em;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  color: var(--ink-soft);
}

/* phone, 2 columns: kalau bilangan gambar ganjil, yang terakhir duduk tengah */
@media (max-width: 719.98px) {
  .gallery__grid > .polaroid:nth-child(odd):last-child {
    width: 68%;
    --tilt: 0.8deg;
  }
}

/* ---------- letter ---------- */
.letter {
  position: relative;
  margin-top: 2.5rem;
  padding: var(--s4) var(--s3) var(--s3);
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(242, 174, 190, 0.35);
}

/* the cat peeking over the top edge of the card */
.letter__cat {
  position: absolute;
  top: -57px;
  left: 50%;
  width: 132px;
  height: auto;
  transform: translateX(-50%);
  color: var(--rose-deep);
  pointer-events: none;
}

.letter__greeting {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--rose-deep);
  margin-bottom: var(--s2);
}

.letter__body p {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--ink);
}
.letter__body p + p { margin-top: var(--s2); }

.letter__signoff {
  margin-top: var(--s3);
  text-align: right;
  color: var(--ink-soft);
  line-height: 1.5;
}

.letter__name {
  display: block;
  margin-top: 0.1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--rose);
}

/* ---------- game ---------- */
.board {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 10px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(242, 174, 190, 0.35);
}

.board__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: 10px;
  padding: 0.25rem 0.25rem 0 0.5rem;
}

.board__moves {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.board__moves span { color: var(--rose-deep); font-size: 1.15rem; }

.btn {
  min-height: 44px;
  padding: 0.55rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--rose-deep);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 18px -8px rgba(184, 70, 95, 0.6);
  transition: transform 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--rose-text); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--pink-2); outline-offset: 2px; }

.board__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 480px) {
  .board { padding: var(--s3); }
  .board__bar { margin-bottom: var(--s2); }
  .board__grid { gap: 12px; }
}

@media (min-width: 600px) {
  .board__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
}

.card {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  perspective: 800px;
  -webkit-tap-highlight-color: transparent;
}
.card:focus-visible { outline: 3px solid var(--rose); outline-offset: 3px; }

.card__inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
  will-change: transform;
}

.card.is-flipped .card__inner,
.card.is-matched .card__inner { transform: rotateY(180deg); }

.card__face {
  position: absolute;
  inset: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: grid;
  place-items: center;
}

/* back: pink dotted pattern + cat face */
.card__back {
  background-color: #ffe6ec;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.85) 1.6px, transparent 1.9px),
    radial-gradient(rgba(255, 255, 255, 0.85) 1.6px, transparent 1.9px);
  background-size: 16px 16px, 16px 16px;
  background-position: 0 0, 8px 8px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 0 0 1px rgba(242, 174, 190, 0.5);
  color: var(--rose-deep);
}
.card__back svg { width: 50%; height: auto; }

/* front: the photo (or the bonus flower) */
.card__front {
  transform: rotateY(180deg);
  background: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.9);
}
.card__front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.card__front svg { width: 60%; height: auto; color: var(--rose); }

.card.is-matched { cursor: default; }
.card.is-matched .card__front {
  box-shadow: inset 0 0 0 3px var(--pink-2);
}
/* the pop waits 0.5s so the flip transition plays first (an animation would
   otherwise override the transition and the card would snap to its face) */
.card.is-matched .card__inner { animation: card-pop 0.45s ease 0.5s; }

@keyframes card-pop {
  0%   { transform: rotateY(180deg) scale(1); }
  40%  { transform: rotateY(180deg) scale(1.06); }
  100% { transform: rotateY(180deg) scale(1); }
}

.board__noscript {
  text-align: center;
  color: var(--ink-soft);
  padding: var(--s2);
}

/* the hidden message, shown by script.js when all pairs are found */
.secret {
  margin-top: var(--s3);
  padding: var(--s3) var(--s2);
  border-radius: var(--r-md);
  text-align: center;
  background: linear-gradient(160deg, #fff0f4 0%, #ffe0e8 100%);
  border: 1px solid rgba(242, 174, 190, 0.6);
}
.secret.is-shown { animation: secret-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

.secret__label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.secret__text {
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  line-height: 1.15;
  color: var(--rose-deep);
}

@keyframes secret-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* confetti canvas (made by script.js, removed when it is done) */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ---------- footer (cat asleep on the top rule) ---------- */
.footer {
  position: relative;
  margin-top: var(--s3);
  padding: var(--s4) var(--gutter) calc(var(--s5) + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
}
.footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100% - 2 * var(--gutter), 40rem);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--pink-2) 25%, var(--pink-2) 75%, transparent);
}
.footer__cat {
  position: absolute;
  top: 0;
  left: 50%;
  width: 128px;
  height: auto;
  transform: translate(-50%, -93%);
  color: var(--rose-deep);
  pointer-events: none;
}

/* ---------- scroll fade-in (only when JS is on; content shows without it) ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* polaroids keep their tilt while fading in; the 2nd in a row lags a little */
.js .polaroid.reveal {
  transform: rotate(var(--tilt, 0deg)) translateY(18px);
  transition-delay: calc(var(--i, 0) * 110ms);
}
.js .polaroid.reveal.is-visible { transform: rotate(var(--tilt, 0deg)); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  /* petals stay as still decoration instead of disappearing */
  .petal {
    animation: none;
    opacity: 0.5;
    top: var(--ty, 40%);
    transform: rotate(var(--r, 30deg));
  }
  .petal--bat { top: 24%; opacity: 0.95; transform: rotate(-18deg); }
  .hero__cue span { animation: none; }
  .card__inner { transition-duration: 0.01s; }
  .card.is-matched .card__inner { animation: none; }
  .secret.is-shown { animation: none; }
  .btn { transition: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .js .polaroid.reveal { transform: rotate(var(--tilt, 0deg)); }
}

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  :root { --s5: 5.5rem; }
  body { font-size: 1.05rem; }
  .hero {
    padding-bottom: 9rem;
    min-height: min(100vh, 900px);
    min-height: min(100svh, 900px);
  }
  .gallery__grid { --gap-x: 22px; gap: 2.2rem var(--gap-x); padding-inline: var(--s1); }
  .polaroid { width: calc((100% - 2 * var(--gap-x)) / 3); padding: 12px 12px 14px; }
  .polaroid figcaption { font-size: 0.9rem; padding-top: 12px; }
  .letter { padding: var(--s4) var(--s4) var(--s3); }
  .letter__cat { left: auto; right: 2.5rem; transform: none; }
  .footer__cat { width: 148px; }
}

/* ---------- butang lagu (bawah kanan) ---------- */
.music-btn {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 46px;
  height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid #f3c9d5;
  border-radius: 50%;
  background: #fffafc;
  color: #c9566f;
  box-shadow: 0 4px 14px rgba(201, 86, 111, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, background 0.18s ease;
}
.music-btn:active { transform: scale(0.94); }
.music-btn:focus-visible { outline: 2px solid #c9566f; outline-offset: 3px; }
.music-btn svg { width: 21px; height: 21px; fill: currentColor; grid-area: 1 / 1; }

/* default (pause): tunjuk icon bergaris */
.music-btn .music-btn__on { display: none; }
.music-btn.is-on { background: #c9566f; color: #fffafc; border-color: #c9566f; }
.music-btn.is-on .music-btn__on { display: block; }
.music-btn.is-on .music-btn__off { display: none; }

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