/* ==========================================================================
   Reset & box model
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
}

/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  --nude-bg: #f0f4ec;
  --nude-panel: rgb(240, 234, 237);
  --nude-text: #6a7a4a;
  --nude-text-soft: #9c8095;
  --intro-reveal-duration: 4s;
  --intro-reveal-delay: 0ms;
  --intro-spiral-duration: 6s;
  --hero-expand-duration: 3s;
  /* Viewport: JS sets --app-height; fallbacks cover static-load + older browsers */
  --viewport-height: 100vh;
  --viewport-height: 100svh;
  --viewport-height: 100dvh;
  --app-height: var(--viewport-height);
}

/* ==========================================================================
   Typography & Language System
   ========================================================================== */

[dir="ltr"] {
  direction: ltr;
}

[dir="rtl"] {
  direction: rtl;
}

[lang="en"] {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

[lang="fa"] {
  font-family: "Noto Sans Arabic", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400; /* Default weight, can be overridden */
  font-style: normal;
  font-variation-settings: "wdth" 100;
}

/* ==========================================================================
   Page shell
   ========================================================================== */

html {
  height: 100%;
  height: -webkit-fill-available;
  height: var(--app-height);
}

body {
  min-height: 100%;
  min-height: -webkit-fill-available;
  min-height: var(--app-height);
  color: var(--nude-text);
  background: var(--nude-bg);
  transition: background-color 0.9s ease;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body.is-after-spiral {
  background-color: var(--nude-panel);
}

body.is-spiral-active .invitation {
  visibility: hidden;
}

/* ==========================================================================
   Start gate (tap to begin + unlock audio)
   ========================================================================== */

body.is-start-pending {
  overflow: hidden;
  background-color: var(--nude-panel);
}

body.is-start-pending .invitation,
body.is-start-pending .intro-spiral-prelude {
  visibility: hidden;
  pointer-events: none;
}

body.is-start-pending .intro-spiral-prelude,
body.is-start-pending .intro-spiral-prelude * {
  animation-play-state: paused;
}

.start-gate {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.5rem
    max(1.5rem, env(safe-area-inset-bottom));
  background: var(--nude-panel);
}

.start-gate__btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--nude-text);
  font-size: clamp(1.15rem, 4.2vw, 1.45rem);
  letter-spacing: 0.04em;
  line-height: 1.4;
  padding: 0.85rem 0.5rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.35s ease, opacity 0.35s ease;
}

.start-gate__btn:hover,
.start-gate__btn:focus-visible {
  color: var(--nude-text-soft);
  outline: none;
}

.start-gate__btn[lang="fa"] {
  font-family: "Noto Sans Arabic", sans-serif;
  letter-spacing: 0;
}

.start-gate__btn[lang="en"] {
  font-family: "Cormorant Garamond", Georgia, serif;
}

/* ==========================================================================
   Spiral prelude (pre-reveal)
   ========================================================================== */

.intro-spiral-prelude {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  background: var(--nude-bg);
  pointer-events: none;
  animation: intro-spiral-prelude-bg var(--intro-spiral-duration) ease-in-out forwards;
}

.intro-spiral-prelude--done {
  opacity: 0;
  visibility: hidden;
}

.intro-spiral-prelude__stage {
  position: relative;
  width: min(72vmin, 72svmin, 28rem);
  height: min(72vmin, 72svmin, 28rem);
}

.intro-spiral-prelude__arm {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform-origin: center;
  will-change: transform;
}

.intro-spiral-prelude__orb {
  position: absolute;
  top: 0;
  left: 0;
  width: clamp(5.4rem, 19.2vmin, 9.6rem);
  height: clamp(5.4rem, 19.2vmin, 9.6rem);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle at 42% 38%,
    rgba(156, 128, 149, 0.18),
    rgba(156, 128, 149, 0.07) 58%,
    transparent 78%
  );
  background: radial-gradient(
    circle at 42% 38%,
    color-mix(in srgb, var(--nude-text-soft) 18%, transparent),
    color-mix(in srgb, var(--nude-text-soft) 7%, transparent) 58%,
    transparent 78%
  );
  filter: blur(3px);
  -webkit-filter: blur(3px);
  will-change: transform, opacity;
  animation: intro-spiral-orb-fade var(--intro-spiral-duration) ease-out forwards;
}

