/* ----------------------------------------------------
   Personal site — Siming Shan
   Editorial classical academic.
   ---------------------------------------------------- */

:root {
  --bg: #fbfaf7;
  --ink: #14110f;
  --ink-soft: #4a4541;
  --ink-faint: #8a847e;
  --rule: #d9d4cc;
  --rule-faint: #ebe7e0;
  --paper: #ffffff;
  --accent: #6a1b1a;          /* default: oxblood — tweakable */
  --accent-soft: #6a1b1a18;

  /* Inter throughout — sans only. --sans kept as the name everywhere. */
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --measure: 64ch;
  --gutter: clamp(20px, 4vw, 56px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color .15s ease, text-decoration-color .15s ease;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

::selection { background: var(--accent); color: var(--bg); }

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: clamp(40px, 6vw, 96px);
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) var(--gutter) 120px;
}

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; gap: 32px; }
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: clamp(40px, 6vw, 80px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 880px) {
  .sidebar { position: relative; top: 0; }
}

.portrait {
  position: relative;
  width: 220px;
  height: 270px;
  border: 1px solid var(--rule);
  background: var(--paper);
  overflow: hidden;
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 32%;
  display: block;
  filter: grayscale(8%) contrast(1.02);
}

.name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

.role {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}
.role .affil { color: var(--ink); font-weight: 500; }
.role .advisor { color: var(--ink-soft); }

.sidebar-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--sans);
  font-size: 14px;
}
.sidebar-links li { display: flex; align-items: center; gap: 10px; }
.sidebar-links .label {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 11px;
  width: 64px;
}
.sidebar-links a {
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1px;
}
.sidebar-links a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Main ---------- */
.main { min-width: 0; }

.section { margin-bottom: 72px; }
.section:last-child { margin-bottom: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.section-head h2 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin: 0;
  color: var(--ink);
}
.section-head .count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  margin-left: auto;
}

/* ---------- About ---------- */
.about p {
  max-width: var(--measure);
  margin: 0 0 1em;
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink);
}
.about p .accent { color: var(--accent); }
.about .lede {
  font-size: 22px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.keywords li:not(:last-child)::after {
  content: " · ";
  color: var(--ink-faint);
  margin: 0 6px;
}

/* ---------- News ---------- */
.news {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 4px 24px;
  font-size: 16px;
  max-width: var(--measure);
}
.news dt {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink-faint);
  padding-top: 6px;
  text-transform: uppercase;
}
.news dd {
  margin: 0 0 14px;
  line-height: 1.55;
  color: var(--ink);
}
.news dd em { color: var(--ink-soft); font-style: italic; }

/* ---------- Publications ---------- */
.pubs { list-style: none; padding: 0; margin: 0; }
.pub {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 28px;
  padding: 22px 0;
  border-top: 1px solid var(--rule-faint);
}
.pub:first-child { border-top: 0; padding-top: 4px; }

.pub-figure {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  align-self: start;
  border: 1px solid var(--rule);
  background: var(--paper);
  overflow: hidden;
}
.pub-figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s ease;
}
.pub-figure:hover img { transform: scale(1.04); }

.pub-body { min-width: 0; }
.pub-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.3;
  margin: 0 0 6px;
  letter-spacing: -0.012em;
}
.pub-title a { text-decoration: none; border-bottom: 1px solid transparent; }
.pub-title a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.pub-authors {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0 0 4px;
}
.pub-authors .me {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}
.pub-venue {
  font-family: var(--sans);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.pub-venue .year { font-style: normal; color: var(--ink); font-variant-numeric: tabular-nums; }

.pub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--sans);
  font-size: 12px;
  margin-top: 8px;
}
.pub-actions a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 3px 10px;
  letter-spacing: .02em;
  background: var(--paper);
  transition: all .15s ease;
}
.pub-actions a:hover { border-color: var(--accent); color: var(--accent); }
.pub-actions a.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pub-actions a.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* ---------- Blog ---------- */
.posts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.post {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 28px;
  padding: 22px 0;
  border-top: 1px solid var(--rule-faint);
  align-items: baseline;
}
.post:first-child { border-top: 0; padding-top: 4px; }
.post .date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.post-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.3;
  margin: 0 0 4px;
  letter-spacing: -0.012em;
}
.post-title a { text-decoration: none; }
.post-title a:hover { color: var(--accent); }
.post-dek {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0;
  max-width: 56ch;
}
.post .readtime {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .04em;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .pub, .post { grid-template-columns: 1fr; gap: 12px; }
  .pub-figure { max-width: 200px; }
}

/* ---------- Footer ---------- */
.colophon {
  margin-top: 96px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.colophon a { color: var(--ink-faint); text-decoration: none; }
.colophon a:hover { color: var(--accent); }

/* ---------- Tweaks panel hook ---------- */
#tweaks-root { position: fixed; bottom: 16px; right: 16px; z-index: 50; }

/* ---------- Publication covers (text placeholders) ---------- */
.pub-cover {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.pub-cover::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(at 30% 22%, rgba(255,255,255,.18), transparent 55%);
  pointer-events: none;
}
.pub-cover-label {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 21px;
  color: #fff;
  letter-spacing: -0.025em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .15);
  z-index: 1;
  transition: transform .25s ease;
}
.pub-cover-fundiff { background: linear-gradient(135deg, #1f3a6a 0%, #5a3c8a 100%); }
.pub-cover-pird    { background: linear-gradient(135deg, #6a1b1a 0%, #b65a30 100%); }
.pub-cover:hover .pub-cover-label { transform: scale(1.05); }

/* ---------- Sidebar interactive Siamese ---------- */
.sidebar-pet {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--rule-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.pet-frame {
  position: relative;
  width: 200px;
  aspect-ratio: 460 / 638;
  cursor: pointer;
  user-select: none;
  transition: filter .25s ease;
}
.pet-frame:hover {
  filter: brightness(1.04) drop-shadow(0 4px 10px rgba(20, 17, 15, .12));
}
.pet-frame.happy { animation: pet-bounce .42s ease-out; }
@keyframes pet-bounce {
  0%   { transform: translateY(0) scale(1); }
  40%  { transform: translateY(-8px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

.pet-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity .18s ease;
  pointer-events: none;
  -webkit-user-drag: none;
}
.pet-img.pet-closed { opacity: 0; }
.pet-frame.blink .pet-img.pet-open   { opacity: 0; }
.pet-frame.blink .pet-img.pet-closed { opacity: 1; }

.sidebar-pet .pet-cap {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 10px 0 0;
  text-align: center;
}

.pet-bubble {
  position: absolute;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  background: var(--ink);
  color: var(--bg);
  padding: 4px 10px;
  border-radius: 14px;
  pointer-events: none;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  z-index: 5;
  animation: pet-bubble-up 1.3s ease-out forwards;
}
@keyframes pet-bubble-up {
  0%   { opacity: 0; transform: translate(-50%, -80%) scale(.6); }
  20%  { opacity: 1; transform: translate(-50%, -110%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}
