/* ============================================================
   LYU MINGLEI — personal site ·「夜航手稿 Night Manuscript」
   night sky / city lights / warm paper / ink / vermilion seal
   zero dependency · system fonts only
   ============================================================ */

:root {
  /* night */
  --night:   #131009;
  --night-2: #1B160F;
  --night-3: #251E14;
  /* paper */
  --paper:   #F4EEE1;
  --paper-2: #ECE3D0;
  --card:    #FBF8F0;
  /* ink */
  --ink:     #221C13;
  --ink-2:   #6E6555;
  --hair:    #D9D0BC;
  --hair-2:  #C6BA9F;
  /* accents */
  --verm:    #C0492B;
  --verm-2:  #A93D22;
  --gold:    #B8892F;
  --gold-2:  #D9A94E;
  /* text on night */
  --cream:   #F0E8D8;
  --cream-2: #B4A88E;
  --cream-3: #877C63;

  --serif: Georgia, "Times New Roman", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --sans:  -apple-system, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --script: "Snell Roundhand", "Savoye LET", "Brush Script MT", cursive;

  --w: 1080px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* View Transitions: cross-fade between pages (progressive enhancement) */
@view-transition { navigation: auto; }

html { scroll-behavior: smooth; background: var(--night); }

body {
  font-family: var(--serif);
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--verm); color: var(--cream); }

.wrap { max-width: var(--w); margin: 0 auto; padding: 0 28px; }

a { color: inherit; }
img { max-width: 100%; display: block; }

/* ---- film grain over everything (paper & night alike) ---- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* ============================================================
   FLOAT NAV — night glass at top, docks to paper glass on scroll
   ============================================================ */

.float-nav {
  position: fixed;
  top: 14px;
  left: 50%;
  translate: -50% 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 28px));
  padding: 9px 10px 9px 24px;
  border-radius: 999px;
  background: rgba(19, 16, 9, .42);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: inset 0 0 0 1px rgba(240, 232, 216, .14), 0 12px 34px rgba(8, 6, 2, .35);
  transition: background .45s ease, box-shadow .45s ease;
}
.float-nav .brand {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 16.5px;
  letter-spacing: -0.02em;
  color: var(--cream);
  text-decoration: none;
  white-space: nowrap;
  transition: color .45s ease;
}
.float-nav .brand i {
  font-style: normal;
  color: var(--verm);
}
.float-nav nav.main { display: flex; gap: 4px; }
.float-nav nav.main a {
  font-family: var(--sans);
  font-size: 13.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cream-2);
  text-decoration: none;
  padding: 8px 13px;
  border-radius: 999px;
  transition: color .45s ease, background .2s ease;
}
.float-nav nav.main a:hover { color: var(--cream); background: rgba(240, 232, 216, .1); }
.float-nav nav.main a[aria-current="page"] { color: var(--night); background: var(--cream); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 8px; }

.cta-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--verm);
  color: #FFF6E8;
  border-radius: 999px;
  padding: 7px 7px 7px 18px;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .25s ease, box-shadow .25s ease, background .45s ease;
}
.cta-pill .arr {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #FFF6E8;
  color: var(--verm-2);
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: transform .25s ease;
}
.cta-pill:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(192, 73, 43, .38); }
.cta-pill:hover .arr { transform: translateX(2px); }

.lang-toggle {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: none;
  border: 1px solid rgba(240, 232, 216, .25);
  color: var(--cream-2);
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .45s ease, border-color .45s ease;
}
.lang-toggle:hover { border-color: var(--cream); color: var(--cream); }

/* docked: masthead scrolled away → paper glass */
body.docked .float-nav {
  background: rgba(244, 238, 225, .88);
  box-shadow: inset 0 0 0 1px rgba(34, 28, 19, .08), 0 10px 30px rgba(34, 28, 19, .12);
}
body.docked .float-nav .brand { color: var(--ink); }
body.docked .float-nav nav.main a { color: var(--ink-2); }
body.docked .float-nav nav.main a:hover { color: var(--ink); background: rgba(34, 28, 19, .06); }
body.docked .float-nav nav.main a[aria-current="page"] { color: var(--verm); background: rgba(192, 73, 43, .1); }
body.docked .lang-toggle { border-color: rgba(34, 28, 19, .2); color: var(--ink-2); }
body.docked .lang-toggle:hover { border-color: var(--ink); color: var(--ink); }
body.docked .cta-pill { background: var(--night); }
body.docked .cta-pill .arr { color: var(--night); }

