/* Giuliana & Jose — Save the Date */

:root {
  --ivory: #f7f1e6;
  --wall: #f5f3ef;
  --ink: #1c1a17;
  --ink-soft: #3a362f;
  --muted: #7a7368;
  --line: #1c1a17;
  --sage: #92986e;
  --shadow: 0 18px 50px rgba(40, 28, 14, 0.14), 0 2px 8px rgba(40, 28, 14, 0.06);
  --env-shadow: drop-shadow(0 22px 28px rgba(55, 50, 30, 0.22)) drop-shadow(0 6px 8px rgba(55, 50, 30, 0.12)) drop-shadow(0 1px 1px rgba(40, 40, 20, 0.18));
  --font-script: "Ballet", "Great Vibes", "Snell Roundhand", cursive;
  --font-display: "Imperial Script", "WindSong", "Snell Roundhand", cursive;
  --font-serif: "Bodoni Moda", "Didot", "Playfair Display", Georgia, serif;
  --font-text: "Cormorant Garamond", "Palatino Linotype", Palatino, serif;
  --card-width: min(92vw, 540px);
  --paper: url("assets/paper-sage.jpg");
  --ease-open: cubic-bezier(0.65, 0.05, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  min-height: 100%;
  background: var(--wall);
  color: var(--ink);
}

body {
  font-family: var(--font-text);
  font-weight: 400;
  line-height: 1.4;
  background-color: var(--wall);
  background-image:
    radial-gradient(ellipse at 50% 30%, #fbfaf7 0%, transparent 64%);
  overflow-x: hidden;
}

body:not(.is-open) {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.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;
}

/* ---------- Intro / closed envelope ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.75rem 1.25rem;
  background-color: var(--wall);
  background-image: radial-gradient(ellipse at 50% 30%, #fbfaf7 0%, transparent 64%);
  transition: opacity 0.85s var(--ease-open), visibility 0.85s var(--ease-open);
}

body.is-revealing .intro,
body.is-open .intro {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.stage {
  position: relative;
  width: min(100%, 640px);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.15rem;
}

.from-block {
  position: relative;
  z-index: 3;
  text-align: center;
  pointer-events: none;
  max-width: 94%;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.kicker {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(0.56rem, 2.1vw, 0.72rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 0.15em;
}

.from-names {
  font-family: var(--font-script);
  font-optical-sizing: auto;
  font-size: clamp(2.35rem, 9.2vw, 4.15rem);
  line-height: 1.2;
  font-weight: 400;
  padding: 0.22em 0.35em 0.28em;
  overflow: visible;
}

.click-hint {
  position: relative;
  z-index: 3;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(0.52rem, 1.9vw, 0.66rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  pointer-events: none;
  color: var(--ink);
  white-space: nowrap;
  text-align: center;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.mail {
  position: relative;
  display: block;
  width: min(78%, 420px);
  aspect-ratio: 1.48 / 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 1;
  background: none;
  transition: transform 0.45s var(--ease-open);
}

.mail:hover,
.mail:focus-visible {
  outline: none;
  transform: translateY(-3px);
}

body.is-opening .mail,
body.is-revealing .mail,
body.is-open .mail {
  transform: none;
}

.envelope {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
}

.env-back,
.env-body {
  display: block;
  position: absolute;
  inset: 0;
  background: transparent;
}

.env-back {
  z-index: 1;
}

.env-body {
  z-index: 3;
  background-image: url("assets/envelope-body.webp");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  filter: var(--env-shadow);
}

.env-cards {
  display: block;
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 0;
  top: -95%;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.emerging {
  display: block;
  position: absolute;
  left: 50%;
  bottom: 4%;
  background: var(--ivory);
  box-shadow: 0 10px 24px rgba(40, 28, 14, 0.16);
  opacity: 0;
  transform: translate(-50%, 0) scale(0.96);
  transition: transform 0.95s var(--ease-open), opacity 0.4s ease;
}

.typo-mini {
  width: 86%;
  aspect-ratio: 1.42 / 1;
  z-index: 2;
  background: var(--ivory);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink);
  border: none;
  outline: 1.5px solid var(--ink);
  outline-offset: -7px;
  padding: 0.6rem;
}

.mini-save {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  line-height: 1;
  overflow: visible;
  padding: 0;
}

.mini-save .save-s {
  font-family: var(--font-display);
  font-size: 2.15rem;
  line-height: 0.7;
  transform: translate(0, 0.08em);
  margin-right: 0.045em;
  -webkit-text-stroke: 0.35px var(--ivory);
  paint-order: fill stroke;
}

.mini-save .save-ave {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  line-height: 0.85;
  padding-bottom: 0.02em;
}

.mini-date {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.08rem;
}

.mini-names {
  font-family: var(--font-script);
  font-optical-sizing: auto;
  font-size: 1.05rem;
  line-height: 1.45;
  margin-top: 0.2rem;
  padding: 0.08em 0.25em 0.12em;
  overflow: visible;
}

.mini-names .amp {
  font-family: var(--font-display);
  font-size: 1.18em;
  padding: 0 0.06em;
  line-height: 1;
  vertical-align: -0.06em;
}

.photo-mini {
  width: 70%;
  z-index: 1;
  padding: 6px;
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: -4px;
}

.photo-mini img {
  width: 100%;
  height: auto;
  display: block;
}

body.is-opening .typo-mini,
body.is-revealing .typo-mini,
body.is-open .typo-mini {
  opacity: 1;
  background: var(--ivory);
  transform: translate(-50%, -118%) scale(1.02);
  transition: transform 0.95s 0.38s var(--ease-open), opacity 0.45s 0.38s ease;
}

body.is-opening .photo-mini,
body.is-revealing .photo-mini,
body.is-open .photo-mini {
  opacity: 1;
  background: var(--ivory);
  transform: translate(-50%, -42%) scale(1.02);
  transition: transform 1s 0.5s var(--ease-open), opacity 0.45s 0.5s ease;
}

.flap-scene {
  display: block;
  position: absolute;
  top: -1.4%;
  left: 0.55%;
  width: 98.9%;
  height: 61%;
  z-index: 5;
  pointer-events: none;
  isolation: isolate;
  perspective: 1100px;
  perspective-origin: 50% 0%;
  transform: translateZ(0);
}

.env-flap {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateX(0deg);
  transform-origin: top center;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.95s var(--ease-open);
  will-change: transform;
}

.flap-front,
.flap-back {
  display: block;
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flap-front {
  background: transparent url("assets/envelope-flap.webp") center / 100% 100% no-repeat;
  transform: translateZ(0.4px);
}

.flap-back {
  background: linear-gradient(180deg, #f4eee2 0%, #ebe3d3 100%);
  transform: rotateX(180deg) translateZ(0.4px);
  clip-path: polygon(2% 4%, 98% 4%, 50% 96%);
}

body.is-opening .env-flap,
body.is-revealing .env-flap,
body.is-open .env-flap {
  transform: rotateX(-158deg);
}

/* Hold the flap in front until it has swung past edge-on, then let cards slide over it. */
body.is-opening .flap-scene,
body.is-revealing .flap-scene,
body.is-open .flap-scene {
  animation: flap-layer 1s var(--ease-open) forwards;
}

@keyframes flap-layer {
  0%, 42% { z-index: 5; }
  43%, 100% { z-index: 1; }
}

body.is-opening .from-block,
body.is-opening .click-hint,
body.is-revealing .from-block,
body.is-revealing .click-hint,
body.is-open .from-block,
body.is-open .click-hint {
  opacity: 0;
}

body.is-opening .env-flap,
body.is-opening .emerging,
body.is-opening .intro,
body.is-revealing .letter {
  will-change: transform, opacity;
}

body.is-open .env-flap,
body.is-open .emerging,
body.is-open .intro,
body.is-open .letter {
  will-change: auto;
}

/* ---------- Opened letter ---------- */

.letter {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 2.25rem 1rem 4.5rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(22px);
  transition:
    opacity 0.85s var(--ease-open),
    transform 0.85s var(--ease-open),
    visibility 0.85s var(--ease-open);
}

body.is-open .letter {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.card {
  width: var(--card-width);
  margin: 0 auto;
  background: var(--ivory);
  position: relative;
  box-shadow: var(--shadow);
}

.card::after {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1px solid var(--line);
  pointer-events: none;
  z-index: 2;
}

.typo-card {
  aspect-ratio: 1.42 / 1;
  display: flex;
  padding: clamp(1.15rem, 4.2vw, 1.7rem);
  color: var(--ink);
}

.typo-card::after {
  border: 1.5px solid var(--ink);
}

.typo-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  padding: 0.15rem 0.35rem 0.35rem;
  overflow: visible;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 1rem;
}

.date-corner {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 400;
  font-size: clamp(1.05rem, 3vw, 1.32rem);
  letter-spacing: 0.04em;
  padding-top: 0.08rem;
  line-height: 1;
  flex: 0 0 auto;
}

.follow-corner {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(0.55rem, 1.7vw, 0.7rem);
  text-align: right;
  line-height: 1.2;
  letter-spacing: 0.01em;
  padding: 0.22em 0 0;
  overflow: visible;
  white-space: nowrap;
  flex: 0 0 auto;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 0.2rem;
}

.save {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  line-height: 1;
  overflow: visible;
  padding: 0.1em 0.15em 0;
  color: var(--ink);
}

.save-s {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(4.4rem, 17.6vw, 6.7rem);
  line-height: 0.62;
  transform: translate(0, 0.08em);
  padding: 0;
  margin-right: 0.045em;
  -webkit-text-stroke: 0.35px var(--ivory);
  paint-order: fill stroke;
}

.save-ave {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.2rem, 9.2vw, 3.65rem);
  letter-spacing: 0.1em;
  line-height: 0.85;
  padding: 0 0 0.02em;
}

.the-date {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.25rem, 9.4vw, 3.8rem);
  letter-spacing: 0.1em;
  line-height: 0.95;
  text-transform: uppercase;
  white-space: nowrap;
  margin-top: 0.06em;
  display: block;
  color: var(--ink);
}

