/* D1: the letters patent. Laid paper, iron-gall ink, a wafer seal. One look, every colour set. */
:root {
  color-scheme: light;
  --paper: #E7DEC6;
  --paper-deep: #D6C9A6;
  --paper-light: #F3ECD9;
  --ink: #2B2117;
  --ink-soft: #5A4A38;
  --rust: #8A4A1F;
  --serif-d: "Libre Caslon Display", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --serif: "Libre Caslon Text", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --cjk: "Noto Serif SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", serif;
  --measure: 36rem;
  --gutter: clamp(20px, 6vw, 120px);
  --col-offset: 0px;
  --ease: cubic-bezier(.3, .7, .2, 1);
}
@media (min-width: 1000px) {
  :root { --col-offset: min(22vw, 300px); --gutter: 10vw; }
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font: 400 18px/1.6 var(--serif);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  min-height: 100vh;
}
html[lang="zh-Hans"] body { font-family: var(--cjk); font-size: 17px; line-height: 1.85; }
html[lang="zh-Hans"] .latin { font-family: var(--serif); }

#paper { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; }
a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; text-decoration-color: var(--ink-soft); transition: text-decoration-color .25s, text-decoration-thickness .25s, color .25s; }
a:hover { color: var(--rust); text-decoration-color: var(--rust); text-decoration-thickness: 2px; }

.skip { position: absolute; z-index: 5; left: var(--gutter); top: -4rem; padding: .6rem 1rem; background: var(--paper-light); border: 1px solid var(--ink); text-decoration: none; }
.skip:focus { top: 1rem; }

/* Header: the seal small, the short name, the nav, the switch */
.top { position: relative; z-index: 2; display: flex; align-items: center; gap: 1.2rem; padding: .9rem var(--gutter); }
.mark { display: inline-flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; font-family: var(--serif-d); font-size: 1.05rem; margin-right: auto; min-height: 44px; }
.mark svg { width: 36px; height: 36px; overflow: visible; transition: transform .4s var(--ease); }
.mark .disc { fill: var(--paper-light); stroke: var(--ink-soft); stroke-width: 1.2; transition: fill .4s; }
.mark .ring { fill: none; stroke: var(--ink-soft); transition: stroke .4s; }
.mark .rim, .mark .mono, .mark .dot { fill: var(--ink-soft); transition: fill .4s; }
.mark:hover svg, .mark:focus-visible svg { transform: scale(.9) rotate(-8deg); }
.mark:hover .disc, .mark:focus-visible .disc { fill: var(--paper); }
.mark:hover .ring, .mark:focus-visible .ring { stroke: var(--rust); }
.mark:hover .mono, .mark:focus-visible .mono, .mark:hover .rim, .mark:focus-visible .rim { fill: var(--rust); }
.mark span { white-space: nowrap; }

