/* ddawnlll — ink on paper. one stylesheet, no javascript.
   motion uses only transform, opacity and clip-path, so it stays on the
   compositor and runs at the display's own rate (120hz where there is one). */

:root {
  color-scheme: light dark;
  /* 青綠: celadon rice paper, pine-black ink, malachite green; cinnabar only on seals */
  --paper: #e4e9da;
  --paper-2: #d9e1cd;
  --mist: #eef2e6;
  --ink: #17201b;
  --ink-2: #2d3a32;
  --muted: #53624f;
  --faint: #93a393; /* decoration only: rules, bullets. never text */
  --rule: rgba(23, 32, 27, .15);
  --jade: #2f6e55;
  --jade-ink: #eef3e8;
  --seal: #a8322b;
  --seal-ink: #f1efe4;
  --wash: rgba(47, 110, 85, .07);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
  --brush: "Kaiti SC", STKaiti, KaiTi, BiauKai, "AR PL UKai CN", "TW-Kai", "LXGW WenKai", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --measure: 42rem;
  --gutter: 6rem;
  --pad: clamp(1rem, 4vw, 3rem);

  /* the one easing: a brush that lands fast and lifts slowly */
  --ease: cubic-bezier(.22, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111712;
    --paper-2: #18201a;
    --mist: #26302a;
    --ink: #e2e9dc;
    --ink-2: #c3cec0;
    --muted: #8a9a8b;
    --faint: #5f6e61;
    --rule: rgba(226, 233, 220, .13);
    --jade: #74b394;
    --jade-ink: #111712;
    --seal: #c4453a;
    --seal-ink: #111712;
    --wash: rgba(116, 179, 148, .07);
  }
}

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .5s; animation-timing-function: var(--ease); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  /* xuan paper fibre */
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 .36 0 0 0 0 .3 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink-2);
  font: 18px/1.65 var(--serif);
  font-feature-settings: "onum", "kern";
  overflow-wrap: break-word;
}

::selection { background: var(--jade); color: var(--jade-ink); }

/* links: an ink line that is drawn, not switched on */
a {
  color: var(--ink); text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat,
              linear-gradient(var(--rule), var(--rule)) 0 100% / 100% 1px no-repeat;
  transition: background-size .5s var(--ease), color .3s;
  padding-bottom: .05em;
}
a:hover { color: var(--jade); background-size: 100% 1px, 100% 1px; }
a:focus-visible { outline: 2px solid var(--jade); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { color: var(--ink); font-weight: 400; }
code, pre, .mono { font-family: var(--mono); font-size: .78em; }
[lang|="zh"] { font-family: var(--brush); }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 9; background: var(--paper); padding: .4em .8em; }

/* ---------- top line ---------- */

.top {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 1.3rem var(--pad);
  font: .82rem/1 var(--mono); letter-spacing: .04em;
}
.top .name { color: var(--ink); }
.top a { color: var(--muted); background: none; }
.top a:hover { color: var(--jade); }

/* ---------- hero: a hanging scroll, unrolled ---------- */

.hero {
  max-width: 76rem; margin: 0 auto; padding: 0 var(--pad);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start;
  gap: clamp(1rem, 4vw, 4rem);
}
.scroll { margin: 0; justify-self: center; }
.unroll { position: relative; overflow: hidden; }
.unroll img {
  display: block; width: auto; max-width: 100%; height: min(86vh, 58rem); object-fit: contain;
  mix-blend-mode: multiply;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent), linear-gradient(to bottom, transparent, #000 7%, #000 93%, transparent);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent), linear-gradient(to bottom, transparent, #000 7%, #000 93%, transparent);
          mask-composite: intersect;
}
/* a band of mist that drifts across the lower mountains */
.mist {
  position: absolute; left: -30%; right: -30%; top: 52%; height: 26%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, var(--mist) 0%, transparent 70%);
  opacity: .55; pointer-events: none;
}
.scroll figcaption, .plate figcaption { font: .7rem/1.5 var(--mono); color: var(--muted); letter-spacing: .02em; margin-top: .4rem; text-align: center; }
.scroll figcaption span, .plate figcaption span { font-family: var(--brush); font-size: .9rem; color: var(--ink-2); margin-right: .4em; }

