@import url("variables.css");
@import url("fonts.css");

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

html {
  color-scheme: light only;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-arabic-body);
  background: #2a050a;
  color: var(--text-body);
  line-height: 1.6;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }

/* ── Music toggle ── */
#music-toggle {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top, 0px));
  inset-inline-end: max(1rem, env(safe-area-inset-right, 0px));
  z-index: 900;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid rgba(223, 209, 198, 0.45);
  background: rgba(42, 5, 10, 0.35);
  backdrop-filter: blur(8px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ivory);
  transition: var(--transition-smooth);
}
#music-toggle:hover { border-color: var(--color-ivory); }
#music-toggle svg { width: 1.25rem; height: 1.25rem; }

/* ── Slideshow stage ── */
.slideshow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2a050a;
}

.slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.slide.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s ease;
  z-index: 2;
}

.slide--ivory {
  background-color: var(--color-ivory);
  background-image: url("../assets/new-assets/web/bg-ivory.webp");
  color: var(--color-olive-dark);
}

.slide--burgundy {
  background-color: #460919;
  background-image: url("../assets/new-assets/web/bg-burgundy.webp");
  color: var(--color-ivory);
}

.slide--rsvp {
  background-color: #2a050a;
  background-image: url("../assets/new-assets/web/bg-rsvp.webp");
  color: var(--color-ivory);
}

.slide-content {
  position: relative;
  z-index: 3;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 1.5rem 6.5rem;
  width: min(36rem, 100%);
  margin: 0 auto;
}
.slide-content::-webkit-scrollbar { display: none; }

/* ── Staggered line fade (keyframed so it restarts cleanly on every slide entry) ── */
.fade-line {
  opacity: 0;
}

.slide.is-active .fade-line {
  animation: fade-line-in 1.15s ease both;
  animation-delay: calc(0.45s + var(--i, 0) * 0.85s);
}

@keyframes fade-line-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Slide 1: Envelope ── */
.slide--envelope {
  background-color: #2a050a;
  cursor: pointer;
}

.envelope-stage {
  position: absolute;
  inset: 0;
  perspective: 1400px;
  overflow: hidden;
}

.envelope-inner-card {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-ivory) url("../assets/new-assets/web/bg-ivory.webp") center / cover no-repeat;
  opacity: 0;
}
.envelope-inner-card img { width: min(38vmin, 210px); height: auto; }

.env-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  will-change: transform, opacity;
}

.env-closed { z-index: 1; }
.env-flap--bottom { z-index: 2; transform-origin: 50% 100%; }
.env-flap--left { z-index: 3; transform-origin: 0 50%; }
.env-flap--right { z-index: 3; transform-origin: 100% 50%; }
.env-flap--top {
  z-index: 4;
  transform-origin: 50% 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.env-wax {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: clamp(150px, 44vmin, 320px);
  height: auto;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.45));
  pointer-events: none;
  will-change: transform, opacity;
}

/* Opening sequence (total ≈ 4.3s, slow and deliberate):
   wax breaks → top flap folds up → side flaps fold out → bottom flap drops → inner card rises */
.envelope-stage.is-opening .env-wax {
  animation: wax-break 0.85s ease-in forwards;
}
.envelope-stage.is-opening .env-closed {
  animation: closed-fade 0.6s ease 0.7s forwards;
}
.envelope-stage.is-opening .env-flap--top {
  animation: flap-top-open 1.7s cubic-bezier(0.3, 0.6, 0.3, 1) 0.65s forwards;
  filter: drop-shadow(0 16px 16px rgba(0, 0, 0, 0.35));
}
.envelope-stage.is-opening .env-flap--left {
  animation: flap-left-open 1.35s cubic-bezier(0.5, 0, 0.8, 0.4) 1.85s forwards;
}
.envelope-stage.is-opening .env-flap--right {
  animation: flap-right-open 1.35s cubic-bezier(0.5, 0, 0.8, 0.4) 1.85s forwards;
}
.envelope-stage.is-opening .env-flap--bottom {
  animation: flap-bottom-open 1.35s cubic-bezier(0.5, 0, 0.8, 0.4) 2.15s forwards;
}
.envelope-stage.is-opening .envelope-inner-card {
  animation: inner-reveal 1.5s ease 1.9s forwards;
}