@media (max-width: 860px) {
  .float-nav { flex-wrap: wrap; row-gap: 2px; padding: 10px 8px 10px 20px; }
  .nav-right { margin-left: auto; }
  .float-nav nav.main {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 4px;
  }
  .float-nav nav.main::-webkit-scrollbar { display: none; }
}

/* ============================================================
   MAST — the night sky masthead (home hero & subpage headers)
   ============================================================ */

.mast {
  position: relative;
  background:
    radial-gradient(130% 74% at 50% 116%, rgba(216, 148, 62, .30), transparent 58%),
    radial-gradient(90% 60% at 82% -14%, rgba(64, 78, 116, .35), transparent 62%),
    radial-gradient(120% 90% at 12% -20%, rgba(43, 36, 24, .9), transparent 70%),
    linear-gradient(180deg, #0E0B06 0%, #171209 58%, #241A0D 100%);
  color: var(--cream);
  overflow: visible;
}
.mast::after { /* the stitched seam: night ends, paper begins */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 7px;
  border-top: 3px solid var(--cream);
  border-bottom: 1px solid var(--cream);
  opacity: .92;
  z-index: 4;
}
#night-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.mast-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* home hero */
.mast-home { min-height: max(92svh, 620px); padding: 150px 0 120px; }
.mast-home .mast-inner { justify-content: center; flex: 1; }
.mast-home .wrap.mast-inner { min-height: max(92svh, 620px); }

/* subpage masthead */
.mast-page { min-height: 54svh; padding: 150px 0 96px; }
.mast-page .wrap.mast-inner { min-height: 54svh; justify-content: center; }

.kicker-night {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 22px;
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.kicker-night::before, .kicker-night::after {
  content: "";
  width: 30px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-2));
}
.kicker-night::after { background: linear-gradient(90deg, var(--gold-2), transparent); }

.mast-title {
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.04;
  color: var(--cream);
}
.mast-home .mast-title { font-size: clamp(3rem, 8.2vw, 6.8rem); }
.mast-page .mast-title { font-size: clamp(2.5rem, 5.8vw, 4.6rem); }
.mast-title .tick { font-style: normal; color: var(--verm); }
.mast-title .zh-side {
  display: block;
  font-size: clamp(.95rem, 1.6vw, 1.15rem);
  font-weight: 400;
  letter-spacing: .42em;
  color: var(--cream-2);
  margin-top: clamp(14px, 2vw, 22px);
  text-indent: .42em; /* optically recenters tracked CJK */
}

/* line-mask reveal */
.ln { display: block; overflow: hidden; padding-bottom: .08em; margin-bottom: -.08em; }
.ln > span { display: block; }
body:not(.reduced) .ln > span {
  translate: 0 112%;
  animation: lnUp .95s cubic-bezier(.19, .8, .22, 1) var(--d, 0s) forwards;
}
@keyframes lnUp { to { translate: 0 0; } }

/* generic hero rise */
body:not(.reduced) .heroR {
  opacity: 0;
  translate: 0 18px;
  animation: heroRise .8s ease var(--d, 0s) forwards;
}
@keyframes heroRise { to { opacity: 1; translate: 0 0; } }

