/* ============================================================
   [INPUT]: depends on pages using zi-* classes, Google font variables, and rough-notation SVG injection
   [OUTPUT]: provides PingPing Atlas tokens, chrome, prose, TOC, and feed/diary shared styles
   [POS]: assets/ style source of truth, consumed by index.html, diary/, and feed/
   [PROTOCOL]: 变更时更新此头部，然后检查 AGENTS.md

   Zi UI — shared style for pingping-site
   Atlas-by-Attio tonality: warm off-white paper (#F6F4EE),
   warm-black ink (#1c1b1b), multi-color sticker accents
   (pink flagship + amber/cyan/indigo variety), 1px hairlines,
   no shadows, tilted-sticker decoration.
   ============================================================ */

:root {
  /* Surface — Atlas warm off-white (was cream #F2F0EE) */
  --bg: #F6F4EE;
  --fg: #1c1b1b;          /* Atlas warm-black */
  --ink: #1c1b1b;         /* prose body — promoted to full warm-black */
  --ink-2: #474746;       /* secondary copy (was --ink) */
  --muted: rgba(28, 27, 27, 0.55);
  --muted-strong: rgba(28, 27, 27, 0.72);
  --muted-faint: #939190;
  --hairline: rgba(28, 27, 27, 0.15);       /* Atlas #1c1b1b26 */
  --hairline-strong: rgba(28, 27, 27, 0.30); /* Atlas #1c1b1b4d */

  /* Atlas accent system — pink flagship, amber/cyan/indigo variety.
     --accent is the default rough-notation / highlight color.
     Use --mark-* directly when you need a specific sticker color. */
  --accent:      #F45397;             /* pink — flagship "love" mark */
  --accent-soft: rgba(244, 83, 151, 0.22);
  --mark-pink:   #F45397;
  --mark-amber:  #FFB525;
  --mark-cyan:   #3AC3FF;
  --mark-indigo: #5648FB;
  --mark-red:    #FF253A;

  /* Typography — Inter body / Inter Tight display / DM Mono chrome /
     Caveat (Biro Script alt) for rare handwritten moments */
  --font-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-body: "Inter", -apple-system, "Helvetica Neue", "Segoe UI",
    Arial, sans-serif;
  --font-display: "Geist", "Inter Tight", "Inter", -apple-system,
    "Helvetica Neue", sans-serif;
  --font-hand: "Caveat", cursive;

  /* Legacy alias — kept so unrelated rules keep compiling. */
  --font-serif: var(--font-body);
}

/* ============================================================
   Atlas signature: tilted-sticker utility.
   Apply .zi-tilt-{neg22|neg15|neg12|12|18|22} to receipts,
   polaroids, sticky notes, channel chips — anything that
   wants to feel taped or pinned to the page.
   ============================================================ */
.zi-tilt-neg22 { transform: rotate(-22deg); }
.zi-tilt-neg15 { transform: rotate(-15deg); }
.zi-tilt-neg12 { transform: rotate(-12deg); }
.zi-tilt-neg6  { transform: rotate(-6deg); }
.zi-tilt-6     { transform: rotate(6deg); }
.zi-tilt-12    { transform: rotate(12deg); }
.zi-tilt-18    { transform: rotate(18deg); }
.zi-tilt-22    { transform: rotate(22deg); }

/* Atlas-style sticker — small label/receipt taped onto the page */
.zi-sticker {
  display: inline-block;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--hairline-strong);
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--fg);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.zi-sticker--pink   { color: var(--mark-pink);   border-color: var(--mark-pink); }
.zi-sticker--amber  { color: var(--mark-amber);  border-color: var(--mark-amber); }
.zi-sticker--cyan   { color: var(--mark-cyan);   border-color: var(--mark-cyan); }
.zi-sticker--indigo { color: var(--mark-indigo); border-color: var(--mark-indigo); }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.625;            /* Atlas body 17/27.625 */
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* Paper grain — same as portfolio main */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Discreet focus ring */
:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 3px;
}

/* Headings — capped at weight 500, tightened tracking */
h1, h2, h3, h4, h5, h6 {
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: inherit; text-decoration: none; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(23, 23, 23, 0.15);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(23, 23, 23, 0.25); }

/* ============================================================
   Chrome: nav header / back link / page wrappers
   ============================================================ */

