/* ============================================================
   Feilong Tang - Academic Homepage (Wikipedia Style)
   ============================================================ */

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

/* ---------- Theme Variables ---------- */
:root {
  --bg-main: #f8f9fa;
  --bg-white: #fff;
  --bg-infobox: #f8f9fa;
  --text-color: #202122;
  --text-muted: #54595d;
  --border-color: #a2a9b1;
  --border-light: #c8ccd1;
  --border-xlight: #eaecf0;
  --link-color: #0645ad;
  --link-visited: #0b0080;
  --heading-color: #000;
  --infobox-title-bg: #eaecf0;
  --news-hover: #f8f9fa;
  --genre-tag-bg: #f8f9fa;
  --genre-tag-color: #54595d;
  --genre-tag-border: #c8ccd1;
  --genre-tag-sec-bg: #fff;
  --additional-bg: #fff8e1;
  --additional-color: #5c4a1a;
  --additional-border: #d4a017;
  --scrollbar-track: #f8f9fa;
  --scrollbar-thumb: #c8ccd1;
}

body.dark-mode {
  --bg-main: #1a1b1e;
  --bg-white: #242526;
  --bg-infobox: #1e1f22;
  --text-color: #e8e9ea;
  --text-muted: #a0a3a8;
  --border-color: #3a3b3c;
  --border-light: #4a4b4c;
  --border-xlight: #2e2f30;
  --link-color: #6b9ce4;
  --link-visited: #9b7de8;
  --heading-color: #f0f0f0;
  --infobox-title-bg: #2e2f30;
  --news-hover: #2e2f30;
  --genre-tag-bg: #2e2f30;
  --genre-tag-color: #a0a3a8;
  --genre-tag-border: #4a4b4c;
  --genre-tag-sec-bg: #242526;
  --additional-bg: #2d2710;
  --additional-color: #d4b860;
  --additional-border: #8a6a10;
  --scrollbar-track: #1a1b1e;
  --scrollbar-thumb: #4a4b4c;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--bg-main);
  transition: background 0.2s, color 0.2s;
}

a { color: var(--link-color); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }

ul, ol { margin: 0.4em 0 0.4em 1.8em; }
li { margin: 0.25em 0; }

p { margin: 0.5em 0; }

hr {
  border: none;
  border-top: 1px solid #a2a9b1;
  margin: 1em 0;
}

/* ---------- Wiki Header ---------- */
.wiki-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5em 0;
  transition: background 0.2s;
}

.wiki-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wiki-logo {
  font-size: 1.1em;
  font-weight: bold;
  color: var(--text-color);
  text-decoration: none;
}
.wiki-logo:hover { text-decoration: none; color: var(--text-color); }

.wiki-nav a {
  color: var(--link-color);
  text-decoration: none;
  margin-left: 1.5em;
  font-size: 0.9em;
}
.wiki-nav a:hover { text-decoration: underline; }

/* ---------- Theme Toggle Button ---------- */
.theme-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-color);
  cursor: pointer;
  font-size: 0.95em;
  padding: 0.25em 0.55em;
  margin-left: 1.2em;
  transition: background 0.2s, color 0.2s;
  vertical-align: middle;
}
.theme-btn:hover { background: var(--bg-main); }

/* ---------- Main layout ---------- */
.wiki-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  min-height: calc(100vh - 80px);
}

/* ---------- Left Sidebar (TOC) ---------- */
.wiki-sidebar {
  width: 176px;
  flex-shrink: 0;
  background: var(--bg-main);
  border-right: 1px solid var(--border-color);
  padding: 0.75em;
  position: sticky;
  top: 0;
  height: fit-content;
}

.wiki-sidebar-title {
  font-weight: bold;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0.5em;
  font-size: 0.9em;
}

.wiki-sidebar ul { list-style: none; margin: 0; padding: 0; }
.wiki-sidebar li { margin: 0.3em 0; }
.wiki-sidebar a { color: var(--link-color); text-decoration: none; font-size: 0.85em; }
.wiki-sidebar a:hover { text-decoration: underline; }

/* ---------- Main Content ---------- */
.wiki-content {
  flex: 1;
  background: var(--bg-white);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  padding: 1.5em 2em;
  min-width: 0;
  transition: background 0.2s;
}

/* ---------- Page Title ---------- */
.wiki-title {
  font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
  font-size: 1.8em;
  font-weight: normal;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.2em;
  margin-bottom: 0.8em;
  color: var(--heading-color);
}

.wiki-title-cn {
  font-size: 0.65em;
  font-weight: normal;
  color: var(--text-muted);
  margin-left: 0.5em;
}

/* ---------- Chinese Name Toggle ---------- */
.cn-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.55em;
  margin-left: 0.4em;
  vertical-align: middle;
  padding: 0 0.2em;
  opacity: 0.7;
}
.cn-toggle:hover { opacity: 1; }

/* ---------- Section Headings ---------- */
h2 {
  font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
  font-size: 1.4em;
  font-weight: normal;
  color: var(--heading-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.2em;
  margin: 1.2em 0 0.5em;
}

h3 {
  font-size: 1.1em;
  font-weight: bold;
  color: var(--text-color);
  margin: 1em 0 0.3em;
}

/* ---------- News ---------- */
.news-scroll {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  margin: 0.5em 0 1em;
}

.news-scroll::-webkit-scrollbar { width: 6px; }
.news-scroll::-webkit-scrollbar-track { background: var(--scrollbar-track); }
.news-scroll::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

.news-list { list-style: none; margin: 0; padding: 0; }

.news-list li {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-xlight);
  font-size: 0.9em;
  align-items: flex-start;
}
.news-list li:last-child { border-bottom: none; }
.news-list li:hover { background: var(--news-hover); }