.top nav { display: flex; gap: 1.3rem; }
.top nav a, .lang a, .lang [aria-current] { position: relative; display: inline-block; color: var(--ink); text-decoration: none; padding: .65rem 0; font-size: .98rem; line-height: 1.4; }
.top nav a::after, .lang a::after, .lang [aria-current]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: .42rem; height: 1.5px; background: var(--ink);
  transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease);
}
.top nav a:hover::after, .top nav a:focus-visible::after, .top nav a[aria-current="page"]::after { transform: scaleX(1); }
.top nav a:hover, .lang a:hover { color: var(--ink); }
.lang { display: flex; align-items: center; gap: .5rem; }
.lang .bar { color: var(--ink-soft); }
.lang [aria-current]::after { transform: scaleX(1); }
.lang:hover [aria-current]::after, .lang:focus-within [aria-current]::after { transform: scaleX(0); transform-origin: right; }
.lang a:hover::after, .lang a:focus-visible::after { transform: scaleX(1); }
@media (max-width: 600px) {
  .top { gap: .9rem; padding-inline: 20px; }
  .top nav { gap: .9rem; }
  .top nav .anchor { display: none; }
  .mark span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Beats */
main { position: relative; z-index: 1; }
.beat { padding: 5rem var(--gutter) 4.5rem calc(var(--gutter) + var(--col-offset)); }
.col { max-width: var(--measure); }
.beat-paper { min-height: calc(100svh - 4.5rem); display: flex; flex-direction: column; justify-content: center; padding-top: 2rem; padding-bottom: 6rem; }
h1 { font: 400 clamp(2.6rem, 7vw, 5.6rem)/1.05 var(--serif-d); margin: 0 0 1.1rem; max-width: 52rem; letter-spacing: -.005em; overflow-wrap: anywhere; }
.rule-open { max-width: 52rem; }
.lede { font-size: clamp(1.1rem, 1.6vw, 1.3rem); line-height: 1.55; max-width: var(--measure); margin: 1.4rem 0 0; }
html[lang="zh-Hans"] .lede { line-height: 1.8; }

h2 { font: 400 clamp(1.6rem, 2.6vw, 2.1rem)/1.2 var(--serif-d); margin: 0 0 .45rem; }
html[lang="zh-Hans"] h2 { font-family: var(--cjk); font-weight: 600; }
h3 { margin: 0; }

.rule { display: block; width: 100%; height: 3px; overflow: visible; }
.rule line { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.rule-soft line { stroke: var(--ink-soft); stroke-width: 1; }
.opener { margin-bottom: 1.6rem; max-width: var(--measure); }

/* The writing */
.entry { margin-top: 2.2rem; max-width: var(--measure); }
.label { font: italic 400 1.08rem/1.4 var(--serif); margin: 0 0 .2rem; }
html[lang="zh-Hans"] .label { font: 600 1.05rem/1.7 var(--cjk); }
.entry .rule { margin: .25rem 0 .7rem; }
.entry p { margin: 0; }

/* The close-up */
.beat-closeup { min-height: 78svh; display: flex; flex-direction: column; justify-content: center; }
.beat-closeup h2 { font: italic 400 1.1rem/1.5 var(--serif); color: var(--ink-soft); margin-bottom: 1.6rem; }
html[lang="zh-Hans"] .beat-closeup h2 { font: 400 1rem/1.8 var(--cjk); }
.large { font: 400 clamp(1.55rem, 3.3vw, 2.5rem)/1.25 var(--serif-d); max-width: 34rem; margin: 0 0 1.3rem; }
html[lang="zh-Hans"] .large { font: 600 clamp(1.35rem, 2.8vw, 2.1rem)/1.5 var(--cjk); }

/* The signatures: six ruled entries */
.steps { list-style: none; margin: 1.8rem 0 0; padding: 0; max-width: var(--measure); }
.steps li { display: grid; grid-template-columns: 2.2rem 1fr; column-gap: .5rem; padding: 1rem 0 0; }
.steps .n { font: italic 400 1.05rem/1.45 var(--serif); color: var(--ink-soft); }
.steps p { margin: .15rem 0 0; color: var(--ink-soft); }
.steps li { position: relative; }
.steps .rule { grid-column: 1 / -1; margin-top: .9rem; }
.flourish { position: absolute; right: -2px; bottom: 0; width: 44px; height: 16px; overflow: visible; }
.flourish path { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }

/* The seal */
.beat-seal { position: relative; }
.seal-wrap { width: min(200px, 54vw); margin: 0 0 2.2rem; }
@media (min-width: 1000px) {
  .seal-wrap { position: absolute; left: var(--gutter); top: 5.4rem; width: 200px; margin: 0; }
}
.seal { display: block; width: 100%; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 50%; -webkit-tap-highlight-color: transparent; color: inherit; }
.seal:focus-visible { outline: 2px solid var(--rust); outline-offset: 8px; }
.seal svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 1.5px 2px rgba(43, 33, 23, .28)) drop-shadow(0 7px 12px rgba(43, 33, 23, .12)); transition: filter .4s, transform .4s var(--ease); }
.seal .disc { fill: var(--paper-light); stroke: var(--ink-soft); stroke-width: 1; transition: fill .45s, stroke .45s; }
.seal .ring { fill: none; stroke: var(--ink-soft); transition: stroke .45s; }
.seal .rim, .seal .mono, .seal .dot { fill: var(--ink-soft); transition: fill .45s, opacity .6s; }
.seal[aria-pressed="true"] svg { transform: scale(.965); filter: drop-shadow(0 0 0 transparent) drop-shadow(0 1px 0 rgba(243, 236, 217, .9)); }
.seal[aria-pressed="true"] .disc { fill: var(--paper); stroke: var(--paper-deep); }
.seal[aria-pressed="true"] .relief { filter: url(#press-big); }
.seal[aria-pressed="true"] .ring { stroke: var(--rust); }
.seal[aria-pressed="true"] .rim, .seal[aria-pressed="true"] .mono, .seal[aria-pressed="true"] .dot { fill: var(--rust); }
.caption { font: italic 400 .9rem/1.45 var(--serif); color: var(--ink-soft); margin: .9rem 0 0; text-align: center; }
html[lang="zh-Hans"] .caption { font: 400 .9rem/1.7 var(--cjk); }
.seal-text { max-width: var(--measure); }
.seal-text h3 { font: italic 400 1.08rem/1.4 var(--serif); margin: 1.8rem 0 .2rem; }
html[lang="zh-Hans"] .seal-text h3 { font: 600 1.05rem/1.7 var(--cjk); }
.seal-text p { margin: .3rem 0 0; }

/* The filing: a folded letter */
.letter { margin-top: 1.4rem; max-width: var(--measure); perspective: 900px; }
.letter summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; padding: .95rem 1.2rem; border: 1px solid var(--ink); background: var(--paper-light); position: relative; transition: transform .3s var(--ease), box-shadow .3s; min-height: 44px; }
.letter summary::-webkit-details-marker { display: none; }
.letter summary::after { content: ""; position: absolute; left: 0; right: 0; bottom: -11px; height: 10px; background: linear-gradient(rgba(43, 33, 23, .22), transparent); transition: opacity .3s; }
.letter[open] summary::after { opacity: 0; }
.letter summary:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--paper-deep); }
.letter summary:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; }
.letter .hint { font: italic 400 .9rem/1.4 var(--serif); color: var(--ink-soft); white-space: nowrap; }
html[lang="zh-Hans"] .letter .hint { font: 400 .9rem/1.7 var(--cjk); }
.letter[open] .hint { display: none; }
.letter-body { border: 1px solid var(--ink); border-top: 0; padding: 1rem 1.2rem 1.3rem; background: var(--paper-light); transform-origin: top center; }
.letter-body p { margin: 0 0 1rem; }
.button { display: inline-block; padding: .6rem 1.1rem; border: 1px solid var(--ink); color: var(--ink); text-decoration: none; font-family: inherit; font-size: 1rem; line-height: 1.4; background: var(--paper-light); cursor: pointer; min-height: 44px; transition: transform .25s var(--ease), box-shadow .25s, color .25s; }
.button:hover, .button:focus-visible { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--paper-deep); color: var(--ink); }