.zi-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 244, 238, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
}
.zi-nav-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.16em;
  color: var(--fg);
}
@media (min-width: 768px) {
  .zi-nav-inner {
    display: flex;
    height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 40px;
    letter-spacing: 0.18em;
  }
}
.zi-nav-brand {
  display: flex;
  align-items: center;
  height: 40px;
  color: var(--fg);
  flex-shrink: 0;
  text-transform: lowercase;
}
.zi-nav-brand strong {
  font-weight: 400;
}
.zi-nav-links {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin: 0 -20px;
  padding: 0 16px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.zi-nav-links::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .zi-nav-links {
    margin: 0;
    padding: 0;
    border-top: 0;
    gap: 28px;
    font-size: 11px;
    overflow: visible;
    align-items: center;
  }
}
.zi-nav-links a {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: rgba(23, 23, 23, 0.45);
  transition: color 0.2s ease, background 0.2s ease;
  border-radius: 2px;
}
.zi-nav-links a:hover,
.zi-nav-links a[aria-current="page"] {
  color: var(--fg);
}
.zi-nav-links a[aria-current="page"] {
  background: rgba(28, 27, 27, 0.04);
}
@media (min-width: 768px) {
  .zi-nav-links a {
    min-height: 0;
    padding: 0;
    border-radius: 0;
  }
  .zi-nav-links a[aria-current="page"] { background: transparent; }
}
.zi-nav-num {
  display: none;
  margin-right: 6px;
  color: rgba(23, 23, 23, 0.30);
}
.zi-nav-links a[aria-current="page"] .zi-nav-num {
  color: rgba(23, 23, 23, 0.55);
}
@media (min-width: 768px) {
  .zi-nav-num { display: inline; }
}

.zi-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 56px 20px 96px;
  position: relative;
  z-index: 2;
}

@media (min-width: 768px) {
  .zi-page { padding: 96px 40px; }
}

/* Small caps mono tag — used for kicker, dates, archive markers */
.zi-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.zi-tag-strong { color: var(--fg); }

/* Hairline-divided list (used for diary/log archives) */
.zi-list {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
}
.zi-list > li { border-bottom: 1px solid var(--hairline); }
.zi-list a {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 24px;
  align-items: baseline;
  padding: 20px 0;
  transition: opacity 0.2s ease;
}
.zi-list a:hover { opacity: 0.65; }
.zi-list .item-date {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.zi-list .item-title {
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.zi-list .item-snippet {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 6px;
  max-width: 58ch;
}
.zi-list .item-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
@media (max-width: 640px) {
  .zi-list a {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .zi-list .item-meta { justify-self: start; }
}

/* Search field, matched to portfolio */
.zi-search {
  width: 100%;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
  letter-spacing: 0.04em;
  transition: border-color 0.2s ease;
}
.zi-search::placeholder {
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 11px;
}
.zi-search:focus {
  outline: none;
  border-color: var(--hairline-strong);
}

/* Back link */
.zi-back {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s ease;
}
.zi-back:hover { color: var(--fg); }

/* ============================================================
   .zi-callout — Atlas-style callout with a margin note
   On desktop the note slides into the right margin; on mobile it
   stacks above the body block.
   ============================================================ */
.zi-callout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 36px 0;
  padding: 22px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.zi-callout-note {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}
.zi-callout-body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--fg);
  margin: 0;
  max-width: 58ch;
  letter-spacing: -0.005em;
}
@media (min-width: 1024px) {
  .zi-callout {
    grid-template-columns: 1fr 220px;
    gap: 36px;
    align-items: start;
    padding: 28px 0;
  }
  .zi-callout-body { order: 1; }
  .zi-callout-note {
    order: 2;
    padding-top: 4px;
    border-left: 1px solid var(--hairline);
    padding-left: 18px;
  }
}

/* rough-notation: keep host elements inline-block so SVG sticks to text */
[data-rn] {
  display: inline-block;
  position: relative;
}

/* ============================================================
   .zi-entry — Atlas-style two-column entry layout
   Desktop: 280px sticky sidebar (kicker · title · meta · toggle)
            + main prose column (max 65ch)
   Mobile:  sidebar stacks above prose, no sticky.
   ============================================================ */
.zi-entry {
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
  max-width: 1180px;
  margin: 64px auto 120px;
  padding: 0 20px;
  position: relative;
  z-index: 2;
}
@media (min-width: 1024px) {
  .zi-entry {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 80px;
    padding: 0 40px;
    margin-top: 88px;
  }
}
.zi-entry-side { position: relative; }
@media (min-width: 1024px) {
  .zi-entry-side {
    position: sticky;
    top: 88px;
    align-self: start;
    padding-right: 12px;
    border-right: 1px solid var(--hairline);
  }
  .zi-entry-side > * + * { margin-top: 0; }
}
.zi-entry-side .zi-tag { display: inline-block; }
.zi-entry-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin-top: 14px;
  text-wrap: balance;
}
@media (min-width: 1024px) {
  .zi-entry-title { font-size: 36px; }
}
.zi-entry .zi-meta {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.zi-entry .zi-meta .dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}
.zi-entry .zi-prose {
  margin: 0;
  max-width: 65ch;
}

