/* ============================================================
   寄语页 · 信笺 / 夜海 / 墙
   与 style.css 一起加载，只放这一页用到的样式
   ============================================================ */

:root {
  /* 网友写的字不在裁剪过的字体里，整段换成系统字体，免得同一句话里字形忽大忽小 */
  --ugc: Georgia, "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
}

/* ---------- 封面 ---------- */
.m-hero {
  position: relative; height: 82vh; height: 82svh; min-height: 560px; overflow: hidden;
  background:
    radial-gradient(110% 70% at 78% 16%, rgba(160, 182, 196, .14), transparent 60%),
    linear-gradient(180deg, #08111a 0%, #0d1821 52%, #0f1e2b 100%);
  color: var(--foam);
}
.m-title {
  position: absolute; right: clamp(24px, 14vw, 240px); top: 50%; transform: translateY(-56%);
  margin: 0; font-family: var(--brush); font-weight: 400; font-size: min(27vh, 24vw); line-height: .98;
  display: flex; flex-direction: column; align-items: center; color: var(--foam);
  text-shadow: 0 0 60px rgba(8, 17, 26, .9);
}
.m-title > span { display: block; animation: ink-in 2.2s var(--ease) both; }
.m-title > span:nth-child(2) { animation-delay: .45s; }
.m-title .seal { position: absolute; left: -2.4em; bottom: .2em; width: 1.9em; height: 1.9em; font-size: clamp(13px, 1.1vw, 17px); animation: stamp .5s 2s cubic-bezier(.3, 1.6, .5, 1) both; }
.m-lead {
  position: absolute; left: clamp(24px, 7vw, 120px); bottom: clamp(80px, 13vh, 140px); max-width: 27em;
  font-size: clamp(15px, 1.1vw, 18px); line-height: 2; color: var(--foam-2); animation: fade 1.8s 1.6s both;
}
.m-lead h1 { margin: 0 0 .5em; font-size: clamp(30px, 3.2vw, 46px); line-height: 1.25; font-weight: 900; letter-spacing: .1em; color: var(--foam); }
.m-lead .eyebrow { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .3em; color: var(--foam-3); margin-bottom: 1.4em; }
.m-lead p { margin: 0 0 .6em; }
.m-tally { font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em; color: var(--foam-3); min-height: 2em; }
.m-tally b { font-family: var(--latin); font-size: 2em; font-weight: 500; color: var(--foam); letter-spacing: 0; margin-right: .2em; vertical-align: -.12em; }
.m-hero .hero-foot { animation: fade 1.6s 2.2s both; }

/* ---------- 写一句 ---------- */
.m-write { padding: clamp(80px, 12vh, 150px) 0; overflow-x: clip; }
.m-write-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.3fr); gap: clamp(40px, 7vw, 120px); align-items: start; }
.m-rules { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.m-rules li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr); padding: 14px 0; border-bottom: 1px solid var(--rule); font-size: 14.5px; line-height: 1.85; color: var(--ink-2); }
.m-rules li b { color: var(--ink); font-weight: 600; }
.m-rules .no { font-family: var(--latin); font-style: italic; color: var(--cinnabar); font-size: 16px; }

