@import url('https://fonts.googleapis.com/css2?family=Alex+Brush&family=Caveat:wght@400;500;600;700&display=swap');

:root {
  --env-bg: #f5f5f5; /* Clean white/off-white for inside of envelope */
  --paper-bg: #ffffff; /* White invitation paper */
  --env-text: #2b2b2b; /* Dark pen ink */
  --env-accent: #111111; /* Black ink for titles */
  --env-border: #e3ddcf;
  
  --font-env-serif: 'Alex Brush', cursive; /* Elegant cursive for titles */
  --font-env-sans: 'Caveat', cursive; /* Casual handwriting for text */
  
  /* Backward compatibility */
  --scrap-bg: var(--paper-bg);
  --scrap-text: var(--env-text);
  --font-script: var(--font-env-serif);
  --font-typewriter: var(--font-env-sans);
  
  /* Very subtle, clean paper texture (not static) */
  --subtle-texture: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
}

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

body {
  margin: 0;
  padding: 0;
  background-color: #ffffff; /* Clean white desk */
  color: var(--env-text);
  font-family: var(--font-env-sans);
  overflow-x: hidden;
  line-height: 1.6;
}

body.env-locked {
  overflow: hidden;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  touch-action: none; /* Prevent touch scrolling on mobile */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

/* THE ENVELOPE OVERLAY */
.envelope-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent; /* Allow body background/watermark to show through */
}

#envelopeFront {
  background-color: transparent !important;
}

#envelopeFront .env-body {
  background: transparent;
  box-shadow: none;
}

