/* Howler — the letter's materials as web tokens: paper, ink, wax, ember, char. */
:root {
  /* A desk a shade darker than the paper, so the letter lifts off it. */
  --page: #e9dec6;
  --page-deep: #ddd0b3;
  --paper: #f8f0de;
  --paper-edge: #e3cfa6;
  --fiber: #9c7e50;
  --ink: #2b1e13;
  --ink-soft: #5a4632;
  --faded: #8a7255;
  --rule: #c8b187;
  --wax: #9b2f2a;
  --wax-deep: #5c0e0a;
  --wax-light: #c9483b;
  --gold: #a8741a;
  --ember: #f0a24a;
  --char: #1d140e;
  --lift: drop-shadow(0 1px 1px rgba(43, 30, 19, .2)) drop-shadow(0 18px 24px rgba(43, 30, 19, .26));
  --display: "Cormorant Garamond", "Iowan Old Style", "Songti SC", "Noto Serif SC", Georgia, serif;
  --text: "EB Garamond", "Iowan Old Style", "Songti SC", "Noto Serif SC", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* Candlelight: a dark room, the paper still paper but dimmer. */
    --page: #140f0b;
    --page-deep: #1d1610;
    --paper: #e4d6b8;
    --paper-edge: #bfa67a;
    --fiber: #7a5f38;
    --ink: #24180e;
    --ink-soft: #4d3b29;
    --faded: #6e5839;
    --rule: #a88f64;
    --wax: #8c2620;
    --gold: #c8923a;
    --lift: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)) drop-shadow(0 22px 30px rgba(0, 0, 0, .65));
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 19px/1.6 var(--text);
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  /* Text set directly on the dark page needs light ink. */
  body { color: #eadcc0; }
}

/* Language: both are in the page; the html lang picks one. */
.zh { display: none; }
html[lang^="zh"] .zh { display: inline; }
html[lang^="zh"] .en { display: none; }

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
img { max-width: 100%; height: auto; display: block; }
kbd {
  font: 500 .85em var(--text);
  padding: .05em .4em;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  border-bottom-width: 2px;
  border-radius: 6px;
  white-space: nowrap;
}

