/* Bleron & Mirlinda — filmed open → freeze last frame → text ON the photo card */

:root {
  --page: #f2edec;
  --ink: #1c1917;
  --ink-soft: rgba(28, 25, 23, 0.78);
  --muted: #6b6560;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --font-script: "Cormorant Infant", "Cormorant Garamond", Georgia, serif;
  --handoff-dur: 0.55s;
  --crossfade-dur: 0.78s;
  /* Card rect in open-last.jpg (fractions of image) — JS may override via CSS vars */
  --card-x1: 0.1986;
  --card-y1: 0.1258;
  --card-x2: 0.8097;
  --card-y2: 0.8016;
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overflow-x: clip;
  height: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
  overflow-x: clip;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 1rem;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 3px;
}

.lang-link {
  position: fixed;
  top: max(0.55rem, env(safe-area-inset-top));
  left: max(0.7rem, env(safe-area-inset-left));
  z-index: 60;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.55rem 0.4rem;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  opacity: 0.72;
  text-decoration: underline;
  text-underline-offset: 0.28em;
  mix-blend-mode: multiply;
}
.lang-link:hover { opacity: 1; color: var(--ink); }

.scene[hidden] { display: none !important; }

/* ——— Envelope / video ——— */
.scene-envelope {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100svw;
  max-width: 100%;
  height: 100svh;
  margin: 0;
  padding: 0;
  background: var(--page);
  overflow: hidden;
  transition: opacity var(--handoff-dur) var(--ease), visibility var(--handoff-dur);
}
.scene-envelope.is-open {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.env-bleed {
  position: absolute;
  inset: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.env-img {
  position: absolute;
  inset: 0;
  margin: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.env-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  user-select: none;
  pointer-events: none;
}
.env-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  opacity: 0;
  pointer-events: none;
  background: transparent;
  z-index: 2;
  transition: opacity var(--crossfade-dur) cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity;
}
.env-video.is-playing { opacity: 1; }
.env-video.is-playing.is-fading-out { opacity: 0; }
.env-poster { z-index: 1; }
.scene-envelope.is-video-open .env-poster { opacity: 0; transition: opacity 0.3s var(--ease); }
/* During soft handoff: let freeze scene show through as video eases out */
.scene-envelope.is-crossfading {
  background: transparent;
  pointer-events: none;
}
.scene-envelope.is-crossfading .env-poster,
.scene-envelope.is-crossfading .seal-hit,
.scene-envelope.is-crossfading .env-hint {
  opacity: 0 !important;
  visibility: hidden;
}

.seal-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(18vmin, 5.5rem);
  height: min(18vmin, 5.5rem);
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.seal-half {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.seal-hit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(18vmin, 5.5rem);
  height: min(18vmin, 5.5rem);
  transform: translate(-50%, -50%);
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  z-index: 5;
}
.seal-pulse {
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.55), transparent 62%);
  opacity: 0.4;
}
.env-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(1.6rem, calc(env(safe-area-inset-bottom) + 1rem));
  z-index: 6;
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  color: var(--muted);
  opacity: 0.78;
  pointer-events: none;
  transition: opacity 0.35s var(--ease);
}
.env-hint.is-out { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .seal-hit { animation: seal-soft 2.8s ease-in-out infinite; }
  .seal-pulse { animation: seal-glow 2.8s ease-in-out infinite; }
  .scene-envelope.is-opening .seal-hit,
  .scene-envelope.is-video-open .seal-hit {
    animation: none;
    opacity: 0;
    pointer-events: none;
  }
  .scene-envelope.use-css-fallback.is-opening .seal-layer { opacity: 1; }
  .scene-envelope.use-css-fallback.is-opening .seal-left {
    animation: seal-crack-l 0.9s var(--ease) forwards;
  }
  .scene-envelope.use-css-fallback.is-opening .seal-right {
    animation: seal-crack-r 0.9s var(--ease) forwards;
  }
  .scene-envelope.use-css-fallback.is-opening .env-closed {
    animation: env-fade-out 1.1s 0.2s var(--ease) forwards;
  }
  .scene-envelope.use-css-fallback.is-opening .env-open {
    animation: env-fade-in 1.15s 0.18s var(--ease) forwards;
  }
}

