/* =============================================================
   张乐涵 · Lehan Zhang — Academic Homepage Style
   ============================================================ */

/* ----- CSS Variables ----- */
:root {
  --bg:            #fefefe;
  --bg-card:       #f9fafb;
  --bg-subcard:    #f5f6f8;
  --text:          #2d2d2d;
  --text-alt:      #5a5a5a;
  --text-muted:    #8a8a8a;
  --heading:       #1a1a1a;
  --border:        #e6e6e6;
  --border-light:  #f0f0f0;
  --accent:        #4f6f8f;
  --accent-dim:    #6b8aaa;
  --accent-warm:   #b8783c;
  --shadow:        0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:     0 4px 20px rgba(0,0,0,0.06);
  --radius:        10px;

  /* Direction color tags */
  --color-perception: #3b82b6;
  --color-generation:#8b5cf6;
  --color-chip:      #f59e0b;
  --color-system:    #10b981;
  --color-algo:      #ef4444;

  --max-w: 820px;
}

[data-theme="dark"] {
  --bg:            #1a1c20;
  --bg-card:       #22252a;
  --bg-subcard:    #262a30;
  --text:          #d4d4d8;
  --text-alt:      #a8a8b0;
  --text-muted:    #707078;
  --heading:       #e8e8ec;
  --border:        #333840;
  --border-light:  #2a2e36;
  --accent:        #8aadd0;
  --accent-dim:    #6d93b8;
  --accent-warm:   #c8945c;
  --shadow:        0 1px 4px rgba(0,0,0,0.2);
  --shadow-lg:     0 4px 20px rgba(0,0,0,0.3);

  --color-perception: #60a5fa;
  --color-generation:#a78bfa;
  --color-chip:      #fbbf24;
  --color-system:    #34d399;
  --color-algo:      #f87171;
}

/* ----- Reset & Base ----- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { text-decoration: underline; color: var(--accent-dim); }
strong { color: var(--heading); font-weight: 600; }
img { max-width:100%; display:block; }

/* ============================================================
   BILINGUAL — Pure: zh mode = zero English; en mode = all English
   ============================================================ */
.en { display: none; }
[data-lang="en"] .zh { display: none; }
[data-lang="en"] .en { display: revert; }

/* Toggle button text */
.zh-active, .en-active { display: none; }
[data-lang="zh"] .zh-active { display: inline; }
[data-lang="en"] .en-active { display: inline; }

/* ============================================================
   LAYOUT
   ============================================================ */
.page { max-width: var(--max-w); margin: 0 auto; padding: 48px 28px 40px; }

/* ----- Header ----- */
.header { margin-bottom: 48px; }
.header-row { display: flex; gap: 36px; align-items: flex-start; }
.header-text { flex:1; min-width:0; }
.header-photo { flex-shrink: 0; text-align: center; }
.header-photo img {
  width: 140px; height: 140px; border-radius: 50%;
  object-fit: cover; box-shadow: var(--shadow-lg);
}
.photo-label { display: block; margin-top: 10px; font-size: 0.78rem; color: var(--text-muted); }

.name { font-size: 2rem; font-weight: 800; color: var(--heading); letter-spacing: 0.04em; margin-bottom: 4px; }
.name-en { display: block; font-size: 1rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0.02em; margin-top: 2px; }
.tagline { font-size: 0.95rem; color: var(--accent); font-weight: 500; margin-bottom: 18px; letter-spacing: 0.06em; }
.bio-main { color: var(--text); margin-bottom: 10px; font-size: 0.97rem; }
.bio-sub { color: var(--text-alt); font-size: 0.9rem; margin-bottom: 18px; }

.contact-row { display: flex; gap: 20px; flex-wrap: wrap; }
.contact-row a {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.9rem; color: var(--text-alt); padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.contact-row a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

/* ----- Sections ----- */
.sec { margin-bottom: 48px; }
.sec-title {
  font-size: 1.2rem; font-weight: 700; color: var(--heading);
  margin-bottom: 20px; padding-bottom: 10px;
  border-bottom: 2px solid var(--border); letter-spacing: 0.03em;
}

/* ----- News ----- */
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-item { font-size: 0.92rem; color: var(--text-alt); line-height: 1.7; }
.news-tag { display: inline-block; font-weight: 700; color: var(--accent); min-width: 64px; margin-right: 4px; font-size: 0.85rem; }

/* ----- Education ----- */
.edu-list { display: flex; flex-direction: column; gap: 18px; }
.edu-item { display: flex; gap: 18px; align-items: baseline; }
.edu-date { flex-shrink: 0; min-width: 110px; font-weight: 700; font-size: 0.88rem; color: var(--accent); }
.edu-detail { display: block; font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   RESEARCH — Main Cards (click to expand)
   ============================================================ */
.rc-hint {
  font-size: 0.8rem; color: var(--text-muted);
  margin-top: -12px; margin-bottom: 16px; font-style: italic;
}

.research-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Main direction card */
.research-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
}
.research-card:hover {
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-lg);
}

.research-card--main {
  cursor: pointer;
  user-select: none;
}
.research-card--main:hover { transform: translateY(-2px); }
.research-card--main.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,111,143,0.12);
}

.rc-icon { font-size: 1.6rem; margin-bottom: 10px; }
.research-card h3 { font-size: 0.98rem; font-weight: 700; color: var(--heading); margin-bottom: 8px; }
.research-card p { font-size: 0.86rem; color: var(--text-alt); line-height: 1.65; }

