/* Academic Homepage — Minimal Style */

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

:root {
  --text: #222; --text-light: #555; --border: #ccc;
  --bg: #fff; --bg-alt: #f9f9f9;
  --link: #1a0dab; --link-hover: #d33;
  --max-width: 780px;
  --font-serif: "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
  --font-sans: "Segoe UI", Helvetica, Arial, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-serif); color: var(--text); background: var(--bg);
  line-height: 1.7; display: flex; flex-direction: column; min-height: 100vh;
}

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

/* Header */
header { border-bottom: 1px solid var(--border); padding: 1rem 0; }
header .container {
  max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem;
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 0.5rem;
}
header h1 { font-size: 1.35rem; font-weight: 600; font-family: var(--font-sans); }
header h1 a { color: var(--text); }
header h1 a:hover { text-decoration: none; }
.site-logo { line-height: 1.2; }
.terminal-logo {
  display: inline-flex;
  align-items: baseline;
  width: 32ch;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  color: #111827;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
}
.terminal-logo:hover {
  color: #0f3e8a;
}
.terminal-logo:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 3px;
}
.terminal-text {
  flex: 0 1 auto;
  min-width: 0;
}
.terminal-command {
  color: #2563eb;
}
.terminal-cursor {
  display: inline-block;
  flex: 0 0 1ch;
  width: 1ch;
  color: #2563eb;
  animation: terminal-cursor-blink 1s steps(1, end) infinite;
}
header nav { font-family: var(--font-sans); font-size: 0.9rem; }
header nav a { margin-left: 1.2rem; color: var(--text-light); }
header nav a:hover { color: var(--text); }
header nav a.active { color: var(--text); font-weight: 600; border-bottom: 1px solid var(--text); padding-bottom: 0.12rem; text-decoration: none; }

@keyframes terminal-cursor-blink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

