:root {
  --burgundy: #4b0713;
  --burgundy-deep: #260208;
  --olive: #4c5829;
  --gold: #d0ab70;
  --gold-pale: #eed6aa;
  --ivory: #f7f1e7;
  --ink: #321811;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--burgundy-deep); }
body { color: var(--ivory); font-family: "Montserrat", sans-serif; overflow: hidden; }
button { font: inherit; }

.splash,
.invitation {
  position: fixed;
  inset: 0;
  min-height: 100svh;
}

.splash {
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--burgundy-deep);
  transition: opacity .85s ease, visibility .85s;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.password-gate {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(31, 1, 7, .58);
  backdrop-filter: blur(8px);
  transition: opacity .65s ease, visibility .65s ease;
}

.password-card {
  width: min(92vw, 480px);
  padding: clamp(1.7rem, 5vw, 3rem);
  text-align: center;
  border: 1px solid rgba(201, 164, 106, .65);
  background: linear-gradient(145deg, rgba(82, 8, 22, .97), rgba(39, 3, 9, .98));
  box-shadow: 0 32px 90px rgba(13, 0, 3, .62), inset 0 0 0 8px rgba(201, 164, 106, .06);
}

.gate-crest {
  width: 104px;
  height: 104px;
  margin-bottom: 1rem;
  border: 2px solid var(--gold);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 28px rgba(13, 0, 3, .38);
}

.gate-kicker {
  margin: 0 0 .55rem;
  color: var(--gold-pale);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .25em;
  text-transform: uppercase;
}

.password-card h2 {
  color: var(--ivory);
  font-size: clamp(2.4rem, 9vw, 4rem);
  line-height: 1;
}
.password-card h2 span { color: var(--gold); font-style: italic; }
.gate-instruction { margin: 1rem 0 1.4rem; color: rgba(247, 241, 231, .78); font-size: .9rem; }

.password-entry { display: grid; grid-template-columns: 1fr auto; }
.password-entry input,
.password-entry button {
  min-height: 52px;
  border-radius: 0;
}
.password-entry input {
  min-width: 0;
  padding: 0 1rem;
  border: 1px solid rgba(201, 164, 106, .55);
  border-right: 0;
  outline: 0;
  color: var(--ivory);
  background: rgba(20, 1, 5, .32);
  font-size: 1rem;
  letter-spacing: .18em;
}
.password-entry input::placeholder { color: rgba(247, 241, 231, .52); letter-spacing: .06em; }
.password-entry input:focus { border-color: var(--gold-pale); box-shadow: inset 0 0 0 1px var(--gold-pale); }
.password-entry button {
  padding: 0 1.25rem;
  border: 1px solid var(--gold);
  color: var(--burgundy-deep);
  background: var(--gold);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .25s ease, background .25s ease;
}
.password-entry button:hover,
.password-entry button:focus-visible { color: var(--ivory); background: transparent; outline: 0; }
.password-error { min-height: 1.25rem; margin: .75rem 0 0; color: #f1b6b9; font-size: .8rem; }
.password-card.is-wrong { animation: gateShake .38s ease; }
.password-gate.is-unlocked { opacity: 0; visibility: hidden; pointer-events: none; }
.eyebrow {
  margin: 0 0 .35rem;
  color: var(--gold-pale);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .26em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 400;
  line-height: .95;
}
h1 { font-size: clamp(2.6rem, 7vw, 5.2rem); }

.envelope-button {
  z-index: 3;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  perspective: 1200px;
  -webkit-tap-highlight-color: transparent;
}

.photo-frame {
  position: relative;
  display: block;
  width: min(100vw, calc(100svh * 1.5));
  height: min(100svh, calc(100vw / 1.5));
  aspect-ratio: 3 / 2;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: var(--burgundy-deep);
  box-shadow: none;
  transform: scale(1.001);
  transition: transform .7s cubic-bezier(.2,.8,.2,1), box-shadow .7s ease;
}

.envelope-button:hover .photo-frame,
.envelope-button:focus-visible .photo-frame {
  transform: scale(1.008);
  box-shadow: none;
}
.envelope-button:focus-visible { outline: 2px solid var(--gold-pale); outline-offset: -8px; }

.envelope-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transition: opacity .75s ease, transform 1.1s cubic-bezier(.2,.7,.2,1);
}
.envelope-closed { opacity: 1; }
.envelope-open { opacity: 0; transform: scale(.985); }

.seal {
  position: absolute;
  left: 50%;
  top: 52.5%;
  display: grid;
  place-items: center;
  width: clamp(74px, 9vw, 138px);
  aspect-ratio: 1;
  overflow: hidden;
  
  border-radius: 50%;
  background: #6a0d1a;
  box-shadow: 0 12px 26px rgba(22, 8, 0, .5), inset 0 0 0 2px rgba(255,255,255,.35), 0 0 0 3px #9b733e;
  transform: translate(-50%, -50%);
  transition: transform .45s cubic-bezier(.3,1.5,.5,1), opacity .42s ease, filter .4s ease;
}
.seal img { width: 100%; height: 100%; object-fit: cover; }
.envelope-button:hover .seal { transform: translate(-50%, -50%) scale(1.07) rotate(2deg); filter: brightness(1.07); }

.light-sweep {
  position: absolute;
  inset: -30%;
  background: linear-gradient(105deg, transparent 42%, rgba(255,255,255,.22) 49%, transparent 56%);
  transform: translateX(-80%);
  animation: sheen 5s 1.2s ease-in-out infinite;
  pointer-events: none;
}

.invitation {
  z-index: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 2rem 1.25rem;
  opacity: 0;
  visibility: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(248,243,234,.94), rgba(248,243,234,.94)),
    url("envelope-open.png") center/cover fixed;
  transition: opacity 1s ease, visibility 1s;
}