/* The Envelope Container */
.env-body {
  position: relative;
  width: 90vw;
  max-width: 600px;
  aspect-ratio: 3 / 2; /* Landscape rectangle envelope */
  height: auto;
  box-shadow: 
    inset 0 10px 20px rgba(0,0,0,0.05),
    0 10px 25px rgba(0,0,0,0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  background: url('../../assets/img/texture_amplop.webp?v=4') center/cover, var(--env-bg);
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.envelope-opened .env-body {
  transform: translateY(calc(50vh + 50px)); /* Moves envelope down to act as a bottom pocket */
}

/* Envelope Flaps */
.env-flap-left, .env-flap-right, .env-flap-bottom, .env-flap-top {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Foolproof wrappers for cross-browser drop-shadow on clip-path */
.flap-wrap {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
}

.flap-left-wrap {
  z-index: 2;
  filter: drop-shadow(2px 0px 3px rgba(0,0,0,0.15));
}

.flap-right-wrap {
  z-index: 2;
  filter: drop-shadow(-2px 0px 3px rgba(0,0,0,0.15));
}

.flap-bottom-wrap {
  z-index: 3;
  filter: drop-shadow(0px -2px 4px rgba(0,0,0,0.15));
}

.flap-top-wrap {
  z-index: 5;
  filter: drop-shadow(0px 3px 5px rgba(0,0,0,0.20));
  transform-origin: top;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.flap-top-wrap.open {
  transform: rotateX(180deg);
  z-index: 1; /* Drop behind bottom flap once opened */
  filter: none;
}

.env-flap-left {
  clip-path: polygon(0 0, 48% 50%, 0 100%);
  background: 
    linear-gradient(135deg, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 30%),
    url('../../assets/img/texture_amplop.webp?v=4') center/cover;
}

.env-flap-right {
  clip-path: polygon(100% 0, 52% 50%, 100% 100%);
  background: 
    linear-gradient(-135deg, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 30%),
    url('../../assets/img/texture_amplop.webp?v=4') center/cover;
}

.env-flap-bottom {
  clip-path: polygon(0 100%, 50% 48%, 100% 100%);
  background: 
    linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 40%),
    url('../../assets/img/texture_amplop.webp?v=4') center/cover;
}

.env-flap-top {
  clip-path: polygon(0 0, 50% 60%, 100% 0);
  background: 
    linear-gradient(180deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 40%),
    url('../../assets/img/texture_amplop.webp?v=4') center/cover;
}

/* Envelope Opener Area - now covers the whole envelope to make it clickable */
.env-wax-seal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: pointer;
  pointer-events: auto;
  display: block;
}

.env-text-top {
  position: absolute;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  min-width: 280px;
  height: auto;
  padding: 12px 20px;
  background-color: var(--paper-bg);
  background-image: var(--subtle-texture);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

/* Tape effect */
.env-text-top::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 70px;
  height: 25px;
  background-color: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.tap-hint {
  font-family: 'Montserrat', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.6rem; /* Slightly smaller to prevent wrapping */
  letter-spacing: 1px;
  line-height: 1; 
  white-space: nowrap; /* Force single line */
  color: #777;
  text-transform: uppercase;
  animation: pulse 2s infinite;
  text-align: center;
}

.opener-text {
  text-align: center;
  line-height: 1;
  white-space: nowrap; /* Force single line */
}

.opener-to, .opener-name {
  font-family: 'Montserrat', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.75rem; /* Make the name line slightly larger than the hint */
  letter-spacing: 2px;
  color: #555;
  text-transform: uppercase;
}

.opener-name {
  margin-left: 5px;
  font-weight: 600;
}

/* Love Wax Seal */
.wax-seal-love {
  position: absolute;
  top: calc(60% - 8px); /* Shifted slightly up from the tip */
  left: 50%;
  transform: translate(-50%, -50%);
  width: 45px;
  height: 45px;
  background: #5c7253; /* Earthy sage green wax */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  box-shadow: 
    inset 0 0 8px rgba(0,0,0,0.4),
    0 4px 6px rgba(0,0,0,0.3);
  border: 1.5px solid #42523b;
  z-index: 20;
}

/* When opening */
.env-wax-seal.break {
  opacity: 0;
  pointer-events: none;
}

@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}


/* THE ACTUAL PAPER INVITATION CONTENT */
.paper-container {
  position: absolute;
  top: 0;
  left: 50%;
  width: 86vw; /* Slightly narrower than envelope's 90vw to fit inside */
  max-width: 570px; /* Slightly narrower than envelope's 600px max-width */
  background: transparent;
  z-index: 10001; /* Between envelopeBack and envelopeFront */
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none; /* Ignore clicks until fully open */
  
  /* Top of paper peeks out from bottom pocket. The empty space forces the user to scroll down to pull the card out! */
  padding-top: calc(100vh - 200px); 
  padding-bottom: 100px;
  
  transform: translateX(-50%); 
}

/* Hide all sections below the header until the envelope is fully open to prevent any weird layout jumps */
.paper-container:not(.fully-open) .env-section {
  display: none;
}

/* 1. Card fades in, peeking out of the pocket */
.paper-container.step-peek {
  opacity: 1;
}

/* 2. Envelope drops down, card drops with it */
.paper-container.step-down {
  opacity: 1;
}

/* 3. Animation finished, make it scrollable */
.paper-container.fully-open {
  opacity: 1;
  pointer-events: auto;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Paper Textures & Pages */
.paper-page {
  width: 100%;
  max-width: 700px;
  background: transparent;
  box-shadow: none;
  min-height: 100vh;
  padding: 40px 15px;
  margin: 0 auto;
}

@media (min-width: 768px) {
    .paper-page {
        padding: 60px 20px;
    }
    .env-header, .env-section {
        padding: 80px 60px !important;
    }
    .paper-container {
        padding: 20px;
    }
}


/* TYPOGRAPHY & SECTIONS */
.env-header, .env-section {
  background-color: var(--paper-bg);
  background-image: var(--subtle-texture);
  box-shadow: 
    0 8px 25px rgba(0,0,0,0.08),
    0 2px 6px rgba(0,0,0,0.04);
  padding: 60px 30px;
  margin: 0 auto 50px auto;
  border-radius: 8px;
  position: relative;
  text-align: center;
}

.env-header::before, .env-section::before {
  content: '';
  position: absolute;
  top: -25px;
  right: -25px;
  width: 140px;
  height: 140px;
  background: url('./img/pojok_kanan_atas.webp') no-repeat top right;
  background-size: contain;
  pointer-events: none;
  z-index: 10;
  opacity: 0.9;
}

.env-header::after, .env-section::after {
  content: '';
  position: absolute;
  bottom: -25px;
  left: -25px;
  width: 140px;
  height: 140px;
  background: url('./img/pojok_kiri_bawah.webp') no-repeat bottom left;
  background-size: contain;
  pointer-events: none;
  z-index: 10;
  opacity: 0.9;
}

.env-header-text {
  font-family: var(--font-env-sans);
  font-size: 0.8rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #777;
  margin-bottom: 20px;
}

/* Ropes connecting the cards */
.env-rope {
  position: absolute;
  top: -65px;
  width: 10px;
  height: 80px;
  background: url('./img/tambang.webp') center/cover;
  z-index: 15;
}
.env-rope-left {
  left: 40px;
}
.env-rope-right {
  right: 40px;
}

/* Eyelet holes on the cards */
.env-rope::before, .env-rope::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background-color: #fcfcfc; /* Center of the hole */
  border: 1.5px solid #8c7e6b; /* The brass eyelet */
  border-radius: 50%;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.1);
  z-index: 16; /* Place ring slightly over the rope to make it look like rope goes inside */
}
.env-rope::before {
  top: 0px;
}
.env-rope::after {
  bottom: 0px;
}

.env-title {
  font-family: var(--font-env-serif);
  font-size: 3.5rem;
  line-height: 1.1;
  color: var(--env-accent);
  margin: 0 0 30px 0;
  font-weight: 400;
}

.env-amp {
  font-size: 2.5rem;
  font-style: italic;
  opacity: 0.7;
}

.env-date {
  font-family: var(--font-env-serif);
  font-size: 1.3rem;
  font-style: italic;
  color: #555;
  border-top: 1px solid var(--env-border);
  border-bottom: 1px solid var(--env-border);
  padding: 15px 0;
  display: inline-block;
  min-width: 250px;
}

.env-subtitle {
  font-family: var(--font-env-serif);
  font-size: 2.2rem;
  font-weight: 400;
  color: var(--env-accent);
  margin-bottom: 30px;
  font-style: italic;
}

.env-text {
  font-size: 1rem;
  color: #555;
  line-height: 1.8;
  max-width: 500px;
  margin: 0 auto;
}

.env-quote-icon {
  font-size: 2rem;
  color: var(--env-accent);
  opacity: 0.3;
  margin-bottom: 15px;
}

/* COUNTDOWN */
.env-countdown {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.cd-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cd-box span {
  font-family: var(--font-env-serif);
  font-size: 2rem;
  color: var(--env-accent);
  min-width: 60px;
}

.cd-box small {
  font-family: var(--font-env-sans);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #888;
}

/* EVENTS */
.env-event-card {
  border: 1px solid var(--env-border);
  padding: 30px;
  margin-bottom: 20px;
  background: rgba(255,255,255,0.5);
}

.event-title {
  font-family: var(--font-env-serif);
  font-size: 1.5rem;
  color: var(--env-accent);
  margin-bottom: 20px;
  font-style: italic;
}

.event-detail {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
  color: #555;
  font-size: 0.95rem;
  text-align: left;
}
.event-detail i {
  color: var(--env-accent);
  font-size: 1.2rem;
  margin-top: 2px;
}

.env-btn {
  display: inline-block;
  background: transparent;
  color: var(--env-accent);
  border: 1px solid var(--env-accent);
  padding: 10px 25px;
  font-family: var(--font-env-sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 15px;
}

.env-btn:hover {
  background: var(--env-accent);
  color: #fff;
}

.env-btn-sm {
  background: #eee;
  color: #333;
  border: none;
  padding: 8px 15px;
  font-size: 0.75rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s;
}
.env-btn-sm:hover { background: #ddd; }

/* SLIDER */
.env-image-box {
  margin: 40px auto 60px auto;
  border: 10px solid #fff;
  border-bottom: 30px solid #fff; /* Polaroid effect */
  background: #fff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  transform: rotate(2deg);
  max-width: 90%;
}

.slider-container {
  width: 100%;
  position: relative;
  overflow: hidden;
  padding-bottom: 120%; /* Portrait aspect ratio */
}

.slider-inner {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

.slide {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}

.slide.active { opacity: 1; }

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

/* GALLERY */
.env-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.gallery-item {
  width: 100%;
  padding-bottom: 100%;
  position: relative;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.gallery-item img {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.gallery-item:hover img {
  transform: scale(1.05);
}

/* BANK & RSVP */
.env-bank-card, .env-rsvp-card {
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--env-border);
  padding: 25px;
  margin-bottom: 15px;
}

.bank-name {
  font-family: var(--font-env-sans);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--env-accent);
}
.bank-num {
  font-family: var(--font-env-serif);
  font-size: 1.5rem;
  margin: 5px 0;
}
.bank-an {
  font-size: 0.9rem;
  color: #666;
}

.env-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
  color: #555;
}

.env-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--env-border);
  background: #fff;
  font-family: var(--font-env-sans);
  font-size: 0.9rem;
  color: #333;
}

.env-input:focus {
  outline: none;
  border-color: var(--env-accent);
}

.env-wish-item {
  border-bottom: 1px solid var(--env-border);
  padding: 15px 0;
}

.env-wish-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.env-badge {
  font-size: 0.6rem;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 10px;
}
.badge-yes { background: #e8f5e9; color: #2e7d32; }
.badge-no { background: #ffebee; color: #c62828; }

/* GLOBAL GRAYSCALE FEATURE */
html[data-tone="monochrome"] .slide img,
body[data-grayscale="1"] .slide img,
html[data-tone="monochrome"] .gallery-item img,
body[data-grayscale="1"] .gallery-item img {
    filter: grayscale(100%) contrast(110%);
}
