/* ============================================================
   极简红囍 · 婚礼请柬
   移动端优先，375 ~ 430px 为基准，纯 CSS/SVG 装饰，离线可用
   ============================================================ */

:root {
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "TW-Kai", "Songti SC", serif;
  --song: "Songti SC", "STSong", "SimSun", "宋体", "Noto Serif CJK SC", serif;
  --serif: "Didot", "Bodoni MT", "Times New Roman", "Songti SC", "STSong", "SimSun", serif;
  --thin-en: "Optima", "Candara", "Didot", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --red: #b7251f;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

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

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

body {
  font-family: var(--sans);
  color: #333;
  background: #fdf4f3;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.font-kai { font-family: var(--kai); }
.font-serif { font-family: var(--serif); }

.app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100vh;
  height: 100svh;
  margin: 0 auto;
  background: #fdf4f3;
  box-shadow: 0 0 70px rgba(150, 95, 105, .12);
  overflow: hidden;
}

/* ==================== 封面 ==================== */

.cover {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 0;
  padding: clamp(28px, 6vh, 52px) 0;
  background:
    radial-gradient(120% 55% at 50% 108%, rgba(247, 193, 202, .38) 0%, rgba(247, 193, 202, 0) 68%),
    radial-gradient(90% 40% at 88% 30%, rgba(255, 255, 255, .6) 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, #fae8eb 0%, #fbeef0 42%, #fae7ea 100%);
  overflow: hidden;
}

/* 柔和光斑 */
.cover-bokeh {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(58px 58px at 10% 24%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 72%),
    radial-gradient(90px 90px at 82% 16%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 70%),
    radial-gradient(44px 44px at 72% 52%, rgba(255, 236, 240, .7), rgba(255, 236, 240, 0) 70%),
    radial-gradient(120px 120px at 26% 64%, rgba(255, 255, 255, .32), rgba(255, 255, 255, 0) 72%),
    radial-gradient(70px 70px at 6% 88%, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 72%);
  z-index: 0;
}

/* 封面点缀：细线星芒 / 小花瓣 / 光点 / 囍字印记 */
.deco {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.spark {
  position: absolute;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #dfa0ae;
  stroke-width: .9;
  opacity: .55;
  animation: sparkle 7s ease-in-out infinite;
}

.spark-a { left: 10%; top: 11%; }
.spark-b { right: 11%; top: 20%; width: 14px; height: 14px; opacity: .42; animation-delay: 1.4s; }
.spark-c { right: 7%; top: 46%; width: 12px; height: 12px; opacity: .38; animation-delay: 2.6s; }
.spark-d { left: 15%; bottom: 17%; width: 16px; height: 16px; opacity: .45; animation-delay: .8s; }

.petal {
  position: absolute;
  width: 7px;
  height: 10px;
  border-radius: 60% 0 60% 0;
  background: rgba(230, 158, 174, .4);
  animation: drift 9s ease-in-out infinite alternate;
}

.petal-a { left: 17%; top: 16%; transform: rotate(28deg); }
.petal-b { right: 15%; top: 30%; transform: rotate(-42deg) scale(.82); animation-delay: 1.2s; }
.petal-c { left: 11%; bottom: 23%; transform: rotate(66deg) scale(.9); animation-delay: 2.1s; }

.dot {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .72);
  animation: drift 8s ease-in-out infinite alternate;
}

.dot-a { width: 6px; height: 6px; left: 7%; top: 33%; }
.dot-b { width: 4px; height: 4px; right: 8%; top: 13%; animation-delay: 1.8s; }
.dot-c { width: 5px; height: 5px; right: 20%; bottom: 14%; animation-delay: 2.8s; }

.deco-seal {
  position: absolute;
  right: 9%;
  top: 6%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(183, 37, 31, .15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.deco-seal img {
  width: 50%;
  height: auto;
  opacity: .26;
}

@keyframes sparkle {
  0%, 100% { opacity: .55; }
  50% { opacity: .3; }
}

@keyframes drift {
  from { translate: 0 0; }
  to { translate: 2px -7px; }
}

/* ---------- 信封 ---------- */

.env-wrap {
  position: relative;
  z-index: 2;
  width: 85%;
  max-width: 368px;
  /* 左右 auto：不支持 flex 的内核里也能水平居中 */
  margin: 0 auto;
  animation: riseIn 1.05s .16s cubic-bezier(.22, .61, .36, 1) both;
}

/* 用百分比撑出信封高宽比，替代 aspect-ratio，旧内核同样生效 */
.env-wrap::before {
  content: "";
  display: block;
  padding-top: 127.72%;
}

.env-wrap::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -14px;
  height: 26px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(199, 116, 131, .34) 0%, rgba(199, 116, 131, 0) 72%);
  filter: blur(4px);
  z-index: 0;
}

/* 卡片容纳层：只裁掉信封下方的部分，向上可自由抽出 */
.card-clip {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
}

.ghost-card {
  position: absolute;
  top: 18%;
  left: 50%;
  width: 71.65%;
  height: 77.5%;
  transform: translateX(-50%) translateX(15px) rotate(2.2deg);
  background: linear-gradient(160deg, #fffefd 0%, #fff 60%, #fdf7f7 100%);
  border-radius: 10px;
  box-shadow: 0 16px 34px rgba(188, 112, 126, .16);
  z-index: 1;
}

.env-back {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 48%;
  border-radius: 9px;
  background: linear-gradient(180deg, #f7c8d0 0%, #f3b4be 60%, #efaab6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55);
  z-index: 1;
}

.env-lining {
  position: absolute;
  left: 1.8%;
  right: 1.8%;
  top: 45%;
  height: 21%;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #fff9f8 0%, #fdf3f2 55%, #fbecea 100%);
  box-shadow: inset 0 8px 14px rgba(190, 120, 130, .12);
  z-index: 2;
}

.env-card {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 71.65%;
  height: 77.5%;
  background: #fff;
  border-radius: 10px;
  box-shadow:
    0 18px 40px rgba(183, 105, 118, .18),
    0 2px 4px rgba(183, 105, 118, .08);
  z-index: 3;
  overflow: hidden;
}

.env-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9);
  pointer-events: none;
}

/* 卡片排版 */
.mini-xi {
  width: 45%;
  height: auto;
  margin: 8% 0 0 13%;
}

.mini-names {
  margin-top: 7%;
  transform: translateX(9%);
  text-align: center;
  font-family: var(--serif);
  font-size: 8px;
  font-size: clamp(7.6px, 2.05vw, 8.8px);
  letter-spacing: 0;
  line-height: 1.4;
  color: #1c1c1c;
  white-space: nowrap;
}

.mini-names em {
  font-style: italic;
  font-weight: 700;
  font-size: 1.28em;
  line-height: normal;
  margin: 0 .22em;
  vertical-align: -.04em;
}

.mini-ms { font-size: .95em; }

.mini-en {
  margin-top: 2.4%;
  transform: translateX(9%);
  text-align: center;
  font-family: var(--thin-en);
  font-size: 7px;
  font-size: clamp(6px, 1.75vw, 7.4px);
  font-weight: 300;
  letter-spacing: .18em;
  color: #8b8b8b;
  white-space: nowrap;
}

.mini-rule {
  width: 57%;
  height: 1px;
  margin: 5% 0 0 27.5%;
  background: #b23a33;
  opacity: .9;
}

.mini-text {
  margin: 4.8% 19% 0 19.5%;
  font-family: var(--kai);
  font-size: 9px;
  font-size: clamp(8.2px, 2.35vw, 9.6px);
  line-height: 1.55;
  letter-spacing: .04em;
  color: #4c4c4c;
  white-space: nowrap;
}

/* 口袋与折角 */
.env-pocket {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 48%;
  -webkit-clip-path: polygon(0 0, 50% 46.6%, 100% 0, 100% 100%, 0 100%);
  clip-path: polygon(0 0, 50% 46.6%, 100% 0, 100% 100%, 0 100%);
  background:
    linear-gradient(112deg, rgba(255, 255, 255, .2) 0%, rgba(255, 255, 255, 0) 38%),
    linear-gradient(115deg, #f5bec8 0%, #efa8b3 42%, #f4b9c2 58%, #eca2af 100%);
  z-index: 4;
}

.env-pocket::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  background-image: var(--grain);
  background-size: 160px 160px;
  mix-blend-mode: soft-light;
  opacity: .5;
}

.env-flap {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 48%;
  -webkit-clip-path: polygon(0 100%, 50% 46.6%, 100% 100%);
  clip-path: polygon(0 100%, 50% 46.6%, 100% 100%);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .4) 0%, rgba(255, 255, 255, 0) 26%),
    linear-gradient(180deg, #fbe1e5 0%, #f6c8d0 42%, #eeabb7 100%);
  box-shadow: inset 0 -20px 30px rgba(196, 113, 128, .13);
  z-index: 5;
}

.env-flap::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  background-image: var(--grain);
  background-size: 160px 160px;
  mix-blend-mode: soft-light;
  opacity: .45;
}