.mast-home .dek {
  font-family: var(--sans);
  font-size: clamp(1.02rem, 1.7vw, 1.22rem);
  line-height: 1.75;
  color: var(--cream-2);
  max-width: 40em;
  margin: clamp(22px, 3vw, 34px) auto 0;
}
.kw-a { color: #E07A55; font-weight: 600; }
.kw-b { color: #8FB3E8; font-weight: 600; }
.kw-c { color: #D9A94E; font-weight: 600; }

.mast-page .mast-lede {
  font-size: 1.08rem;
  font-style: italic;
  color: var(--cream-2);
  max-width: 44em;
  margin-top: clamp(16px, 2.4vw, 24px);
}
html[lang="zh-CN"] .mast-page .mast-lede { font-style: normal; }

/* proof chip */
.proof-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(240, 232, 216, .07);
  border: 1px solid rgba(240, 232, 216, .16);
  border-radius: 999px;
  padding: 5px 20px 5px 5px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
  letter-spacing: .02em;
}
.proof-pill img {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 12%;
  box-shadow: 0 0 0 2px rgba(217, 169, 78, .55);
}

/* CTA */
.cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: clamp(30px, 4.5vw, 46px);
  flex-wrap: wrap;
}
.cta-big {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: var(--verm);
  color: #FFF6E8;
  border-radius: 999px;
  padding: 9px 9px 9px 28px;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 18px 44px rgba(192, 73, 43, .35);
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease;
  will-change: transform;
}
.cta-big .arr {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #FFF6E8;
  color: var(--verm-2);
  display: grid;
  place-items: center;
  font-size: 17px;
  transition: transform .25s ease;
}
.cta-big:hover { background: var(--verm-2); transform: translateY(-2px); box-shadow: 0 24px 54px rgba(192, 73, 43, .42); }
.cta-big:hover .arr { transform: translateX(3px); }
.doodle { width: 64px; height: 30px; flex: none; }
.doodle path { stroke: var(--cream-2); }
.doodle-note {
  font-family: var(--sans);
  font-style: italic;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cream-2);
  rotate: -5deg;
}
.proof-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: clamp(26px, 3.6vw, 38px);
  flex-wrap: wrap;
}
.stars { color: var(--gold-2); letter-spacing: 3px; font-size: 15px; }
.proof-text { font-family: var(--sans); font-size: 13.5px; font-weight: 600; color: var(--cream-2); }

/* scroll cue */
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 30px;
  translate: -50% 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--cream-3);
}
.scroll-cue i {
  width: 1px; height: 44px;
  background: rgba(240, 232, 216, .22);
  position: relative;
  overflow: hidden;
}
.scroll-cue i::after {
  content: "";
  position: absolute;
  left: 0; top: -10px;
  width: 1px; height: 10px;
  background: var(--gold-2);
  animation: cueDrop 2.2s ease-in-out infinite;
}
@keyframes cueDrop { 0% { top: -10px; } 70%, 100% { top: 48px; } }
.scroll-cue:hover { color: var(--cream-2); }

/* ghost page numeral */
.ghost-no {
  position: absolute;
  right: 3vw;
  bottom: 4vh;
  z-index: 1;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(6rem, 17vw, 12.5rem);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(240, 232, 216, .20);
  user-select: none;
  pointer-events: none;
}

/* the seal — vermilion 「吕」 stamp straddling the seam */
.seal {
  position: absolute;
  right: clamp(16px, 7vw, 96px);
  bottom: -33px;
  z-index: 5;
  width: clamp(52px, 6vw, 66px);
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(192, 73, 43, .35));
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
  will-change: transform;
}
.seal:hover { transform: rotate(-7deg) scale(1.06); }

/* ============================================================
   MARQUEE — outlined editorial word-band on paper
   ============================================================ */

.marquee {
  border-bottom: 1px solid var(--hair);
  padding: 20px 0 16px;
  overflow: hidden;
  background: var(--paper);
}
.marquee-track {
  display: flex;
  align-items: baseline;
  gap: 44px;
  width: max-content;
  animation: marq 42s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track span {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.9rem, 4.2vw, 3.2rem);
  line-height: 1.15;
  color: transparent;
  -webkit-text-stroke: 1.2px rgba(34, 28, 19, .5);
  white-space: nowrap;
}
.marquee-track span.sol { color: var(--verm); -webkit-text-stroke: 0; }
.marquee-track i {
  font-style: normal;
  font-size: 11px;
  color: var(--gold);
  translate: 0 -8px;
}
@keyframes marq { to { transform: translateX(-50%); } }

/* ============================================================
   PAPER SECTIONS
   ============================================================ */

.section { padding: 72px 0 20px; }