/* ============================================================
   Atlas-style aggregator: long single page with left TOC + sections

   Mobile (<1024px) — off-canvas drawer slides down from the top.
     toggle button (.zi-toc-toggle) sticks below the nav, shows
     the active entry label. tap → opens drawer. tap entry → closes.
   Desktop (≥1024px) — fixed 320/336px left sidebar.
   ============================================================ */
.zi-toc {
  position: fixed;
  /* mobile: nav stacks to ~85px (brand 40 + border + links 44).
     desktop ≥768px nav collapses to single 48px row (handled below). */
  top: 85px;
  left: 0; right: 0;
  bottom: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
  z-index: 35;
  display: flex;
  flex-direction: column;
  padding: 22px 24px 24px;
  transform: translateY(-110%);
  transition: transform 0.32s cubic-bezier(.25,.1,.25,1);
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}
.zi-toc.is-open { transform: translateY(0); }

/* Mobile drawer toggle — sticky pill below nav. Hidden on desktop.
   z-index above the drawer so user can tap to close while open. */
.zi-toc-toggle {
  position: sticky;
  top: 85px;                 /* mobile nav stack height */
  z-index: 36;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  background: rgba(246, 244, 238, 0.92);
  backdrop-filter: blur(6px);
  border: 0;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}
.zi-toc-toggle-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zi-toc-toggle-chev {
  display: inline-block;
  width: 12px; height: 12px;
  border-right: 1.5px solid var(--fg);
  border-bottom: 1.5px solid var(--fg);
  transform: rotate(45deg);
  transition: transform 0.22s ease;
  margin-top: -4px;
  flex-shrink: 0;
}
.zi-toc-toggle[aria-expanded="true"] .zi-toc-toggle-chev { transform: rotate(-135deg); margin-top: 2px; }

@media (min-width: 768px) {
  /* nav collapses to single 48px row; drawer + toggle align to that */
  .zi-toc { top: 48px; }
  .zi-toc-toggle { top: 48px; }
}
@media (min-width: 1024px) {
  .zi-toc {
    right: auto;
    width: 320px;
    padding: 28px 24px 28px 32px;
    border-right: 1px solid var(--hairline);
    border-bottom: 0;
    transform: none;
    transition: none;
  }
  .zi-toc-toggle { display: none; }
}
@media (min-width: 1280px) {
  .zi-toc {
    width: 336px;
    padding: 32px 28px 32px 36px;
  }
}

/* Atlas-style TOC head: brand + two-line by-line credit */
.zi-toc-head {
  flex-shrink: 0;
  margin-bottom: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}
.zi-toc-brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--fg);
}
.zi-toc-brand-dot {
  color: var(--muted);
  margin-left: 1px;
}
.zi-toc-byline {
  margin: 2px 0 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  color: var(--muted-strong);
}
.zi-toc-byline a {
  color: var(--fg);
  border-bottom: 1px solid var(--hairline-strong);
  padding-bottom: 1px;
  transition: border-color 0.18s ease;
}
.zi-toc-byline a:hover { border-bottom-color: var(--fg); }

.zi-toc-list {
  list-style: none;
  margin: 0;
  padding: 4px 4px 0 0;
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: thin;
}
.zi-toc-list::-webkit-scrollbar { width: 3px; }

/* Atlas-style chapter row: mono number + (title / byline) stack.
   position:relative anchors the rough-notation SVG to THIS item so
   it tracks the row when .zi-toc-list scrolls internally (otherwise
   the SVG drifts to a non-scrolling ancestor and floats between items). */
