/* ==========================================================================
   Mingyu Park — personal research page
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --font: 'Lato', Verdana, Helvetica, sans-serif;

  --bg: #ffffff;
  --text: #1f2328;
  --muted: #5b636d;
  --border: #e6e8eb;

  --link: #1772d0;
  --link-hover: #f09228;
  --accent: #d63a3a;            /* highlighted numbers / baselines */

  --highlight-bg: #fffbe6;      /* featured publication card */
  --highlight-border: #f3d97a;

  --radius: 10px;
  --max-width: 820px;
  --gutter: 20px;
  --media-size: 180px;
}

/* Dark theme — enabled by the toggle button (default is light). */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #15171a;
  --text: #e6e8eb;
  --muted: #9aa3ad;
  --border: #2b2f35;

  --link: #5aa9ff;
  --link-hover: #ffb35c;
  --accent: #ff6b6b;

  --highlight-bg: #22201a;
  --highlight-border: #5c4f22;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  transition: transform .15s ease-in-out, border-color .15s ease-in-out;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: scale(1.08);
  border-color: var(--link-hover);
}

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color .15s ease-in-out;
}

a:hover,
a:focus {
  color: var(--link-hover);
}

img,
video {
  display: block;
  max-width: 100%;
}

p {
  margin: 0 0 .75em;
}

p:last-child {
  margin-bottom: 0;
}

/* ---------- Layout ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter) 40px;
}

.section {
  margin-top: 44px;
}

.section-title {
  margin: 0 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .2px;
}

.subsection-title {
  margin: 18px 0 6px;
  font-size: 16px;
  font-weight: 700;
}

/* ---------- Header / intro ---------- */
.intro {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 32px;
  align-items: center;
  padding-top: 40px;
}

.name {
  margin: 0 0 16px;
  font-size: 34px;
  font-weight: 700;
  text-align: center;
}

.profile-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .12);
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.social-links img {
  height: 22px;
  transition: transform .15s ease-in-out;
}

.social-links a:hover img {
  transform: translateY(-2px);
}

/* ---------- News ---------- */
.news-list {
  margin: 0;
  padding-left: 1.2em;
}

.news-list li {
  margin: 4px 0;
}

.news-date {
  display: inline-block;
  min-width: 92px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Generic two-column entry (publications, education, work, ...) ---------- */
.entry {
  display: grid;
  grid-template-columns: var(--media-size) 1fr;
  gap: 24px;
  align-items: center;
  padding: 20px;
  border-radius: var(--radius);
}

.entry + .entry {
  margin-top: 12px;
}

.entry-logo {
  display: flex;
  justify-content: center;
}

.entry-logo img {
  max-height: 80px;
  width: auto;
}

.entry-logo img.logo-wide {
  max-height: none;
  width: 100%;
  max-width: 160px;
}

/* Transparent logos are designed for white — give them a white tile in dark mode. */
:root[data-theme="dark"] .entry-logo img {
  padding: 8px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.entry-title {
  font-weight: 700;
}

.entry-meta {
  color: var(--muted);
}

/* ---------- Publications ---------- */
.pub.featured {
  background: var(--highlight-bg);
  border: 1px solid var(--highlight-border);
}

.papertitle {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.pub-authors,
.pub-venue,
.pub-links {
  margin: 4px 0 0;
}

.pub-venue {
  color: var(--muted);
}

/* Compact icon "pill" links (paper / site). */
.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pub-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  transition: color .15s ease-in-out, border-color .15s ease-in-out;
}

.pub-link img {
  width: 13px;
  height: 13px;
  opacity: .8;
  transition: opacity .15s ease-in-out;
}

.pub-link:hover,
.pub-link:focus {
  border-color: var(--link-hover);
  color: var(--link-hover);
}

.pub-link:hover img,
.pub-link:focus img {
  opacity: 1;
}

/* Icons are black-on-transparent; flip them for dark mode. */
:root[data-theme="dark"] .pub-link img {
  filter: invert(1);
}

.pub-venue em {
  color: var(--text);
  font-weight: 700;
}

.pub-desc {
  margin-top: 10px;
}

.me {
  font-weight: 700;
}

.accent,
.accent a {
  color: var(--accent);
  font-weight: 700;
}

/* Square thumbnail that swaps to a video on hover (CSS only, no per-paper JS).
   Fixed square box; image and video are stacked and fill it edge to edge. */
.pub-media {
  position: relative;
  width: var(--media-size);
  height: var(--media-size);
  flex: none;
  align-self: center;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  line-height: 0;
}

.pub-media img,
.pub-media video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: cover;
  object-position: center;
}

.pub-media video {
  opacity: 0;
  transition: opacity .2s ease-in-out;
}

.pub-media:hover video,
.pub-media:focus-within video {
  opacity: 1;
}

/* ---------- Academic services ---------- */
.services dd {
  margin: 0 0 0 1.2em;
  font-weight: 700;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 48px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ==========================================================================
   Child pages (project pages, personal projects)
   ========================================================================== */

.back-link {
  display: inline-block;
  padding-top: 24px;
  color: var(--muted);
  font-size: 14px;
}

.back-link:hover,
.back-link:focus {
  color: var(--link-hover);
}

/* Page header */
.page-header {
  padding-top: 28px;
  text-align: center;
}

.page-title {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
}

.page-venue {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 16px;
}

.page-authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 16px;
}

.page-affiliation {
  margin-top: 4px;
  color: var(--muted);
}

.page-header .pub-links {
  justify-content: center;
  margin-top: 16px;
}

/* Body text */
.prose {
  text-align: justify;
  hyphens: auto;
}

/* Project block (one per project on the personal-projects page) */
.project + .project {
  margin-top: 56px;
}

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 8px;
}

.project-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
}

.project-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.project-head .pub-links {
  margin-top: 0;
}

.subheading {
  margin: 28px 0 10px;
  font-size: 17px;
  font-weight: 700;
}

/* Figures: single or side-by-side images / videos with captions */
.figure {
  margin: 16px auto 18px;
}

.figure-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}

.figure-item {
  margin: 0;
}

.figure img,
.figure video {
  width: 100%;
  border-radius: 8px;
  background: #ffffff;
}

.figure figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.figure.narrow { max-width: 320px; }
.figure.medium { max-width: 480px; }
.figure.wide   { max-width: 640px; }

/* Citation block */
.bibtex {
  position: relative;
}

.bibtex pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--highlight-bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: color .15s ease-in-out, border-color .15s ease-in-out;
}

.copy-btn:hover,
.copy-btn:focus {
  border-color: var(--link-hover);
  color: var(--link-hover);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .theme-toggle {
    top: 10px;
    right: 10px;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .intro-photo {
    order: -1;
    max-width: 180px;
    margin: 0 auto;
  }

  .entry {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }

  .pub-media {
    width: min(240px, 100%);
    height: auto;
    aspect-ratio: 1 / 1;
    justify-self: center;
  }

  .entry-logo img {
    max-height: 64px;
  }

  .page-title {
    font-size: 22px;
  }

  .prose {
    text-align: left;
  }
}
