/* ═══════════════════════════════════════════════
   密函 · Sealed Letter
   象牙纸面 / 墨色衬线 / 火漆封缄
   ═══════════════════════════════════════════════ */

:root {
  --bg: #ece2cc;
  --bg-deep: #ddd0b2;
  --paper: #f8f2e3;
  --paper-hi: #fdf9ee;
  --ink: #2b241a;
  --ink-soft: #7a6b50;
  --ink-faint: #a4977b;
  --hairline: rgba(43, 36, 26, 0.16);
  --wax: #8e2f26;
  --wax-deep: #641d16;
  --wax-hi: #b14a3c;
  --gold: #a07c2c;
  --gold-soft: #c8ab6b;
  --serif-cn: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --serif-en: "Cormorant Garamond", "Noto Serif SC", "Songti SC", serif;
  --shadow-lg: 0 30px 60px -18px rgba(43, 36, 26, 0.35);
  --shadow-md: 0 14px 34px -14px rgba(43, 36, 26, 0.3);
}

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

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

body {
  min-height: 100vh;
  font-family: var(--serif-cn);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--bg) 0%, var(--bg-deep) 78%, #cfbf9d 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* 纸张噪点 */
.grain {
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 60;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.055'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: rgba(142, 47, 38, 0.22); }

/* ── 页眉 / 页脚 ─────────────────────────── */

.site-head {
  width: min(680px, 92vw);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 28px 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-seal { width: 34px; height: 34px; color: var(--wax); }

.brand-word {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.35em;
}
.brand-word em {
  font-family: var(--serif-en);
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-left: 10px;
}

.site-tag {
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--ink-faint);
}

.site-foot {
  padding: 26px 20px 34px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  text-align: center;
}

/* ── 舞台与视图 ─────────────────────────── */

.stage {
  flex: 1;
  width: min(680px, 92vw);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0 20px;
}

.view { display: flex; flex-direction: column; align-items: center; text-align: center; }
.view[hidden] { display: none; }

/* 入场：错落浮现 */
.view > * {
  animation: rise 0.85s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}
.view > *:nth-child(2) { animation-delay: 0.08s; }
.view > *:nth-child(3) { animation-delay: 0.16s; }
.view > *:nth-child(4) { animation-delay: 0.24s; }
.view > *:nth-child(5) { animation-delay: 0.32s; }

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

.ornament { color: var(--gold); font-size: 15px; letter-spacing: 1em; }

.page-title {
  margin-top: 14px;
  font-size: clamp(26px, 4.6vw, 38px);
  font-weight: 600;
  letter-spacing: 0.14em;
}

.page-sub {
  margin-top: 14px;
  font-size: 14.5px;
  line-height: 2;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* ── 纸面卡片（表单） ─────────────────────── */

.paper-card {
  margin-top: 34px;
  width: min(520px, 100%);
  background:
    linear-gradient(175deg, var(--paper-hi), var(--paper) 55%, #f1e8d3);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  padding: 34px 34px 30px;
  text-align: left;
  position: relative;
}
.paper-card::before {
  /* 顶部装订线 */
  content: "";
  position: absolute;
  top: 10px; left: 14px; right: 14px;
  border-top: 1px solid var(--hairline);
  opacity: 0.5;
}

.field { display: block; margin-bottom: 24px; }

.field-label {
  display: block;
  font-size: 12.5px;
  letter-spacing: 0.32em;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

textarea, input[type="password"], input[type="text"] {
  width: 100%;
  font-family: var(--serif-cn);
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 8px 2px 10px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  border-radius: 0;
}
textarea:focus, input:focus {
  border-bottom-color: var(--gold);
  box-shadow: 0 1px 0 var(--gold-soft);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 34px;
  /* 信纸横线 */
  background-image: repeating-linear-gradient(
    transparent, transparent 33px, rgba(43, 36, 26, 0.09) 33px, rgba(43, 36, 26, 0.09) 34px
  );
  background-attachment: local;
  border-bottom: none;
}

.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 44px; }

.pw-toggle {
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-58%);
  font-family: var(--serif-cn);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  transition: color 0.25s;
}
.pw-toggle:hover { color: var(--ink); }

/* 分段选项 */
.segments { display: flex; flex-wrap: wrap; gap: 8px; }

.seg {
  font-family: var(--serif-cn);
  font-size: 13.5px;
  letter-spacing: 0.1em;
  padding: 8px 18px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.28s cubic-bezier(0.3, 0.9, 0.3, 1);
}
.seg:hover { border-color: var(--ink-soft); color: var(--ink); transform: translateY(-1px); }
.seg.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  box-shadow: 0 6px 14px -6px rgba(43, 36, 26, 0.5);
}

.form-error {
  min-height: 20px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--wax);
  margin-bottom: 6px;
}