/* The docket */
.docket { position: relative; z-index: 1; padding: 2.6rem var(--gutter) 2.6rem calc(var(--gutter) + var(--col-offset)); font-size: .92rem; color: var(--ink-soft); border-top: 1px solid var(--paper-deep); }
.docket p { margin: .3rem 0; max-width: var(--measure); }
.docket a { color: inherit; }

/* Contact page */
.page { padding: 3rem var(--gutter) 5rem calc(var(--gutter) + var(--col-offset)); }
.page h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
.form { max-width: var(--measure); margin-top: 2.2rem; }
.form .row { display: grid; gap: 0 2rem; }
@media (min-width: 700px) { .form .row { grid-template-columns: 1fr 1fr; } }
.field { margin: 0 0 1.5rem; }
.field label { display: block; font: italic 400 1rem/1.4 var(--serif); margin-bottom: .25rem; }
html[lang="zh-Hans"] .field label { font: 400 1rem/1.7 var(--cjk); }
.field input, .field textarea { display: block; width: 100%; font: inherit; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--ink-soft); border-radius: 0; padding: .55rem 0; min-height: 44px; transition: border-color .25s, background-color .25s, box-shadow .25s; }
.field input:focus, .field textarea:focus { outline: none; border-bottom-color: var(--rust); box-shadow: 0 1px 0 var(--rust); background: var(--paper-light); }
.field textarea { min-height: 7.5rem; resize: vertical; }
.note { font: italic 400 .92rem/1.5 var(--serif); color: var(--ink-soft); margin-top: 1.1rem; max-width: var(--measure); }
html[lang="zh-Hans"] .note { font: 400 .92rem/1.7 var(--cjk); }
.sent { border: 1px solid var(--ink); padding: 1.1rem 1.2rem; background: var(--paper-light); margin-top: 2.2rem; max-width: var(--measure); }
.sent p { margin: 0; }