.intro-spiral-prelude__arm--a {
  transform: rotate(0deg) translateX(40.8vmin);
  animation: intro-spiral-arm-a var(--intro-spiral-duration) linear forwards;
}

.intro-spiral-prelude__arm--b {
  transform: rotate(180deg) translateX(40.8vmin);
  animation: intro-spiral-arm-b var(--intro-spiral-duration) linear forwards;
}

.intro-spiral-prelude__merge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(5.4rem, 19.2vmin, 9.6rem);
  height: clamp(5.4rem, 19.2vmin, 9.6rem);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.35);
  opacity: 0;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(156, 128, 149, 0.24),
    rgba(156, 128, 149, 0.1) 62%,
    transparent 82%
  );
  background: radial-gradient(
    circle at 50% 50%,
    color-mix(in srgb, var(--nude-text-soft) 24%, transparent),
    color-mix(in srgb, var(--nude-text-soft) 10%, transparent) 62%,
    transparent 82%
  );
  filter: blur(4px);
  -webkit-filter: blur(4px);
  animation: intro-spiral-merge var(--intro-spiral-duration) ease-out forwards;
}

/* Transform-based keyframes (no @property) — works in Safari, Samsung Internet, etc. */
@keyframes intro-spiral-arm-a {
  0% {
    transform: rotate(0deg) translateX(40.8vmin);
  }

  22% {
    transform: rotate(108deg) translateX(38.4vmin);
  }

  48% {
    transform: rotate(324deg) translateX(24vmin);
  }

  68% {
    transform: rotate(540deg) translateX(8vmin);
  }

  78%,
  100% {
    transform: rotate(720deg) translateX(0);
  }
}

@keyframes intro-spiral-arm-b {
  0% {
    transform: rotate(180deg) translateX(40.8vmin);
  }

  22% {
    transform: rotate(288deg) translateX(38.4vmin);
  }

  48% {
    transform: rotate(504deg) translateX(24vmin);
  }

  68% {
    transform: rotate(720deg) translateX(8vmin);
  }

  78%,
  100% {
    transform: rotate(900deg) translateX(0);
  }
}

@keyframes intro-spiral-orb-fade {
  0%,
  78% {
    opacity: 1;
  }

  88%,
  100% {
    opacity: 0;
  }
}

@keyframes intro-spiral-merge {
  0%,
  78% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }

  86% {
    opacity: 0.35;
    transform: translate(-50%, -50%) scale(0.85);
  }

  94% {
    opacity: 0.22;
    transform: translate(-50%, -50%) scale(1.15);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45);
  }
}

@keyframes intro-spiral-prelude-bg {
  0%,
  78% {
    background-color: var(--nude-bg);
  }

  86% {
    background-color: #eee8eb;
    background-color: color-mix(in srgb, var(--nude-panel) 38%, var(--nude-bg));
  }

  92% {
    background-color: #f2eaed;
    background-color: color-mix(in srgb, var(--nude-panel) 72%, var(--nude-bg));
  }

  100% {
    background-color: var(--nude-panel);
  }
}

/* ==========================================================================
   Invitation card layout
   ========================================================================== */

.invitation {
  display: flex;
  flex-direction: row;
  width: 100%;
  min-height: var(--app-height);
  height: var(--app-height);
}

.invitation__copy-column {
  position: relative;
  flex: 0 0 38%;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 0;
  padding: max(1rem, env(safe-area-inset-top)) 0 max(1rem, env(safe-area-inset-bottom));
  background: var(--nude-panel);
  overflow: hidden;
}

.copy-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
}

/* ==========================================================================
   Headline stack (SAVE / the / DATE)
   ========================================================================== */

.headline-stack {
  --headline-font-size: clamp(2.5rem, 11vh, 7rem);
  --headline-font-size: clamp(2.5rem, 11dvh, 7rem);
  --headline-the-gap-before: 0.39em;
  --headline-the-gap-after: 0.12em;
  --headline-the-offset: 0.2em;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transform: rotate(90deg) rotate(180deg);
  -webkit-transform: rotate(90deg) rotate(180deg);
  transform-origin: center center;
  -webkit-transform-origin: center center;
}