.invitation::before,
.invitation::after {
  content: "";
  position: fixed;
  width: min(34vw, 420px);
  aspect-ratio: 1;
  border: 1px solid rgba(92, 103, 53, .23);
  border-radius: 50%;
}
.invitation::before { left: -12vw; top: -18vw; }
.invitation::after { right: -12vw; bottom: -18vw; }

.invitation-inner {
  position: relative;
  width: min(100%, 700px);
  padding: clamp(2rem, 7vw, 5.5rem);
  text-align: center;
  border: 1px solid rgba(152, 112, 54, .45);
  background: rgba(255, 252, 246, .72);
  box-shadow: 0 25px 90px rgba(60, 39, 19, .14);
}
.invitation-inner::before { content: ""; position: absolute; inset: 9px; border: 1px solid rgba(152,112,54,.22); pointer-events: none; }
.crest { width: clamp(100px, 18vw, 155px); height: auto; margin-bottom: 1.25rem; border-radius: 50%; }
.invitation .eyebrow { color: var(--olive); }
h2 { color: var(--burgundy); font-size: clamp(3.8rem, 10vw, 7.5rem); }
.ampersand { color: var(--gold); font-style: italic; }
.rule { display: flex; align-items: center; gap: .7rem; width: min(70%, 300px); margin: 1.8rem auto; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--gold); }
.rule span { width: 7px; aspect-ratio: 1; border: 1px solid var(--gold); transform: rotate(45deg); }
.invitation-copy { max-width: 34rem; margin: 0 auto 1.25rem; font: italic 400 clamp(1.25rem, 3vw, 1.75rem)/1.5 "Cormorant Garamond", serif; }
.placeholder { margin: 0; color: #69713f; font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; }
.replay { margin-top: 2rem; padding: .8rem 1.1rem; border: 0; border-bottom: 1px solid var(--gold); color: var(--burgundy); background: transparent; cursor: pointer; }
.replay:focus-visible { outline: 2px solid var(--olive); outline-offset: 4px; }

body.opening .seal { opacity: 0; transform: translate(-50%, 30%) rotate(18deg) scale(.7); }
body.opening .envelope-closed { opacity: 0; transform: scale(1.04); }
body.opening .envelope-open { opacity: 1; transform: scale(1.02); }
body.opening .photo-frame { animation: openLift 2.05s cubic-bezier(.22,.72,.2,1) both; }
body.revealed .splash { opacity: 0; visibility: hidden; }
body.revealed .invitation { opacity: 1; visibility: visible; }
body.revealed .invitation-inner { animation: cardArrive 1.05s .15s cubic-bezier(.2,.8,.2,1) both; }

@keyframes arrive { from { opacity: 0; transform: translateY(-12px); } }
@keyframes sheen { 0%, 58% { transform: translateX(-80%); } 82%, 100% { transform: translateX(80%); } }
@keyframes openLift { 0% { transform: scale(1.001); } 45% { transform: scale(1.018); } 100% { transform: scale(1.055); } }
@keyframes cardArrive { from { opacity: 0; transform: translateY(28px) scale(.985); } }
@keyframes gateShake { 25% { transform: translateX(-8px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }

@media (max-width: 680px) {
  .seal { top: 52.5%; width: clamp(72px, 18vw, 106px); }
  .password-entry { grid-template-columns: 1fr; gap: .65rem; }
  .password-entry input { border-right: 1px solid rgba(201, 164, 106, .55); text-align: center; }
  .invitation-inner { padding: 2.5rem 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .splash, .invitation, .envelope-photo, .seal { transition-duration: .01ms !important; }
}


/* Responsive envelope composition: keep the complete artwork and flowers visible. */
@media (max-aspect-ratio: 3/2) {
  .photo-frame {
    width: 100vw;
    height: calc(100vw / 1.5);
    max-height: 100svh;
  }
}

@media (min-aspect-ratio: 3/2) {
  .photo-frame {
    width: calc(100svh * 1.5);
    max-width: 100vw;
    height: 100svh;
  }
}

@media (max-width: 680px) {
  .splash {
    padding: max(10px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .photo-frame {
    width: min(100%, 100vw);
    height: auto;
    aspect-ratio: 3 / 2;
  }

  .envelope-photo {
    object-fit: contain;
  }

  .seal {
    top: 52.5%;
    width: clamp(58px, 16vw, 90px);
  }
}

@media (max-width: 430px) and (orientation: portrait) {
  .photo-frame {
    width: 100vw;
    height: auto;
    max-height: calc(100svh - 20px);
  }
}
