:root {
  --green: #0B6E4F;
  --green-dark: #084F39;
  --blue: #4E6E9E;
  --blue-dark: #3A5480;
  --gold: #FFC72C;
  --cream: #FFF8ED;
  --brown: #2B1B12;
  --white: #FFFFFF;
  --error: #D6336C;
  --pastel-bg: #F5CD4D;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(43, 27, 18, 0.12);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--cream);
  color: var(--brown);
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: 'Fredoka', 'Poppins', sans-serif;
  margin: 0;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.8rem;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: var(--white);
  box-shadow: 0 8px 20px rgba(78, 110, 158, 0.4);
}

.btn-calendar {
  display: block;
  width: fit-content;
  margin: 1.5rem auto 0;
  background: var(--white);
  color: var(--green);
  border: 2px solid var(--green);
}

.btn-calendar:hover {
  background: var(--green);
  color: var(--white);
}

.btn-calendar-ics {
  display: block;
  width: fit-content;
  margin: 0.6rem auto 0;
  background: none;
  border: none;
  color: var(--blue-dark);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem;
}

body.cover-active {
  overflow: hidden;
  height: 100vh;
}

/* ---------- MOBILE-ONLY APP SHELL ---------- */
/* Undangan didesain buat dibuka di HP (dishare via WA). Di layar lebar,
   tetep dikunci ke lebar HP di tengah supaya proporsinya gak berantakan. */
body {
  background: var(--brown);
}

#app-shell {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--cream);
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.35);
}

/* ---------- COVER / ENVELOPE ---------- */
.cover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pastel-bg);
  transition: opacity 0.6s ease;
}

.cover.cover-hidden {
  opacity: 0;
  pointer-events: none;
}

.cover-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  text-align: center;
}

.cover-invited {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  font-weight: 800;
  color: var(--green);
  -webkit-text-stroke: 3px var(--white);
  paint-order: stroke fill;
  margin: 0;
}

.cover-hello {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue-dark);
  background: var(--white);
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  margin: 0;
}

.envelope {
  position: relative;
  width: 220px;
  height: 150px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  perspective: 800px;
  transition: transform 0.2s ease;
  animation: envelope-idle 2.6s ease-in-out infinite;
}

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

.envelope:not(:disabled):hover {
  animation-play-state: paused;
  transform: translateY(-4px) scale(1.03);
}

.envelope.opened {
  animation: none;
}

.envelope-seal {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--white);
  box-shadow: 0 3px 6px rgba(43, 27, 18, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  z-index: 4;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.envelope.opened .envelope-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
}

.envelope-shadow {
  position: absolute;
  bottom: -18px;
  left: 10%;
  width: 80%;
  height: 18px;
  background: rgba(43, 27, 18, 0.18);
  border-radius: 50%;
  filter: blur(4px);
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: var(--blue);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.envelope-letter {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 6%;
  height: 70%;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(43, 27, 18, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  z-index: 1;
  opacity: 0;
  transform: translateY(10%) scale(0.85);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease 0.2s;
}

.envelope-body-front {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70%;
  background: var(--blue-dark);
  clip-path: path('M 0 0 Q 45 23 110 44 Q 175 23 220 0 L 220 93 Q 220 105 208 105 L 12 105 Q 0 105 0 93 Z');
  z-index: 2;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 58%;
  background: var(--blue-dark);
  clip-path: path('M 0 12 Q 0 0 12 0 L 208 0 Q 220 0 220 12 Q 175 45 110 87 Q 45 45 0 12 Z');
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 0.7s ease-in;
  z-index: 3;
}

.envelope.opened .envelope-flap {
  transform: rotateX(180deg);
  z-index: 0;
}

.envelope.opened .envelope-letter {
  opacity: 1;
  transform: translateY(-62%) scale(1.05);
  z-index: 4;
}

.cover-hint {
  font-size: 0.9rem;
  color: var(--brown);
  opacity: 0.75;
  margin: 0;
  animation: bounce 1.8s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ---------- HERO ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 3rem 1.25rem 0;
  background:
    var(--pastel-bg)
    url('https://ytruxpkjxsnngkifavhc.supabase.co/storage/v1/object/public/invite-images/theme/pattern-cluster.webp')
    repeat;
  background-size: 220px auto;
  overflow: hidden;
}

.hero-stage {
  position: relative;
  z-index: 2;
  max-width: 420px;
  width: 100%;
  padding-bottom: 3rem;
  animation: fadeIn 0.8s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Theme illustration layer (fixed to this dino design; not admin-editable) */
.theme-squiggle {
  position: absolute;
  width: 70px;
  opacity: 0.9;
  z-index: 1;
}

.sq-2 { top: 34%; right: -10%; width: 56px; transform: rotate(20deg); }

.arch-title-img {
  width: min(88%, 340px);
  height: auto;
  margin: 0 auto 0.5rem;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 3px 4px rgba(43, 27, 18, 0.15));
}

.arch-frame {
  position: relative;
  width: min(78vw, 300px);
  height: min(78vw, 300px);
  margin: 0 auto;
  border: 4px solid var(--blue);
  border-radius: 50% 50% 12px 12px / 60% 60% 12px 12px;
  background: var(--white);
  box-shadow: var(--shadow);
  overflow: visible;
}

.arch-photo {
  position: absolute;
  inset: 4px;
  border-radius: 50% 50% 8px 8px / 60% 60% 8px 8px;
  overflow: hidden;
  background: var(--cream);
}

.arch-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.star-icon {
  position: absolute;
  width: 66px;
  z-index: 3;
  filter: drop-shadow(0 4px 6px rgba(43, 27, 18, 0.2));
  animation: twinkle 2.4s ease-in-out infinite;
}

.star-icon-left { top: -8%; left: 2%; animation-delay: 0s; }
.star-icon-right { top: -8%; right: 2%; animation-delay: 1.2s; }

@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.12) rotate(-6deg); }
}

