/* ------------------------------------------------------------------ *
 *  Warm editorial black & white theme — zhichengzheng
 *  Self-contained, no framework dependencies. Responsive + dark mode.
 * ------------------------------------------------------------------ */

:root {
  --bg:        #f7f4ee;   /* warm paper */
  --panel:     #fbf9f4;   /* slightly lighter card tone */
  --fg:        #23211c;   /* warm near-black ink */
  --muted:     #6f6a5f;   /* warm grey */
  --faint:     #8f897c;
  --line:      #e3ddd0;   /* hairline on paper */
  --hover-bg:  #efe9dc;
  --max:       42rem;     /* comfortable serif measure */
}

/* Dark palette — shared by the system preference and an explicit choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:       #17150f;   /* warm dark, not pure black */
    --panel:    #1e1c15;
    --fg:       #f6f4ef;   /* brighter, near-white ink */
    --muted:    #ccc5b3;
    --faint:    #aca592;
    --line:     #2c2920;
    --hover-bg: #23201a;
  }
}
:root[data-theme="dark"] {
  --bg:       #17150f;
  --panel:    #1e1c15;
  --fg:       #f6f4ef;
  --muted:    #ccc5b3;
  --faint:    #aca592;
  --line:     #2c2920;
  --hover-bg: #23201a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Charter,
               Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  overflow-wrap: break-word;
}

img { max-width: 100%; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 3.25rem 1.6rem 4.5rem;
}

/* ---- links ---- */
a {
  color: var(--fg);
  text-decoration: none;
  background-image: linear-gradient(var(--faint), var(--faint));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  padding-bottom: 1px;
  transition: color .18s, background-size .18s;
}
a:hover { color: var(--muted); background-size: 100% 1.5px; }

