@font-face {
  font-family: "Cormorant Garamond";
  src: url("assets/fonts/cormorant-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("assets/fonts/cormorant-italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("assets/fonts/montserrat-medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

:root {
  --forest: #102019;
  --forest-soft: #294338;
  --ivory: #f7f0e4;
  --paper: #ede2d0;
  --ink: #29372f;
  --gold: #c8a96c;
  --gold-deep: #98763f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--forest);
  color: var(--ivory);
  font-family: "Cormorant Garamond", Georgia, serif;
  overflow: hidden;
  place-items: center;
}

button {
  font: inherit;
}

.ambient {
  position: fixed;
  inset: -35px;
  background:
    linear-gradient(rgba(7, 16, 12, .68), rgba(7, 16, 12, .78)),
    url("assets/villa-emo-selvatico.webp") center / cover;
  filter: blur(18px);
  transform: scale(1.08);
}

.app {
  position: relative;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100svh;
  isolation: isolate;
  overflow: hidden;
  background: var(--forest);
  box-shadow: 0 0 70px rgba(0, 0, 0, .38);
}

.landing,
.opening {
  position: absolute;
  inset: 0;
  min-height: 100vh;
  min-height: 100svh;
}

.landing {
  z-index: 1;
  overflow: hidden;
}

.landing__photo,
.landing__overlay,
.landing__frame {
  position: absolute;
  inset: 0;
}

.landing__photo {
  background: url("assets/villa-emo-selvatico.webp") calc(52% + 5px) 48% / cover no-repeat;
  transform: scale(1.04);
  animation: photo-breathe 18s ease-in-out infinite alternate;
}

.landing__overlay {
  background:
    linear-gradient(180deg, rgba(5, 14, 10, .22) 0%, rgba(5, 14, 10, .12) 26%, rgba(5, 14, 10, .62) 72%, rgba(5, 14, 10, .9) 100%),
    radial-gradient(circle at 50% 38%, transparent 0 28%, rgba(4, 12, 8, .33) 92%);
}

.landing__frame {
  inset: max(15px, env(safe-area-inset-top)) 15px max(15px, env(safe-area-inset-bottom));
  border: 1px solid rgba(247, 240, 228, .28);
  pointer-events: none;
}

.landing__content {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
  padding:
    calc(max(26px, env(safe-area-inset-top)) + 2.5vh)
    24px
    calc(max(22px, env(safe-area-inset-bottom)) + 2.4vh);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-shadow: 0 2px 26px rgba(0, 0, 0, .38);
}

.monogram {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: clamp(1.8rem, 5.4vh, 3.6rem);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  place-items: center;
  color: var(--ivory);
  background:
    radial-gradient(circle at 34% 29%, rgba(255,255,255,.25), transparent 20%),
    linear-gradient(145deg, #355448, #10241b);
  box-shadow: 0 7px 18px rgba(0,0,0,.28), inset 0 0 0 4px rgba(0,0,0,.13);
  transform: translateY(-35px);
}

.monogram::before {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(200, 169, 108, .68);
  border-radius: 50%;
  content: "";
}

.monogram span {
  position: relative;
  z-index: 1;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: .72rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: .1em;
  line-height: 1;
  text-indent: .1em;
}

.landing h1 {
  margin: 0;
  font-size: clamp(3.85rem, 17vw, 5.55rem);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .77;
}

/* Il titolo riceve il focus solo dopo l'apertura per orientare i lettori di
   schermo: non è un controllo interattivo e non deve mostrare una cornice. */
.landing h1:focus {
  outline: none;
}

.landing h1 span,
.landing h1 em {
  display: block;
}

.landing h1 em {
  margin: .13em 0 .08em;
  color: #e2c78f;
  font-size: .42em;
  font-weight: 400;
}

.details {
  display: flex;
  margin-top: clamp(2.2rem, 6vh, 4rem);
  flex-direction: column;
  align-items: center;
}

.details__label {
  margin: 0 0 .58rem;
  color: rgba(247, 240, 228, .86);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(.62rem, 2.4vw, .72rem);
  font-weight: 500;
  letter-spacing: .28em;
  text-indent: .28em;
}

.details__date {
  margin: 0;
  color: #f1ddb5;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(.74rem, 3vw, .88rem);
  font-weight: 500;
  letter-spacing: .33em;
  text-indent: .33em;
}

.details > span {
  width: 44px;
  height: 1px;
  margin: 1rem 0 .85rem;
  background: rgba(200, 169, 108, .82);
}

.details__place {
  margin: 0;
  color: #fff7e9;
  font-size: clamp(1.48rem, 6.3vw, 1.95rem);
  font-style: italic;
  letter-spacing: .055em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .72), 0 0 22px rgba(200, 169, 108, .18);
}

.countdown {
  display: grid;
  width: 82%;
  max-width: 315px;
  margin-top: clamp(2.2rem, 7vh, 4.5rem);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.countdown__unit {
  display: flex;
  min-width: 0;
  padding: .56rem .12rem .48rem;
  border: 1px solid rgba(247, 240, 228, .23);
  background: rgba(10, 27, 20, .34);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-direction: column;
  align-items: center;
}

.countdown__unit strong {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.48rem, 6.1vw, 1.88rem);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  line-height: 1;
}

.countdown__unit small {
  margin-top: .38rem;
  color: rgba(247, 240, 228, .72);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(.46rem, 1.75vw, .55rem);
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.js .landing__content {
  opacity: 0;
  transform: translateY(22px) scale(.985);
}

.is-revealed .landing__content {
  animation: reveal-content 1.5s .28s cubic-bezier(.2, .74, .2, 1) forwards;
}

.opening {
  z-index: 5;
  display: grid;
  overflow: hidden;
  background: var(--ivory);
  perspective: 1400px;
  place-items: center;
  transition: opacity 1s .15s ease, visibility 0s 1.2s;
}

.opening__paper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 9%, rgba(255,255,255,.92), transparent 34%),
    radial-gradient(circle at 84% 88%, rgba(159,121,65,.09), transparent 36%),
    repeating-linear-gradient(8deg, transparent 0 5px, rgba(71,52,25,.017) 6px 7px),
    var(--ivory);
}

.opening__paper::after {
  position: absolute;
  inset: 15px;
  border: 1px solid rgba(152, 118, 63, .26);
  content: "";
}

.opening__corner {
  position: absolute;
  z-index: 1;
  width: 44px;
  height: 44px;
  pointer-events: none;
}

.opening__corner--top {
  top: 27px;
  right: 27px;
  border-top: 1px solid rgba(152, 118, 63, .54);
  border-right: 1px solid rgba(152, 118, 63, .54);
}

.opening__corner--bottom {
  bottom: 27px;
  left: 27px;
  border-bottom: 1px solid rgba(152, 118, 63, .54);
  border-left: 1px solid rgba(152, 118, 63, .54);
}

.envelope {
  position: relative;
  z-index: 3;
  width: min(86vw, 430px);
  height: min(57vw, 286px);
  max-height: 286px;
  min-height: 208px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.envelope:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 16px;
}

.envelope__body {
  position: absolute;
  inset: 0;
  display: block;
  filter: drop-shadow(0 24px 25px rgba(73, 51, 23, .22));
  transform-style: preserve-3d;
  transition: transform 1.75s cubic-bezier(.2,.72,.2,1);
}

.envelope__back,
.envelope__front,
.envelope__flap {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(120, 88, 42, .14);
}

.envelope__back {
  z-index: 1;
  border-radius: 2px;
  background:
    repeating-linear-gradient(8deg, transparent 0 5px, rgba(71,52,25,.019) 6px 7px),
    #e8dbc4;
}

.envelope__card {
  position: absolute;
  z-index: 2;
  top: 7%;
  right: 6%;
  bottom: 6%;
  left: 6%;
  display: flex;
  border: 1px solid rgba(152, 118, 63, .42);
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 9%, rgba(255,255,255,.8), transparent 34%),
    #f9f3e9;
  box-shadow: 0 7px 20px rgba(73, 51, 23, .15);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translateY(12%);
  transition: transform 3.75s 2.2s cubic-bezier(.16,.8,.2,1), box-shadow 3.5s 2.2s ease;
}

.envelope__card strong {
  font-size: clamp(1.35rem, 6.4vw, 2.25rem);
  font-weight: 400;
}

.envelope__card strong em {
  color: var(--gold-deep);
  font-weight: 400;
}

.envelope__card-line {
  color: var(--gold-deep);
  font-size: clamp(.78rem, 3.2vw, 1rem);
  font-style: italic;
  letter-spacing: .035em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .85s 2.8s ease, transform .85s 2.8s ease;
}

.envelope__card-intro {
  margin-bottom: .45rem;
}

.envelope__card-outro {
  margin-top: .45rem;
}


.envelope__front {
  z-index: 3;
  border-radius: 2px;
  background:
    linear-gradient(148deg, transparent 49.6%, rgba(255,255,255,.17) 50%),
    linear-gradient(32deg, #decdb1 49.6%, #eadfcb 50%);
  clip-path: polygon(0 39%, 50% 74%, 100% 39%, 100% 100%, 0 100%);
}

.envelope__flap {
  z-index: 4;
  height: 63%;
  border-radius: 2px 2px 0 0;
  background:
    radial-gradient(circle at 50% 0, rgba(255,255,255,.65), transparent 52%),
    linear-gradient(158deg, #f1e7d5, #d7c3a3);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform 1.9s .75s cubic-bezier(.34,.02,.18,1), z-index 0s 2.2s;
}

.envelope__seal {
  position: absolute;
  z-index: 5;
  top: 58%;
  left: 50%;
  display: grid;
  width: 72px;
  height: 72px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  place-items: center;
  color: var(--ivory);
  background:
    radial-gradient(circle at 34% 29%, rgba(255,255,255,.25), transparent 20%),
    linear-gradient(145deg, #355448, #10241b);
  box-shadow: 0 7px 18px rgba(44,31,16,.34), inset 0 0 0 5px rgba(0,0,0,.13);
  transform: translate3d(-50%, -50%, 0) rotate(0deg);
  transition: opacity .34s .42s ease, transform .62s ease, box-shadow .55s ease;
}

.envelope__seal::before {
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(200, 169, 108, .68);
  border-radius: 50%;
  content: "";
}

.envelope__seal span {
  position: relative;
  z-index: 1;
  display: block;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: .88rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: .1em;
  line-height: 1;
  text-indent: .1em;
  transform: rotate(0deg);
  writing-mode: horizontal-tb;
}

.envelope__prompt {
  position: absolute;
  top: calc(100% + 1.8rem);
  left: 50%;
  color: #725f42;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(.62rem, 2.5vw, .72rem);
  font-weight: 500;
  letter-spacing: .22em;
  text-indent: .22em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
  animation: prompt-pulse 2.2s ease-in-out infinite;
  transition: opacity .3s ease;
}

.is-opening .envelope {
  pointer-events: none;
}

.is-opening .envelope__prompt {
  opacity: 0;
}

.is-opening .envelope__seal {
  opacity: 0;
  box-shadow: 0 0 38px 16px rgba(200, 169, 108, .46);
  transform: translate3d(-50%, -50%, 0) scale(1.28) rotate(0deg);
}

.is-opening .envelope__flap {
  z-index: 0;
  transform: rotateX(180deg);
}

.is-opening .envelope__card {
  z-index: 2;
  box-shadow: 0 27px 42px rgba(73, 51, 23, .25);
  transform: translateY(-45%);
}

.is-opening .envelope__card-line {
  opacity: 1;
  transform: translateY(0);
}

.is-opening .envelope__body {
  transform: translateY(5%) scale(1.025);
}

.is-revealed .opening {
  opacity: 0;
  visibility: hidden;
}

@keyframes prompt-pulse {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

@keyframes photo-breathe {
  to { transform: scale(1.095); }
}

@keyframes reveal-content {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-height: 700px) {
  .monogram {
    width: 48px;
    height: 48px;
    margin-bottom: 1.45rem;
    transform: translateY(-24px);
  }

  .landing h1 {
    font-size: clamp(3.45rem, 15vw, 4.8rem);
  }

  .details {
    margin-top: 1.55rem;
  }

  .countdown {
    margin-top: 1.6rem;
  }

  .countdown__unit {
    padding: .54rem .12rem .46rem;
  }
}

@media (min-width: 521px) {
  .app {
    max-height: 980px;
  }

  .landing,
  .opening,
  .landing__content {
    max-height: 980px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
  }
}