.zi-toc-item {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  color: rgba(23, 23, 23, 0.45);
  transition: color 0.18s ease;
}
.zi-toc-item:hover { color: var(--fg); }
.zi-toc-item.active { color: var(--fg); }

.zi-toc-num {
  position: relative;       /* anchor for rough-notation SVG */
  overflow: visible;        /* let the scribbled circle bleed out */
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  letter-spacing: 0;
  color: rgba(23, 23, 23, 0.45);
  align-self: start;
  padding-top: 1px;
  transition: color 0.18s ease;
}
/* rough-notation injects an SVG sibling — make sure it can paint outside */
.zi-toc-num .rough-annotation {
  overflow: visible !important;
  pointer-events: none;
}
.zi-toc-item:hover .zi-toc-num,
.zi-toc-item.active .zi-toc-num { color: var(--fg); }

.zi-toc-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.zi-toc-title {
  display: block;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.35;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zi-toc-date {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: -0.005em;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zi-toc-item.active .zi-toc-date { color: var(--muted-strong); }

.zi-toc-foot {
  flex-shrink: 0;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--hairline);
}

/* main content column */
.zi-aggregate-main {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 120px;
}
@media (min-width: 1024px) {
  .zi-aggregate-main {
    margin-left: 320px;
    padding: 96px 60px 160px;
    max-width: none;
  }
  .zi-aggregate-main .zi-aggregate-hero,
  .zi-aggregate-main .zi-section,
  .zi-aggregate-main .zi-aggregate-foot {
    max-width: 65ch;
    margin-left: 0;
    margin-right: auto;
  }
}
@media (min-width: 1280px) {
  .zi-aggregate-main {
    margin-left: 336px;
    padding-left: 96px;
  }
}

.zi-aggregate-hero {
  padding-bottom: 64px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 48px;
}
.zi-aggregate-title {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin-top: 16px;
  max-width: 22ch;
  text-wrap: balance;
}
@media (min-width: 1024px) {
  .zi-aggregate-title { font-size: 56px; }
}
.zi-aggregate-lede {
  margin-top: 22px;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--muted-strong);
  max-width: 58ch;
}

.zi-section {
  padding: 72px 0;
  border-bottom: 1px solid var(--hairline);
  scroll-margin-top: 80px;
  /* per-entry accent — drives rough-notation strokes (rn.js),
     TOC ring (diary-toc.js), sidenote color, blockquote color,
     and the highlighter wash inside the entry. */
  --rn-color: var(--mark-pink);
  --rn-color-soft: color-mix(in srgb, var(--rn-color) 22%, transparent);
}
.zi-section:nth-of-type(4n+2) { --rn-color: var(--mark-cyan); }
.zi-section:nth-of-type(4n+3) { --rn-color: var(--mark-amber); }
.zi-section:nth-of-type(4n+4) { --rn-color: var(--mark-indigo); }
.zi-section:last-of-type { border-bottom: 0; }
.zi-section-head {
  margin-bottom: 32px;
}
.zi-section-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin-top: 14px;
  max-width: 30ch;
  text-wrap: balance;
}
@media (min-width: 1024px) {
  .zi-section-title { font-size: 36px; }
}
.zi-prose-section { font-size: 17px; }
.zi-prose-section p { max-width: 62ch; }

/* Atlas in-content quotation — handwritten accent text, centered,
   sits between paragraphs (no border, no NOTE label). Mid-size between
   sidenote (20px) and author byline (40px). */
.zi-prose-section blockquote {
  display: block;
  margin: 36px auto;
  padding: 0;
  border: 0;
  font-style: normal;
  max-width: none;
}
.zi-prose-section blockquote::before {
  content: none;
  display: none;
}
.zi-prose-section blockquote p {
  font-family: var(--font-hand);
  font-size: 26px;
  font-weight: 500;
  font-style: normal;
  line-height: 1.12;
  letter-spacing: 0;
  color: var(--rn-color, var(--accent));
  text-align: center;
  text-wrap: balance;
  max-width: 22ch;
  margin: 0 auto;
}
@media (min-width: 1024px) {
  .zi-prose-section blockquote p { font-size: 30px; max-width: 20ch; }
}

/* CSS highlighter-pen marker — bottom-half wash, text stays readable.
   Picks up the entry's --rn-color-soft so each entry's highlighter
   matches its accent. */