@keyframes seal-soft {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.04); }
}
@keyframes seal-glow {
  0%, 100% { opacity: 0.22; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(1.1); }
}
@keyframes seal-crack-l {
  0% { transform: translate(0,0) rotate(0); opacity: 1; }
  100% { transform: translate(-70%, -32%) rotate(-22deg); opacity: 0; }
}
@keyframes seal-crack-r {
  0% { transform: translate(0,0) rotate(0); opacity: 1; }
  100% { transform: translate(72%, -28%) rotate(20deg); opacity: 0; }
}
@keyframes env-fade-out { to { opacity: 0; } }
@keyframes env-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ——— Freeze still + on-card text ——— */
.scene-invite {
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  max-width: 100%;
  height: 100svh;
  overflow: hidden;
  background: var(--page);
}
.scene-invite .freeze-still {
  opacity: 1;
}
@media (prefers-reduced-motion: no-preference) {
  .scene-invite.is-soft-in .freeze-still {
    animation: freeze-soft-in 0.5s var(--ease) both;
  }
}
@keyframes freeze-soft-in {
  from { opacity: 0.92; }
  to { opacity: 1; }
}
.freeze-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.freeze-still {
  position: absolute;
  inset: 0;
  margin: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.freeze-still img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  user-select: none;
  pointer-events: none;
}

/* Text container — JS sets left/top/width/height from cover-mapped card rect */
.oncard {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* padding as % of card box — set via JS too for consistency */
  padding: 6% 8%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  pointer-events: none;
  /* start invisible until positioned + revealed */
  opacity: 0;
}
.scene-invite.is-ready .oncard {
  opacity: 1;
  pointer-events: auto;
}

.oncard > * {
  position: relative;
  max-width: 100%;
  flex-shrink: 1;
  min-height: 0;
}
/* Visible by default if JS fails; hide only under js-ready until .is-in */
.oncard > * {
  opacity: 1;
  transform: none;
}
html.js-ready .oncard > * {
  opacity: 0;
  transform: translate3d(0, 6px, 0);
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease);
}
html.js-ready .oncard > *.is-in,
html.js-ready.scene-text-forced .oncard > *,
html.js-ready .scene-invite.text-forced .oncard > * {
  opacity: 1 !important;
  transform: translate3d(0, 0, 0) !important;
}

.eyebrow {
  margin: 0 0 0.15em;
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(0.72rem, 2.6vw, 0.95rem);
  color: var(--muted);
  line-height: 1.25;
}
.invite-line {
  margin: 0 0 0.45em;
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(0.68rem, 2.4vw, 0.88rem);
  color: var(--ink-soft);
  line-height: 1.3;
}
.names {
  margin: 0 0 0.3em;
  font-weight: 600;
  font-size: clamp(1.35rem, 5.6vw, 2.05rem);
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-shadow:
    0 0.5px 0 rgba(255,255,255,0.4),
    0 -0.35px 0.35px rgba(0,0,0,0.12);
}
.names .amp {
  display: inline-block;
  margin: 0 0.12em;
  font-style: italic;
  font-weight: 500;
  opacity: 0.75;
}
.date-line {
  margin: 0 0 0.2em;
  font-size: clamp(0.82rem, 3vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.25;
}
.meta-line {
  margin: 0 0 0.45em;
  font-size: clamp(0.72rem, 2.5vw, 0.92rem);
  color: var(--ink-soft);
  line-height: 1.3;
}
.meta-line strong {
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.meta-line .dot { margin: 0 0.2em; opacity: 0.55; }
.maps-link {
  color: inherit;
  font-style: italic;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.4px;
  pointer-events: auto;
}
.countdown {
  margin: 0 0 0.35em;
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(0.72rem, 2.5vw, 0.9rem);
  color: var(--muted);
  line-height: 1.3;
}
.text-link {
  display: block;
  width: 100%;
  margin: 0.02rem 0;
  padding: 0.28rem 0.1rem;
  min-height: 36px;
  color: var(--ink-soft) !important;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 0.4px;
  font-size: clamp(0.55rem, 1.9vw, 0.68rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.25;
  pointer-events: auto;
}
.text-link:hover { color: var(--ink) !important; }
.closing {
  margin: 0.35em 0 0;
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(0.7rem, 2.4vw, 0.88rem);
  color: var(--muted);
  line-height: 1.3;
}

/* Short phones: tighten type */
@media (max-height: 700px) {
  .oncard { padding: 5% 7%; }
  .invite-line { margin-bottom: 0.3em; }
  .names { font-size: clamp(1.2rem, 5vw, 1.7rem); }
  .text-link { min-height: 32px; padding: 0.2rem 0.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .seal-hit, .seal-pulse { animation: none !important; }
  .env-video { transition: none !important; }
  .oncard > * {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