/* Expand "+" icon */
.rc-expand-icon {
  position: absolute;
  top: 20px; right: 20px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-highlight);
  border-radius: 50%;
  transition: transform 0.3s, background 0.2s, color 0.2s;
}
.research-card--main.active .rc-expand-icon {
  transform: rotate(45deg);
  background: var(--accent);
  color: #fff;
}
.research-card--main:hover .rc-expand-icon {
  background: var(--accent-dim);
  color: #fff;
}

/* Sub-cards grid — hidden by default, animated */
.research-sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  overflow: hidden;
  transition: grid-template-rows 0.35s ease, opacity 0.35s ease, margin 0.35s ease;
}
.research-sub-grid--3col {
  grid-template-columns: repeat(3, 1fr);
}
.research-sub-grid[hidden] {
  display: none;
}

/* Sub-card */
.research-card--sub {
  background: var(--bg-subcard);
  border-left: 3px solid var(--border);
  padding: 18px 20px;
  position: relative;
}
.research-card--sub:hover { border-left-color: var(--accent-dim); }

/* Direction-specific left border colors */
.sub-mm-perception  { border-left-color: var(--color-perception) !important; }
.sub-mm-generation  { border-left-color: var(--color-generation) !important; }
.sub-ei-chip         { border-left-color: var(--color-chip) !important; }
.sub-ei-system       { border-left-color: var(--color-system) !important; }
.sub-ei-algo         { border-left-color: var(--color-algo) !important; }

/* Sub-card tag pill */
.rc-sub-tag {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 10px; border-radius: 99px;
  color: #fff;
  letter-spacing: 0.04em;
}
.tag-perception { background: var(--color-perception); }
.tag-generation { background: var(--color-generation); }
.tag-chip       { background: var(--color-chip); }
.tag-system     { background: var(--color-system); }
.tag-algo       { background: var(--color-algo); }

/* ============================================================
   PUBLICATIONS
   ============================================================ */
.pub-section { margin-bottom: 8px; }

.pub-cat-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.pub-cat-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.pub-cat-header strong { font-size: 0.95rem; }

.pub-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.pub-card:hover { border-color: var(--accent-dim); box-shadow: var(--shadow-lg); }

.pub-card-top {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 6px;
}

.pub-title {
  font-size: 1rem; font-weight: 700; color: var(--heading);
  line-height: 1.5; flex: 1;
}

/* Publication type tag (matches research direction color) */
.pub-type-tag {
  flex-shrink: 0;
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 10px; border-radius: 99px;
  color: #fff;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.pub-authors { font-size: 0.88rem; color: var(--text-alt); margin-bottom: 4px; }
.pub-authors strong { color: var(--accent); }
.pub-desc { font-size: 0.88rem; color: var(--text-alt); margin-bottom: 10px; line-height: 1.6; }
.pub-meta { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pub-venue { font-size: 0.85rem; font-weight: 700; color: var(--accent); font-style: italic; }
.pub-links { font-size: 0.85rem; color: var(--text-muted); }
.pub-links a { font-weight: 500; }

/* ============================================================
   PUBLICATION EMPTY STATE — Paimon
   ============================================================ */
.pub-empty {
  text-align: center;
  padding: 32px 20px 28px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.paimon-img {
  width: 100px; height: 100px;
  object-fit: contain;
  margin: 0 auto 16px;
  opacity: 0.85;
}
.paimon-quote {
  font-size: 1.05rem; font-weight: 700;
  color: var(--heading);
  margin-bottom: 4px;
}
.paimon-sub {
  font-size: 0.85rem; color: var(--text-muted);
}

/* ============================================================
   HOBBIES
   ============================================================ */
.hobby-text { font-size: 0.95rem; color: var(--text); margin-bottom: 6px; }
.hobby-quote { font-size: 0.9rem; color: var(--text-muted); font-style: italic; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  margin-top: 48px; padding-top: 18px;
  border-top: 1px solid var(--border-light);
  text-align: center;
}
.footer p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.8; }
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--accent); }
.footer-idol { margin-bottom: 6px; }
.footer-idol strong { color: var(--accent-warm); }

/* ============================================================
   FLOATING CONTROLS
   ============================================================ */
.float-ctrls {
  position: fixed; bottom: 28px; right: 28px;
  display: flex; gap: 8px; z-index: 100;
}
.ctrl-btn {
  width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--bg-card);
  font-size: 0.78rem; font-weight: 700; color: var(--text-alt);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s, transform 0.15s, color 0.3s;
}
.ctrl-btn:hover {
  transform: scale(1.08); border-color: var(--accent-dim); color: var(--accent);
}
#themeToggle { font-size: 1.1rem; }

[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"]  .theme-icon-light{ display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 800px) {
  .research-sub-grid--3col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .page { padding: 32px 20px 32px; }
  .header-row { flex-direction: column-reverse; align-items: center; text-align: center; }
  .header-photo img { width: 110px; height: 110px; }
  .name { font-size: 1.6rem; }
  .contact-row { justify-content: center; }
  .research-main-grid { grid-template-columns: 1fr; }
  .research-sub-grid,
  .research-sub-grid--3col { grid-template-columns: 1fr; }
  .edu-item { flex-direction: column; gap: 4px; }
  .news-tag { min-width: auto; margin-right: 8px; }
  .float-ctrls { bottom: 18px; right: 18px; }
  .ctrl-btn { width: 40px; height: 40px; }
  .pub-card-top { flex-direction: column; }
}