.inscription {
  display: flex; flex-direction: row-reverse; align-items: flex-start; gap: clamp(.8rem, 2vw, 1.6rem);
  padding-top: clamp(1rem, 8vh, 5rem);
}
.inscription .big {
  display: flex; flex-direction: column; margin: 0;
  font: 400 clamp(4.2rem, 9vw, 8.4rem)/1.08 var(--brush); color: var(--ink);
}
.inscription .small { writing-mode: vertical-rl; font: 1.05rem/1.9 var(--brush); letter-spacing: .32em; color: var(--ink-2); padding-top: .6rem; }
.inscription .col { display: flex; flex-direction: column; align-items: center; gap: 1rem; }

/* ---------- seals ---------- */

.seal {
  display: inline-grid; place-items: center;
  width: 2.3rem; height: 2.3rem;
  background: var(--seal); color: var(--seal-ink);
  font: 1.35rem/1 var(--brush);
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--seal), inset 0 0 0 3px var(--seal-ink);
  transform: rotate(-2deg); user-select: none;
}
.seal.duo { width: 2.1rem; height: 3.6rem; font-size: 1.05rem; line-height: 1.1; writing-mode: vertical-rl; letter-spacing: .1em; }
.seal.line { background: none; color: var(--jade); box-shadow: inset 0 0 0 1.5px var(--jade); border-radius: 50% / 46%; }

/* ---------- page grid ---------- */

main { padding: 0 var(--pad) 3rem; }
.sec {
  max-width: calc(var(--gutter) + var(--measure) + 3rem);
  margin: 0 auto;
  display: grid; grid-template-columns: var(--gutter) minmax(0, var(--measure)); column-gap: 3rem;
}
.sec > .body { grid-column: 2; min-width: 0; }
.mark {
  grid-column: 1; grid-row: 1 / span 20; align-self: start;
  position: sticky; top: 2rem;
  display: flex; flex-direction: column; align-items: center; gap: .9rem; padding-top: .3rem;
}
.mark .glyph { writing-mode: vertical-rl; font: 2.5rem/1 var(--brush); letter-spacing: .12em; color: var(--ink); }

.sec h2 { font-size: 1.55rem; margin: 0 0 1.4rem; line-height: 1.2; }
.minor { font: .72rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 2.6rem 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--rule); }

.stroke { display: block; width: min(18rem, 60%); height: 22px; margin: 4.5rem auto 3.5rem; color: var(--ink); opacity: .5; }

/* ---------- me ---------- */

.intro { padding-top: 3rem; }
.intro h1 { font-size: clamp(2.4rem, 6vw, 3.4rem); line-height: 1.05; margin: 0 0 .7rem; letter-spacing: -.01em; }
.intro .lead { font-size: 1.2rem; color: var(--ink); margin: 0 0 1rem; }
.intro p { margin: 0 0 1rem; }
.links { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; margin: 1.4rem 0 0; padding: 0; list-style: none; font: .85rem/1.6 var(--mono); }
.links a { color: var(--muted); }
.links a::before { content: "◦ "; color: var(--faint); }

/* ---------- wu wei ---------- */