/* ── 火漆按钮 ─────────────────────────── */

.btn-seal {
  width: 100%;
  margin-top: 8px;
  font-family: var(--serif-cn);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: #f6ecdc;
  background:
    radial-gradient(120% 160% at 30% 20%, var(--wax-hi), var(--wax) 45%, var(--wax-deep) 100%);
  border: none;
  border-radius: 999px;
  padding: 17px 20px;
  cursor: pointer;
  box-shadow: 0 14px 28px -10px rgba(142, 47, 38, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.25);
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.4, 1), box-shadow 0.3s, filter 0.3s;
}
.btn-seal:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 20px 34px -12px rgba(142, 47, 38, 0.6), inset 0 1px 1px rgba(255,255,255,0.3); }
.btn-seal:active { transform: translateY(0) scale(0.985); }
.btn-seal:disabled { cursor: wait; filter: saturate(0.6) brightness(0.92); transform: none; }

.btn-seal--small { width: auto; padding: 12px 44px; margin-top: 4px; }

/* ── 链接页 ─────────────────────────── */

.seal-stamp {
  width: 84px; height: 84px;
  color: var(--wax);
  animation: stamp 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both 0.15s;
}
@keyframes stamp {
  0% { opacity: 0; transform: scale(1.7) rotate(-14deg); }
  60% { opacity: 1; transform: scale(0.94) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(-3deg); }
}
.seal-stamp svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 10px rgba(142, 47, 38, 0.35)); }

.link-box {
  margin-top: 30px;
  width: min(520px, 100%);
  background: var(--paper-hi);
  border: 1px dashed rgba(43, 36, 26, 0.35);
  border-radius: 4px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
}

.link-url {
  flex: 1;
  font-family: var(--serif-en);
  font-size: 15.5px;
  letter-spacing: 0.03em;
  color: var(--ink);
  word-break: break-all;
  text-align: left;
}