.headline-stack__column {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.headline {
  line-height: 1.3;
  color: var(--nude-text);
  white-space: nowrap;
  font-size: var(--headline-font-size, clamp(2.5rem, 11vh, 7rem));
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

.headline--the-offset {
  margin-inline-start: var(--headline-the-gap-before);
  margin-inline-end: var(--headline-the-gap-after);
  margin-top: var(--headline-the-offset);
}

.headline--script {
  font-family: "WindSong", cursive;
  font-weight: 500;
  font-style: normal;
}

.headline--sans {
  font-family: "M PLUS 1p", sans-serif;
  font-weight: 100;
  font-style: normal;
}

/* ==========================================================================
   Event details (couple + date)
   ========================================================================== */

.event-details {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  font-weight: 400;
  font-style: normal;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--nude-text-soft);
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  text-orientation: mixed;
  -webkit-text-orientation: mixed;
  white-space: nowrap;
  transform: translateY(-50%) rotate(180deg);
  -webkit-transform: translateY(-50%) rotate(180deg);
  flex-shrink: 0;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

.event-details.event-details--typing {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.event-details.event-details--typing:not(.event-details--done)::after {
  content: "|";
  margin-left: 0.05em;
  opacity: 0.85;
  animation: typing-caret-blink 0.9s step-end infinite;
}

.event-details.event-details--done::after {
  content: none;
}

@keyframes typing-caret-blink {
  50% {
    opacity: 0;
  }
}

/* ==========================================================================
   Photo gallery column
   ========================================================================== */

.invitation__photo-column {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.photo-frame {
  overflow: hidden;
  min-height: 0;
  flex-shrink: 0;
}

.photo-frame--compact {
  flex: 0 0 25%;
}

.photo-frame--featured {
  flex: 1 1 40%;
  min-height: 0;
}

.photo-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  -webkit-object-fit: cover;
}

/* ==========================================================================
   Intro blur reveal (overlay layers)
   ========================================================================== */

.intro-reveal-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  -webkit-backdrop-filter: blur(32px);
  backdrop-filter: blur(32px);
  background: var(--nude-panel);
  background: color-mix(in srgb, var(--nude-panel) 100%, transparent);
  opacity: 1;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  transition: opacity var(--intro-reveal-duration) ease-in var(--intro-reveal-delay);
}

body.is-intro-revealing .intro-reveal-overlay {
  opacity: 0;
}

body.is-layout-locked .invitation__copy-column,
body.is-layout-locked .invitation__photo-column {
  flex: 0 0 auto;
}

body.is-intro-pending,
body.is-intro-revealing,
body.is-layout-locked {
  overflow-x: hidden;
}

body.is-intro-pending .event-details {
  opacity: 0;
}

/* ==========================================================================
   Photo spotlight overlay
   ========================================================================== */

body.is-spotlight-pending,
body.is-spotlight-active {
  overflow: hidden;
}

.photo-spotlight {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

.photo-spotlight__viewport {
  position: fixed;
  top: var(--reveal-top, 0);
  left: var(--reveal-left, 0);
  width: var(--reveal-width, 100vw);
  height: var(--reveal-height, var(--app-height));
  overflow: hidden;
  z-index: 1;
  background: var(--nude-text-soft);
  transition:
    top var(--hero-expand-duration) cubic-bezier(0.4, 0, 0.2, 1),
    left var(--hero-expand-duration) cubic-bezier(0.4, 0, 0.2, 1),
    width var(--hero-expand-duration) cubic-bezier(0.4, 0, 0.2, 1),
    height var(--hero-expand-duration) cubic-bezier(0.4, 0, 0.2, 1);
}

.photo-spotlight--expanded .photo-spotlight__viewport {
  top: 0;
  left: 0;
  width: 100vw;
  height: var(--app-height);
}

.photo-spotlight__viewport img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  -webkit-object-fit: cover;
  opacity: 1;
  transition: filter var(--hero-expand-duration) cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-transition: -webkit-filter var(--hero-expand-duration) cubic-bezier(0.4, 0, 0.2, 1);
}

.photo-spotlight--expanded .photo-spotlight__viewport img {
  filter: brightness(0.42);
  -webkit-filter: brightness(0.42);
}

.photo-spotlight__dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background var(--hero-expand-duration) cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.photo-spotlight--expanded .photo-spotlight__dim {
  background: var(--nude-text-soft);
  opacity: 0.42;
  filter: brightness(0.42);
  -webkit-filter: brightness(0.42);
}

.photo-spotlight__message {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: max(1.5rem, env(safe-area-inset-top)) 2rem max(7.5rem, calc(env(safe-area-inset-bottom) + 6rem));
  max-width: 36rem;
  margin-inline: auto;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: rgba(255, 252, 248, 0.94);
  text-align: center;
  white-space: pre-line;
  opacity: 0;
  transition: opacity 0.6s ease 0.15s;
}

.photo-spotlight--typing .photo-spotlight__message {
  opacity: 1;
}

.photo-spotlight__address {
  position: fixed;
  left: 50%;
  bottom: max(2.75rem, calc(env(safe-area-inset-bottom) + 1.75rem));
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem 1.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 252, 248, 0.5);
  background: rgba(156, 128, 149, 0.2);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: rgba(255, 252, 248, 0.95);
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateX(-50%) translateY(14px);
  transition:
    opacity 1.6s ease,
    transform 1.6s ease,
    background 0.4s ease,
    border-color 0.4s ease;
}

.photo-spotlight__address--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.photo-spotlight__address:hover,
.photo-spotlight__address:focus-visible {
  background: rgba(156, 128, 149, 0.34);
  border-color: rgba(255, 252, 248, 0.85);
  outline: none;
}

.photo-spotlight__address-icon {
  width: 1.2em;
  height: 1.2em;
  flex-shrink: 0;
}

/* ==========================================================================
   Address page
   ========================================================================== */

.address-body {
  display: flex;
  min-height: var(--app-height);
  background: var(--nude-panel);
}

.address {
  position: relative;
  margin: auto;
  width: min(92%, 30rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  padding: max(4rem, calc(env(safe-area-inset-top) + 3rem)) 1.25rem
    max(2.5rem, calc(env(safe-area-inset-bottom) + 1.5rem));
  text-align: center;
  animation: address-fade-in 0.9s ease both;
}

@keyframes address-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.address__back {
  position: absolute;
  top: max(1.25rem, env(safe-area-inset-top));
  inset-inline-start: 0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  color: var(--nude-text-soft);
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 999px;
  transition: color 0.3s ease;
}

.address__back:hover,
.address__back:focus-visible {
  color: var(--nude-text);
  outline: none;
}

.address__back-icon {
  width: 1.05em;
  height: 1.05em;
}

.address__photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 18px 40px -24px rgba(106, 122, 74, 0.55);
}

.address__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.address__title {
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 400;
  color: var(--nude-text);
  line-height: 1.2;
}

.address__subtitle {
  margin-top: -0.85rem;
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  color: var(--nude-text-soft);
  line-height: 1.4;
}

.address__text {
  font-size: clamp(1rem, 3.8vw, 1.2rem);
  line-height: 2;
  color: var(--nude-text-soft);
  white-space: pre-line;
}

.address__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.address__map-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.78rem 1.7rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--nude-text) 45%, transparent);
  background: transparent;
  color: var(--nude-text);
  font-size: clamp(1rem, 3vw, 1.15rem);
  letter-spacing: 0.02em;
  text-decoration: none;
  transition:
    background 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease;
}

