/* =========================================================================
   Wedding invitation — styles
   Names, dates, photo and music are set in index.html, not here.

   ✏️ COLORS & FONTS
   Want a different look? Change only the values in :root just below.
   Each color is used everywhere automatically.
   ========================================================================= */

:root {
  /* ✏️ Colors */
  --wine: #6B1426;
  --wine-deep: #480B18;
  --wine-soft: #8A2440;
  --blush: #F5E4E1;
  --blush-deep: #EACBC8;
  --paper: #FFFAF6;
  --gold: #C9A35B;
  --gold-light: #E6CC91;
  --gold-ink: #86662B;
  --ink: #3A1620;
  --ink-soft: #6A4750;

  /* ✏️ Fonts (English). Arabic fonts are set just below in html[lang="ar"]. */
  --font-script: "Pinyon Script", "Snell Roundhand", cursive;
  --font-serif: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --gutter: clamp(16px, 5vw, 48px);
}

/* ✏️ Arabic fonts */
html[lang="ar"] {
  --font-script: "Aref Ruqaa", "Amiri", serif;
  --font-serif: "Amiri", "Noto Naskh Arabic", serif;
}

/* Arabic is a connected script: never track it, never slant it. */
html[lang="ar"] body * {
  letter-spacing: normal !important;
  font-style: normal !important;
}

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

[hidden] { display: none !important; }

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

html.is-locked,
html.is-locked body { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--blush);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