/* 信笺：朱丝栏，横线跟着文字一起滚动 */
.letter {
  --line: 2.1em;
  position: relative; background: #f6f1e6; padding: clamp(26px, 3.4vw, 46px) clamp(22px, 3.2vw, 48px) clamp(24px, 3vw, 40px);
  border: 1px solid rgba(192, 67, 47, .55); outline: 1px solid rgba(192, 67, 47, .55); outline-offset: 5px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 26px 60px -30px rgba(26, 27, 30, .35);
  margin: 6px;
}
.letter::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(120% 80% at 0% 0%, rgba(255, 255, 255, .7), transparent 55%), radial-gradient(90% 60% at 100% 100%, rgba(217, 207, 188, .5), transparent 60%);
}
.letter > * { position: relative; }
.letter-to { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 .6em; }
.letter-to span { font-size: clamp(20px, 1.7vw, 25px); font-weight: 600; letter-spacing: .14em; }
.letter-to small { font-family: var(--mono); font-size: 10.5px; letter-spacing: .2em; color: var(--ink-3); }
:is(.letter, .slip) textarea, :is(.letter, .slip) input[type="text"] {
  width: 100%; border: 0; border-radius: 0; background: transparent; color: var(--ink); font: inherit; outline: none;
  font-family: var(--ugc); letter-spacing: .04em;
}
:is(.letter, .slip) textarea {
  display: block; resize: vertical; min-height: calc(var(--line) * 7); max-height: 60vh; font-size: clamp(17px, 1.25vw, 19px); line-height: var(--line);
  padding: 0 .1em; background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line) - 1px), rgba(192, 67, 47, .32) calc(var(--line) - 1px), rgba(192, 67, 47, .32) var(--line));
  background-attachment: local;
}
:is(.letter, .slip) :is(textarea, input)::placeholder { color: rgba(107, 102, 93, .62); font-family: var(--serif); }
.letter-sign { display: grid; grid-template-columns: auto minmax(0, 15em) auto; align-items: end; justify-content: end; gap: 14px; margin-top: 1.6em; }
.letter-sign label { font-size: 15px; letter-spacing: .2em; color: var(--ink-2); padding-bottom: 6px; }
.letter-sign input[type="text"] { font-size: 18px; padding: 4px 2px 5px; border-bottom: 1px solid rgba(26, 27, 30, .45); transition: border-color .3s; }
.letter-sign input[type="text"]:focus { border-bottom-color: var(--cinnabar); }
:is(.letter, .slip) textarea:focus-visible { box-shadow: -10px 0 0 -8px var(--cinnabar); }
.letter-date { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--ink-3); padding-bottom: 8px; white-space: nowrap; }
.counter { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--ink-3); text-align: right; margin-top: 6px; }
.counter.is-near { color: var(--cinnabar); }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.send-row { display: flex; align-items: center; gap: clamp(18px, 2.4vw, 30px); margin-top: clamp(30px, 4vh, 44px); flex-wrap: wrap; }
.send-btn {
  width: 104px; height: 104px; flex: none; border: 0; border-radius: 50%; cursor: pointer; position: relative;
  background: var(--cinnabar); color: #f6efe2; font-family: var(--brush); font-size: 58px; line-height: 1;
  box-shadow: inset 0 0 0 4px var(--cinnabar), inset 0 0 0 6px rgba(246, 239, 226, .75), 0 18px 40px -12px rgba(155, 50, 35, .55);
  transition: transform .2s var(--ease), opacity .3s; filter: url(#rough);
}
.send-btn:hover { transform: rotate(-5deg) scale(1.04); }
.send-btn:active { transform: scale(.94); }
.send-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 6px; }
.send-btn[disabled] { cursor: progress; opacity: .6; transform: none; }
.send-btn.busy span { animation: breathe 1.2s infinite var(--ease); }
@keyframes breathe { 50% { opacity: .35; } }
.status { flex: 1 1 14em; min-height: 1.9em; font-size: 15px; line-height: 1.8; color: var(--ink-2); }
.status.err { color: var(--cinnabar-deep); }
:is(.letter, .slip) textarea[aria-invalid="true"] { box-shadow: -10px 0 0 -8px var(--cinnabar); }
.letter-sign input[aria-invalid="true"] { border-bottom-color: var(--cinnabar); border-bottom-width: 2px; }

/* 寄出之后：信笺盖章（反馈页的勘误单 .slip 共用） */
.letter.sent .letter-body { opacity: .38; transition: opacity .6s var(--ease); }
:is(.letter, .slip) .postmark {
  position: absolute; right: clamp(18px, 4vw, 56px); top: clamp(28px, 6vw, 70px); z-index: 2; pointer-events: none;
  width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; text-align: center;
  border: 3px double var(--cinnabar); color: var(--cinnabar); font-family: var(--brush); font-size: 46px; line-height: 1;
  opacity: 0; transform: scale(1.7) rotate(-18deg); filter: url(#rough);
}
:is(.letter, .slip) .postmark .brush { display: block; }
:is(.letter, .slip) .postmark small { display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: .18em; margin-top: 6px; }
:is(.letter, .slip).sent .postmark { animation: postmark .55s cubic-bezier(.3, 1.6, .5, 1) forwards; }
@keyframes postmark { to { opacity: .92; transform: scale(1) rotate(-12deg); } }
.again { display: none; border: 1px solid var(--rule); background: transparent; padding: 7px 18px; border-radius: 999px; cursor: pointer; font-size: 14px; letter-spacing: .14em; color: var(--ink-2); transition: all .25s; }
.again:hover { border-color: var(--ink); color: var(--ink); }
:is(.letter, .slip).sent .again { display: inline-block; }
:is(.letter, .slip).sent .send-btn { display: none; }

/* ---------- 寄语墙 ---------- */
.m-wall { background: linear-gradient(180deg, #0d1821 0%, #0b151d 100%); color: var(--foam); padding: clamp(90px, 13vh, 160px) 0 0; overflow: hidden; }
.m-wall .ch-num { color: var(--ember); }
.wall-note { max-width: 36em; color: var(--foam-2); margin-top: -1em; margin-bottom: clamp(36px, 6vh, 64px); }
.notes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: clamp(18px, 2vw, 28px); }
.note {
  position: relative; display: flex; flex-direction: column; background: #f3ede1; color: var(--ink); padding: 26px 24px 20px; border-radius: 2px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 22px 40px -22px rgba(0, 0, 0, .7);
  transform: rotate(var(--tilt, 0deg)); transition: transform .5s var(--ease), box-shadow .5s var(--ease);
  opacity: 0; animation: drift-in .9s var(--ease) forwards; animation-delay: var(--d, 0s);
}
.note:hover { transform: rotate(0deg) translateY(-4px); box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 30px 50px -22px rgba(0, 0, 0, .8); }
@keyframes drift-in { from { opacity: 0; transform: translateY(24px) rotate(var(--tilt, 0deg)); } to { opacity: 1; transform: rotate(var(--tilt, 0deg)); } }
.note::before { content: ""; position: absolute; left: 24px; right: 24px; top: 12px; height: 2px; background: linear-gradient(90deg, var(--cinnabar) 0 22px, transparent 22px); opacity: .85; }
.note-body { margin: 0 0 1em; font-family: var(--ugc); font-size: 16.5px; line-height: 1.9; letter-spacing: .03em; white-space: pre-line; overflow-wrap: anywhere; }
.note-sign { margin: auto 0 0; padding-top: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-top: 1px solid rgba(26, 27, 30, .1); }
.note-name { font-family: var(--ugc); font-weight: 600; font-size: 15px; letter-spacing: .06em; overflow-wrap: anywhere; }
.note-name::before { content: "—— "; color: var(--ink-3); font-weight: 400; }
.note-date { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--ink-3); white-space: nowrap; }
.note-no { position: absolute; right: 18px; top: 8px; font-family: var(--latin); font-style: italic; font-size: 13px; color: var(--ink-3); }
.note.mine { background: transparent; color: var(--foam); border: 1px dashed rgba(235, 230, 216, .4); box-shadow: none; }
.note.mine .note-sign { border-top-color: var(--rule-d); }
.note.mine .note-date, .note.mine .note-name::before { color: var(--foam-3); }
.note.mine::before { background: linear-gradient(90deg, var(--ember) 0 22px, transparent 22px); }
.note .pending { position: absolute; right: 14px; top: 8px; font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--ember); }

