/* Layout: one narrow reading column; quiet nav on top; type does all the work. */
:root {
  --bg: #faf8f4;
  --fg: #1d1b18;
  --muted: #8a857c;
  --rule: #e4dfd6;
  --serif: "EB Garamond", "Iowan Old Style", Georgia, "Noto Serif SC", serif;
  --zh: "Noto Serif SC", "Songti SC", serif;
  --gutter: 24px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514; --fg: #d9d4ca; --muted: #7c776e; --rule: #2c2a27; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161514; --fg: #d9d4ca; --muted: #7c776e; --rule: #2c2a27; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--fg); color: var(--bg); }
a:focus-visible, button:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }
h1, h2, h3 { text-wrap: balance; }

.theme {
  background: none; border: 0; color: var(--muted); font: inherit;
  font-size: 18px; cursor: pointer; padding: 4px; line-height: 1;
}
.theme:hover { color: var(--fg); }
.theme.float {
  position: fixed; z-index: 10;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
}

.label {
  font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; color: var(--muted);
}

/* ---------- site nav ---------- */
.site-nav {
  max-width: 40rem; margin: 0 auto;
  padding-block: calc(22px + env(safe-area-inset-top, 0px)) 0;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.site-nav .home { font-size: .78rem; letter-spacing: .26em; text-transform: uppercase; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.4rem; align-items: center; }
.site-nav ul a { font-size: .9rem; color: var(--muted); transition: color .2s; }
.site-nav ul a:hover, .site-nav ul a[aria-current] { color: var(--fg); }

/* ---------- generic page column ---------- */
.page {
  max-width: 40rem; margin: 0 auto;
  padding-block: 14vh 80px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.page > h1 { font-weight: 400; font-size: 2.4rem; letter-spacing: .02em; margin: 0 0 3rem; line-height: 1.15; }
.page section + section { margin-top: 4.5rem; }
.page section > .label { margin: 0 0 1rem; }
.empty { color: var(--muted); font-style: italic; }

/* home */
.intro h1 { font-weight: 400; font-size: clamp(2.6rem, 9vw, 4rem); margin: 0; line-height: 1.1; letter-spacing: .01em; }
.intro p { margin: .8rem 0 0; color: var(--muted); font-style: italic; }

/* entries (works & writing lists) */
.entries { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.entries li { border-bottom: 1px solid var(--rule); }
.entries a { display: block; padding: 1.3rem 0; transition: padding .25s; }
.entries a:hover { padding-left: .5rem; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.entry-title { font-size: 1.5rem; line-height: 1.25; }
.entry-meta { font-size: .8rem; color: var(--muted); letter-spacing: .06em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-summary { margin: .35rem 0 0; color: var(--muted); font-size: 1rem; font-style: italic; }

/* prose (about, posts) */
.prose p { margin: 0 0 1.1em; }
.prose .break { text-align: center; color: var(--muted); margin: 2em 0; letter-spacing: .6em; }
.prose .signoff { margin-top: 2.6em; text-align: right; font-style: italic; color: var(--muted); line-height: 1.5; }
[hidden] { display: none !important; }
.portrait { margin: 0 0 2.6rem; max-width: 22rem; }
.portrait img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 1; background: #000; }
.post-head { margin-bottom: 3rem; }
.post-head h1 { font-weight: 400; font-size: 2.4rem; margin: .4rem 0 0; line-height: 1.15; }
.back { display: inline-block; margin-top: 4rem; font-size: .85rem; letter-spacing: .08em; color: var(--muted); }
.back:hover { color: var(--fg); }

footer.site-foot {
  max-width: 40rem; margin: 0 auto;
  padding-block: 0 48px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  color: var(--muted); font-size: .75rem; letter-spacing: .1em;
}

/* ---------- work cover ---------- */
.cover {
  max-width: 34rem; margin: 0 auto; text-align: center;
  padding-block: 14vh 80px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.cover h1 {
  font-weight: 400; font-size: clamp(3rem, 11vw, 5rem);
  letter-spacing: .04em; margin: 0; line-height: 1.1;
}
.author { margin: .9rem 0 0; color: var(--muted); font-size: .8rem; letter-spacing: .28em; text-transform: uppercase; }
.epigraph {
  margin: 12vh auto 0; max-width: 26rem; font-style: italic;
  font-size: 1rem; color: var(--muted); line-height: 1.65;
}
.epigraph p { margin: 0 0 .8rem; }
.epigraph .zh { font-family: var(--zh); font-style: normal; letter-spacing: .08em; color: var(--fg); }
.epigraph cite { font-style: normal; font-size: .85rem; letter-spacing: .06em; }
.begin {
  display: inline-block; margin-top: 10vh;
  font-size: .8rem; letter-spacing: .24em; text-transform: uppercase;
  border-bottom: 1px solid var(--fg); padding-bottom: 4px; transition: opacity .2s;
}
.begin:hover { opacity: .55; }
.toc { margin-top: 12vh; text-align: left; }
.toc ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.toc li { border-bottom: 1px solid var(--rule); }
.toc a { display: flex; gap: 1.4rem; align-items: baseline; padding: .85rem 0; font-size: 1rem; transition: padding .25s; }
.toc a:hover { padding-left: .5rem; }
.toc .num { width: 2.4rem; flex: none; letter-spacing: .06em; }
.toc .first { min-width: 0; color: var(--muted); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { margin-top: 2.2rem; color: var(--muted); font-size: .8rem; letter-spacing: .06em; }

/* ---------- chapter ---------- */
.progress { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 2px; z-index: 20; }
.progress span { display: block; height: 100%; width: 0; background: var(--fg); opacity: .5; }
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9; background: var(--bg);
  padding-block: calc(18px + env(safe-area-inset-top, 0px)) 14px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  font-size: .75rem; letter-spacing: .24em; text-transform: uppercase; color: var(--muted);
  transition: background .3s;
}
.bar a:hover { color: var(--fg); }
.bar .sep { margin: 0 .6em; opacity: .5; }

.chapter {
  max-width: 33rem; margin: 0 auto;
  padding-block: 22vh 64px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.chapter h2 { text-align: center; font-weight: 400; font-size: 2.2rem; letter-spacing: .1em; margin: 0 0 4.5rem; }
.chapter article p { margin: 0; text-indent: 1.5em; }
.chapter article p:first-child { text-indent: 0; }
.chapter article p:first-child::first-line { font-variant: small-caps; letter-spacing: .04em; }
.fin { text-align: center; margin: 4rem 0 0; color: var(--muted); }
.pager {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 6rem; padding-top: 1.4rem; border-top: 1px solid var(--rule);
  font-size: .85rem; letter-spacing: .08em;
}
.pager span { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.pager a { transition: opacity .2s; }
.pager a:hover { opacity: .55; }

@media (max-width: 600px) {
  :root { --gutter: 16px; }
  body { font-size: 19px; }
  .chapter { padding-block: 16vh 48px; }
  .site-nav ul { gap: 1rem; }
  .theme.float { top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(8px + env(safe-area-inset-right, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