.creed p { margin: 0 0 1rem; }
.creed .first { font-size: 1.28rem; line-height: 1.55; color: var(--ink); }
blockquote { margin: 1.8rem 0; padding: .2rem 0 .2rem 1.4rem; border-left: 2px solid var(--jade); font-size: 1.2rem; font-style: italic; color: var(--ink); }
blockquote p { margin: 0; }
.inspo { list-style: none; padding: 0; margin: 1.2rem 0 1.6rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .8rem; }
.inspo li { border-top: 1px solid var(--rule); padding-top: .6rem; }
.inspo a { font-size: 1.05rem; }
.inspo span { display: block; font: .74rem/1.4 var(--mono); color: var(--muted); }
.flash { display: flex; align-items: center; gap: 1rem; margin: 2rem 0 0; padding: 1rem 1.2rem; background: var(--wash); border-radius: 2px; }
.flash q { font-size: 1.12rem; color: var(--ink); }

.plate { margin: 0 0 1.8rem; }
.plate img { display: block; width: 100%; height: auto; mix-blend-mode: multiply;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent), linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent), linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent);
          mask-composite: intersect; }
.plate.side { float: right; width: min(14rem, 38%); margin: .3rem 0 1rem 1.8rem; }
.plate.side figcaption { text-align: left; }

/* ---------- writing ---------- */

.pair { display: grid; grid-template-columns: minmax(0, 1fr) 12.5rem; gap: 2.4rem; align-items: start; }
.pair .plate { margin: 0; }
.pair .plate figcaption { text-align: left; }
.writings { list-style: none; padding: 0; margin: 0; }
.writings li { display: grid; grid-template-columns: 3.4rem 1fr; gap: 1.2rem; align-items: start; padding: 1.1rem 0; border-top: 1px solid var(--rule); }
.writings li:last-child { border-bottom: 1px solid var(--rule); }
.writings .g { font: 2.1rem/1 var(--brush); color: var(--ink); writing-mode: vertical-rl; margin: 0 auto; }
.writings a { font-size: 1.28rem; color: var(--ink); background-size: 0 1px, 0 1px; }
.writings a:hover { background-size: 100% 1px, 0 1px; }
.writings p { margin: .25rem 0 .2rem; font-size: .96rem; }
.writings small { font: .72rem var(--mono); color: var(--muted); }

/* ---------- building ---------- */


.trail { list-style: none; padding: 0; margin: 0; }
.trail > li { display: grid; grid-template-columns: 5.2rem 1fr; gap: 0 1.2rem; }
.trail .day { font: .76rem/2.3 var(--mono); color: var(--muted); text-align: right; }
.trail ol { list-style: none; margin: 0; padding: 0 0 1rem 1.3rem; border-left: 1px solid var(--rule); }
.trail ol li { position: relative; padding: .32rem 0; line-height: 1.45; }
.trail ol li::before { content: ""; position: absolute; left: calc(-1.3rem - 3.5px); top: .95rem; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); opacity: .7; }
.trail > li:first-child ol li:first-child::before { background: var(--jade); opacity: 1; }
.trail .repo { font: .72rem var(--mono); color: var(--muted); margin-right: .5rem; background: none; }
.trail .msg { color: var(--ink-2); background-size: 0 1px, 0 1px; }
.trail .msg:hover { background-size: 100% 1px, 0 1px; }
.trail code { font-size: .7rem; color: var(--muted); margin-left: .4rem; }

/* ---------- built ---------- */

.built { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.6rem 2.4rem; }
.built h3 { font: .72rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; padding-bottom: .4rem; border-bottom: 1px solid var(--rule); }
.built ul { list-style: none; margin: 0; padding: 0; }
.built li { padding: .35rem 0; font-size: .95rem; line-height: 1.45; }
.built li a { font-size: 1.04rem; background-size: 0 1px, 0 1px; }
.built li span { display: block; color: var(--muted); font-size: .92rem; }
.built li a:hover { background-size: 100% 1px, 0 1px; }