.zi-highlight {
  background: linear-gradient(
    transparent 55%,
    var(--rn-color-soft, var(--accent-soft)) 55%,
    var(--rn-color-soft, var(--accent-soft)) 92%,
    transparent 92%
  );
  padding: 0 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ============================================================
   Handwriting reveal — word-by-word typewriter stagger.
   reveal.js splits .zi-sidenote and blockquote <p> text into
   <span class="zi-word"> tokens, each with a custom property
   `--i` (word index). On viewport entry the parent gets
   `.zi-revealed` and the words fade-in + rise sequentially.
   Feels like Atlas's tegaki.js text being written, not wiped.
   ============================================================ */
.zi-prose-section .zi-sidenote .zi-word,
.zi-prose-section blockquote .zi-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 540ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 540ms cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: calc(var(--i, 0) * 170ms);
}
.zi-prose-section .zi-sidenote.zi-revealed .zi-word,
.zi-prose-section blockquote p.zi-revealed .zi-word {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .zi-prose-section .zi-sidenote .zi-word,
  .zi-prose-section blockquote .zi-word {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ============================================================
   .zi-sidenote — Atlas-style margin annotation
   Rendered as a <span> INSIDE the paragraph it comments on (see
   restyle.py post-processing). Atlas signature: handwritten font,
   accent color, ~22px, leading-none, text-balance.
     - <1280px: stacks below paragraph as handwritten accent prose
     - ≥1280px: absolute-positioned in the right margin, vertically
       CENTERED with its host paragraph (Atlas exact spec)
   ============================================================ */
.zi-prose-section { position: relative; }
.zi-prose-section p { position: relative; }
/* Atlas spec — sidenote has TWO presentations:
     <1420px: centered inline below the paragraph (`mx-auto mt-8 max-w-xs
              text-center`) — Atlas exact narrow-screen pattern
     ≥1420px: absolute-positioned in the right margin, vertically centered
              with the host paragraph (`absolute top-1/2 left-full max-w-40
              translate-x-10 -translate-y-1/2`)
   Both use Biro-Script-equivalent (Caveat) handwriting, weight 500,
   accent color, leading-none, text-balance. Copied from inspector. */
.zi-prose-section .zi-sidenote {
  display: block;
  margin: 32px auto 0;            /* mt-8 + mx-auto */
  max-width: 320px;               /* max-w-xs */
  text-align: center;
  font-family: var(--font-hand);
  font-size: 20px;
  font-weight: 500;
  font-style: normal;
  line-height: 1.05;
  letter-spacing: 0;
  color: var(--rn-color, var(--accent));
  text-wrap: balance;
}

@media (min-width: 1420px) {
  .zi-prose-section .zi-sidenote {
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translate(10px, -50%);
    margin: 0;
    width: 100%;
    max-width: 160px;
    text-align: start;
    font-size: 20px;
    line-height: 1.05;
    color: var(--rn-color, var(--accent));
  }
}

/* sub-headings inside an entry: keep mono-uppercase look but the
   inside is wrapped in data-rn so rough-notation underlines on view */
.zi-prose-section h2 {
  margin-top: 2.4em;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg);
  font-family: var(--font-mono);
}
.zi-prose-section h2 [data-rn] { display: inline-block; }

/* Atlas-style figure — applies to every <figure data-artifact>, whether
   it lives inside .zi-prose or directly under .zi-section (cover figure).
   Small, centered, edges fade into cream paper via radial mask. */
figure[data-artifact] {
  margin: 36px auto;
  max-width: 460px;
  text-align: center;
}
figure[data-artifact] img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
  background: transparent;
  /* Artifact images are pre-processed to transparent bg (see
     tools/transparent_bg.py / agent post-step). No blend mode needed —
     amber ink sits directly on page cream. */
}
figure[data-artifact] figcaption {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
figure[data-artifact] figcaption::before { content: "[ "; }
figure[data-artifact] figcaption::after { content: " ]"; }

.zi-aggregate-foot {
  padding-top: 72px;
  text-align: center;
  border-top: 1px solid var(--hairline);
}

/* mono pill — fixed top-right, like atlas section indicator */
.zi-pill {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 40;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--hairline-strong);
  background: rgba(246, 244, 238, 0.90);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg);
}
.zi-pill-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--fg);
}
@media (min-width: 1280px) {
  .zi-pill { display: inline-flex; }
}