.kicker {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--verm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.kicker::before { content: ""; width: 34px; height: 1px; background: var(--verm); flex: none; }
.kicker .no { font-family: var(--serif); font-style: italic; letter-spacing: 0; margin-right: 2px; font-size: 13px; }

h2.title {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.018em;
  margin-bottom: 14px;
}
h2.title .zh { font-size: .5em; color: var(--ink-2); margin-left: 14px; font-weight: 400; letter-spacing: .18em; }

.lede {
  font-size: 1.12rem;
  color: var(--ink-2);
  max-width: 640px;
  margin: 18px 0 8px;
}

/* ---------- index / table of contents ---------- */

.toc { margin-top: 34px; border-top: 2px solid var(--ink); }
.toc-row {
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr auto 44px;
  gap: 22px;
  align-items: baseline;
  padding: 26px 6px;
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  overflow: hidden;
}
.toc-row::before { /* ink wash sweeps in from the left on hover */
  content: "";
  position: absolute;
  inset: 0;
  background: var(--night);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform .38s cubic-bezier(.65, 0, .35, 1);
  z-index: 0;
}
.toc-row:hover::before { transform: scaleX(1); }
.toc-row > * { position: relative; z-index: 1; transition: color .3s ease, translate .3s ease; }
.toc-row .no {
  font-style: italic;
  color: var(--gold);
  font-size: 1.7rem;
  font-variant-numeric: oldstyle-nums;
  transition: color .3s ease;
}
.toc-row .name { font-size: clamp(1.4rem, 2.6vw, 1.9rem); transition: translate .3s ease; }
.toc-row .name .zh { font-size: .8rem; color: var(--ink-2); margin-left: 14px; letter-spacing: .18em; }
.toc-row .hint { font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.toc-row .arr {
  font-size: 1.3rem;
  color: var(--verm);
  opacity: 0;
  translate: -14px 0;
  transition: opacity .3s ease, translate .3s ease;
}
.toc-row:hover .name { translate: 10px 0; }
.toc-row:hover .no { color: var(--gold-2); }
.toc-row:hover .name, .toc-row:hover .hint { color: var(--cream); }
.toc-row:hover .name .zh { color: var(--cream-2); }
.toc-row:hover .arr { opacity: 1; translate: 0 0; }

/* ---------- now strip — the ledger on night ---------- */

.now {
  background: linear-gradient(180deg, var(--paper) 0%, var(--night) 9%, var(--night) 91%, var(--paper) 100%);
  color: var(--cream);
  padding: 64px 0 58px;
  margin: 72px 0 0;
}
.now .label {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.now .label i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--verm);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192, 73, 43, .5); } 50% { box-shadow: 0 0 0 7px rgba(192, 73, 43, 0); } }
.now ul { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 0 40px; }
.now li {
  font-size: 1.04rem;
  font-style: italic;
  padding: 16px 4px;
  border-top: 1px solid rgba(240, 232, 216, .14);
}
.now li::before { content: "✦"; color: var(--gold-2); margin-right: 12px; font-style: normal; font-size: .8rem; }
html[lang="zh-CN"] .now li { font-style: normal; }

/* ---------- contact ---------- */

.contact { text-align: left; padding: 84px 0 40px; }
.contact h2 { font-size: clamp(1.9rem, 4.4vw, 2.9rem); font-weight: 500; line-height: 1.25; max-width: 20em; }
.contact-row { display: flex; align-items: center; gap: 22px; margin-top: 26px; flex-wrap: wrap; }
.contact .mail {
  display: inline-block;
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
  font-style: italic;
  text-decoration: none;
  color: var(--verm);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 3px;
  transition: background-size .35s ease;
}
.contact .mail:hover { background-size: 0% 1px; }
.copy-btn {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--hair-2);
  color: var(--ink-2);
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s ease, border-color .25s ease, background .25s ease;
}
.copy-btn:hover { border-color: var(--ink); color: var(--ink); }
.copy-btn.done { background: var(--ink); border-color: var(--ink); color: var(--cream); }