/* ---- header / nav ---- */
.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .4rem 1.5rem;
  padding-bottom: 1.9rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--line);
}
.site-head .brand {
  font-weight: 600;
  font-size: 1.18rem;
  letter-spacing: .005em;
  background: none;
  padding: 0;
}
.site-nav {
  display: flex;
  gap: 1.5rem;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .13em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.site-nav a { color: var(--faint); background: none; padding: 0; }
.site-nav a:hover { color: var(--fg); }
.site-nav a.active { color: var(--fg); }

/* ---- intro ---- */
.intro { display: flex; gap: 2rem; align-items: center; margin-bottom: 2.4rem; flex-wrap: wrap; }
.intro > div { min-width: 0; flex: 1 1 240px; }
.intro img {
  width: 122px; height: 122px;
  border-radius: 6px;
  object-fit: cover;
  filter: grayscale(35%) contrast(1.02);
  flex: none;
}
.intro h1 {
  font-size: 2.1rem; margin: 0 0 .35rem;
  font-weight: 600; letter-spacing: -.012em; line-height: 1.15;
}
.intro .role {
  color: var(--muted); margin: 0;
  font-size: 1.06rem; font-style: italic;
}

/* ---- name pronunciation ---- */
.name { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .1em; }

.pron-btn {
  -webkit-appearance: none; appearance: none;
  background: none; border: 0; padding: 0;
  margin-left: .45em;
  display: inline-flex; align-items: center;
  color: var(--faint);
  cursor: pointer;
  font-size: 1.4rem; line-height: 1;
  border-radius: 999px;
  transition: color .18s;
}
.pron-btn:hover { color: var(--fg); }
.pron-btn:focus-visible { outline: 2px solid var(--faint); outline-offset: 3px; }
.pron-btn svg { display: block; }
.pron-btn .pron-wave { opacity: .55; transition: opacity .18s; }
.pron-btn:hover .pron-wave { opacity: .9; }
.pron-btn.is-playing .pron-wave { animation: pron-pulse .9s ease-in-out infinite; }
.pron-btn.is-playing .pron-wave:nth-of-type(2) { animation-delay: .18s; }

@keyframes pron-pulse {
  0%, 100% { opacity: .3; }
  50%      { opacity: 1; }
}

/* ---- theme toggle ---- */
.theme-btn { margin-left: .2em; font-size: 1.25rem; }
.theme-btn svg { display: block; transition: transform .3s ease; }
.theme-btn:hover svg { transform: rotate(15deg); }

/* Show the icon for the theme you'd switch TO. */
.icon-sun  { display: none; }
.icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
:root[data-theme="dark"]  .icon-sun  { display: block; }
:root[data-theme="dark"]  .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun  { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

/* name flash on playback */
.name-flash { animation: name-flash .6s ease-in-out; }
@keyframes name-flash {
  0%   { color: var(--fg); }
  35%  { color: #c07a3e; text-shadow: 0 0 .6em rgba(192,122,62,.35); }
  100% { color: var(--fg); text-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pron-btn.is-playing .pron-wave { animation: none; }
  .name-flash { animation-duration: .01s; }
}

/* ---- body text ---- */
p { margin: 0 0 1.25rem; }

/* section divider label */
h2.section {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .15em;
  color: var(--faint); font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 3.4rem 0 1.4rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--line);
}

/* ---- social row ---- */
.social {
  display: flex; gap: 1.6rem; margin: 1.9rem 0 0;
  font-size: .82rem; text-transform: uppercase; letter-spacing: .13em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.social a { color: var(--faint); background: none; padding: 0; }
.social a:hover { color: var(--fg); }

/* ---- publication / item list ---- */
.item {
  position: relative;
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  column-gap: 1.5rem;
  grid-template-areas:
    "thumb body"
    "tldr  tldr";
  align-items: start;
  padding: 1.6rem 0;
}
.item + .item { border-top: 1px solid var(--line); }
.item .body { grid-area: body; min-width: 0; }
.item .thumb { grid-area: thumb; width: 148px; }
.item .thumb img {
  width: 100%; border-radius: 5px; display: block;
  filter: grayscale(35%);
  border: 1px solid var(--line);
  opacity: .68;
  transition: opacity .3s, filter .3s;
}
.item:hover .thumb img { opacity: 1; filter: grayscale(0%); }
.item .body h3 { font-size: 1.14rem; margin: 0 0 .4rem; line-height: 1.4; font-weight: 600; }
.item .body .authors { font-size: .97rem; color: var(--fg); margin: 0 0 .25rem; }
.item .body .venue { font-size: .95rem; color: var(--muted); font-style: italic; margin: 0 0 .7rem; }
.item em { font-style: italic; }
.item .authors a { color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.tag {
  font-size: .74rem; color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-transform: uppercase; letter-spacing: .08em;
  border: 1px solid var(--line); border-radius: 4px;
  padding: .18rem .6rem; cursor: pointer;
  background: none;
}
.tag:hover { color: var(--fg); border-color: var(--muted); background: var(--hover-bg); }

details.abs { display: contents; }
details.abs summary {
  font-size: .74rem; color: var(--muted); cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-transform: uppercase; letter-spacing: .08em;
  list-style: none; display: inline-block;
  border: 1px solid var(--line); border-radius: 4px; padding: .18rem .6rem;
}
details.abs summary::-webkit-details-marker { display: none; }
details.abs[open] summary,
.item:hover details.abs summary {
  color: var(--fg); border-color: var(--muted);
}
.item .tldr {
  grid-area: tldr;
  display: none;
  font-size: .98rem; color: var(--muted); font-style: italic;
  margin: .55rem 0 0;
}
.item:has(details[open]) .tldr,
.item:hover .tldr { display: block; }

/* On wide screens, float the TL;DR into the empty right-hand gutter as a
   margin note — it leaves the flow, so the panel height never changes. */
@media (min-width: 1180px) {
  .item .tldr {
    grid-area: auto;          /* anchor to the panel box, not the full-width row */
    position: absolute;
    top: 1.6rem;
    left: 100%;
    width: 15rem;
    margin: 0 0 0 2rem;
    font-size: .9rem; line-height: 1.6;
    padding-left: 1rem;
    border-left: 2px solid var(--line);
  }
  /* Transparent bridge spanning the gutter gap so moving the cursor from the
     panel onto the note keeps .item:hover alive — the note won't vanish while
     the cursor is crossing over to it. */
  .item .tldr::before {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    left: -2rem; width: 2rem;
  }
}

/* ---- project grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem 1.8rem;
  margin-top: 1.6rem;
}
.card a { background: none; padding: 0; display: block; }
.card img {
  width: 100%; aspect-ratio: 16/10; object-fit: cover;
  border-radius: 7px; border: 1px solid var(--line);
  filter: grayscale(35%);
  transition: filter .25s, opacity .25s;
  display: block;
}
.card a:hover img { filter: grayscale(0%); opacity: .95; }
.card h3 { font-size: 1.08rem; margin: .85rem 0 .35rem; font-weight: 600; }
.card p { font-size: .95rem; color: var(--muted); margin: 0; line-height: 1.6; }

/* ---- footer ---- */
footer {
  margin-top: 4.5rem; padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  font-size: .82rem; color: var(--faint);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: .02em;
}
footer a { color: var(--faint); background: none; padding: 0; }
footer a:hover { color: var(--fg); }

/* ---- mobile ---- */
@media (max-width: 620px) {
  body { font-size: 18px; line-height: 1.72; }
  .wrap { padding: 2.25rem 1.35rem 3.25rem; }
  .site-head { margin-bottom: 2.25rem; }
  .intro { gap: 1.4rem; margin-bottom: 2rem; }
  .intro img { width: 100px; height: 100px; }
  .intro h1 { font-size: 1.8rem; }
  .grid { grid-template-columns: 1fr; gap: 1.75rem; }
  .item {
    grid-template-columns: 1fr;
    grid-template-areas: "thumb" "body" "tldr";
    row-gap: 1rem;
  }
  .item .thumb { width: 100%; max-width: 300px; }
  .item .tldr { margin-top: 0; }
}
