/* Rafi weds Serena — white and gold, scroll-story version.
   Header: a round window in the card that you travel through into the photograph.
   Our story: photographs landing on a stack as you scroll.

   Everything scroll-driven lives under `html.motion`, which the script adds only
   when motion is welcome. Without it the page is a plain, complete document. */

@font-face { font-family: "Tinos"; src: url("../assets/fonts/tinos-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Tinos"; src: url("../assets/fonts/tinos-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Tinos"; src: url("../assets/fonts/tinos-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --white: #FFFFFF;
  --gold: #A8843E;
  --gold-deep: #8F6E2C;
  --gold-line: #D9C79E;
  --times: "Times New Roman", Times, "Tinos", "Liberation Serif", serif;
  --gutter: clamp(1.25rem, 5vw, 4rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--white);
  color: var(--gold-deep);
  font-family: var(--times);
  font-size: 1.125rem;
  line-height: 1.45;
  text-align: center;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
p, h1, h2, dl, dd { margin: 0; }
::selection { background: var(--gold-deep); color: var(--white); }
:focus-visible { outline: 1px solid var(--gold-deep); outline-offset: 4px; }

.caps {
  font-size: clamp(0.78rem, 0.72rem + 0.25vw, 0.9rem);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding-left: 0.3em;
}

.rule {
  display: flex; align-items: center; justify-content: center; gap: 0.9rem;
  width: min(15rem, 60%); margin-inline: auto; color: var(--gold);
}
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: 0.6; }
.rule i { width: 0.4rem; height: 0.4rem; background: currentColor; rotate: 45deg; }

.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15.5rem; min-height: 3.25rem;
  padding: 0.9rem 1.5rem 0.9rem 1.78rem;
  border: 1px solid var(--gold-deep);
  background: var(--white); color: var(--gold-deep);
  font: 400 0.82rem/1.2 var(--times);
  letter-spacing: 0.28em; text-transform: uppercase; text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.btn-solid { background: var(--gold-deep); color: var(--white); }
.btn:hover { background: var(--gold-deep); color: var(--white); }
.btn-solid:hover { background: var(--white); color: var(--gold-deep); }

.lang { display: flex; align-items: center; justify-content: center; gap: 0.35rem; color: var(--gold-line); }
.lang button {
  appearance: none; min-width: 2.5rem; min-height: 2.5rem; margin: 0; padding: 0 0.2rem;
  border: 0; background: none; color: var(--gold-deep);
  font: 400 0.82rem/1 var(--times); letter-spacing: 0.24em; cursor: pointer; opacity: 0.55;
}
.lang button[aria-pressed="true"] { opacity: 1; text-decoration: underline; text-underline-offset: 0.45em; text-decoration-thickness: 1px; }
.lang button:hover { opacity: 1; }

/* =====================================================================
   1. Header scene — plain version (no script / reduced motion)
   ===================================================================== */
.scene-stage { position: relative; display: grid; }
.collage { display: none; }
.portal-ring { display: none; }

.portal-ui { order: -1; display: grid; justify-items: center; gap: 1.5rem; padding: 2rem var(--gutter) 2.5rem; }
.portal-bar { display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left; }
.portal-bar .caps { padding-left: 0; letter-spacing: 0.24em; }
.monogram { --halo: var(--white); display: block; height: clamp(7rem, 20vh, 11rem); width: auto; color: var(--gold); overflow: visible; }
.portal-names { font-size: clamp(1.3rem, 0.8rem + 2.6vw, 2.2rem); letter-spacing: 0.2em; text-transform: uppercase; padding-left: 0.2em; line-height: 1.2; }
.portal-names em { font-style: italic; letter-spacing: 0; text-transform: none; color: var(--gold); font-size: 0.94em; margin: 0 0.12em 0 -0.05em; }
.portal-bottom { display: grid; justify-items: center; gap: 1.4rem; }
#enter, .portal-hint { display: none; }

.hero-card { position: relative; height: 82vh; height: 82svh; overflow: hidden; color: var(--white); }
.hero-card picture, .hero-img { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-img { object-fit: cover; object-position: 47% 50%; }
.hero-scrim { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(6, 10, 20, 0.5) 0%, rgba(6, 10, 20, 0) 42%); }
.hero-names {
  position: absolute; left: 0; right: 0; top: 9%;
  padding: 0 1rem;
  font-weight: 400; font-style: italic;
  font-size: clamp(2.7rem, 1.2rem + 7.4vw, 7.5rem);
  line-height: 1;
  text-shadow: 0 0.06em 0.6em rgba(20, 16, 6, 0.45);
}
.hero-names em { font-size: 0.62em; margin: 0 0.1em; }
.hero-date { position: absolute; left: 0; right: 0; top: calc(9% + clamp(3.4rem, 1.8rem + 8.4vw, 9.2rem)); text-shadow: 0 0 1em rgba(20, 16, 6, 0.6); }

/* =====================================================================
   1. Header scene — scroll-driven version
   --p1  0→1  the window opens to the full photograph
   --p2  0→1  names arrive on the photograph
   --p3  0→1  the photograph settles into a collage
   ===================================================================== */
html.motion .scene { height: 360vh; }
html.motion .scene-stage {
  --r0: min(31vw, 19vh);      /* radius of the window on the opening card */
  --cy: 45%;                  /* its vertical centre */
  position: sticky; top: 0; display: block;
  height: 100vh; height: 100svh;
  overflow: hidden; background: var(--white);
}

html.motion .hero-card {
  position: absolute; inset: 0; height: auto;
  clip-path: circle(calc(var(--r0) + (150vmax - var(--r0)) * var(--p1, 0)) at 50% var(--cy));
  transform: scale(calc(1 - 0.42 * var(--p3, 0)));
  will-change: clip-path, transform;
}
html.motion .scene.is-open .hero-card { clip-path: inset(0 round calc(2.4rem * var(--p3, 0))); }
/* While the window is small the picture is pulled back so the couple sits inside it.
   It only has to cover the window then, not the screen; it reaches full size well
   before the window grows to the screen edges. */
html.motion .hero-img {
  transform: scale(min(1, calc(0.72 + 4.7 * var(--p1, 0))));
  transform-origin: 50% 45%;
  will-change: transform;
}
html.motion .hero-scrim { opacity: var(--p2, 0); }
html.motion .hero-names, html.motion .hero-date {
  opacity: var(--p2, 0);
  translate: 0 calc(1.2rem * (1 - var(--p2, 0)));
}

/* thin gold ring around the window; it flies past as you go through */
html.motion .portal-ring {
  display: block; position: absolute;
  left: 50%; top: var(--cy);
  width: calc(var(--r0) * 2 + 1.5rem); height: calc(var(--r0) * 2 + 1.5rem);
  margin: calc(var(--r0) * -1 - 0.75rem) 0 0 calc(var(--r0) * -1 - 0.75rem);
  border: 1px solid var(--gold); border-radius: 50%;
  transform: scale(calc(1 + 7 * var(--p1, 0)));
  opacity: calc(1 - 2.5 * var(--p1, 0));
  pointer-events: none;
}

html.motion .portal-ui {
  position: absolute; inset: 0; display: block; padding: 0;
  opacity: calc(1 - 3.2 * var(--p1, 0));
  transform: scale(calc(1 + 0.9 * var(--p1, 0)));
  transform-origin: 50% var(--cy);
}
html.motion .scene.is-open .portal-ui { visibility: hidden; }
/* double hairline frame of the card */
html.motion .portal-ui::before, html.motion .portal-ui::after {
  content: ""; position: absolute; border: 1px solid var(--gold); pointer-events: none;
}
html.motion .portal-ui::before { inset: clamp(0.7rem, 2vw, 1.25rem); opacity: 0.55; }
html.motion .portal-ui::after { inset: calc(clamp(0.7rem, 2vw, 1.25rem) + 5px); }
html.motion .portal-bar { position: absolute; inset: 0 0 auto 0; width: auto; padding: clamp(1.9rem, 4.5vw, 2.75rem) clamp(2rem, 6vw, 4.25rem) 0; z-index: 1; }
html.motion .portal-top {
  position: absolute; left: 0; right: 0;
  bottom: calc(100% - var(--cy) + var(--r0) + clamp(1.6rem, 4vh, 2.6rem));
  display: grid; justify-items: center;
}
html.motion .monogram { height: clamp(4.5rem, 13vh, 8rem); }
html.motion .portal-bottom {
  position: absolute; left: 0; right: 0;
  top: calc(var(--cy) + var(--r0) + clamp(1.8rem, 4.5vh, 3rem));
  gap: clamp(1rem, 2.6vh, 1.6rem);
}
html.motion #enter { display: inline-flex; }
html.motion .portal-hint { display: block; opacity: 0.7; }

/* collage: four photographs slide in around the settling hero */
html.motion .collage { display: block; position: absolute; inset: 0; }
.collage-card {
  position: absolute; overflow: hidden; border-radius: clamp(0.9rem, 2.4vw, 1.8rem);
  opacity: calc(var(--p3, 0) * 1.6);
  translate: calc(var(--dx) * (1 - var(--p3, 0))) calc(var(--dy) * (1 - var(--p3, 0)));
  will-change: translate;
}
.collage-card img { width: 100%; height: 100%; object-fit: cover; }
/* portrait screens: hero settles to 58% of the screen, cards peek round its corners */
.c1 { --dx: -60vw; --dy: -8vh; left: 3vw; top: 9vh; width: 36vw; height: 22vh; }
.c1 img { object-position: 50% 62%; }
.c2 { --dx: -60vw; --dy: 10vh; left: 2vw; top: 63vh; width: 40vw; height: 21vh; }
.c3 { --dx: 60vw; --dy: -10vh; right: 2vw; top: 14vh; width: 38vw; height: 20vh; }
.c3 img { object-position: 46% 50%; }
.c4 { --dx: 60vw; --dy: 12vh; right: 3vw; top: 66vh; width: 34vw; height: 24vh; }
.c4 img { object-position: 50% 72%; }
html.motion .hero-card { z-index: 1; }
html.motion .portal-ring, html.motion .portal-ui { z-index: 2; }

@media (orientation: landscape) {
  .c1 { left: 5vw; top: 8vh; width: 21vw; height: 34vh; }
  .c2 { left: 9vw; top: 50vh; width: 17vw; height: 36vh; }
  .c3 { right: 6vw; top: 12vh; width: 19vw; height: 30vh; }
  .c4 { right: 4vw; top: 48vh; width: 22vw; height: 42vh; }
  .c4 img { object-position: 50% 78%; }
}

/* =====================================================================
   2. Invitation line
   ===================================================================== */
.invite-wrap { padding: clamp(5rem, 16vh, 11rem) var(--gutter); }
.invite {
  max-width: 19ch; margin-inline: auto;
  font-style: italic;
  font-size: clamp(2.1rem, 1.1rem + 4.6vw, 4.4rem);
  line-height: 1.12; text-wrap: balance; color: var(--gold);
}
.invite .w { transition: opacity 0.35s ease; }
html.motion .invite .w { opacity: 0.22; }
html.motion .invite .w.on { opacity: 1; }

/* =====================================================================
   3. Our story — plain version: a simple column of photographs
   ===================================================================== */
.story { padding: 0 var(--gutter) clamp(4rem, 10vw, 7rem); }
.story-title {
  font-weight: 400;
  font-size: clamp(3.4rem, 1.4rem + 10vw, 9rem);
  line-height: 0.95; letter-spacing: -0.015em; color: var(--gold-deep);
}
.story-count { margin-top: 0.9rem; }
.story-hint { margin-top: 2rem; opacity: 0.8; }
.deck { display: grid; gap: 2rem; justify-items: center; margin-top: 2.5rem; }

.polaroid {
  appearance: none; display: block; margin: 0; cursor: pointer;
  width: min(74vw, 21rem);
  padding: 0.7rem 0.7rem 0;
  border: 1px solid #ECE4D2;
  background: var(--white);
  box-shadow: 0 1.1rem 2.4rem -1rem rgba(70, 52, 14, 0.38), 0 0.15rem 0.5rem rgba(70, 52, 14, 0.08);
  color: var(--gold-deep); font: inherit;
  -webkit-tap-highlight-color: transparent;
}
.polaroid-photo { display: block; aspect-ratio: 4 / 4.6; overflow: hidden; background: #F3EEE2; }
.polaroid-photo img { width: 100%; height: 100%; object-fit: cover; }
.polaroid-no { display: block; padding: 0.7rem 0 0.8rem; font-style: italic; font-size: 1.05rem; letter-spacing: 0.08em; }

/* 3. Our story — scroll-driven: sticky stage, photographs land on the stack */
html.motion .story { height: calc(100vh + 7 * 62vh); padding: 0; }
html.motion .story-stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
}
html.motion .story-head { position: absolute; left: 0; right: 0; top: clamp(2.2rem, 7vh, 5rem); }
html.motion .story-title { font-size: clamp(3.2rem, 1.4rem + 9vw, 8.5rem); }
html.motion .deck { display: block; position: absolute; inset: 0; margin: 0; }
html.motion .polaroid {
  position: absolute; left: 50%; top: 57%;
  width: min(66vw, 41vh, 23rem);
  will-change: transform;
}
html.motion .story-count { position: absolute; left: 0; right: 0; bottom: clamp(2.9rem, 6.5vh, 4.2rem); margin: 0; }
html.motion .story-hint { position: absolute; left: 0; right: 0; bottom: clamp(1.1rem, 3vh, 2rem); margin: 0; }

/* =====================================================================
   4. So please join us — the gold side
   ===================================================================== */
.count { position: relative; background: var(--gold-deep); color: var(--white); padding: clamp(4rem, 10vw, 6.5rem) var(--gutter); }
.count::before { content: ""; position: absolute; inset: clamp(0.7rem, 2vw, 1.25rem); border: 1px solid rgba(255, 255, 255, 0.5); pointer-events: none; }
.count-inner { position: relative; display: grid; justify-items: center; max-width: 60rem; margin-inline: auto; }
.count-mark { width: clamp(3.75rem, 9vw, 5.5rem); height: auto; margin-bottom: 1.5rem; }
.count-join { font-style: italic; font-size: clamp(1.4rem, 1rem + 1.6vw, 2.1rem); }
.count-date { margin: 0.4rem 0 clamp(1.75rem, 5vw, 2.75rem); font-size: clamp(2.6rem, 1.2rem + 6.6vw, 6rem); line-height: 1.05; }
.count-grid { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; margin-top: clamp(1.25rem, 3.5vw, 2rem); }
.count-cell { display: grid; gap: 0.6rem; padding: 0.25rem 0.15rem; min-width: 0; }
.count-cell + .count-cell { border-left: 1px solid rgba(255, 255, 255, 0.4); }
.count-cell b { font-weight: 400; font-size: clamp(2.2rem, 0.9rem + 6.6vw, 5rem); line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.count-cell span { font-size: clamp(0.68rem, 0.55rem + 0.45vw, 0.9rem); letter-spacing: 0.22em; text-transform: uppercase; padding-left: 0.22em; }
.count-done { margin-top: 1.5rem; font-style: italic; font-size: clamp(2.5rem, 1rem + 8vw, 6rem); line-height: 1.05; }

/* =====================================================================
   5. Details, footer
   ===================================================================== */
.details { max-width: 68rem; margin-inline: auto; padding: clamp(3.5rem, 9vw, 6rem) var(--gutter) clamp(4rem, 10vw, 7rem); }
.facts { display: grid; }
.fact { display: grid; gap: 0.6rem; padding: 1.9rem 0.5rem; }
.fact + .fact { border-top: 1px solid var(--gold-line); }
.fact-main { display: block; font-size: clamp(1.75rem, 1.25rem + 2vw, 2.6rem); line-height: 1.12; }
.fact-sub { display: block; margin-top: 0.3rem; font-style: italic; font-size: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem 1.25rem; margin-top: clamp(2.25rem, 6vw, 3.25rem); }

.foot { display: grid; justify-items: center; gap: 1.4rem; padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(4.5rem, 10vw, 6rem); border-top: 1px solid var(--gold-line); }
.foot-mark { width: clamp(4.5rem, 10vw, 6.5rem); height: auto; margin-top: clamp(1.5rem, 4vw, 2.5rem); }
.foot-line { font-style: italic; font-size: clamp(2.4rem, 1.2rem + 5.5vw, 5rem); line-height: 1.05; color: var(--gold); }

/* =====================================================================
   Lightbox
   ===================================================================== */
.lightbox {
  max-width: none; max-height: none; width: 100vw; height: 100vh; height: 100dvh;
  margin: 0; padding: clamp(1rem, 4vw, 3rem); border: 0;
  background: rgba(255, 255, 255, 0.96); color: var(--gold-deep);
}
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; gap: 1rem; justify-items: center; align-items: center; }
.lightbox::backdrop { background: rgba(255, 255, 255, 0.6); }
.lightbox img { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; border: 1px solid var(--gold-line); padding: 0.6rem; background: var(--white); }
.lightbox-close { appearance: none; border: 0; background: none; color: inherit; font-family: var(--times); cursor: pointer; min-height: 2.75rem; padding-inline: 1rem 0.7rem; }

@media (min-width: 48rem) {
  .facts { grid-template-columns: repeat(3, 1fr); }
  .fact { padding: 0.75rem 1.5rem; }
  .fact + .fact { border-top: 0; border-left: 1px solid var(--gold-line); }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .invite .w { transition: none; }
}

/* =====================================================================
   Music: plays from the start of the visit. Where the browser holds sound
   back until the first tap, a small hint sits beside the button.
   ===================================================================== */
.music-wrap {
  position: fixed; z-index: 20;
  right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 0.6rem;
}
.music-hint {
  padding: 0.55rem 0.9rem; border-radius: 2rem;
  background: var(--white); color: var(--gold-deep);
  border: 1px solid var(--gold-line);
  box-shadow: 0 0.4rem 1.2rem rgba(60, 44, 10, 0.12);
  font-size: 0.68rem; white-space: nowrap;
  opacity: 0; translate: 0.6rem 0; pointer-events: none;
  transition: opacity 0.5s ease, translate 0.5s ease;
}
.music-wrap.is-waiting .music-hint { opacity: 1; translate: 0 0; }
.music {
  width: 3rem; height: 3rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--white); color: var(--gold-deep);
  border: 1px solid var(--gold-line);
  box-shadow: 0 0.4rem 1.2rem rgba(60, 44, 10, 0.12);
  cursor: pointer;
}
.music:hover, .music:focus-visible { border-color: var(--gold); }
.music-bars { display: flex; align-items: flex-end; gap: 3px; height: 1rem; }
.music-bars i { display: block; width: 2px; height: 30%; background: currentColor; border-radius: 1px; }
.music-bars i:nth-child(2) { height: 60%; }
.music-bars i:nth-child(3) { height: 100%; }
.music-bars i:nth-child(4) { height: 45%; }
.music[aria-pressed="true"] .music-bars i { animation: bar 1.1s ease-in-out infinite alternate; }
.music[aria-pressed="true"] .music-bars i:nth-child(2) { animation-delay: -0.4s; }
.music[aria-pressed="true"] .music-bars i:nth-child(3) { animation-delay: -0.8s; }
.music[aria-pressed="true"] .music-bars i:nth-child(4) { animation-delay: -0.2s; }
@keyframes bar { from { height: 20%; } to { height: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .music[aria-pressed="true"] .music-bars i { animation: none; }
}