@keyframes wax-break {
  0% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  40% { transform: translate(-50%, -55%) scale(1.07) rotate(-3deg); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1.12) rotate(4deg); opacity: 0; }
}

@keyframes closed-fade {
  to { opacity: 0; }
}

@keyframes flap-top-open {
  0% { transform: rotateX(0deg); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: rotateX(-180deg); opacity: 0; }
}

@keyframes flap-left-open {
  0% { transform: rotateY(0deg) translateX(0); opacity: 1; }
  100% { transform: rotateY(74deg) translateX(-10%); opacity: 0; }
}

@keyframes flap-right-open {
  0% { transform: rotateY(0deg) translateX(0); opacity: 1; }
  100% { transform: rotateY(-74deg) translateX(10%); opacity: 0; }
}

@keyframes flap-bottom-open {
  0% { transform: rotateX(0deg) translateY(0); opacity: 1; }
  100% { transform: rotateX(70deg) translateY(12%); opacity: 0; }
}

@keyframes inner-reveal {
  0% { opacity: 0; transform: scale(0.93) translateY(16px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.envelope-stage.is-opened {
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 0.8s ease, transform 0.8s ease;
  pointer-events: none;
}

.envelope-hint {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: max(4.9rem, calc(env(safe-area-inset-bottom, 0px) + 3.8rem));
  text-align: center;
  font-family: var(--font-arabic-body);
  font-size: 0.95rem;
  letter-spacing: 0;
  color: var(--color-ivory);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
  animation: pulse-hint 2s ease-in-out infinite;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.envelope-skip {
  position: absolute;
  z-index: 11;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(1.1rem, env(safe-area-inset-bottom, 0px));
  padding: 0.4rem 1rem;
  border: 1px solid rgba(223, 209, 198, 0.55);
  border-radius: 999px;
  background: rgba(42, 5, 10, 0.35);
  backdrop-filter: blur(6px);
  color: var(--color-ivory);
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.4s ease;
}

.slide--envelope.is-opening .envelope-hint,
.slide--envelope.is-opening .envelope-skip { opacity: 0; pointer-events: none; }

@keyframes pulse-hint {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ── Shared ornaments ── */
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  color: var(--color-olive);
  margin: 0.6rem 0;
}
.divider > span:first-child,
.divider > span:last-child {
  display: block;
  width: 4.2rem;
  height: 1px;
  background: color-mix(in srgb, currentColor 55%, transparent);
}
.divider .divider-star { font-size: 0.95rem; line-height: 1; }
.divider--light { color: var(--color-ivory); }

/* ── Slide 2: Wording ── */
.slide--wording .slide-content { gap: 0.45rem; }

.verse-wrap { color: var(--color-olive-dark); margin-bottom: 1.1rem; }
.verse {
  font-family: var(--font-arabic-display);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0;
  font-size: clamp(1.45rem, 5.6vw, 2.1rem);
  line-height: 2;
}
.verse-curve { width: min(17rem, 72vw); height: 1.1rem; margin: 0.35rem auto 0; }

.wording-lead {
  font-size: clamp(1rem, 3.8vw, 1.2rem);
  line-height: 1.9;
  color: var(--color-olive-dark);
  margin: 0.35rem 0;
}

.family-block { line-height: 1.5; }
.family-label { font-size: 0.95rem; opacity: 0.75; }
.family-name {
  font-family: var(--font-arabic-display);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0;
  font-size: clamp(1.5rem, 5.5vw, 2rem);
  line-height: 1.8;
  color: var(--color-olive-dark);
}
.wording-and {
  font-family: var(--font-arabic-display);
  font-size: 1.15rem;
  line-height: 1.6;
  color: color-mix(in srgb, var(--color-olive-dark) 68%, transparent);
}

.couple-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  font-family: var(--font-arabic-display);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0;
  font-size: clamp(2.1rem, 9vw, 3.2rem);
  line-height: 1.7;
  color: var(--color-olive-dark);
  margin-top: 0.4rem;
}
.couple-sep {
  display: block;
  width: 1px;
  height: 2.2rem;
  background: color-mix(in srgb, var(--color-olive) 45%, transparent);
}

/* ── Slide 3: Date & venue ── */
.slide--venue .slide-content { gap: 1rem; }

.venue-inshallah {
  font-family: var(--font-arabic-display);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0;
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  line-height: 1.9;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  text-align: start;
  min-width: min(19rem, 84vw);
}
a.info-row { transition: opacity 0.3s ease; }
a.info-row:hover { opacity: 0.82; }

.info-icon {
  flex: 0 0 auto;
  width: 2.9rem;
  height: 2.9rem;
  border: 1px solid rgba(223, 209, 198, 0.65);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.info-icon svg { width: 1.25rem; height: 1.25rem; }

.info-text { display: flex; flex-direction: column; line-height: 1.45; }
.info-label { font-size: clamp(1.05rem, 4vw, 1.3rem); }
.info-value {
  font-size: clamp(1.45rem, 5.5vw, 1.9rem);
  letter-spacing: 0.04em;
}
.info-value--venue { font-size: clamp(1.3rem, 5vw, 1.75rem); }

.map-card {
  position: relative;
  display: block;
  width: min(23rem, 88vw);
  height: 11.5rem;
  margin-top: 0.9rem;
  border-radius: 0.8rem;
  overflow: hidden;
  background: var(--color-ivory);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.venue-map {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: none;
  opacity: 0.92;
}
.map-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -88%);
  width: 2.6rem;
  color: var(--color-olive);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.3));
  pointer-events: none;
}
.map-pin svg { width: 100%; height: auto; }

/* ── Slide 4: Closing ── */
.slide--closing .slide-content { gap: 0.6rem; }
.monogram { width: min(44vw, 200px); height: auto; margin-bottom: 1.2rem; }
.closing-wait { font-size: clamp(1.05rem, 4vw, 1.3rem); color: var(--color-olive-dark); }
.couple-line--closing { margin-top: 0; }
.closing-date {
  font-size: clamp(1rem, 4vw, 1.25rem);
  letter-spacing: 0;
  color: var(--color-olive-dark);
  margin-top: 0.4rem;
}

/* ── Slide 5: RSVP ── */
.rsvp-content { width: min(27rem, 100%); justify-content: center; }
.rings { width: 4rem; color: var(--color-ivory); margin-bottom: 0.7rem; }
.rings svg { width: 100%; height: auto; }

.rsvp-title {
  font-family: var(--font-arabic-display);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0;
  font-size: clamp(1.9rem, 7vw, 2.5rem);
  line-height: 1.8;
}
.rsvp-lead { font-size: clamp(1rem, 4vw, 1.2rem); line-height: 1.9; }

.rsvp-form { width: 100%; text-align: start; margin-top: 0.6rem; }

.hp-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: 0;
}