.btn-copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif-cn);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: all 0.3s;
}
.btn-copy:hover { background: var(--ink); color: var(--paper); }
.btn-copy.is-copied { background: var(--gold); border-color: var(--gold); color: #fff; }
.icon-copy { width: 15px; height: 15px; }

.fine-print {
  margin-top: 18px;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.link-again {
  margin-top: 26px;
  font-size: 13.5px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.25s, border-color 0.25s;
}
.link-again:hover { color: var(--wax); border-bottom-color: var(--wax); }

/* ── 信封 ─────────────────────────── */

.sealed-eyebrow {
  font-size: 12.5px;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--gold);
}

.envelope-scene {
  margin-top: 44px;
  perspective: 1400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.envelope {
  position: relative;
  width: min(360px, 86vw);
  aspect-ratio: 36 / 23;
  transform-style: preserve-3d;
  filter: drop-shadow(0 34px 34px rgba(43, 36, 26, 0.28));
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.9s, filter 0.9s;
}

.env-back {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, #e6d9ba, #dcccA4 70%, #d3c294);
  border-radius: 5px;
}

.env-letter {
  position: absolute;
  left: 5%; top: 5%;
  width: 90%; height: 92%;
  background: linear-gradient(180deg, var(--paper-hi), var(--paper));
  border: 1px solid rgba(43, 36, 26, 0.1);
  border-radius: 3px;
  box-shadow: 0 4px 14px rgba(43, 36, 26, 0.12);
  transform: rotate(-0.6deg);
  transition: transform 1.1s cubic-bezier(0.3, 0.9, 0.25, 1) 1.05s;
  z-index: 2;
}
.env-letter-lines {
  position: absolute; inset: 18% 12% 0;
  display: flex; flex-direction: column; gap: 14px;
}
.env-letter-lines i {
  height: 2px;
  background: rgba(43, 36, 26, 0.14);
  border-radius: 2px;
}
.env-letter-lines i:nth-child(2) { width: 88%; }
.env-letter-lines i:nth-child(3) { width: 94%; }
.env-letter-lines i:nth-child(4) { width: 62%; }

.env-pocket {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #f2e7ca, #e9dcba 60%, #dfcfa5);
  clip-path: polygon(0 0, 50% 47%, 100% 0, 100% 100%, 0 100%);
  border-radius: 5px;
  z-index: 3;
}
.env-pocket::after {
  /* 折痕阴影 */
  content: "";
  position: absolute; inset: 0;
  clip-path: polygon(0 0, 50% 47%, 100% 0, 100% 3%, 50% 50%, 0 3%);
  background: rgba(43, 36, 26, 0.08);
}

.env-flap {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 56%;
  background: linear-gradient(200deg, #ead9b0, #dcc998 65%, #d0bb85);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  z-index: 4;
  border-radius: 5px 5px 0 0;
}

.env-seal {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -34%);
  width: 72px; height: 72px;
  border: none;
  cursor: pointer;
  border-radius: 48% 52% 51% 49% / 54% 47% 53% 46%;
  background:
    radial-gradient(circle at 34% 30%, var(--wax-hi), var(--wax) 46%, var(--wax-deep) 88%);
  box-shadow:
    0 10px 22px -6px rgba(100, 29, 22, 0.65),
    inset 0 2px 3px rgba(255, 255, 255, 0.28),
    inset 0 -3px 6px rgba(0, 0, 0, 0.25);
  z-index: 5;
  display: grid;
  place-items: center;
  transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.4, 1), filter 0.3s;
  animation: sealPulse 2.6s ease-in-out infinite;
}
@keyframes sealPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
.env-seal:hover { transform: translate(-50%, -34%) scale(1.07) rotate(-2deg); }

.seal-ring {
  position: absolute; inset: 9px;
  border: 1.5px solid rgba(246, 236, 220, 0.55);
  border-radius: 50% 48% 51% 49% / 47% 53% 47% 53%;
}
.seal-char {
  font-size: 26px;
  font-weight: 600;
  color: #f6ecdc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.seal-hint {
  margin-top: 30px;
  font-size: 13px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: var(--ink-soft);
  animation: hintBreathe 2.6s ease-in-out infinite;
}
@keyframes hintBreathe {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* 拆启动画序列 */
.envelope.is-opening .env-seal {
  animation: sealCrack 0.55s cubic-bezier(0.5, 0, 0.8, 0.4) forwards;
}
@keyframes sealCrack {
  0% { transform: translate(-50%, -34%) scale(1); opacity: 1; }
  35% { transform: translate(-50%, -34%) scale(1.18) rotate(5deg); opacity: 1; filter: brightness(1.25); }
  100% { transform: translate(-50%, -30%) scale(0.4) rotate(-18deg); opacity: 0; filter: brightness(0.9); }
}
.envelope.is-opening .env-flap {
  animation: flapOpen 1.05s cubic-bezier(0.55, 0, 0.35, 1) 0.4s forwards;
}
@keyframes flapOpen {
  0% { transform: rotateX(0deg); z-index: 4; }
  49.9% { z-index: 4; }
  50% { z-index: 1; }
  100% { transform: rotateX(180deg); z-index: 1; }
}
.envelope.is-opening .env-letter {
  transform: rotate(0deg) translateY(-64%);
}
.seal-hint.is-hidden { animation: none; opacity: 0; transition: opacity 0.4s; }

.envelope.is-departed {
  transform: translateY(46px) scale(0.92) rotateX(8deg);
  opacity: 0;
  filter: drop-shadow(0 10px 18px rgba(43, 36, 26, 0.2)) blur(2px);
}

/* ── 口令面板 ─────────────────────────── */

.pw-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(43, 36, 26, 0.34);
  backdrop-filter: blur(7px) saturate(0.85);
  -webkit-backdrop-filter: blur(7px) saturate(0.85);
  animation: sheetFade 0.4s ease both;
}
.pw-sheet[hidden] { display: none; }
@keyframes sheetFade { from { opacity: 0; } to { opacity: 1; } }

.pw-card {
  width: min(400px, 88vw);
  background: linear-gradient(175deg, var(--paper-hi), var(--paper) 60%, #f0e6d0);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  box-shadow: var(--shadow-lg);
  padding: 32px 32px 28px;
  text-align: center;
  animation: sheetUp 0.55s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}
@keyframes sheetUp {
  from { opacity: 0; transform: translateY(34px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.pw-card.is-shaking { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.pw-title {
  font-size: 15px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--ink-soft);
  margin-bottom: 22px;
}
.pw-actions { display: flex; justify-content: center; margin-top: 10px; }

/* ── 信纸页 ─────────────────────────── */

.letter-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.countdown {
  position: relative;
  width: 58px; height: 58px;
}
.countdown svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.cd-track {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 2;
}
.cd-bar {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 0;
}
.cd-num {
  position: absolute; inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif-en);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.letter-paper {
  margin-top: 26px;
  width: min(560px, 100%);
  background:
    linear-gradient(178deg, var(--paper-hi), var(--paper) 50%, #f2e9d4);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  padding: 46px 48px 34px;
  position: relative;
  animation: letterIn 1s cubic-bezier(0.22, 1, 0.3, 1) both;
}
@keyframes letterIn {
  from { opacity: 0; transform: translateY(-30px) rotate(-1.2deg) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.letter-paper::before, .letter-paper::after {
  /* 双层纸角 */
  content: "";
  position: absolute;
  width: 26px; height: 26px;
  border-color: var(--gold-soft);
  border-style: solid;
  opacity: 0.65;
}
.letter-paper::before { top: 10px; left: 10px; border-width: 1px 0 0 1px; }
.letter-paper::after { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; }

.letter-body { transition: filter 0.4s linear, opacity 0.4s linear, transform 0.4s linear; }

.letter-text {
  font-size: 17.5px;
  line-height: 2.15;
  letter-spacing: 0.05em;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.letter-foot {
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 12.5px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  text-align: right;
}

.burn-note {
  margin-top: 24px;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--wax);
}

/* 余烬粒子 */
.ember {
  position: fixed;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, #e8a34c, var(--wax) 70%);
  box-shadow: 0 0 8px 2px rgba(232, 140, 60, 0.55);
  pointer-events: none;
  z-index: 55;
  animation: emberRise var(--dur, 1.8s) cubic-bezier(0.25, 0.6, 0.35, 1) forwards;
}
@keyframes emberRise {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  70% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(var(--dx, 0px), var(--dy, -140px)) scale(0.25); }
}

/* ── 灰烬页 ─────────────────────────── */

.ash-seal {
  width: 88px; height: 88px;
  color: var(--ink-faint);
  animation: ashIn 1.4s ease both;
  filter: blur(0.4px);
}
@keyframes ashIn {
  from { opacity: 0; transform: scale(1.25) rotate(10deg); filter: blur(3px); }
  to { opacity: 0.8; transform: none; filter: blur(0.4px); }
}
.ash-seal svg { width: 100%; height: 100%; }

/* ── 响应式 ─────────────────────────── */

@media (max-width: 560px) {
  .site-head { padding-top: 20px; }
  .site-tag { display: none; }
  .paper-card { padding: 26px 22px 24px; }
  .letter-paper { padding: 36px 26px 26px; }
  .brand-word { font-size: 18px; }
  .link-box { flex-direction: column; align-items: stretch; }
  .btn-copy { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