.upstream { list-style: none; padding: 0; margin: 0; }
.upstream li { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .8rem 0; border-top: 1px solid var(--rule); }
.minor + .upstream li:first-child { border-top: 0; }
.upstream .r { font: .74rem var(--mono); color: var(--muted); }
.upstream .t { grid-column: 1; color: var(--ink-2); line-height: 1.45; background-size: 0 1px, 0 1px; justify-self: start; }
.upstream .t:hover { background-size: 100% 1px, 0 1px; }
.state { grid-column: 2; grid-row: 1 / span 2; align-self: center; font: .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: .25em .6em; border: 1px solid var(--faint); color: var(--muted); border-radius: 2px; }
.state.merged { background: var(--jade); border-color: var(--jade); color: var(--jade-ink); }
.state.open { border-color: var(--ink); color: var(--ink); }

/* ---------- seasons ---------- */

figure { margin: 0 0 2.2rem; }
figure svg { display: block; width: 100%; height: auto; overflow: visible; }
figcaption { font: .74rem/1.5 var(--mono); color: var(--muted); margin-top: .6rem; letter-spacing: .02em; }
figcaption b { color: var(--jade); font-weight: 400; }
.charts { display: block; }
.heat .d { fill: var(--ink); }
.heat .d0 { fill: var(--ink); opacity: .07; }
.heat .peak { fill: var(--jade); }
.heat text { fill: var(--muted); font: 9px var(--mono); }
.updated { font: .72rem var(--mono); color: var(--muted); margin: 0; }

/* ---------- letters & footer ---------- */

.contact .mail { font-size: clamp(1.4rem, 4vw, 2rem); color: var(--ink); background-size: 0 1px, 0 1px; }
.contact .mail:hover { background-size: 100% 1px, 0 1px; }
.contact p { margin: .4rem 0; }
.contact .mono { color: var(--muted); }

footer {
  max-width: calc(var(--gutter) + var(--measure) + 3rem); margin: 0 auto; padding: 3rem var(--pad);
  display: flex; gap: 1.2rem; align-items: center;
  font: .74rem/1.6 var(--mono); color: var(--muted);
}
footer p { margin: 0; }

/* ---------- a single essay ---------- */

.paperhead { display: flex; justify-content: space-between; align-items: center; padding: 1.4rem var(--pad); font: .82rem var(--mono); }
.paperhead a { color: var(--muted); background: none; }
.paperhead a:hover { color: var(--jade); }
.post-head { padding-top: 3rem; }
.post-head h1 { font-size: clamp(2.2rem, 6vw, 3.3rem); line-height: 1.1; margin: 0 0 .8rem; }
.post-head .meta { font: .78rem var(--mono); color: var(--muted); }
.post { font-size: 1.1rem; }
.post h2 { font-size: 1.5rem; margin: 2.6rem 0 .8rem; }
.post h3 { font-size: 1.22rem; margin: 2.2rem 0 .6rem; }
.post p { margin: 0 0 1.1rem; }
.post ul { padding-left: 1.2rem; }
.post li { margin: .35rem 0; }
.post li::marker { color: var(--jade); }
.post-end { display: flex; justify-content: center; margin: 3.5rem 0 0; }

/* =========================================================
   motion
   ========================================================= */