/* mail popover — Say Hello opens this instead of a mail client */
.mail-pop {
  position: fixed;
  z-index: 70;
  width: min(320px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(8, 6, 2, .30);
  padding: 15px 18px 16px;
  opacity: 0;
  translate: 0 6px;
  pointer-events: none;
  transition: opacity .22s ease, translate .22s ease;
}
.mail-pop.show { opacity: 1; translate: 0 0; pointer-events: auto; }
.mail-pop .label {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.mail-pop .addr {
  font-size: 1.02rem;
  font-style: italic;
  color: var(--ink);
  word-break: break-all;
  line-height: 1.5;
}
.mail-pop .row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.mail-pop .pop-copy {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  background: var(--verm);
  color: #FFF6E8;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background .25s ease, transform .25s ease;
}
.mail-pop .pop-copy:hover { background: var(--verm-2); transform: translateY(-1px); }
.mail-pop .pop-copy.done { background: var(--ink); }
.mail-pop .pop-open {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: .06em;
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  padding: 8px 14px;
  transition: color .25s ease, border-color .25s ease;
}
.mail-pop .pop-open:hover { color: var(--ink); border-color: var(--ink); }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  translate: -50% 16px;
  z-index: 90;
  background: var(--night);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: .04em;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 16px 40px rgba(8, 6, 2, .35), inset 0 0 0 1px rgba(240, 232, 216, .14);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, translate .3s ease;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- footer — night returns ---------- */

.site-foot {
  margin-top: 96px;
  background:
    radial-gradient(90% 70% at 50% 118%, rgba(216, 148, 62, .16), transparent 60%),
    linear-gradient(180deg, var(--paper) 0%, var(--night) 8%, #0E0B06 100%);
  color: var(--cream);
  padding: 0 0 42px;
}
.foot-rule { border-top: 3px solid var(--ink); border-bottom: 1px solid var(--ink); height: 6px; }
.foot-mark {
  padding-top: 64px;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 8.4vw, 6.4rem);
  line-height: 1;
  letter-spacing: .01em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(240, 232, 216, .3);
  user-select: none;
}
.foot-mark .zh {
  display: block;
  font-size: clamp(.8rem, 1.6vw, 1rem);
  letter-spacing: .78em;
  color: var(--cream-3);
  -webkit-text-stroke: 0;
  margin-top: 14px;
}
.foot-inner {
  padding: 44px 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.signature {
  font-family: var(--script);
  font-size: 2.1rem;
  line-height: 1.2;
  color: var(--cream);
}
.foot-right { display: flex; align-items: center; gap: 20px; }
.backtop {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(240, 232, 216, .3);
  background: none;
  color: var(--cream-2);
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .3s ease, color .3s ease, border-color .3s ease, transform .3s ease;
}
.backtop:hover { background: var(--verm); border-color: var(--verm); color: #FFF6E8; transform: translateY(-3px); }
.foot-copy {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--cream-3);
  text-align: right;
  line-height: 1.7;
}

/* ---------- dossier cards (research / projects / writing) ---------- */

.entry {
  position: relative;
  border: 1px solid var(--hair);
  background: var(--card);
  padding: 32px 32px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 28px;
  transition: translate .3s ease, box-shadow .3s ease, border-color .3s ease;
}
.entry:hover {
  translate: 0 -3px;
  border-color: var(--hair-2);
  box-shadow: 0 18px 38px rgba(34, 28, 19, .09);
}
.entry:last-of-type { margin-bottom: 0; }
.entry h3 { font-size: 1.42rem; font-weight: 500; line-height: 1.3; }
.entry h3 .zh { font-size: .9rem; color: var(--ink-2); margin-left: 10px; font-weight: 400; }
.entry .sub { font-style: italic; color: var(--ink-2); font-size: .95rem; margin: 6px 0 12px; }
.entry p.body { color: var(--ink-2); }
.entry .meta { font-family: var(--sans); font-size: 12px; color: var(--ink-2); text-align: right; line-height: 1.9; }
.entry .meta .tag {
  display: inline-block;
  border: 1px solid var(--hair-2);
  padding: 4px 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 10px;
  margin-bottom: 8px;
}
.entry .meta .tag.stamp {
  border: 1.5px solid var(--verm);
  color: var(--verm);
  rotate: -4deg;
  border-radius: 2px;
  font-weight: 700;
}
.entry.featured { border-left: 3px solid var(--gold); }

/* ---------- project cards ---------- */

.p-row {
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr 190px;
  gap: 28px;
  padding: 36px 32px;
  border: 1px solid var(--hair);
  background: var(--card);
  margin-bottom: 20px;
  transition: translate .3s ease, box-shadow .3s ease, border-color .3s ease;
}
.p-row:hover { translate: 0 -4px; border-color: var(--hair-2); box-shadow: 0 22px 44px rgba(34, 28, 19, .1); }
.p-row .no {
  font-style: italic;
  font-size: 2.1rem;
  color: var(--gold);
  line-height: 1.1;
  font-variant-numeric: oldstyle-nums;
  transition: color .3s ease;
}
.p-row:hover .no { color: var(--verm); }
.p-row h3 { font-size: 1.6rem; font-weight: 500; line-height: 1.25; }
.p-row h3 .zh { font-size: .95rem; color: var(--ink-2); font-weight: 400; margin-left: 12px; }
.p-row .desc { color: var(--ink-2); margin-top: 12px; max-width: 620px; font-size: 1rem; }
.p-row .meta { font-family: var(--sans); font-size: 12px; }
.p-row .meta .tag {
  display: inline-block;
  border: 1px solid var(--ink-2);
  padding: 4px 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 10.5px;
  margin-bottom: 12px;
}
.p-row .meta .tag.live {
  background: var(--verm);
  border-color: var(--verm);
  color: #FFF6E8;
  rotate: -3deg;
  border-radius: 2px;
  font-weight: 700;
}
.p-row .meta .link { display: block; margin-top: 4px; color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--hair); transition: color .25s ease, border-color .25s ease; }
.p-row .meta .link:hover { color: var(--verm); border-bottom-color: var(--verm); }
.p-row .meta .soon { color: var(--ink-2); font-style: italic; }

/* flowing-light border on project cards (conic sweep, border-only) */
@property --card-angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.p-row::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1.5px;
  background: conic-gradient(from var(--card-angle),
    transparent 0 66%, var(--gold-2) 78%, var(--verm) 88%, #7FA8E8 96%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
.p-row:hover::before { opacity: 1; animation: cardSpin 4.5s linear infinite; }
@keyframes cardSpin { to { --card-angle: 360deg; } }

/* ---------- prose blocks ---------- */

.prose { max-width: 720px; }
.prose p { margin-bottom: 1.15em; }
.dropcap::first-letter {
  float: left;
  font-size: 3.4em;
  line-height: .85;
  padding: 6px 10px 0 0;
  color: var(--verm);
  font-style: italic;
}

/* ---------- gallery ---------- */

.chapters-nav {
  position: sticky;
  top: 78px;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 8px;
  padding: 12px 0;
  background: rgba(244, 238, 225, .9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.chapters-nav a {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .1em;
  text-decoration: none;
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  padding: 6px 16px;
  color: var(--ink-2);
  background: var(--card);
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}
.chapters-nav a:hover { border-color: var(--ink); color: var(--ink); }
.chapters-nav a.active { background: var(--ink); border-color: var(--ink); color: var(--cream); }

.chapter { padding-top: 46px; }
.chapter + .chapter { border-top: 1px solid var(--hair); margin-top: 34px; padding-top: 56px; }
.chapter-title { font-size: 1.65rem; font-weight: 500; line-height: 1.3; }
.chapter-title .no { font-style: italic; color: var(--verm); margin-right: 12px; }
.chapter-title .zh { font-size: 1rem; color: var(--ink-2); margin-left: 10px; font-weight: 400; }
.chapter-intro {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 30px;
  margin: 10px 0 4px;
  max-width: 920px;
}
.chapter-intro .en { font-style: italic; color: var(--ink-2); }
.chapter-intro .zh {
  color: var(--ink-2);
  font-size: .95rem;
  border-left: 1px solid var(--hair);
  padding-left: 24px;
}
@media (max-width: 720px) {
  .chapter-intro { grid-template-columns: 1fr; gap: 10px; }
  .chapter-intro .zh { border-left: none; padding-left: 0; }
}
.chapter .gallery { margin-top: 16px; }

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 26px;
}
.gallery figure { margin: 0; }
.gallery .ph-frame {
  aspect-ratio: 4 / 5;
  cursor: zoom-in;
  background: var(--card);
  border: 1px solid var(--hair);
  transition: box-shadow .3s ease, translate .3s ease;
}
.gallery .ph-frame.r-land,
.gallery .ph-frame.r-port,
.gallery .ph-frame.r-sq { aspect-ratio: 4 / 5; }
.gallery .ph-frame:hover {
  translate: -3px -3px;
  box-shadow: 7px 7px 0 var(--card), 7px 7px 0 1.5px var(--verm);
}
.gallery .ph-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .55s ease, opacity .5s ease;
  opacity: 0;
}
.gallery .ph-frame img.loaded { opacity: 1; }
.gallery .ph-frame:hover img { transform: scale(1.045); }

@media (max-width: 860px) { .gallery { grid-template-columns: repeat(2, 1fr); } }

/* photo frame — portrait & empty states */
.ph-frame {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ph-frame img { width: 100%; height: 100%; object-fit: cover; }
.ph-frame .ph-empty {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-align: center;
  padding: 20px;
  line-height: 2;
}
.ph-frame .ph-empty .big { font-family: var(--serif); font-style: italic; font-size: 18px; letter-spacing: .02em; text-transform: none; }

.ph-caption {
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-2);
  margin-top: 10px;
  line-height: 1.5;
}
.ph-caption em { color: var(--verm); }

/* ---------- hobby chips ---------- */

.hobbies { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 26px; }
.hobbies .chip {
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 1rem;
  font-style: italic;
  background: var(--card);
  transition: border-color .25s ease, translate .25s ease, box-shadow .25s ease;
}
.hobbies .chip:hover {
  translate: 0 -2px;
  border-color: var(--ink);
  box-shadow: 0 10px 24px rgba(34, 28, 19, .08);
}
.hobbies .chip span { color: var(--verm); margin-right: 10px; font-style: normal; }
html[lang="zh-CN"] .hobbies .chip { font-style: normal; }

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

.w-row {
  border-top: 1px solid var(--hair);
  padding: 34px 4px;
}
.w-row:last-of-type { border-bottom: 1px solid var(--hair); }
.w-row h3 { font-size: 1.75rem; font-weight: 500; }
.w-row h3 .zh { font-size: 1.05rem; color: var(--ink-2); margin-left: 14px; font-weight: 400; }
.w-row .sub { font-style: italic; color: var(--ink-2); margin: 6px 0 14px; }
.w-row p.body { max-width: 680px; color: var(--ink-2); }
.w-row .excerpt {
  position: relative;
  margin: 20px 0 0;
  padding: 26px 30px 24px 58px;
  background: var(--paper-2);
  border-left: 3px solid var(--verm);
  font-style: italic;
  color: var(--ink-2);
  max-width: 660px;
}
html[lang="zh-CN"] .w-row .excerpt { font-style: normal; }
.w-row .excerpt::before {
  content: "\201C";
  position: absolute;
  top: 2px; left: 14px;
  font-family: var(--serif);
  font-size: 3.6rem;
  line-height: 1;
  color: var(--verm);
  opacity: .8;
}
.w-row .excerpt a {
  display: inline-block;
  margin-top: 10px;
  font-style: normal;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--verm);
  text-decoration: none;
  border-bottom: 1px solid var(--verm);
  padding-bottom: 2px;
  transition: color .25s ease, border-color .25s ease;
}
.w-row .excerpt a:hover { color: var(--verm-2); border-color: var(--verm-2); }

/* ---------- reveal on scroll (guarded) ---------- */

body.reveal-ready .reveal {
  opacity: 0;
  translate: 0 18px;
  transition: opacity .65s ease, translate .65s ease;
  transition-delay: var(--stagger, 0s);
}
body.reveal-ready .reveal.in { opacity: 1; translate: 0 0; }

/* ---------- focus & scrollbar ---------- */

:focus-visible { outline: 2px solid var(--verm); outline-offset: 3px; }

html { scrollbar-width: thin; scrollbar-color: var(--hair-2) var(--paper); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--hair-2); border: 3px solid var(--paper); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-2); }