.form-group { margin-bottom: 1.35rem; }
.form-group label,
.form-label {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.55rem;
  color: var(--color-ivory);
}

.form-input {
  width: 100%;
  padding: 0.55rem 0.15rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(223, 209, 198, 0.55);
  border-radius: 0;
  color: var(--color-ivory);
  font-size: 1.08rem;
  transition: border-color 0.3s ease;
}
.form-input::placeholder { color: rgba(223, 209, 198, 0.55); }
.form-input:focus { outline: none; border-bottom-color: var(--color-ivory); }
.form-input--number { text-align: start; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.rsvp-toggle { display: flex; gap: 0.8rem; }
.rsvp-choice { flex: 1 1 0; margin: 0; cursor: pointer; }
.rsvp-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
}
.rsvp-choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 3.2rem;
  padding: 0.65rem 0.5rem;
  border: 1px solid rgba(223, 209, 198, 0.55);
  border-radius: 0.6rem;
  color: var(--color-ivory);
  font-size: clamp(0.92rem, 3.6vw, 1.05rem);
  line-height: 1.5;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.rsvp-choice input:checked + span {
  background: var(--color-ivory);
  color: var(--color-olive-dark);
  border-color: var(--color-ivory);
}
.rsvp-choice input:focus-visible + span { outline: 2px solid var(--color-ivory); outline-offset: 3px; }