/* Motion. Pre-states only when JS runs and motion is allowed; the still state is the finished sheet. */
.js:not(.rm) .top { opacity: 0; animation: appear .8s ease .3s forwards; }
.js:not(.rm) .beat-paper h1 { clip-path: inset(0 100% 0 0); animation: write 1.3s var(--ease) 1s forwards; }
.js:not(.rm) .beat-paper .rule-open line { stroke-dashoffset: 1; animation: draw .75s var(--ease) .7s forwards; }
.js:not(.rm) .beat-paper .lede { opacity: 0; animation: appear .8s ease 1.8s forwards; }
.js:not(.rm) .reveal h2 { clip-path: inset(0 100% 0 0); transition: clip-path 1s var(--ease); }
.js:not(.rm) .reveal.inview h2 { clip-path: inset(0 0 0 0); }
.js:not(.rm) .rule-write line { stroke-dashoffset: 1; transition: stroke-dashoffset 1.1s var(--ease) .1s; }
.js:not(.rm) .inview .rule-write line, .js:not(.rm) .rule-write.inview line { stroke-dashoffset: 0; }
.js:not(.rm) .flourish path { stroke-dashoffset: 1; transition: stroke-dashoffset .6s var(--ease) 1.1s; }
.js:not(.rm) .inview .flourish path { stroke-dashoffset: 0; }
.js:not(.rm) .seal .disc, .js:not(.rm) .seal .ring { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.4s var(--ease), stroke .45s, fill .45s; }
.js:not(.rm) .seal .ring:nth-of-type(2) { transition-delay: .3s; }
.js:not(.rm) .seal .rim, .js:not(.rm) .seal .mono, .js:not(.rm) .seal .dot { opacity: 0; transition: opacity .7s ease .9s, fill .45s; }
.js:not(.rm) .seal.inview .disc, .js:not(.rm) .seal.inview .ring { stroke-dashoffset: 0; }
.js:not(.rm) .seal.inview .rim, .js:not(.rm) .seal.inview .mono, .js:not(.rm) .seal.inview .dot { opacity: 1; }
.js:not(.rm) .letter[open] .letter-body { animation: unfold .7s var(--ease); }
@keyframes write { to { clip-path: inset(0 0 0 0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }
@keyframes unfold { from { transform: rotateX(-88deg); opacity: .3; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .top, .beat-paper .lede { opacity: 1; }
  .beat-paper h1, .reveal h2 { clip-path: none; }
  .rule line, .seal .disc, .seal .ring, .flourish path { stroke-dashoffset: 0 !important; }
  .seal .rim, .seal .mono, .seal .dot { opacity: 1; }
}