/* ---- CJK: no fake italics in zh mode ---- */
html[lang="zh-CN"] .dek,
html[lang="zh-CN"] .ph-caption,
html[lang="zh-CN"] .entry .sub,
html[lang="zh-CN"] .w-row .sub,
html[lang="zh-CN"] .chapter-intro p,
html[lang="zh-CN"] .toc-row .no,
html[lang="zh-CN"] .p-row .no,
html[lang="zh-CN"] .lb-cap,
html[lang="zh-CN"] .now .label { font-style: normal; }

/* ---------- lightbox ---------- */

.lb {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 4, .93);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.lb.open { display: flex; }
.lb .lb-img {
  max-width: 88vw;
  max-height: 86vh;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
}
.lb .lb-cap {
  position: absolute;
  bottom: 26px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--cream-2);
  font-style: italic;
  font-size: .95rem;
  letter-spacing: .04em;
}
.lb button {
  position: absolute;
  background: none;
  border: none;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 2.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 10px 18px;
  transition: color .2s ease, transform .2s ease;
}
.lb button:hover { color: var(--verm); }
.lb .lb-close { top: 10px; right: 16px; font-size: 2rem; }
.lb .lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb .lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb .lb-prev:hover { transform: translateY(-50%) translateX(-3px); }
.lb .lb-next:hover { transform: translateY(-50%) translateX(3px); }