#guests-wrap { transition: opacity 0.4s ease; }
#guests-wrap.is-hidden { display: none; }

.btn-submit {
  width: 100%;
  padding: 0.95rem 1.5rem;
  margin-top: 0.4rem;
  background: var(--color-ivory);
  color: var(--color-olive-dark);
  border: 0;
  border-radius: 0.6rem;
  font-size: 1.08rem;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.btn-submit:hover { opacity: 0.88; }
.btn-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.rsvp-error, .rsvp-success {
  display: none;
  margin-top: 1.1rem;
  text-align: center;
  font-size: 1.02rem;
  line-height: 1.9;
}
.rsvp-success { font-size: 1.15rem; }
#rsvp-card.is-error .rsvp-error { display: block; }
#rsvp-card.is-sent .rsvp-form { display: none; }
#rsvp-card.is-sent .rsvp-success { display: block; }
#rsvp-card.is-sent .rsvp-error { display: none; }

/* ── Slideshow controls ── */
.slideshow-controls {
  position: fixed;
  z-index: 800;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(1.15rem, env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(42, 5, 10, 0.32);
  border: 1px solid rgba(223, 209, 198, 0.28);
  backdrop-filter: blur(8px);
}
.slideshow-controls[hidden] { display: none; }

.nav-btn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(223, 209, 198, 0.4);
  background: transparent;
  color: var(--color-ivory);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease, opacity 0.3s ease;
}
.nav-btn:hover { background: rgba(223, 209, 198, 0.16); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }
.nav-btn svg { width: 1.1rem; height: 1.1rem; }

.slideshow-dots { display: flex; align-items: center; gap: 0.55rem; }
.dot {
  width: 0.55rem;
  height: 0.55rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(223, 209, 198, 0.75);
  background: transparent;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease;
}
.dot.is-active { background: var(--color-ivory); transform: scale(1.25); }

/* ── Small screens ── */
@media (max-width: 767px) {
  .slide-content { padding: 2.6rem 1.15rem 6rem; }
  .slide--wording .slide-content { gap: 0.3rem; }
  .verse-wrap { margin-bottom: 0.7rem; }
  .map-card { height: 10rem; }
  .env-wax { width: clamp(140px, 46vmin, 260px); }
}

@media (max-height: 700px) {
  .slide-content { padding-top: 1.8rem; padding-bottom: 5.2rem; }
  .verse { font-size: clamp(1.25rem, 5vw, 1.7rem); }
  .family-name { font-size: clamp(1.3rem, 5vw, 1.7rem); }
  .couple-line { font-size: clamp(1.8rem, 8vw, 2.6rem); }
  .monogram { width: min(34vw, 150px); margin-bottom: 0.6rem; }
  .map-card { height: 8.5rem; }
  .form-group { margin-bottom: 1rem; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .slide, .envelope-stage {
    transition-duration: 0.01s !important;
    transition-delay: 0s !important;
  }
  .slide.is-active .fade-line {
    animation-duration: 0.01s !important;
    animation-delay: 0s !important;
  }
  .envelope-hint { animation: none; }
  .envelope-stage.is-opening .env-wax,
  .envelope-stage.is-opening .env-closed,
  .envelope-stage.is-opening .env-flap--top,
  .envelope-stage.is-opening .env-flap--left,
  .envelope-stage.is-opening .env-flap--right,
  .envelope-stage.is-opening .env-flap--bottom,
  .envelope-stage.is-opening .envelope-inner-card {
    animation-duration: 0.01s !important;
    animation-delay: 0s !important;
  }
}