/* ============================================================
   .zi-lang-toggle — bilingual view switcher (zh / en / both)
   Hidden by default; lang-toggle.js shows it when it detects an
   English span inside .zi-prose.
   ============================================================ */
.zi-lang-toggle {
  display: none;            /* JS toggles to inline-flex if applicable */
  align-items: center;
  gap: 2px;
  margin: 0 auto 28px;
  padding: 3px;
  border: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.zi-lang-toggle button {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 8px 14px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: inherit;
  transition: color 0.18s ease, background 0.18s ease;
}
.zi-lang-toggle button:hover { color: var(--fg); }
.zi-lang-toggle button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

/* Default: hide english spans + bilingual breaks (zh-only view).
   No flash of "stacked" content before lang-toggle.js kicks in. */
.zi-prose [lang="en"] { display: none; }
.zi-prose br[data-bili] { display: none; }

/* explicit zh mode (same as default — keeps semantics clear) */
article[data-lang-mode="zh"] .zi-prose [lang="en"] { display: none; }
article[data-lang-mode="zh"] .zi-prose br[data-bili] { display: none; }

/* en-only: hide chinese, show english as primary */
article[data-lang-mode="en"] .zi-prose [lang="zh"] { display: none; }
article[data-lang-mode="en"] .zi-prose [lang="en"] {
  display: inline;
  color: var(--fg);
  font-style: normal;
}
article[data-lang-mode="en"] .zi-prose br[data-bili] { display: none; }

/* both: show english under chinese, italic + muted so it reads as translation */
article[data-lang-mode="both"] .zi-prose [lang="en"] {
  display: inline;
  color: var(--muted-strong);
  font-style: italic;
}
article[data-lang-mode="both"] .zi-prose br[data-bili] { display: inline; }

/* ============================================================
   .zi-prose — long-form Source Serif body for diary/log entries
   Mirrors portfolio's globals.css zi-prose, tuned for CN+EN mix.
   ============================================================ */
.zi-prose {
  font-family: var(--font-body);
  font-feature-settings: "kern", "liga";
  font-size: 17px;
  line-height: 1.625;
  color: var(--ink);
  max-width: 65ch;
  margin: 0 auto;
}
.zi-prose > * + * { margin-top: 1.25em; }
.zi-prose h1 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin-bottom: 0.35em;
}
.zi-prose h2 {
  margin-top: 2.4em;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-faint);
  line-height: 1.5;
}
.zi-prose h3 {
  margin-top: 1.8em;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.zi-prose p {
  color: var(--ink);
}
.zi-prose strong {
  color: var(--fg);
  font-weight: 600;
}
.zi-prose em { font-style: italic; color: var(--fg); }
.zi-prose a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 4px;
  transition: text-decoration-color 200ms ease;
}
.zi-prose a:hover { text-decoration-color: var(--fg); }
.zi-prose ul, .zi-prose ol {
  margin-top: 1.1em;
  padding-left: 1.4em;
  color: rgba(23, 23, 23, 0.82);
}
.zi-prose ul { list-style: disc; }
.zi-prose ol { list-style: decimal; }
.zi-prose li + li { margin-top: 0.45em; }
.zi-prose blockquote {
  margin: 1.6em 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 1px solid var(--hairline-strong);
  font-style: italic;
  color: var(--fg);
  max-width: 58ch;
}
.zi-prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  background: rgba(23, 23, 23, 0.06);
  border-radius: 3px;
}
.zi-prose pre {
  font-family: var(--font-mono);
  margin: 1.5em 0;
  padding: 1rem 1.25rem;
  background: rgba(23, 23, 23, 0.04);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.zi-prose pre code { background: none; padding: 0; }
.zi-prose hr {
  margin: 2.4em auto;
  border: 0;
  border-top: 1px solid var(--hairline);
  width: 40%;
}
.zi-prose figure { margin: 2em 0; }
.zi-prose figcaption {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}
.zi-prose img {
  margin: 1.6em 0;
  max-width: 100%;
  height: auto;
}

/* Header block above prose body (kicker + title + date) */
.zi-entry-header {
  margin-bottom: 48px;
  text-align: center;
}
.zi-entry-header .zi-tag { display: inline-block; }
.zi-entry-header h1 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-top: 14px;
  color: var(--fg);
  text-wrap: balance;
}
.zi-entry-header .zi-meta {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.zi-entry-header .zi-meta .dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