.hero-name-img {
  width: min(70%, 260px);
  height: auto;
  margin: -1.5rem auto 0;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 3px 4px rgba(43, 27, 18, 0.15));
}

.theme-dino {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(43, 27, 18, 0.18));
}

.dino-bl { width: min(46vw, 190px); left: -8%; bottom: -70px; }
.dino-br { width: min(46vw, 190px); right: -10%; bottom: -70px; }
.dino-egg { width: min(20vw, 80px); left: 50%; bottom: -10px; transform: translateX(-140%); }
.dino-fly { width: min(22vw, 90px); right: -6%; top: -2%; transform: rotate(8deg); }

.theme-balloon-cluster {
  position: absolute;
  z-index: 2;
  width: min(20vw, 82px);
  left: -8%;
  top: 12%;
  filter: drop-shadow(0 6px 8px rgba(43, 27, 18, 0.15));
}

.hero-invite-blurb {
  position: relative;
  z-index: 2;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--green);
  max-width: 320px;
  margin: 0.5rem auto 1rem;
}

.hero-badges {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.5rem 0 1.75rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--white);
  color: var(--blue-dark);
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  border: 2px dashed var(--gold);
}

.countdown {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.countdown-item {
  background: var(--white);
  border-radius: 14px;
  padding: 0.75rem 0.5rem;
  min-width: 64px;
  box-shadow: var(--shadow);
}

.countdown-item span {
  display: block;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue);
}

.countdown-item small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brown);
  opacity: 0.7;
}

.hero-cta {
  position: relative;
  z-index: 2;
  font-size: 1.1rem;
}

.hero-grass {
  position: relative;
  z-index: 1;
  width: calc(100% + 6rem);
  max-width: calc(100% + 6rem);
  margin-left: -3rem;
  margin-top: -20px;
  height: 110px;
  background-image: url('https://ytruxpkjxsnngkifavhc.supabase.co/storage/v1/object/public/invite-images/theme/grass.webp');
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
}

/* ---------- SECTIONS ---------- */
.section {
  position: relative;
  padding: 4rem 1.25rem;
  max-width: 720px;
  margin: 0 auto;
  overflow: hidden;
}

.section-alt {
  position: relative;
  background: var(--white);
  max-width: 100%;
  overflow: hidden;
}

.section-alt > *:not(.section-deco) {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.section-deco {
  position: absolute;
  z-index: 0;
  opacity: 0.9;
  pointer-events: none;
}

.section > *:not(.section-deco),
.section-alt > *:not(.section-deco) {
  position: relative;
  z-index: 1;
}

.deco-squiggle-tr { width: 64px; top: 1rem; right: 1rem; transform: rotate(15deg); }
.deco-squiggle-tl { width: 64px; top: 1rem; left: 1rem; transform: rotate(-20deg) scaleX(-1); }
.deco-egg-bl { width: 120px; bottom: -0.5rem; left: -1rem; }
.deco-dino-br { width: 170px; bottom: -1.25rem; right: -1.75rem; opacity: 0.95; }
.deco-star-bl { width: 52px; bottom: 1rem; left: 1rem; animation: twinkle 2.4s ease-in-out infinite; }
.deco-star-tr { width: 56px; top: 1rem; right: 1rem; animation: twinkle 2.4s ease-in-out infinite 1s; }

.section-title {
  position: relative;
  z-index: 1;
  text-align: center;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: clamp(1.7rem, 6vw, 2.3rem);
  line-height: 1.2;
  color: var(--green);
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.detail-cards {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.detail-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1rem;
  text-align: center;
}

.detail-card:nth-child(2n) { transform: rotate(-1.5deg); }
.detail-card:nth-child(2n+1) { transform: rotate(1.5deg); }

.detail-icon {
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 0.6rem;
  border-radius: 50%;
}

.detail-icon-green { background: #DCEFE6; }
.detail-icon-blue { background: #E1E8F2; }
.detail-icon-gold { background: #FDF0CE; }

.detail-card h3 {
  font-size: 1rem;
  color: var(--green);
  margin-bottom: 0.35rem;
}

.detail-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--blue-dark);
  font-weight: 600;
}

.detail-notes {
  text-align: center;
  margin-top: 1.5rem;
  background: var(--gold);
  color: var(--brown);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 500;
}

/* ---------- LOCATION ---------- */
.location-address {
  text-align: center;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 1.5rem;
}

.map-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 10;
  border: 4px solid var(--blue);
}

.map-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  filter: saturate(1.35) hue-rotate(-6deg) contrast(1.03);
}

/* ---------- GALLERY ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.gallery-grid img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* ---------- RSVP ---------- */
.rsvp-cheer {
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: var(--green);
  margin: 0 0 1rem;
}

.photobooth-promo-text {
  position: relative;
  z-index: 1;
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: var(--blue-dark);
  max-width: 320px;
  margin: 0 auto 1.25rem;
}

#photobooth-promo {
  text-align: center;
}