@media (prefers-reduced-motion: no-preference) {

  /* 1. the scroll unrolls from its top rod */
  .unroll { animation: unroll 2.4s var(--ease) .15s both; will-change: clip-path; }
  .unroll img { animation: settle 3.2s var(--ease) .15s both; }
  @keyframes unroll { from { clip-path: inset(-24px -24px 100% -24px); } to { clip-path: inset(-24px -24px -80px -24px); } }
  @keyframes settle { from { transform: scale(1.045) translateY(-1.5%); } to { transform: none; } }

  /* 2. mist drifts, slowly, forever */
  .mist { animation: drift 26s ease-in-out infinite alternate, fadein 3s ease-out 1.2s both; will-change: transform; }
  @keyframes drift { from { transform: translateX(-9%); } to { transform: translateX(9%); } }
  @keyframes fadein { from { opacity: 0; } }

  /* 3. 無 then 為: ink settling into paper */
  .inscription .big span { display: block; animation: ink 1.8s var(--ease) both; }
  .inscription .big span:nth-child(1) { animation-delay: 1s; }
  .inscription .big span:nth-child(2) { animation-delay: 1.45s; }
  .inscription .small { animation: rise 1.6s var(--ease) 2s both; }
  @keyframes ink { from { opacity: 0; transform: translateY(-.18em) scale(1.08); } 60% { opacity: .92; } to { opacity: 1; transform: none; } }
  @keyframes rise { from { opacity: 0; transform: translateY(-.6rem); } to { opacity: 1; transform: none; } }

  /* 4. the seal is pressed, once */
  .seal-press { animation: stamp .7s cubic-bezier(.3, 1.4, .5, 1) 2.7s both; }
  @keyframes stamp {
    0% { opacity: 0; transform: scale(1.7) rotate(-14deg); }
    55% { opacity: 1; transform: scale(.93) rotate(-1deg); }
    100% { opacity: 1; transform: scale(1) rotate(-2deg); }
  }

  /* 5. as you read on, the strokes between sections are drawn.
        scroll-driven, so it costs nothing until it is on screen;
        browsers without it simply show the stroke. */
  @supports (animation-timeline: view()) {
    .stroke { transform-origin: 0 50%; animation: draw linear both; animation-timeline: view(); animation-range: entry 20% cover 45%; }
    @keyframes draw { from { transform: scaleX(0); opacity: 0; } 30% { opacity: .5; } to { transform: scaleX(1); opacity: .5; } }

  }
}

/* ---------- small screens ---------- */

@media (max-width: 52rem) {
  :root { --gutter: 0rem; }
  .hero { grid-template-columns: minmax(0, 1fr); position: relative; }
  .inscription { position: absolute; top: 1rem; right: var(--pad); padding: 0; }
  .inscription .big { font-size: clamp(2.6rem, 11vw, 3.6rem); }
  .inscription .small, .inscription .col { display: none; }
  .unroll img { height: auto; width: 100%; max-height: 70vh; }
  .sec { grid-template-columns: minmax(0, 1fr); column-gap: 0; }
  .sec > .body { grid-column: 1; }
  .mark { position: static; grid-row: auto; flex-direction: row; align-items: center; gap: .7rem; margin-bottom: 1rem; padding: 0; }
  .mark .glyph { writing-mode: horizontal-tb; }
  .mark .glyph { font-size: 1.7rem; letter-spacing: .05em; }
  .pair { grid-template-columns: minmax(0, 1fr); }
  .pair .plate { width: min(14rem, 60%); margin: 0 auto; }
  .plate.side { float: none; width: min(16rem, 70%); margin: 0 auto 1.6rem; }
}
@media (max-width: 36rem) {
  body { font-size: 17px; }
  .scroll { padding-right: 3.6rem; }
  .trail > li { grid-template-columns: 1fr; }
  .trail .day { text-align: left; line-height: 1.6; }
  .stroke { margin: 3.2rem auto 2.6rem; }
}

/* ---------- night: paintings hang on a dark wall ---------- */

@media (prefers-color-scheme: dark) {
  .unroll img, .plate img {
    mix-blend-mode: normal; filter: brightness(.88);
    -webkit-mask-image: none; mask-image: none;
  }
  .unroll { box-shadow: 0 0 0 10px #1c251e, 0 0 0 11px rgba(226, 233, 220, .1), 0 40px 70px -30px #000; margin: 11px; }
  .plate img { box-shadow: 0 0 0 10px #1c251e, 0 0 0 11px rgba(226, 233, 220, .1); }
  .plate { padding: 11px; }
  .mist { opacity: .22; background: radial-gradient(ellipse 50% 50% at 50% 50%, #e6efe2 0%, transparent 70%); }
}

@media print {
  body { background: #fff; color: #000; }
  .hero, .stroke, .plate { display: none; }
  .mark { position: static; }
}