@keyframes lbIn {
  from { transform: scale(.965); }
  to   { transform: none; }
}
.lb.open .lb-img { animation: lbIn .32s ease; }
.lb.open .lb-cap { animation: lbIn .45s ease; }

@keyframes lbFromL { from { translate: -20px 0; } to { translate: 0 0; } }
@keyframes lbFromR { from { translate: 20px 0; } to { translate: 0 0; } }
.lb .lb-img.lb-from-l { animation: lbFromL .28s ease; }
.lb .lb-img.lb-from-r { animation: lbFromR .28s ease; }

/* ---------- reading progress line ---------- */

.progress-line {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, var(--verm), var(--gold-2));
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 80;
  pointer-events: none;
}

/* ---------- prose links: underline grows on hover ---------- */

.prose p a, .entry p a, .desc a, .excerpt a, .chapter-intro p a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 2px;
  transition: background-size .35s ease;
}
.prose p a:hover, .entry p a:hover, .desc a:hover, .chapter-intro p a:hover {
  background-size: 100% 1px;
}

/* ---------- custom cursor ---------- */

body.cursor-on, body.cursor-on * { cursor: none !important; }
.cursor-dot, .cursor-ring {
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity .25s ease;
}
.cursor-dot {
  width: 7px; height: 7px;
  background: var(--verm);
  margin: -3.5px 0 0 -3.5px;
}
.cursor-ring {
  width: 34px; height: 34px;
  margin: -17px 0 0 -17px;
  border: 1.5px solid rgba(192, 73, 43, .6);
  transition: width .25s ease, height .25s ease, margin .25s ease, opacity .25s ease, border-color .25s ease;
}
body.cursor-on .cursor-dot, body.cursor-on .cursor-ring { opacity: 1; }
body.cursor-hover .cursor-ring {
  width: 52px; height: 52px;
  margin: -26px 0 0 -26px;
  border-color: rgba(184, 137, 47, .9);
}
body.cursor-down .cursor-ring { width: 26px; height: 26px; margin: -13px 0 0 -13px; }