/* Breadcrumb */
.breadcrumb-wrap { border-bottom: 1px solid #eee; background: var(--bg); }
.breadcrumb {
  max-width: var(--max-width); margin: 0 auto; padding: 0.85rem 1.5rem 0.95rem;
}
.breadcrumb-path { font-family: var(--font-sans); font-size: 0.82rem; color: var(--text-light); margin-bottom: 0.25rem; }
.breadcrumb-path a { color: var(--text-light); }
.breadcrumb-path span { margin: 0 0.4rem; color: #888; }
.breadcrumb h2 { font-family: var(--font-sans); font-size: 1.35rem; font-weight: 600; line-height: 1.35; margin: 0; color: var(--text); }

/* Main */
main {
  max-width: var(--max-width); margin: 0 auto; padding: 2rem 1.5rem;
  flex: 1; width: 100%;
}

/* Sections */
section { margin-bottom: 2.5rem; }
section h2 {
  font-size: 1.2rem; font-family: var(--font-sans); font-weight: 600;
  border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; margin-bottom: 1rem;
}
section h3 { font-size: 1rem; font-weight: 600; margin: 1rem 0 0.3rem; }
p { margin-bottom: 0.75rem; }

/* About */
.about-row {
  display: flex;
  gap: 1.8rem;
  align-items: flex-start;
}

.about-figure {
  width: 140px;
  min-width: 140px;
  margin: 0;
}

.about-photo {
  width: 100%;
  border-radius: 4px;
  display: block;
}

.about-figure figcaption {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.35;
  margin-top: 0.35rem;
}

.about-info { flex: 1; }

.about-info .name {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.about-info .affiliation {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 0.6rem;
}

.more-link {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 1.4rem;
}

.profile-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 999px;
  text-decoration: none;
  color: #222;
  font-size: 0.92rem;
  line-height: 1;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.profile-links a:hover {
  background-color: #f5f5f5;
  border-color: #bbb;
  transform: translateY(-1px);
}

.profile-links i {
  font-size: 1rem;
}

/* News */
.news-list, .news-timeline { margin: 0; padding: 0; }
.news-entry { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid #eee; }
.news-entry:last-child { border-bottom: none; }
.news-date { font-family: var(--font-sans); font-size: 0.86rem; color: var(--text-light); white-space: nowrap; }
.news-title { font-family: var(--font-sans); font-size: 0.96rem; font-weight: 600; line-height: 1.45; }
.news-title a { color: var(--text); }
.news-title a:hover { color: var(--link); }
.news-summary { font-size: 0.9rem; color: var(--text-light); line-height: 1.5; margin-top: 0.15rem; }
.news-timeline { position: relative; margin-left: 0.2rem; }
.timeline-entry { position: relative; grid-template-columns: 7rem 1fr; border-bottom: none; padding: 0 0 1.15rem 1.1rem; }
.timeline-entry::before { content: ""; position: absolute; left: 0.2rem; top: 0.45rem; width: 7px; height: 7px; border-radius: 50%; background: var(--text); }
.timeline-entry::after { content: ""; position: absolute; left: calc(0.2rem + 3px); top: 1.05rem; bottom: 0.1rem; border-left: 1px solid #ddd; }
.timeline-entry:last-child::after { display: none; }

/* Lists */
ul, ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
li { margin-bottom: 0.4rem; }

/* Item list (auto-generated) */
.section-intro {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 0.8rem;
}

.item-list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 1.2rem; padding: 1rem 0; border-bottom: 1px solid #eee; align-items: flex-start; }
.item:last-child { border-bottom: none; }
.item-thumbnail { width: 120px; min-width: 120px; height: 90px; object-fit: cover; border-radius: 3px; background: var(--bg-alt); border: 1px solid #eee; }
.item-body { flex: 1; min-width: 0; }
.item-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.15rem; }
.item-title { font-family: var(--font-sans); font-weight: 600; font-size: 1rem; margin-bottom: 0.15rem; line-height: 1.4; }
.item-title a { color: var(--text); }
.item-title a:hover { color: var(--link); }
.item-title a::after, .news-title a::after {
  content: ""; display: inline-block; width: 0.36em; height: 0.36em;
  border-top: 1px solid currentColor; border-right: 1px solid currentColor;
  transform: rotate(45deg); margin-left: 0.35rem; vertical-align: 0.08em;
  opacity: 0.55;
}
.item-title a:hover::after, .news-title a:hover::after { opacity: 0.9; }
.item-year { flex: 0 0 auto; font-family: var(--font-sans); font-size: 0.78rem; font-weight: 600; line-height: 1.2; border: 1px solid var(--border); border-radius: 3px; padding: 0.16rem 0.45rem; color: var(--text); background: var(--bg-alt); }
.publication-year { margin-top: 0.05rem; }
.item-meta { font-size: 0.9rem; color: var(--text-light); margin-bottom: 0.2rem; }
.item-summary { font-size: 0.92rem; margin-bottom: 0.25rem; line-height: 1.55; }
.item-links { font-size: 0.85rem; margin-top: 0.2rem; }
.item-links a { margin-right: 0.5rem; }
.item-tags { margin-top: 0.3rem; }
.tag { display: inline-block; font-size: 0.78rem; font-family: var(--font-sans); background: var(--bg-alt); border: 1px solid #e0e0e0; border-radius: 3px; padding: 0.1rem 0.45rem; margin: 0.1rem 0.25rem 0.1rem 0; color: var(--text-light); }
.empty-note { color: var(--text-light); font-style: italic; }
.view-all { margin-top: 0.5rem; font-family: var(--font-sans); font-size: 0.9rem; }

/* Detail page */
.detail-header { margin-bottom: 1.5rem; }
.detail-header h2 { border-bottom: none; font-size: 1.3rem; margin-bottom: 0.3rem; padding-bottom: 0; }
.detail-meta { font-size: 0.92rem; color: var(--text-light); margin-bottom: 0.5rem; }
.detail-figure { margin: 1.5rem 0; }
.detail-figure img { max-width: 100%; border-radius: 3px; }
.detail-figure figcaption { font-size: 0.85rem; color: var(--text-light); margin-top: 0.3rem; }

/* Project detail pages */
.project-hero {
  margin: 0 0 1.2rem;
}

.project-hero img {
  display: block;
  width: 100%;
  border: none;
  border-radius: 0;
}

.project-page img {
  border: none;
}

.project-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.9rem 0 1.4rem;
  font-family: var(--font-sans);
  font-size: 0.86rem;
}

.project-link-row a {
  border: 1px solid #ddd;
  border-radius: 3px;
  color: var(--text);
  padding: 0.22rem 0.55rem;
}

.project-link-row a:hover {
  border-color: #aaa;
  color: var(--link);
  text-decoration: none;
}

.conversion-grid {
  display: grid;
  gap: 1rem;
  margin: 0.8rem 0 1.5rem;
}

.conversion-card {
  margin: 0;
  border-top: 1px solid #eee;
  padding-top: 0.8rem;
}

.conversion-card figcaption,
.project-process figcaption {
  color: var(--text-light);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  margin-bottom: 0.45rem;
}

.conversion-chain {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 0.8fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
}

.conversion-chain img {
  display: block;
  max-width: 100%;
  border-radius: 3px;
}

.conversion-chain img:not(.conversion-arrow) {
  border: 1px solid #eee;
}

.conversion-arrow {
  padding: 0.25rem 0.15rem;
}

.project-process {
  margin: 0.8rem 0 1.5rem;
}

.project-process img {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  border: none;
  border-radius: 0;
}

.project-source-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  line-height: 1.45;
  margin: 0.4rem 0 0.9rem;
}

.project-source-item,
.project-source-links > span {
  border-top: 1px solid var(--border);
  min-width: 0;
  padding-top: 0.45rem;
}

.project-source-label,
.project-source-links strong {
  color: var(--text-light);
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 0.12rem;
}

.project-source-row {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
}

.project-source-url {
  overflow-wrap: anywhere;
}

.github-stars {
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  display: inline-block;
  font-size: 0.74rem;
  line-height: 1.25;
  padding: 0.08rem 0.36rem;
  white-space: nowrap;
}

.project-notice {
  color: #b00020;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.p2p-demo-table,
.p2p-team-table {
  border-collapse: separate;
  border-spacing: 0.75rem 0.35rem;
  margin: 0.6rem auto 1.6rem;
  text-align: center;
  width: 100%;
}

.p2p-demo-table td,
.p2p-team-table td {
  border: none;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  vertical-align: middle;
}

.p2p-demo-table img {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}

.p2p-demo-table td:first-child img,
.p2p-demo-table td:last-child img {
  width: 100%;
  max-width: 120px;
}

.p2p-arrow {
  width: 260px;
}

.p2p-video {
  display: block;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  margin: 0.7rem auto 0.85rem;
  background: #111;
}

.code-example {
  margin: 1rem 0 1.6rem;
  background: var(--bg-alt);
  padding: 0.75rem 0.85rem;
}

.code-example summary {
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.code-example summary span {
  color: #2563eb;
}

.code-example pre {
  max-height: 26rem;
  overflow: auto;
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  background: #fff;
  font-size: 0.78rem;
  line-height: 1.45;
}

.code-example code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre;
}

.p2p-team-table {
  border-spacing: 1.2rem 0.3rem;
}

.p2p-person {
  width: 100px;
  height: 129px;
  border: none;
  background-color: transparent;
  background-position: center;
  background-size: cover;
  cursor: pointer;
}

.person1 { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person1_a.png"); }
.person2 { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person2_a.png"); }
.person3 { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person3_a.png"); }
.person4 { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person4_a.png"); }

.person1:hover { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person1_b.png"); }
.person2:hover { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person2_b.png"); }
.person3:hover { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person3_b.png"); }
.person4:hover { background-image: url("https://www.comp.nus.edu.sg/~guoyi/project/picture2pixel/img/person4_b.png"); }

.story-media {
  margin: 1rem auto 1.45rem;
  text-align: center;
}

.story-media img {
  border: none;
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: min(100%, 560px);
}

.story-media figcaption {
  color: var(--text-light);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  margin-top: 0.35rem;
}

.story-sponsor {
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  margin-top: 1.4rem;
  padding-top: 0.85rem;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  margin-top: auto;
}

footer .container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  text-align: center;
}

.katex-display { margin: 1rem 0; }

/* Responsive */
@media (max-width: 600px) {
  html { font-size: 15px; }
  header .container { flex-direction: column; align-items: flex-start; }
  .terminal-logo {
    width: 32ch;
    font-size: 0.9rem;
  }
  header nav { margin-top: 0.3rem; }
  header nav a { margin-left: 0; margin-right: 1rem; }
  .breadcrumb { padding: 0.8rem 1rem; }
  .about-row { flex-direction: column; gap: 1rem; }
  .about-figure {
    width: 188px;
    min-width: auto;
    align-self: center;
    text-align: center;
  }
  main { padding: 1.5rem 1rem; }
  .news-entry, .timeline-entry { grid-template-columns: 1fr; gap: 0.1rem; }
  .timeline-entry { padding-left: 1rem; }
  .item { flex-direction: column; gap: 0.6rem; }
  .item-heading { align-items: baseline; }
  .item-thumbnail { width: 100%; min-width: auto; height: auto; max-height: 200px; }
  .conversion-chain {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .conversion-arrow {
    width: 160px;
    transform: rotate(90deg);
  }
  .project-source-links {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .p2p-demo-table,
  .p2p-demo-table tbody,
  .p2p-demo-table tr,
  .p2p-demo-table td {
    display: block;
    width: 100%;
  }
  .p2p-demo-table {
    border-spacing: 0;
  }
  .p2p-demo-table td {
    padding: 0.25rem 0;
  }
  .p2p-demo-table td:first-child img,
  .p2p-demo-table td:last-child img {
    max-width: 210px;
  }
  .p2p-arrow {
    width: 160px;
    transform: rotate(90deg);
  }
  .p2p-team-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media print {
  header, footer, nav { display: none; }
  main { max-width: 100%; padding: 0; }
  a { color: var(--text); }
}