#photobooth-promo .btn {
  display: inline-block;
}

.rsvp-note {
  text-align: center;
  font-weight: 600;
  color: var(--blue-dark);
  background: var(--cream);
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin: -0.5rem 0 1.5rem;
}

.rsvp-deadline {
  text-align: center;
  font-weight: 500;
  color: var(--green);
  margin-bottom: 1.5rem;
}

.rsvp-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  background: var(--white);
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rsvp-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.rsvp-form input,
.rsvp-form textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 2px solid #F0E4D4;
  background: var(--cream);
  color: var(--brown);
  resize: vertical;
}

.rsvp-form input:focus,
.rsvp-form textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.rsvp-status {
  margin: 0;
  min-height: 1.2em;
  font-weight: 500;
  text-align: center;
}

.rsvp-status.ok { color: #1a8f4d; }
.rsvp-status.err { color: var(--error); }

.rsvp-field-hint {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--blue-dark);
  opacity: 0.85;
}

/* ---------- GUESTBOOK ---------- */
.guestbook-cheer {
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: var(--green);
  margin: 0 0 1.25rem;
}

.guestbook-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guestbook-entry {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem;
  text-align: left;
  animation: guestbook-in 0.4s ease both;
}

@keyframes guestbook-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.guestbook-entry-name {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: var(--blue-dark);
}

.guestbook-entry-message {
  margin: 0.3rem 0 0;
  color: var(--brown);
}

.guestbook-entry-time {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--brown);
  opacity: 0.55;
}

.guestbook-empty {
  text-align: center;
  color: var(--brown);
  opacity: 0.65;
  font-weight: 500;
}

.guestbook-load-more {
  margin: 1.25rem auto 0;
}

#guestbook-load-more[hidden] {
  display: none;
}

/* ---------- FOOTER ---------- */
.footer {
  position: relative;
  text-align: center;
  padding: 3rem 1.25rem 0;
  color: var(--brown);
  overflow: hidden;
}

.footer-contact {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.25rem;
  color: var(--green);
  margin: 0.25rem 0 1.5rem;
}

.footer-signoff {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--blue-dark);
  margin: 1rem 0 0.15rem;
}

.footer-signoff-love {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--green);
  margin: 0 0 1.25rem;
}

.footer-note {
  font-size: 0.85rem;
  opacity: 0.6;
  margin-bottom: 2rem;
}

.footer-grass {
  width: calc(100% + 6rem);
  max-width: calc(100% + 6rem);
  margin-left: -3rem;
  height: 110px;
  background-image: url('https://ytruxpkjxsnngkifavhc.supabase.co/storage/v1/object/public/invite-images/theme/grass.webp');
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
}

/* ---------- CONFETTI ---------- */
#confetti-layer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100%;
  max-width: 480px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation: fall linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(360deg);
  }
}

/* ---------- MUSIC TOGGLE ---------- */
.music-toggle-layer {
  position: fixed;
  top: 0;
  left: 50%;
  width: 100%;
  max-width: 480px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1001;
}

.music-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: var(--white);
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.music-toggle[hidden] {
  display: none;
}

/* ---------- SCROLL REVEAL ---------- */
/* Content is visible by default so it never depends on JS running.
   Only once JS confirms it's ready (html.js-ready) do sections start
   hidden and fade in as they scroll into view. */
html.js-ready .section,
html.js-ready .footer {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

html.js-ready .section.in-view,
html.js-ready .footer.in-view {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .hero-balloons span,
  .confetti-piece,
  .section,
  .footer {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