.place {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(0.55rem, 1.7vw, 0.68rem);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  margin-top: 1.05em;
  color: var(--ink);
}

.names {
  font-family: var(--font-script);
  font-optical-sizing: auto;
  font-size: clamp(1.85rem, 6vw, 2.55rem);
  line-height: 1.5;
  margin-top: 0.15em;
  font-weight: 400;
  overflow: visible;
  padding: 0.12em 0.45em 0.22em;
  color: var(--ink);
}

.names .amp {
  font-family: var(--font-display);
  font-size: 1.2em;
  padding: 0 0.08em;
  line-height: 1;
  vertical-align: -0.08em;
}

.photo-card {
  margin-top: 2rem;
}

.photo-card figure {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 18px;
}

.photo-card img {
  width: 100%;
  height: auto;
  object-fit: cover;
  filter: contrast(1.02);
}

/* ---------- Details ---------- */

.details {
  width: var(--card-width);
  margin: 2.75rem auto 0;
  text-align: center;
  padding: 0 0.5rem;
}

.when {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(0.68rem, 2vw, 0.78rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

.when-date {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.45rem, 5.2vw, 2rem);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.rule {
  display: block;
  width: 42px;
  height: 1px;
  background: var(--ink);
  margin: 1.35rem auto;
  opacity: 0.7;
}

.venue-name {
  font-family: var(--font-text);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.45rem, 4.6vw, 1.85rem);
  line-height: 1.2;
}

.venue-coll {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(0.62rem, 1.9vw, 0.72rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-top: 0.45rem;
  color: var(--ink-soft);
}

.venue-place {
  font-family: var(--font-text);
  font-size: clamp(1.05rem, 3.2vw, 1.2rem);
  margin-top: 0.85rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- Countdown (ref 2, lower section) ---------- */

.countdown-block {
  width: var(--card-width);
  margin: 2.75rem auto 0;
  text-align: center;
  padding: 0 0.4rem;
}

.countdown-kicker {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(0.68rem, 2vw, 0.8rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
}

.countdown {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: start;
  justify-items: center;
  column-gap: 0.05em;
  max-width: 26rem;
  margin: 0 auto;
}

.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
}

.unit strong {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.85rem, 7.2vw, 2.85rem);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.unit span {
  font-family: var(--font-serif);
  font-size: 0.52rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
}

.colon {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.85rem, 7.2vw, 2.85rem);
  line-height: 1;
  padding: 0 0.1em;
  line-height: 1;
  transform: translateY(-0.02em);
}

.follow {
  font-family: var(--font-script);
  font-optical-sizing: auto;
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  margin-top: 1.5rem;
  line-height: 1.35;
  padding: 0.15em 0.4em 0.25em;
  overflow: visible;
}

@media (min-width: 720px) {
  .letter {
    padding-top: 3.5rem;
    padding-bottom: 5.5rem;
  }

  .card::after {
    inset: 14px;
  }

  .photo-card {
    margin-top: 2.5rem;
  }

  .photo-card figure {
    padding: 22px;
  }

  .details {
    margin-top: 3.25rem;
  }

  .countdown-block {
    margin-top: 3.25rem;
  }

  .mail {
    width: min(58%, 440px);
  }

  body.is-opening .typo-mini,
  body.is-revealing .typo-mini,
  body.is-open .typo-mini {
    transform: translate(-50%, -118%) scale(1.02);
  }

  body.is-opening .photo-mini,
  body.is-revealing .photo-mini,
  body.is-open .photo-mini {
    transform: translate(-50%, -42%) scale(1.02);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mail,
  .env-flap,
  .emerging,
  .from-block,
  .click-hint,
  .intro,
  .letter {
    transition: none !important;
    animation: none !important;
  }

  body.is-revealing .letter,
  body.is-open .letter {
    transition: none !important;
    transform: none;
    opacity: 1;
    visibility: visible;
  }
}

@media print {
  .intro {
    display: none !important;
  }

  body,
  body:not(.is-open) {
    overflow: visible;
    height: auto;
    background: white;
  }

  .letter {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    padding: 0;
  }
}
