@font-face {
  font-family: "DM Serif Text";
  src: url("./assets/DMSerifText-Italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #faf8f1;
  --ink: #182f42;
  --muted: #536475;
  --rule: #d6d7cf;
  --red: #b3442b;
  --serif: "DM Serif Text", Georgia, serif;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; text-underline-offset: .23em; }
button, input { font: inherit; }
button, summary { cursor: pointer; }
:focus-visible { outline: 3px solid #236b91; outline-offset: 4px; }
.masthead, main, footer { width: min(1160px, 88%); margin-inline: auto; }
.masthead, footer { display: flex; align-items: center; justify-content: space-between; }
.masthead { padding-block: 27px; border-bottom: 1px solid var(--rule); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font: italic 30px/1 var(--serif); text-decoration: none; }
.brand-mark {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--ink);
}
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; }
.brand-mark::before { inset: 11px 7px 10px; border-radius: 2px; background: #fff9e6; }
.brand-mark::after {
  inset: 11px 7px auto;
  height: 10px;
  background: var(--ink);
  clip-path: polygon(0 0, 50% 67%, 100% 0, 100% 21%, 50% 90%, 0 21%);
}
.home-link, footer { color: var(--muted); font-size: .83rem; }
.home-link { padding: 8px 0 8px 8px; text-decoration-thickness: 1px; }
.home-link:hover, .manual a:hover { color: var(--red); }

main {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  align-items: center;
  gap: clamp(38px, 6vw, 92px);
  min-height: min(72vh, 760px);
  padding-block: clamp(48px, 7vw, 100px);
}
h1 {
  margin: 0;
  font: 650 clamp(2.8rem, 4.45vw, 4.25rem)/1.16 "Songti SC", "STSong", "SimSun", serif;
  letter-spacing: -.035em;
}
h1 em { font: italic 1.14em/1 var(--serif); color: var(--red); }
.intro { max-width: 28em; margin: 21px 0 32px; font-size: 1rem; line-height: 1.8; color: var(--muted); }
.intro strong { font-weight: 600; color: var(--ink); }
.application { min-width: 0; }
form, .manual { max-width: 28rem; }
label { display: block; margin-bottom: 10px; font-weight: 650; }
.address-field {
  display: flex;
  align-items: center;
  min-height: 55px;
  overflow: hidden;
  border: 1px solid #8695a0;
  border-radius: 6px;
  background: #fffef9;
}
.address-field:focus-within { outline: 3px solid #236b91; outline-offset: 2px; }
.address-field:has([aria-invalid="true"]) { border-color: var(--red); }
.address-field input { flex: 1; width: 0; min-width: 0; padding: 14px; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: 1.06rem; }
.address-field input::placeholder { color: #687789; font-size: .94rem; }
.address-field span { flex: none; padding-inline: 13px; border-left: 1px solid var(--rule); font: 500 1rem/1.4 ui-monospace, Consolas, monospace; }
.hint, .error, .send-status, .manual-body { font-size: .87rem; line-height: 1.65; }
.hint, .error { margin: 8px 0 0; }
.hint, .send-status { color: var(--muted); }
.error { color: #992610; }
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-top: 22px;
  min-height: 48px;
  padding: 0 23px;
  border: 1px solid var(--ink);
  border-radius: 5px;
  color: white;
  background: var(--ink);
  font-weight: 650;
}
.primary:hover { background: #2b4b60; }
.primary:active { transform: translateY(1px); }
.button-envelope { position: relative; width: 18px; height: 13px; border: 1.5px solid; border-radius: 2px; }
.button-envelope::before { content: ""; position: absolute; inset: 0 0 auto; height: 8px; background: currentColor; clip-path: polygon(0 0, 50% 65%, 100% 0, 100% 20%, 50% 88%, 0 20%); }
.send-status { margin: 9px 0 0; }
.manual { margin-top: 19px; }
.manual summary { width: fit-content; padding: 5px 3px 5px 0; color: var(--ink); font-size: .88rem; text-underline-offset: .2em; }
.manual summary:hover { text-decoration: underline; }
.manual-body { padding: 4px 0 0 12px; margin-top: 6px; border-left: 2px solid var(--rule); }
.manual-body p { margin: 0 0 9px; color: var(--muted); }
.manual dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 12px; margin: 0; }
.manual dt { color: var(--muted); }
.manual dd { margin: 0; overflow-wrap: anywhere; }
.copy { border: 1px solid var(--rule); background: transparent; color: var(--ink); margin-top: 11px; padding: 6px 12px; border-radius: 4px; }
.copy:hover { border-color: var(--ink); }
.copy-status { margin-left: 5px; color: var(--muted); }

.preview {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  container-type: inline-size;
  aspect-ratio: 1.17;
  margin: 0;
  overflow: hidden;
  border: 1px solid #b7c7c5;
  border-radius: 3px;
  background-color: #dae7e4;
  background-image: linear-gradient(#4a6f7620 1px, transparent 1px), linear-gradient(90deg, #4a6f7620 1px, transparent 1px);
  background-size: 8.33% 8.33%;
}
.register-mark { position: absolute; width: 14px; height: 14px; border: solid #648484; }
.top-left { top: 15px; left: 15px; border-width: 1px 0 0 1px; }
.bottom-right { bottom: 15px; right: 15px; border-width: 0 1px 1px 0; }
.back-envelope, .postcard { grid-area: 1 / 1; width: 75%; aspect-ratio: 1.51; }
.back-envelope {
  position: relative;
  overflow: hidden;
  transform: translate(1%, 5%) rotate(8deg);
  background: #698c9b;
  border: 1px solid #587c89;
  box-shadow: 1px 5px 11px #1e3e501c;
}
.back-envelope::before { content: ""; position: absolute; inset: 0; background: #a4becc; clip-path: polygon(0 0, 100% 0, 50% 70%); }
.postcard {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 4.9% 5.4% 4.7%;
  border: 1px solid #cfc7ae;
  background: #fffbeb;
  transform: rotate(-7deg);
  box-shadow: 0 5px 15px #2437432b;
}
.postcard::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: max(4px, 1.1cqw);
  background: repeating-linear-gradient(122deg, #ae503e 0 12px, #fffbeb 12px 22px, #446876 22px 34px, #fffbeb 34px 44px);
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.printed-brand { font: italic 6.8cqw/1 var(--serif); color: #274655; }
.stamp {
  display: grid;
  place-items: center;
  width: 13cqw;
  aspect-ratio: .85;
  background: var(--red);
  color: #fff1d0;
  mask: linear-gradient(#000 0 0) center / calc(100% - 6px) calc(100% - 6px) no-repeat,
        radial-gradient(circle, transparent 2px, #000 2.6px) -3px -3px / 6px 6px;
}
.stamp span { width: 78%; height: 80%; display: grid; place-items: center; border: 1px solid #ead0a7; font: italic 7.2cqw/1 var(--serif); }
.postmark { position: absolute; right: 13.5%; top: 25%; display: grid; gap: 3px; width: 16%; transform: rotate(-10deg); }
.postmark i { display: block; height: 4px; border-top: 1px solid #395568aa; border-radius: 50%; }
.card-label { margin-top: auto; font-size: clamp(.62rem, 2.15cqw, .85rem); letter-spacing: .12em; color: var(--muted); }
.card-address { margin-top: 5px; min-width: 0; color: #244457; font: 500 clamp(.93rem, 4.1cqw, 1.65rem)/1.13 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.address-rules { border-block: 1px solid #a1aaa0; margin-top: 3%; height: 8%; flex-shrink: 0; }
footer { gap: 12px; padding: 18px 0 25px; border-top: 1px solid var(--rule); }
footer span:last-child { font: .78rem/1.6 ui-monospace, Consolas, monospace; }

@media (max-width: 740px) {
  .masthead, main, footer { width: min(89%, 540px); }
  .masthead { padding-block: 18px; }
  .wordmark { font-size: 26px; }
  main { grid-template-columns: minmax(0, 1fr); gap: 34px; padding-block: 38px; }
  h1 { font-size: clamp(2.7rem, 7.9vw, 3.45rem); }
  .intro { margin: 16px 0 24px; }
  form, .manual { max-width: none; }
  .preview { aspect-ratio: 1.4; }
  .back-envelope, .postcard { width: 70%; }
  .primary { width: 100%; }
}
@media (max-width: 360px) {
  .address-field input { padding-inline: 9px; }
  .address-field span { padding-inline: 8px; }
}