.news-date {
  flex-shrink: 0;
  min-width: 58px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85em;
  padding-top: 1px;
}

/* ---------- Publications ---------- */
.pub-note {
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 0.8em;
}

.publications { margin-top: 0.3em; }

.publications ol.bibliography {
  list-style: none;
  padding: 0;
  margin: 0;
}

.publications ol.bibliography li {
  margin-bottom: 0.6em;
  padding: 0.6em 0;
  border-bottom: 1px solid var(--border-xlight);
}
.publications ol.bibliography li:last-child { border-bottom: none; }

.pub-entry { line-height: 1.45; }

.pub-entry .title {
  font-weight: bold;
  display: block;
  margin-bottom: 0.2em;
}
.pub-entry .title a { color: var(--link-color); }

.pub-entry .periodical {
  display: block;
  margin: 0.2em 0;
}

.genre-tag {
  display: inline-block;
  padding: 0.1em 0.45em;
  border: 1px solid var(--genre-tag-border);
  border-radius: 3px;
  background: var(--genre-tag-bg);
  color: var(--genre-tag-color);
  font-size: 0.82em;
  line-height: 1.3;
  margin: 0.1em 0.3em 0.1em 0;
  white-space: normal;
  word-break: break-word;
}

.genre-tag-secondary {
  border-color: var(--border-xlight);
  background: var(--genre-tag-sec-bg);
}
.genre-tag-secondary a { color: var(--link-color); text-decoration: none; }
.genre-tag-secondary a:hover { text-decoration: underline; }

.genre-tag-first {
  background: #f0fdf4;
  color: #166534;
  border-color: #86efac;
}

body.dark-mode .genre-tag-first {
  background: #0d2b1a;
  color: #6ee7a0;
  border-color: #2d6a45;
}

.genre-tag-oral {
  background: #fef3c7;
  color: #92400e;
  border-color: #f59e0b;
}

body.dark-mode .genre-tag-oral {
  background: #2d1f06;
  color: #fbbf24;
  border-color: #7a5100;
}

.genre-tag-award {
  background: #fef9c3;
  color: #713f12;
  border-color: #eab308;
}

body.dark-mode .genre-tag-award {
  background: #2a2000;
  color: #facc15;
  border-color: #7a6000;
}

.pub-entry .additional {
  display: block;
  color: var(--additional-color);
  background: var(--additional-bg);
  border-left: 3px solid var(--additional-border);
  padding: 0.2em 0.5em;
  border-radius: 2px;
  font-size: 0.85em;
  margin: 0.2em 0;
}

.pub-entry .author {
  display: block;
  color: var(--text-muted);
  font-size: 0.88em;
  margin-top: 0.2em;
}

/* ---------- Author expand/collapse ---------- */
.author-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--link);
  font-size: 0.75em;
  padding: 0 2px;
  vertical-align: middle;
  line-height: 1;
}
.author-expand-btn:hover {
  opacity: 0.75;
}

/* ---------- Right Infobox ---------- */
.wiki-infobox-container {
  width: 260px;
  flex-shrink: 0;
  padding: 0.75em;
  background: var(--bg-infobox);
}

.infobox {
  border: 1px solid var(--border-color);
  background: var(--bg-infobox);
  font-size: 0.88em;
  padding: 0.5em;
  position: sticky;
  top: 0.5em;
}

.infobox-title {
  background: var(--infobox-title-bg);
  text-align: center;
  font-weight: bold;
  padding: 0.4em;
  margin: -0.5em -0.5em 0.5em -0.5em;
  font-size: 1em;
}

.infobox img {
  width: 100%;
  border: 1px solid var(--border-light);
  display: block;
}

.infobox-caption {
  text-align: center;
  font-size: 0.85em;
  color: var(--text-muted);
  padding: 0.3em 0;
  border-bottom: 1px solid var(--border-xlight);
  margin-bottom: 0.3em;
}

.infobox-row {
  padding: 0.3em 0;
  border-top: 1px solid var(--border-xlight);
  font-size: 0.92em;
}
.infobox-row:first-of-type { border-top: none; }

.infobox-label { font-weight: bold; }

.infobox-row a { word-break: break-all; }
.infobox-row i { width: 1.2em; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .wiki-infobox-container { width: 220px; }
}

@media (max-width: 900px) {
  .wiki-wrapper { flex-direction: column; }
  .wiki-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    position: static;
  }
  .wiki-sidebar ul { display: flex; flex-wrap: wrap; gap: 0.5em; }
  .wiki-sidebar li { margin: 0; }
  .wiki-infobox-container {
    width: 100%;
    order: -1;
  }
  .infobox {
    max-width: 400px;
    margin: 0 auto;
    position: static;
  }
  .wiki-content {
    border-left: none;
    border-right: none;
    padding: 1em;
  }
}

@media (max-width: 600px) {
  .wiki-content { padding: 0.75em; }
  .wiki-title { font-size: 1.4em; }
  h2 { font-size: 1.2em; }
}