.wall-empty { padding: clamp(40px, 8vh, 90px) 0; text-align: center; color: var(--foam-2); }
.wall-empty .brush { display: block; font-size: clamp(90px, 12vw, 170px); line-height: 1; color: rgba(235, 230, 216, .16); margin-bottom: .1em; }
.wall-empty a { color: var(--foam); }
.wall-error { margin: 0; padding: clamp(30px, 6vh, 60px) 0 0; text-align: center; color: var(--foam-2); }
.m-wall [hidden] { display: none; }
.wall-more { display: flex; justify-content: center; margin-top: clamp(40px, 6vh, 64px); }
.wall-more button { border: 1px solid var(--rule-d); background: transparent; color: var(--foam-2); padding: 9px 26px; border-radius: 999px; cursor: pointer; font-size: 14px; letter-spacing: .16em; transition: all .25s; }
.wall-more button:hover { color: var(--foam); border-color: var(--foam-2); }
.wall-more button[disabled] { opacity: .5; cursor: progress; }
.m-wall .footer { margin-top: clamp(90px, 13vh, 150px); }

/* English edition */
html[lang="en"] .m-lead { line-height: 1.62; max-width: 25em; }
html[lang="en"] .m-lead h1 { font-family: var(--latin); font-weight: 600; font-size: clamp(40px, 4.2vw, 62px); line-height: 1.02; letter-spacing: -.005em; }
html[lang="en"] .m-rules li { font-size: 15.5px; line-height: 1.55; }
html[lang="en"] .m-rules li b { font-weight: 600; }
html[lang="en"] .letter-to span { font-family: var(--latin); font-style: italic; font-weight: 600; font-size: clamp(25px, 2.1vw, 31px); letter-spacing: .005em; }
html[lang="en"] .letter-sign label { font-family: var(--latin); font-style: italic; font-size: 20px; letter-spacing: .01em; padding-bottom: 4px; }
html[lang="en"] .status { line-height: 1.5; }
html[lang="en"] .again, html[lang="en"] .wall-more button { letter-spacing: .04em; }
html[lang="en"] .note-name::before { content: "— "; }

@media (max-width: 820px) {
  .m-write-grid { grid-template-columns: minmax(0, 1fr); }
  .m-title { right: 7vw; font-size: min(24vh, 30vw); top: 40%; }
  .m-lead { right: 24px; bottom: 76px; }
  .m-lead h1 { font-size: 28px; }
  .letter-sign { grid-template-columns: auto minmax(0, 1fr); justify-content: stretch; }
  .letter-date { grid-column: 1 / -1; text-align: right; padding: 0; }
  :is(.letter, .slip) .postmark { width: 104px; height: 104px; font-size: 36px; }
}
@media (max-width: 560px) {
  .send-btn { width: 88px; height: 88px; font-size: 48px; }
  .letter-to small { display: none; }
  .m-hero .hero-foot span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .note { opacity: 1; animation: none; }
}