.env-crease {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 48%;
  z-index: 6;
  pointer-events: none;
}

/* 打开按钮 */
.btn-make {
  position: absolute;
  left: 50%;
  top: 77.4%;
  transform: translateX(-50%);
  width: 49.5%;
  max-width: 214px;
  height: 40px;
  height: clamp(35px, 9.6vw, 41px);
  border-radius: 999px;
  background: linear-gradient(180deg, #e46d76 0%, #d95461 100%);
  color: #fff;
  font-family: var(--kai);
  font-size: 16px;
  font-size: clamp(15px, 4.4vw, 18px);
  letter-spacing: .18em;
  text-indent: .18em;
  box-shadow:
    0 8px 18px rgba(198, 74, 88, .32),
    inset 0 1px 0 rgba(255, 255, 255, .22);
  z-index: 8;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .2s ease, box-shadow .2s ease;
}

.btn-make:active {
  transform: translateX(-50%) scale(.98);
  box-shadow: 0 4px 10px rgba(198, 74, 88, .28);
}

/* ---------- 打开转场 ---------- */
.env-card,
.ghost-card {
  transition: transform .95s cubic-bezier(.4, .02, .2, 1), box-shadow .9s ease;
}

.env-flap {
  transition: transform .8s cubic-bezier(.4, .02, .2, 1);
}

.cover.is-opening .env-card {
  animation: none;
  transform: translate(-50%, -22%) scale(1.045);
  box-shadow:
    0 34px 60px rgba(160, 90, 105, .26),
    0 2px 6px rgba(160, 90, 105, .1);
}

.cover.is-opening .ghost-card {
  transform: translateX(-50%) translateX(15px) translateY(-9%) rotate(2.2deg);
}

.cover.is-opening .env-flap {
  transform: translateY(2.2%);
}

.cover.is-fading {
  opacity: 0;
  transition: opacity .95s cubic-bezier(.45, .05, .55, .95);
}

.invite.is-entering {
  animation: inviteIn 1.05s cubic-bezier(.33, .02, .25, 1) both;
}

@keyframes inviteIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ==================== 长页正文 ==================== */

.invite {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #f9dce1 0px, #fbebeb 150px, #fdf4f3 300px, #fdf4f3 100%);
  padding: 34px 0;
  padding: clamp(26px, 4.6vh, 48px) 0;
}

.cover.is-gone { display: none; }
body.is-invite .invite { display: block; display: flex; }

.xi-giant {
  width: 58%;
  max-width: 260px;
  height: auto;
  /* 自动上边距：内容不满一屏时整体居中，内容超高时归零、可正常滚动 */
  margin: auto 0 0 6%;
  user-select: none;
  pointer-events: none;
  margin-bottom: 30px;
}

.watermark {
  position: absolute;
  left: 50%;
  bottom: 30px;
  bottom: clamp(18px, 4vh, 46px);
  transform: translateX(-50%);
  width: 62%;
  max-width: 282px;
  opacity: .03;
  pointer-events: none;
  z-index: 0;
  user-select: none;
}

.names {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  margin-top: clamp(18px, 3.1vh, 28px);
  padding-left: 25%;
  text-align: center;
  font-family: var(--serif);
  font-size: 16.5px;
  font-size: clamp(15px, 4.3vw, 18.5px);
  letter-spacing: .04em;
  color: #191919;
  white-space: nowrap;
}

.names em {
  font-style: italic;
  font-weight: 700;
  font-size: 1.5em;
  line-height: 0;
  vertical-align: -0.1em;
  margin: 0 .1em;
}

.en-line {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  margin-top: clamp(9px, 1.4vh, 13px);
  padding-left: 25%;
  text-align: center;
  font-family: var(--thin-en);
  font-size: 11px;
  font-size: clamp(9.5px, 2.75vw, 12px);
  font-weight: 300;
  letter-spacing: .26em;
  color: #808080;
  white-space: nowrap;
}

.rule {
  position: relative;
  z-index: 1;
  height: 1.5px;
  margin: 24px 9.6% 0;
  margin: clamp(20px, 3.2vh, 29px) 9.6% 0;
  background: linear-gradient(90deg, #b23a33 0%, #b53a33 50%, #b23a33 100%);
  opacity: .95;
}

.invite-body {
  position: relative;
  z-index: 1;
  margin-top: 28px;
  margin-top: clamp(24px, 4vh, 34px);
  /* 自动下边距，与囍字的 auto 上边距配合实现整体纵向居中 */
  margin-bottom: auto;
  padding: 0 8%;
  font-family: var(--kai);
  font-size: 16px;
  font-size: clamp(15px, 4.1vw, 17px);
  line-height: 1.58;
  letter-spacing: .1em;
  color: #494949;
}

.invite-body p { font-weight: 400; }

.invite-body .tight {
  line-height: 1.7;
  letter-spacing: .14em;
}

.couple {
  margin-top: 26px;
  margin-top: clamp(22px, 3.6vh, 32px);
  padding-left: 2.1em;
}

.couple p {
  line-height: 1.85;
  letter-spacing: .12em;
}

.info {
  margin-top: 30px;
  margin-top: clamp(26px, 4.4vh, 40px);
}

.info p {
  line-height: 1.6;
  letter-spacing: .08em;
  margin-bottom: 10px;
  margin-bottom: clamp(9px, 1.6vh, 14px);
  white-space: nowrap;
}

.info p:last-child { margin-bottom: 0; }

/* ==================== 固定 UI ==================== */

.fixed-ui {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 40;
  pointer-events: none;
}

.map-btn {
  position: absolute;
  right: 17px;
  bottom: 22px;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  pointer-events: auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: rgba(128, 123, 123, .56);
  color: #fff;
  font-size: 9px;
  letter-spacing: .04em;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(90, 70, 74, .18);
  transition: transform .18s ease, opacity .3s ease, visibility .3s;
  opacity: 0;
  visibility: hidden;
}

.map-btn.is-on {
  opacity: 1;
  visibility: visible;
}

.map-btn:active { transform: scale(.94); }

/* ==================== 动效 ==================== */

/* 默认可见；只有 JS 正常运行时（<html class="js">）才把待入场内容藏起来，
   这样脚本报错或旧内核里也不会出现整页空白 */
.reveal {
  transition: opacity .9s ease, transform .9s cubic-bezier(.22, .61, .36, 1);
}

html.js .reveal {
  opacity: 0;
  transform: translateY(16px);
}

html.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

/* 不支持毛玻璃时用更实的底色，保证按钮文字可读 */
@supports not (backdrop-filter: blur(6px)) {
  .map-btn { background: rgba(128, 123, 123, .78); }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html.js .reveal { opacity: 1; transform: none; }
}

@media (max-width: 350px) {
  .invite-body { letter-spacing: .06em; font-size: 14.5px; }
  .names { font-size: 14px; }
}