html[lang="ar"] body { font-size: 1.15rem; line-height: 1.75; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    var(--grain, none),
    radial-gradient(120% 70% at 50% -10%, #FCF1EE 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 115%, var(--blush-deep) 0%, transparent 70%),
    var(--blush);
}

main { position: relative; z-index: 1; }

p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* ---------- Falling petals ---------- */
#petals {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Wax seal (the "open" button on the envelope) ---------- */
.seal {
  position: absolute;
  left: 50%;
  top: 55%;
  z-index: 6;
  width: max(19%, 62px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(.8rem, 2.6vw, 1.15rem);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: scale .16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.seal:hover { scale: 1.04; }
.seal:active,
.seal.is-pressed { scale: .93; }

.env.is-opened .seal { cursor: default; pointer-events: none; }

.seal__shadow,
.seal__half {
  position: absolute;
  inset: 0;
  border-radius: 48% 52% 50% 50% / 51% 49% 52% 48%;
}

.seal__shadow {
  box-shadow: 0 6px 14px rgba(30, 5, 10, .5), 0 2px 3px rgba(30, 5, 10, .35);
}

/* Poured wax: light from the top-left, darker rim, pressed inner ring */
.seal__half {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 248, 220, .75) 0 6%, transparent 22%),
    radial-gradient(circle at 50% 50%, #E2C27A 0%, var(--gold) 46%, #8C6828 88%, #6E4F1C 100%);
  box-shadow:
    inset 0 -5px 9px rgba(70, 42, 8, .45),
    inset 0 3px 5px rgba(255, 244, 210, .45);
}

.seal__half::before {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  box-shadow:
    inset 0 2px 3px rgba(80, 50, 12, .55),
    0 1px 0 rgba(255, 240, 200, .5);
}

/* The wax cracks along a jagged line as the flap lifts */
.seal__half--a { clip-path: polygon(0 0, 53% 0, 46% 21%, 56% 40%, 47% 60%, 54% 79%, 48% 100%, 0 100%); }
.seal__half--b { clip-path: polygon(53% 0, 100% 0, 100% 100%, 48% 100%, 54% 79%, 47% 60%, 56% 40%, 46% 21%); }

.seal__mono {
  position: relative;
  line-height: 1;
  white-space: nowrap;
  color: #5A3E12;
  /* Stamped into the wax: shadow above, light catching the lower edge */
  text-shadow: 0 1px 0 rgba(255, 238, 196, .7), 0 -1px 0 rgba(60, 36, 6, .45);
}

html[lang="ar"] .seal__mono { font-family: "Aref Ruqaa", "Amiri", serif; line-height: 1.4; }

/* A soft ring invites the tap — only while the envelope is still sealed */
.seal::after {
  content: "";
  position: absolute;
  inset: -14%;
  border-radius: 50%;
  border: 1.5px solid var(--gold-light);
  opacity: 0;
  pointer-events: none;
  animation: seal-ring 2.4s var(--ease) infinite;
}

.env.is-opened .seal::after { animation: none; }

@keyframes seal-ring {
  0%   { transform: scale(.85); opacity: .85; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* ---------- Top & bottom controls ---------- */
.lang-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  inset-inline-end: 14px;
  z-index: 60;
  min-height: 42px;
  padding: .35rem 1.1rem;
  border: 1px solid rgba(201, 163, 91, .75);
  border-radius: 999px;
  background: rgba(255, 250, 246, .9);
  color: var(--wine);
  font-size: 1rem;
  cursor: pointer;
  transition: background .3s, color .3s;
}

.lang-btn:hover { background: var(--paper); }
.lang-btn [lang="ar"] { font-family: "Amiri", serif; font-weight: 700; }
.lang-btn [lang="en"] { font-family: "Bodoni Moda", Georgia, serif; font-style: italic; }

.music-btn {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  inset-inline-end: 16px;
  z-index: 60;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(201, 163, 91, .7);
  border-radius: 50%;
  background: var(--wine);
  color: var(--gold-light);
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(72, 11, 24, .6);
  transition: transform .3s var(--ease), background .3s;
}

.music-btn:hover { background: var(--wine-soft); transform: translateY(-2px); }
.music-btn:active { transform: scale(.94); transition-duration: .1s; }

.music-btn__eq { display: none; gap: 3px; align-items: flex-end; height: 18px; }
.music-btn__eq i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform-origin: bottom;
  animation: eq 1.1s ease-in-out infinite;
}
.music-btn__eq i:nth-child(2) { animation-delay: -.4s; }
.music-btn__eq i:nth-child(3) { animation-delay: -.7s; }
.music-btn__eq i:nth-child(4) { animation-delay: -.2s; }

.music-btn.is-playing .music-btn__note { display: none; }
.music-btn.is-playing .music-btn__eq { display: flex; }

@keyframes eq {
  0%, 100% { transform: scaleY(.3); }
  50%      { transform: scaleY(1); }
}

/* ---------- 1. Envelope stage ---------- */
.stage {
  position: relative;
  height: 260vh;
  height: 260svh;
}

.stage__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  perspective: 1200px;
  opacity: 0;
  transition: opacity .9s var(--ease);
}

/* The scene fades in once the fonts are ready, so no text ever flashes in a fallback font */
html.is-ready .stage__sticky { opacity: 1; }

.env {
  position: absolute;
  left: 50%;
  top: 56%;
  width: min(86vw, 460px, 54vh);
  width: min(86vw, 460px, 54svh);
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%);
  will-change: transform;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.env.is-opened { cursor: default; }

.env__back,
.env__front,
.env__flap,
.env__flap-shadow,
.env__card { position: absolute; }

/* Inside of the envelope: lined paper */
.env__back {
  inset: 0;
  z-index: 1;
  border-radius: 5px;
  background:
    var(--grain, none),
    repeating-linear-gradient(45deg, rgba(212, 178, 122, .45) 0 1px, transparent 1px 6px),
    linear-gradient(#F6E2DC, #EBCFC7);
  box-shadow:
    0 2px 4px rgba(72, 11, 24, .25),
    0 18px 30px -12px rgba(72, 11, 24, .45),
    0 44px 70px -30px rgba(72, 11, 24, .5);
}

/* The photo card: heavy cream stock with a gold hairline */
.env__card {
  left: 5%;
  top: 6%;
  width: 90%;
  height: 88%;
  z-index: 3;
  margin: 0;
  padding: 3.2%;
  border-radius: 3px;
  background: var(--grain, none), linear-gradient(#FFFCF8, #F6EDE4);
  box-shadow:
    inset 0 1px 0 #fff,
    0 1px 1px rgba(58, 22, 32, .18),
    0 16px 32px -12px rgba(58, 22, 32, .5);
  will-change: transform;
}

.env__card::after {
  content: "";
  position: absolute;
  inset: 1.5%;
  border: 1px solid rgba(201, 163, 91, .6);
  border-radius: 2px;
  pointer-events: none;
}

.env__card img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 1px;
  background: var(--blush-deep);
  box-shadow: 0 0 0 1px rgba(58, 22, 32, .08);
}

/* Front pocket (side and bottom flaps), cut with a V so the card shows through */
.env__front {
  inset: 0;
  z-index: 4;
  overflow: hidden;
  border-radius: 0 0 5px 5px;
  clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%);
}

.env__pocket {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ✏️ Text comes from envelopeTo in index.html */
.env__to {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 8%;
  text-align: center;
  font-family: var(--font-script);
  font-size: clamp(1rem, 4.2vw, 1.55rem);
  line-height: 1.3;
  color: var(--gold-light);
  text-shadow: 0 1px 0 rgba(40, 4, 12, .5);
}

html[lang="ar"] .env__to { font-size: clamp(.95rem, 3.8vw, 1.35rem); line-height: 1.6; }

/* A soft band of light that glides across the paper as the envelope turns */
.env__sheen {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -100%;
  width: 100%;
  background: linear-gradient(100deg, rgba(255, 240, 235, 0) 25%, rgba(255, 240, 235, .07) 42%, rgba(255, 250, 245, .15) 50%, rgba(255, 240, 235, .07) 58%, rgba(255, 240, 235, 0) 75%);
  pointer-events: none;
  will-change: transform;
}

/* Shadow the closed flap casts onto the pocket */
.env__flap-shadow {
  left: 0;
  top: 0;
  width: 100%;
  height: 62%;
  z-index: 4;
  overflow: visible;
  pointer-events: none;
  will-change: opacity;
}

.env__flap {
  left: 0;
  top: 0;
  width: 100%;
  height: 58%;
  z-index: 5;
  overflow: visible;
  transform-origin: 50% 0;
}

.env__flap-face { fill: url(#flap-front); }

/* Once the flap has swung past vertical we see its lined inside, behind the card */
.env.is-flap-open .env__flap { z-index: 2; }
.env.is-flap-open .env__flap-face { fill: url(#flap-liner); }

/* Once the photo has cleared the pocket it moves in front of everything */
.env.is-card-out .env__card { z-index: 7; }

.stage-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(7vh, 40px);
  text-align: center;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  pointer-events: none;
  transition: opacity .4s var(--ease);
}

/* ---------- Reveal on arrival ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 1.2s var(--ease), transform 1.2s var(--ease);
  transition-delay: var(--delay, 0s);
}

.is-visible .reveal { opacity: 1; transform: none; }

/* ---------- 2. Invitation ---------- */
.invite {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 14vh var(--gutter);
  text-align: center;
}

.invite__inner { max-width: 44rem; }

.invite__text {
  font-size: clamp(1.2rem, 3.4vw, 1.65rem);
  font-style: italic;
  line-height: 1.45;
  color: var(--wine);
  margin-bottom: 1.25rem;
}

html[lang="ar"] .invite__text { font-size: clamp(1.4rem, 4vw, 1.9rem); line-height: 1.6; }

.names {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-script);
  font-weight: 400;
  font-size: clamp(3.4rem, 13vw, 7.4rem);
  line-height: 1.1;
  color: var(--wine);
}

html[lang="ar"] .names {
  font-size: clamp(3rem, 11vw, 6rem);
  line-height: 1.4;
  font-weight: 700;
}

/* Names are revealed as if written by hand, in the reading direction */
.names__line {
  display: block;
  padding: .06em .22em;
  overflow-wrap: anywhere;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.9s var(--ease);
  transition-delay: var(--delay, .2s);
}

html[dir="rtl"] .names__line { clip-path: inset(0 0 0 100%); }

.is-visible .names__line,
html[dir="rtl"] .is-visible .names__line { clip-path: inset(0 0 0 0); }

.names__amp {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: .36em;
  line-height: 1;
  color: var(--gold-ink);
  margin: .1em 0;
}

html[lang="ar"] .names__amp { font-size: .45em; line-height: 1.4; }

.invite__date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  color: var(--ink-soft);
}

.invite__date::before,
.invite__date::after {
  content: "";
  width: clamp(24px, 8vw, 56px);
  height: 1px;
  background: var(--gold);
}

.invite__message {
  max-width: 32rem;
  margin: 1.4rem auto 0;
  color: var(--ink-soft);
  line-height: 1.75;
}

/* ---------- 3. Venue ---------- */
.venue {
  display: grid;
  place-items: center;
  padding: 6vh var(--gutter) 10vh;
}

.venue__wrap {
  width: 100%;
  max-width: 40rem;
  perspective: 1000px;
}

.venue-card {
  position: relative;
  padding: clamp(2.25rem, 7vw, 3.75rem) clamp(1.25rem, 6vw, 3.5rem);
  border-radius: 4px;
  background: var(--grain, none), linear-gradient(#FFFCF9, var(--paper));
  text-align: center;
  box-shadow:
    0 30px 60px -30px rgba(72, 11, 24, .4),
    0 8px 20px -12px rgba(72, 11, 24, .25);
  transition: transform .7s var(--ease);
}

.venue-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(201, 163, 91, .6);
  border-radius: 2px;
  pointer-events: none;
}

.venue-card__join {
  font-style: italic;
  color: var(--ink-soft);
}

.venue-card__name {
  margin: .35rem 0 .7rem;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 6vw, 2.8rem);
  line-height: 1.2;
  color: var(--wine);
}

html[lang="ar"] .venue-card__name { font-weight: 700; line-height: 1.45; }

.venue-card__details {
  max-width: 30rem;
  margin-inline: auto;
  color: var(--ink-soft);
}

.ornament {
  display: block;
  width: 140px;
  height: 14px;
  margin: 1.9rem auto;
  color: var(--gold);
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem 1.5rem;
  margin: 0;
}

.facts__item--wide { grid-column: 1 / -1; }

.facts dt {
  font-size: .92rem;
  font-style: italic;
  color: var(--gold-ink);
}

.facts dd {
  margin: .15rem 0 0;
  font-size: 1.1rem;
  color: var(--ink);
}

/* Countdown */
.countdown {
  margin-top: 2.25rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(201, 163, 91, .45);
}

.countdown__title {
  margin-bottom: 1rem;
  font-style: italic;
  color: var(--ink-soft);
}

.countdown__grid {
  display: flex;
  justify-content: center;
  gap: clamp(.5rem, 3vw, 1.5rem);
}

.countdown__cell {
  min-width: 4.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.countdown__num {
  font-size: clamp(1.9rem, 7vw, 2.7rem);
  font-weight: 500;
  line-height: 1.15;
  color: var(--wine);
  font-variant-numeric: tabular-nums lining-nums;
}

.countdown__unit {
  font-size: .85rem;
  color: var(--gold-ink);
}

.countdown__done {
  font-family: var(--font-script);
  font-size: clamp(2.2rem, 8vw, 3rem);
  line-height: 1.4;
  color: var(--wine);
}

/* Map button */
.map-btn {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 50px;
  margin-top: 2.4rem;
  padding: .85rem 1.9rem;
  border-radius: 999px;
  background: var(--wine);
  color: var(--paper);
  text-decoration: none;
  font-size: 1.02rem;
  box-shadow: 0 12px 24px -12px rgba(72, 11, 24, .7);
  transition: background .3s, transform .3s var(--ease);
}

.map-btn:hover { background: var(--wine-soft); transform: translateY(-2px); }
.map-btn svg { color: var(--gold-light); flex: none; }

/* ---------- Closing ---------- */
.closing {
  padding: 6vh var(--gutter) 18vh;
  text-align: center;
}

.closing__line {
  max-width: 26rem;
  margin: 0 auto 1rem;
  font-style: italic;
  color: var(--ink-soft);
}

.closing__mono {
  font-family: var(--font-script);
  font-size: clamp(2.6rem, 9vw, 3.4rem);
  line-height: 1.4;
  color: var(--gold-ink);
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .facts { grid-template-columns: 1fr; }
  .countdown__cell { min-width: 3.4rem; }
}

/* ---------- Setup notices (only shown on your own computer) ---------- */
.dev-notice {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 80;
  max-width: min(440px, calc(100vw - 24px));
  padding: .75rem 1rem;
  border: 1px solid var(--gold);
  border-left: 4px solid #B3122E;
  border-radius: 6px;
  background: #FFF8EC;
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 12px 30px rgba(58, 22, 32, .2);
}

.dev-notice p { margin: .3rem 0; }

.dev-notice__close {
  float: right;
  margin-left: .75rem;
  border: 0;
  background: none;
  color: var(--wine);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

html[lang="ar"] .dev-notice,
html[lang="ar"] .dev-notice * { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .names__line {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
  }
  .seal::after,
  .music-btn__eq i { animation: none; }
}