/* ---------- responsive ---------- */

@media (max-width: 820px) {
  .p-row { grid-template-columns: 1fr; gap: 14px; padding: 28px 22px; }
  .p-row .meta { text-align: left; }
  .entry { grid-template-columns: 1fr; padding: 26px 22px; }
  .entry .meta { text-align: left; }
  .toc-row { grid-template-columns: 54px 1fr 34px; }
  .toc-row .hint { display: none; }
  .mast-home { padding: 130px 0 110px; }
  .mast-page { padding: 130px 0 84px; }
  .ghost-no { opacity: .6; }
  .seal { right: 18px; bottom: -26px; }
}

/* ---------- reduced motion: everything readable, nothing moves ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ln > span { animation: none !important; translate: none !important; }
  .heroR { animation: none !important; opacity: 1 !important; translate: none !important; }
  body.reveal-ready .reveal { opacity: 1 !important; translate: none !important; transition: none !important; }
  .marquee-track { animation: none !important; }
  .scroll-cue i::after { animation: none; }
  .now .label i { animation: none; }
  .p-row:hover::before { animation: none; }
  .lb .lb-img.lb-from-l, .lb .lb-img.lb-from-r, .lb.open .lb-img, .lb.open .lb-cap { animation: none; }
  .float-nav { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .cursor-dot, .cursor-ring { display: none; }
  body.cursor-on, body.cursor-on * { cursor: auto !important; }
}

/* ---------- print ---------- */

@media print {
  body::after, .float-nav, .progress-line, .marquee, .scroll-cue, .ghost-no, .seal, .backtop, .toast, .cursor-dot, .cursor-ring { display: none !important; }
  .mast, .now, .site-foot { background: #fff !important; color: #000 !important; }
  body.reveal-ready .reveal { opacity: 1 !important; translate: none !important; }
}
