:root {
  --ivory: #fbf6ee;
  --blush: #f4d9d6;
  --blush-deep: #b9707a;
  --sage: #9caf92;
  --sage-soft: #dfe7d8;
  --sage-deep: #55694f;
  --gold: #c9a96a;
  --gold-soft: #e9d6ac;
  --gold-deep: #8a6c33;
  --ink: #4a4240;
  --nav-h: 66px;
  --nav-space: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom, 0px));

  --bs-body-font-family: "Lexend", sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--ivory);
}

/* ---------- Single-screen shell ---------- */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

body {
  position: fixed;
  inset: 0;
  margin: 0;
  font-family: "Lexend", sans-serif;
  font-weight: 300;
  background:
    radial-gradient(circle at 12% 18%, rgba(244, 217, 214, .75), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(223, 231, 216, .85), transparent 44%),
    radial-gradient(circle at 50% 50%, #fffdf9, var(--ivory) 70%);
}

button, input, a { font-family: inherit; }
:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Decorations ---------- */
.decor { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

.frame {
  position: absolute;
  inset: 10px;
  border: 1px solid var(--gold);
  border-radius: 20px;
}
.frame::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(201, 169, 106, .45);
  border-radius: 15px;
}

.corner {
  position: absolute;
  width: clamp(110px, 27vmin, 290px);
  height: clamp(110px, 27vmin, 290px);
}
.corner-tl { top: 0; left: 0; }
.corner-tr { top: 0; right: 0; transform: scaleX(-1); }
.corner-bl { bottom: 0; left: 0; transform: scaleY(-1); }
.corner-br { bottom: 0; right: 0; transform: scale(-1); }

.bloom-blush { --petal: #eab9b8; --petal-in: #f6d6d3; }
.bloom-rose  { --petal: #d99aa0; --petal-in: #ecbfc0; }
.bloom-cream { --petal: #f1dcc6; --petal-in: #fcefe0; }
.petals { fill: var(--petal, #eab9b8); }
.petals-inner { fill: var(--petal-in, #f6d6d3); }

.petal-layer span {
  position: absolute;
  top: -20px;
  width: 11px;
  height: 14px;
  background: #ecc0c0;
  border-radius: 80% 0 70% 50%;
  opacity: 0;
  animation: drift linear infinite;
}
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0); opacity: 0; }
  10%  { opacity: .65; }
  90%  { opacity: .45; }
  100% { transform: translate(70px, 108vh) rotate(420deg); opacity: 0; }
}

/* ---------- Views ---------- */
.stage {
  position: fixed;
  top: 22px;
  left: 20px;
  right: 20px;
  bottom: var(--nav-space);
  transition: bottom .5s;
}
.is-cover .stage { bottom: 22px; }

.view {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  grid-template: 100% / 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity .55s, visibility 0s .55s;
}
.view.active { opacity: 1; visibility: visible; transition: opacity .7s .1s, visibility 0s; }

/* Content block; script.js scales it down if the screen is too short */
.fit {
  grid-area: 1 / 1;
  place-self: center;
  width: min(100%, 780px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px;
  scale: var(--fit, 1);
}
.view.active .fit > * { animation: rise .8s both; }
.view.active .fit > :nth-child(2) { animation-delay: .08s; }
.view.active .fit > :nth-child(3) { animation-delay: .16s; }
.view.active .fit > :nth-child(4) { animation-delay: .24s; }
.view.active .fit > :nth-child(5) { animation-delay: .32s; }
.view.active .fit > :nth-child(6) { animation-delay: .40s; }
@keyframes rise { from { opacity: 0; translate: 0 18px; } }

/* ---------- Type ---------- */
.kicker {
  margin: 0 0 8px;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.title {
  margin: 0 0 6px;
  font-size: clamp(1.75rem, 5vw, 2.7rem);
  font-weight: 200;
  letter-spacing: .02em;
  color: var(--sage-deep);
}
.small-copy { margin: 6px 0; font-size: .82rem; line-height: 1.7; }
.arabic { margin: 0 0 6px; font-size: 1.45rem; line-height: 1.8; color: var(--gold-deep); }
.arabic-large { font-size: 1.65rem; line-height: 2; }
.sprig { display: block; flex: none; width: 170px; height: 28px; margin: 6px auto 12px; }

/* ---------- Buttons ---------- */
.btn-gold, .btn-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 28px;
  border: 1px solid var(--gold);
  border-radius: 40px;
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-decoration: none;
  cursor: pointer;
  transition: transform .25s, box-shadow .25s, background-color .25s;
}
.btn-gold {
  background: linear-gradient(120deg, #d8bd83, #f2e2bb 50%, #d2b273);
  color: #4d3a16;
  box-shadow: 0 6px 18px rgba(138, 108, 51, .25);
}
.btn-line { background: rgba(255, 255, 255, .6); color: var(--gold-deep); }
.btn-gold:hover, .btn-line:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(138, 108, 51, .28); color: #4d3a16; }

/* ---------- Opening envelope ---------- */
.envelope {
  --w: min(340px, 78vw);
  position: relative;
  flex: none;
  width: var(--w);
  height: calc(var(--w) * .66);
  margin: calc(var(--w) * .38) 0 26px;
  padding: 0;
  border: 0;
  background: none;
  perspective: 900px;
  cursor: pointer;
  filter: drop-shadow(0 18px 22px rgba(120, 80, 70, .22));
}
.view.active .fit > .envelope { animation: rise .8s .16s both, float 4.5s 1s ease-in-out infinite; }
.view.active .fit > .envelope.open { animation: none; }
@keyframes float { 50% { transform: translateY(-9px); } }

.envelope > span { position: absolute; display: block; }
.env-back { inset: 0; border-radius: 10px; background: #dfaeb0; border: 1px solid var(--gold); }
.env-letter {
  left: 5%;
  right: 5%;
  top: 5%;
  height: 88%;
  z-index: 1;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 5%;
  background: #fffdf8;
  border: 1px solid var(--gold);
  border-radius: 8px;
  outline: 1px solid rgba(201, 169, 106, .4);
  outline-offset: -6px;
  color: var(--sage-deep);
  transition: transform .9s .55s cubic-bezier(.25, .8, .25, 1);
}
.env-letter .sprig { width: 55%; height: 20px; margin: 0 auto 4px; }
.env-name { font-size: calc(var(--w) * .066); font-weight: 200; letter-spacing: .03em; line-height: 1.35; }
.env-amp { font-size: calc(var(--w) * .045); color: var(--gold-deep); line-height: 1.2; }
.env-pocket {
  inset: 0;
  z-index: 2;
  border-radius: 10px;
  background: linear-gradient(90deg, #f1cfcc 50%, #eac2c0 50%);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.env-pocket::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(#f7dedb, #f4d6d3);
  clip-path: polygon(0 100%, 50% 48%, 100% 100%);
}
.env-flap {
  left: 0;
  top: 0;
  width: 100%;
  height: 62%;
  z-index: 3;
  background: linear-gradient(#e5b4b5, #efc9c7);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform .7s ease-in-out, z-index 0s .4s;
}
.env-seal {
  left: 50%;
  top: 60%;
  z-index: 4;
  width: 62px;
  height: 62px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 1px;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6e7c1, #c9a96a 62%, #a5844a);
  box-shadow: 0 4px 10px rgba(90, 60, 30, .35), inset 0 0 0 4px rgba(255, 255, 255, .22);
  color: #4d3a16;
  font-size: 1.05rem;
  font-weight: 400;
  transition: opacity .3s, scale .3s;
}
.env-seal small { font-size: .6rem; }
.envelope.open { cursor: default; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-letter { transform: translateY(-48%); }
.envelope.open .env-seal { opacity: 0; scale: 1.5; }

/* ---------- Invitation and closing arch ---------- */
.arch {
  position: relative;
  width: min(100%, 460px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 46px 22px 28px;
  background: rgba(255, 253, 248, .86);
  border: 1px solid var(--gold);
  border-radius: 230px 230px 22px 22px;
  box-shadow: 0 20px 50px rgba(150, 105, 90, .14), inset 0 0 0 6px var(--ivory), inset 0 0 0 7px var(--gold-soft);
}
.host { margin: 4px 0 0; font-size: .74rem; line-height: 1.6; }
.host strong { display: block; font-size: 1.05rem; font-weight: 400; color: var(--sage-deep); }
.host + .small-copy { font-size: .74rem; text-wrap: balance; }
.couple { margin: 4px 0; font-weight: 100; }
.couple-name {
  display: block;
  font-size: clamp(1.9rem, 8.4vw, 2.7rem);
  font-weight: 200;
  letter-spacing: .015em;
  line-height: 1.25;
  white-space: nowrap;
  background: linear-gradient(110deg, #7d5f2a, #b8924d 45%, #8a6c33);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.couple-amp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 1.25rem;
  color: var(--blush-deep);
}
.couple-amp i { width: 46px; height: 1px; background: var(--gold); }
.date-pill {
  margin: 8px 0 0;
  padding: 7px 20px;
  border-radius: 30px;
  background: var(--sage-soft);
  color: var(--sage-deep);
  font-size: .8rem;
  font-weight: 400;
  letter-spacing: .08em;
}
.arch .title { font-size: clamp(1.5rem, 6.4vw, 2.1rem); white-space: nowrap; }
.closing-bloom { width: 44px; height: 44px; margin-bottom: 6px; }
.signature { margin: 6px 0 14px; font-size: .95rem; font-weight: 300; color: var(--blush-deep); }

/* ---------- Cards ---------- */
.card-blush { --card: linear-gradient(165deg, #fffaf8, #f8e1de); --accent: #9c525d; }
.card-sage  { --card: linear-gradient(165deg, #fbfdf9, #e0e9da); --accent: var(--sage-deep); }

.event-card, .count-card, .family-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--gold);
  box-shadow: 0 14px 32px rgba(140, 100, 85, .13), inset 0 0 0 5px rgba(255, 255, 255, .65), inset 0 0 0 6px var(--gold-soft);
  color: var(--ink);
}

.event-grid, .count-grid, .family-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 3vw, 24px);
  width: 100%;
  max-width: 620px;
  margin-bottom: 10px;
}

.event-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 10px 22px;
  border-radius: 150px 150px 18px 18px;
  cursor: pointer;
  transition: transform .3s, box-shadow .3s;
}
.event-card:hover, .event-card:focus-visible { transform: translateY(-7px); box-shadow: 0 22px 40px rgba(140, 100, 85, .22), inset 0 0 0 5px rgba(255, 255, 255, .65), inset 0 0 0 6px var(--gold); }
.card-bloom { width: 42px; height: 42px; transition: rotate .6s; }
.event-card:hover .card-bloom { rotate: 72deg; }
.event-label { margin-top: 8px; font-size: clamp(1.1rem, 4vw, 1.5rem); font-weight: 300; color: var(--accent); }
.event-day { font-size: clamp(3.2rem, 12vw, 5rem); font-weight: 100; line-height: 1.1; color: var(--gold-deep); }
.event-month { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.event-weekday { font-size: .78rem; opacity: .8; }
.event-more {
  margin-top: 14px;
  padding: 7px 14px;
  border: 1px solid var(--gold);
  border-radius: 30px;
  background: rgba(255, 255, 255, .75);
  font-size: .72rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- Countdown ---------- */
.count-grid { grid-template-columns: 1fr; max-width: 520px; gap: 14px; }
.count-card { padding: 18px 16px; border-radius: 24px; }
.count-card h3 { margin: 0; font-size: 1.25rem; font-weight: 300; color: var(--accent); }
.count-date { margin: 0 0 10px; font-size: .74rem; letter-spacing: .06em; }
.timer { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 420px; margin: 0 auto; }
.timer[hidden] { display: none; }
.timer div { display: flex; flex-direction: column; padding: 8px 2px; background: rgba(255, 255, 255, .8); border: 1px solid var(--gold-soft); border-radius: 40px 40px 12px 12px; }
.timer strong { font-size: clamp(1.5rem, 7vw, 2.3rem); font-weight: 200; line-height: 1.2; color: var(--gold-deep); font-variant-numeric: tabular-nums; }
.timer span { font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; }
.count-done { margin: 12px 0 4px; color: var(--accent); font-weight: 400; }

/* ---------- Family ---------- */
.family-card { padding: 22px 12px 18px; border-radius: 70px 70px 18px 18px; }
.family-card p { margin: 0 0 8px; font-size: .78rem; line-height: 1.6; }
.family-card h3 { margin: 0 0 8px; font-size: clamp(1rem, 4vw, 1.35rem); font-weight: 300; color: var(--accent); }
.family-card .family-role { margin-bottom: 4px; font-size: .62rem; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-deep); }
.family-card .family-extra { font-size: .72rem; }
.family-card .family-place { margin: 0; padding-top: 8px; border-top: 1px solid var(--gold-soft); }
.compliments { max-width: 520px; margin: 4px 0 14px; font-size: .82rem; line-height: 1.6; }
.compliments span { display: block; font-size: .62rem; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-deep); }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  width: min(480px, calc(100% - 36px));
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  translate: -50% 0;
  background: rgba(255, 253, 249, .93);
  border: 1px solid var(--gold);
  border-radius: 40px;
  box-shadow: 0 10px 30px rgba(140, 100, 85, .22), inset 0 0 0 3px rgba(233, 214, 172, .35);
  transition: translate .6s, opacity .6s;
}
.is-cover .bottom-nav { translate: -50% 150%; opacity: 0; pointer-events: none; }
.bottom-nav button {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  border: 0;
  border-radius: 30px;
  background: transparent;
  color: var(--sage-deep);
  font-size: .64rem;
  font-weight: 400;
  cursor: pointer;
  transition: background-color .3s, color .3s;
}
.bottom-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button:hover { background: var(--blush); }
.bottom-nav button.active { background: var(--sage-deep); color: #fffdf6; }

/* ---------- Popup ---------- */
.modal { --bs-modal-width: 440px; }
.modal-backdrop { --bs-backdrop-bg: #6d5552; --bs-backdrop-opacity: .45; }
.modal-content {
  overflow: hidden;
  background: linear-gradient(170deg, #fffdf9, #fbeeec 55%, #eef2e9);
  border: 1px solid var(--gold);
  border-radius: 26px;
  box-shadow: 0 30px 70px rgba(80, 50, 45, .3), inset 0 0 0 6px rgba(255, 255, 255, .6), inset 0 0 0 7px var(--gold-soft);
}
.modal-content .btn-close { position: absolute; top: 18px; right: 18px; z-index: 2; }
.modal-body { padding: 28px 28px 30px; text-align: center; }
.details { margin: 12px 0 20px; }
.details > div { padding: 10px 0; border-bottom: 1px solid var(--gold-soft); }
.details > div:first-child { border-top: 1px solid var(--gold-soft); }
.details dt { font-size: .62rem; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-deep); }
.details dd { margin: 2px 0 0; font-size: 1rem; font-weight: 400; }
.details small { display: block; font-size: .76rem; font-weight: 300; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 575px) {
  .frame { inset: 6px; }
  .stage { left: 14px; right: 14px; }
  .corner { width: 104px; height: 104px; }
  .corner-bl, .corner-br { width: 90px; height: 90px; }
  .arch { padding-top: 42px; padding-left: 16px; padding-right: 16px; }
  .modal-body { padding: 24px 20px; }
}

@media (max-width: 479px) {
  .family-grid { grid-template-columns: 1fr; max-width: 330px; }
  .family-card { padding: 14px 12px 12px; border-radius: 40px 40px 16px 16px; }
  .family-card br { display: none; }
  .family-card p { margin-bottom: 4px; }
  .family-card h3 { margin-bottom: 4px; }
  #view-family .title { font-size: 1.6rem; }
  #view-family .sprig { margin-bottom: 6px; }
}

/* Short, wide screens (landscape phones): use the width */
@media (max-height: 560px) and (min-width: 620px) {
  :root { --nav-h: 52px; }
  .stage { top: 14px; }
  .bottom-nav { bottom: 12px; }
  .bottom-nav button { gap: 0; }
  .view .sprig, .card-bloom, .closing-bloom, .view .kicker { display: none; }
  .title { font-size: 1.5rem; margin-bottom: 10px; }
  .count-grid { grid-template-columns: 1fr 1fr; max-width: 720px; }
  .event-card { padding: 18px 10px 14px; border-radius: 60px 60px 18px 18px; }
  .event-day { font-size: 3rem; }
  .event-more { margin-top: 6px; }
  .envelope { --w: 250px; margin-top: 70px; margin-bottom: 14px; }
  .view-cover .arabic { font-size: 1.2rem; }
  .arch { width: min(100%, 600px); padding: 14px 22px; border-radius: 40px; }
  .arch .arabic { font-size: 1.15rem; line-height: 1.6; margin: 0; }
  .arch .small-copy { margin: 2px 0; line-height: 1.5; }
  .arch br { display: none; }
  .couple { display: flex; align-items: center; gap: 12px; }
  .couple-name { font-size: 1.9rem; }
  .couple-amp i { display: none; }
  .signature { margin-bottom: 8px; }
  .family-card { padding: 12px 12px 10px; border-radius: 36px 36px 16px 16px; }
  .modal-body { padding: 14px 24px 18px; }
  .modal-body .sprig { display: none; }
  .details { margin: 6px 0 12px; }
  .details > div { padding: 4px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
  .petal-layer { display: none; }
}