.skip { position: absolute; left: -9999px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { left: 16px; top: 12px; z-index: 10; background: var(--paper); color: var(--ink); padding: 6px 12px; border-radius: 6px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(16px, calc((100vw - 1120px) / 2));
  /* Opaque rather than frosted: a backdrop blur is recomputed on every scrolled frame. */
  background: color-mix(in srgb, var(--page) 96%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 45%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 600 24px/1 var(--display); letter-spacing: .01em; }
.topbar nav { display: flex; align-items: center; gap: 22px; font-size: 17px; }
.topbar nav a { text-decoration: none; opacity: .8; }
.topbar nav a:hover { opacity: 1; }
.lang {
  font: 500 15px var(--text); color: inherit; background: none; cursor: pointer;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent); border-radius: 999px; padding: 3px 12px;
}
@media (max-width: 720px) {
  .topbar nav a:not([href^="https"]) { display: none; }
}

main { padding: 0 16px; overflow-x: clip; } /* the fire canvas reaches past the letter for its sparks */

/* Hero */
.hero {
  max-width: 1120px; margin: 0 auto; padding: 72px 0 40px;
  display: grid; grid-template-columns: 1fr 1.15fr; gap: 56px; align-items: center;
}
@media (max-width: 920px) { .hero { grid-template-columns: 1fr; padding-top: 40px; gap: 40px; } }
.hero-icon { width: 112px; height: 112px; margin-bottom: 12px; filter: drop-shadow(0 10px 18px rgba(43, 30, 19, .25)); }
h1 { font: 700 clamp(56px, 8vw, 84px)/.95 var(--display); margin: 0; letter-spacing: -.01em; }
.slogan { font: italic 600 clamp(28px, 3.6vw, 38px)/1.2 var(--display); color: var(--wax); margin: 10px 0 18px; }
@media (prefers-color-scheme: dark) { .slogan { color: #d96a52; } }
.lede { font-size: 21px; max-width: 30em; margin: 0 0 28px; }
.meta { font-size: 15px; opacity: .7; margin-top: 18px; }

.actions { display: flex; flex-wrap: wrap; gap: 14px; }
.actions.center { justify-content: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 24px; border-radius: 999px;
  font: 600 19px var(--display); letter-spacing: .02em; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.wax {
  color: #fbeee0;
  background: radial-gradient(120% 140% at 30% 25%, var(--wax-light), var(--wax) 55%, var(--wax-deep));
  box-shadow: inset 0 1px 0 rgba(255, 220, 200, .25), 0 6px 18px -6px rgba(92, 14, 10, .6);
}
.btn.quiet { border: 1px solid color-mix(in srgb, currentColor 35%, transparent); }

/* The star seal: a reader's mark, in the amber wax the app uses for attachments. */
.star-seal {
  display: inline-flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 22px 4px 5px;
  border-radius: 999px; border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  text-decoration: none; transition: border-color .2s ease, background-color .2s ease;
}
.star-seal:hover { border-color: color-mix(in srgb, #b5801f 70%, transparent); background: color-mix(in srgb, #f0c46a 10%, transparent); }
.star-seal:focus-visible { outline: 2px solid #b5801f; outline-offset: 3px; }
.star-wax {
  position: relative; flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 48% 52% 46% 54% / 53% 47% 55% 45%;
  background: radial-gradient(70% 70% at 36% 30%, #f3cd7a, #b5801f 58%, #5e3b08);
  box-shadow: inset 0 0 0 4px rgba(94, 59, 8, .42), inset 0 0 0 6px rgba(243, 205, 122, .22), 0 3px 6px rgba(43, 30, 19, .3);
  transform: rotate(-10deg);
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1), box-shadow .3s ease;
}
.mark { font-size: 18px; line-height: 1; color: #5e3b08; text-shadow: -.5px -.6px 0 rgba(255, 232, 175, .6); }
.star-seal:hover .star-wax { transform: rotate(-24deg) translateY(-3px) scale(1.07); box-shadow: inset 0 0 0 4px rgba(94, 59, 8, .42), inset 0 0 0 6px rgba(243, 205, 122, .22), 0 8px 12px rgba(43, 30, 19, .28); }
.star-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.star-label { font: 600 19px var(--display); letter-spacing: .02em; }
.star-meta { font-size: 13.5px; opacity: .72; }

/* Pressed: down hard, a ring of wax spreads, a few sparks fly. */
.ripple { position: absolute; inset: -2px; border-radius: 50%; border: 2px solid rgba(181, 128, 31, .6); opacity: 0; pointer-events: none; }
.sparks i {
  position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%;
  background: #ffd27a; box-shadow: 0 0 6px #ffb347; opacity: 0; pointer-events: none;
}
.sparks i:nth-child(1) { --a: 0deg; } .sparks i:nth-child(2) { --a: 45deg; } .sparks i:nth-child(3) { --a: 90deg; }
.sparks i:nth-child(4) { --a: 135deg; } .sparks i:nth-child(5) { --a: 180deg; } .sparks i:nth-child(6) { --a: 225deg; }
.sparks i:nth-child(7) { --a: 270deg; } .sparks i:nth-child(8) { --a: 315deg; }
.star-seal.pressing .star-wax { animation: seal-press .6s cubic-bezier(.2, .8, .3, 1); }
.star-seal.pressing .ripple { animation: seal-ripple .7s ease-out .2s; }
.star-seal.pressing .sparks i { animation: seal-spark .65s ease-out .22s; }
@keyframes seal-press {
  0% { transform: rotate(-24deg) translateY(-7px) scale(1.16); }
  42% { transform: rotate(-6deg) translateY(1px) scale(.86); }
  68% { transform: rotate(-12deg) scale(1.05); }
  100% { transform: rotate(-10deg) scale(1); }
}
@keyframes seal-ripple { from { transform: scale(.85); opacity: .85; } to { transform: scale(2.2); opacity: 0; } }
@keyframes seal-spark {
  0% { opacity: 1; transform: rotate(var(--a)) translateY(-14px); }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(-34px) scale(.4); }
}
/* Sealed: the impression set a shade deeper. */
.star-seal.sealed .star-wax { background: radial-gradient(70% 70% at 36% 30%, #e6b65c, #a3711a 58%, #4f3106); }
@media (prefers-reduced-motion: reduce) {
  .star-wax, .star-seal:hover .star-wax { transition: none; transform: rotate(-10deg); }
  .star-seal.pressing .star-wax, .star-seal.pressing .ripple, .star-seal.pressing .sparks i { animation: none; }
}

/* The live letter */
.demo { margin: 0; }
.hero > * { min-width: 0; }
/* The shadow sits on a wrapper: the sheet's deckled clip-path would cut off its own. */
.paper { filter: var(--lift); }
.stage { position: relative; }
.sheet {
  position: relative; min-height: 360px; padding: 26px 30px 18px;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, color-mix(in srgb, var(--paper-edge) 70%, transparent)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .35  0 0 0 0 .2  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    var(--paper);
  color: var(--ink);
  border-radius: 3px;
  clip-path: polygon(0 1%, 7% 0, 18% .8%, 31% .2%, 46% .9%, 60% .1%, 74% .7%, 88% .2%, 100% .9%, 99.6% 20%, 100% 41%, 99.5% 63%, 100% 82%, 99.4% 100%, 85% 99.3%, 70% 100%, 52% 99.4%, 35% 100%, 19% 99.2%, 6% 100%, 0 99.3%, .4% 78%, 0 56%, .5% 33%, 0 14%);
}
.sheet::after {
  /* The fold. */
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--fiber) 18%, transparent) 15%, color-mix(in srgb, var(--fiber) 18%, transparent) 85%, transparent);
}
.sheet-head { display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--rule); padding-bottom: 12px; }
.seal {
  flex: none; width: 54px; height: 54px; display: grid; place-items: center;
  border-radius: 48% 52% 46% 54% / 53% 47% 55% 45%;
  background: radial-gradient(70% 70% at 36% 30%, #c9483b, #9b2f2a 55%, #5c0e0a);
  box-shadow: inset 0 0 0 5px rgba(92, 14, 10, .45), inset 0 0 0 7px rgba(217, 100, 80, .25), 0 3px 6px rgba(43, 30, 19, .35);
  transform: rotate(-8deg);
}
.seal span { font: 700 24px/1 var(--display); color: #5c0e0a; text-shadow: -.6px -.7px 0 rgba(255, 190, 170, .45); }
.ask { margin: 0; font: italic 500 23px/1.3 var(--display); color: var(--ink-soft); min-height: 1.3em; }
.ask::before { content: "✦ "; color: var(--gold); font-style: normal; font-size: .8em; }
.answer { margin: 16px 2px 12px; min-height: 9.5em; font-size: 18.5px; line-height: 1.62; white-space: pre-wrap; }
.answer .fresh { color: var(--gold); text-shadow: 0 0 8px rgba(240, 196, 106, .55); }
/* The quill rests after the last word, nib on the baseline; out of the flow, so lines don't jump. */
.answer .quill { position: relative; }
.answer .quill::after {
  content: ""; position: absolute; left: 100%; bottom: .22em; width: 1.5em; height: 1.5em; margin-left: 1px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'><path d='M13 27 C 14 15, 26 4, 39 1 C 35 13, 26 23, 13 27 Z' fill='%233a2b20'/><path d='M13.5 26.5 C 21 21, 28 13, 38.5 1.5' stroke='%23efe3c8' stroke-width='1' fill='none'/><path d='M16 22 C 20 21, 24 18, 27 14 M19 13 C 22 10, 26 7, 30 5' stroke='%236e5a44' stroke-width='.6' fill='none' opacity='.7'/><path d='M4 36 L 14 27' stroke='%23d8c7a2' stroke-width='2.4' stroke-linecap='round'/><path d='M1 39 L 5.2 34.2 L 6.8 35.8 Z' fill='%231a120d'/></svg>") no-repeat left bottom / contain;
  transform-origin: 0 100%; animation: quill 0.9s ease-in-out infinite;
}
@keyframes quill { 50% { transform: translate(1px, -1.5px) rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .answer .quill::after { animation: none; } }
.sheet-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid color-mix(in srgb, var(--rule) 70%, transparent); padding-top: 8px;
  font: italic 14.5px var(--text); color: var(--faded);
}
/* Both canvases reach 40px past the sheet on three sides (sparks) and 46px below it (the ash). */
.fire, .ash { position: absolute; left: -40px; top: -40px; width: calc(100% + 80px); height: calc(100% + 86px); pointer-events: none; }
/* Ash lies behind the paper, so the next letter covers any still in the air; fire burns in front. */
.ash { z-index: 0; transition: opacity 2.4s ease; }
.fire { z-index: 2; }
.ash.fading { opacity: 0; }
.paper { position: relative; z-index: 1; transition: filter .45s ease; }
.paper.burning { filter: none; }
.demo figcaption { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 40px; font-size: 16px; }
.burn-now {
  font: 600 17px var(--display); cursor: pointer; color: inherit; background: none;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent); border-radius: 999px; padding: 4px 16px;
}
.burn-now:hover { border-color: var(--ember); color: var(--ember); }
.hint { opacity: .6; }

/* Chapters */
.chapter { max-width: 1120px; margin: 0 auto; padding: 72px 0; border-top: 1px solid color-mix(in srgb, var(--rule) 40%, transparent); }
h2 { font: 600 clamp(36px, 5vw, 52px)/1.1 var(--display); text-align: center; margin: 0 0 12px; }
h3 { font: 600 30px/1.15 var(--display); margin: 0 0 12px; }
.chapter-lede { text-align: center; font-size: 21px; margin: 0 auto 48px; max-width: 34em; opacity: .85; }
.feature { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; align-items: center; margin: 56px 0; }
.feature.flip { grid-template-columns: 1fr 1.25fr; }
.feature.flip > img { order: 2; }
.feature > * { min-width: 0; } /* let long code lines scroll instead of widening the column */
.feature p { margin: 0 0 14px; }
.settings-shot { max-width: min(460px, 100%); justify-self: center; border-radius: 12px; }
.aside { font-style: italic; opacity: .7; font-size: 17px; }
@media (max-width: 860px) {
  .feature, .feature.flip { grid-template-columns: 1fr; gap: 24px; }
  .feature.flip > img { order: 0; }
}
pre {
  margin: 18px 0 0; padding: 14px 16px; border-radius: 10px; overflow-x: auto;
  background: var(--char); color: #f1dfbd; font: 14.5px/1.6 var(--mono);
}

.models { list-style: none; padding: 0; margin: 8px auto 12px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 820px; }
.models li { padding: 6px 16px; border-radius: 999px; border: 1px solid color-mix(in srgb, currentColor 22%, transparent); font-size: 17px; }
.center { text-align: center; }
.small { font-size: 16px; opacity: .72; }

.vows { list-style: none; padding: 0; margin: 32px auto 0; max-width: 680px; }
.vows li { padding: 14px 0 14px 40px; position: relative; border-bottom: 1px solid color-mix(in srgb, var(--rule) 40%, transparent); }
.vows li::before {
  content: ""; position: absolute; left: 6px; top: 22px; width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--wax-light), var(--wax) 60%, var(--wax-deep));
}

.install ol { max-width: 640px; margin: 32px auto 32px; padding-left: 1.2em; }
.install li { margin: 0 0 14px; padding-left: 6px; }
.install li::marker { font: 600 22px var(--display); color: var(--wax); }

.colophon { text-align: center; padding: 56px 16px 64px; border-top: 1px solid color-mix(in srgb, var(--rule) 40%, transparent); }
.colophon img { margin: 0 auto 8px; }
.small-slogan { font-size: 26px; margin: 4px 0 14px; }
.colophon p { margin: 6px auto; max-width: 40em; }
.maker { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 14px auto 10px !important; }
.heart { font-size: .9em; }
.author { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font: 600 20px var(--display); }
.author img { width: 28px; height: 28px; margin: 0; border-radius: 50%; box-shadow: 0 0 0 2px color-mix(in srgb, var(--wax) 55%, transparent); }
.author:hover span { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 520px) {
  body { font-size: 18px; }
  .sheet { padding: 20px 18px 14px; }
  .ask { font-size: 20px; }
  /* Room for the longest answer, so the page below doesn't jump as letters come and go. */
  .answer { min-height: 14em; }
}