.address__map-link:hover,
.address__map-link:focus-visible {
  background: var(--nude-text);
  color: var(--nude-panel);
  border-color: var(--nude-text);
  outline: none;
}

.address__map-icon {
  width: 1.2em;
  height: 1.2em;
  flex-shrink: 0;
}

.address--korooki {
  width: min(96%, 42rem);
  max-width: 100%;
  min-width: 0;
  gap: 1.25rem;
}

.address__korooki {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 16px;
  background: var(--nude-panel);
  box-shadow: 0 18px 40px -24px rgba(106, 122, 74, 0.45);
  isolation: isolate;
}

.address__korooki img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  mix-blend-mode: multiply;
  filter: contrast(0.92) brightness(0.98) sepia(0.12);
}

.address__korooki-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--nude-panel) 28%, transparent);
  mix-blend-mode: multiply;
}

/* ==========================================================================
   Reduced motion overrides
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .intro-spiral-prelude {
    display: none;
  }

  body.is-spiral-active .invitation {
    visibility: visible;
  }

  .intro-reveal-overlay {
    transition: none;
    opacity: 0;
  }

  body.is-intro-pending .event-details {
    opacity: 1;
  }

  .photo-spotlight__address {
    transition: opacity 0.4s ease;
    transform: translateX(-50%);
  }

  .photo-spotlight__address--visible {
    transform: translateX(-50%);
  }

  .address {
    animation: none;
  }
}

