/* Jun-Kun Chen — homepage v2
   Restrained academic layout tuned for recruiters: strong hierarchy, short scan path,
   evidence-first content. Light theme only. */

:root {
  --ink: #171a1e;
  --text: #2d3238;
  --muted: #5d6570;
  --faint: #656d77;
  --line: #e4e7eb;
  --line-strong: #d3d8de;
  --surface: #f6f7f9;
  --surface-2: #eef1f4;
  --accent: #1c5ea5;
  --accent-ink: #164b84;
  --accent-soft: #e8f0f9;
  --ok: #2b7a4b;
  --page: min(1120px, calc(100% - 40px));
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: #fff;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
strong { font-weight: 600; color: var(--ink); }
h1, h2, h3, h4 { color: var(--ink); margin: 0; }
p { margin: 0; }
:focus-visible { outline: 2px solid #77a9d7; outline-offset: 3px; }

.page { width: var(--page); margin-inline: auto; }
.skip-link {
  position: fixed; z-index: 30; top: 8px; left: 8px;
  padding: 8px 12px; color: #fff; background: var(--ink);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  min-height: 54px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.site-name { color: var(--ink); font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; }
.site-name:hover { color: var(--ink); text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 22px; }
.site-nav a { color: #454c55; font-size: 14px; font-weight: 500; }
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.site-nav .nav-cv {
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
}
.site-nav .nav-cv:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 48px;
  align-items: start;
  padding: 44px 0 34px;
  scroll-margin-top: 70px;
}
.hero h1 {
  font-size: 36px; line-height: 1.1; letter-spacing: -.03em; font-weight: 700;
}
.hero-alias { margin-top: 6px; color: var(--faint); font-size: 12.5px; }
.hero-title { margin-top: 12px; font-size: 16px; font-weight: 600; color: var(--ink); }
.hero-title a { color: inherit; }
.hero-title a:hover { color: var(--accent); }
.hero-lead { margin-top: 16px; max-width: 760px; font-size: 16.5px; line-height: 1.6; color: var(--text); }
.hero-lead + .hero-lead { margin-top: 10px; }
.hero-lead a { white-space: nowrap; }

.status-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin-top: 18px;
  font-size: 14px; color: var(--muted);
}
.status-line .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(43, 122, 75, .15);
}
.status-line strong { font-weight: 600; }
.status-line .sep { color: var(--line-strong); }

.hero-links {
  display: flex; flex-wrap: wrap; gap: 8px 10px;
  margin-top: 18px;
}
.hero-links a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px; font-weight: 500;
}
.hero-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.hero-links a.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.hero-links a.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.hero-links svg { width: 14px; height: 14px; fill: currentColor; flex: none; }

.portrait-wrap { padding-top: 6px; }
.portrait {
  width: 168px; height: 168px; display: block;
  object-fit: cover; object-position: 50% 40%;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
}

/* ---------- highlights ---------- */
.highlights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}
.highlights li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px; line-height: 1.5; color: var(--text);
}
.highlights svg { width: 18px; height: 18px; margin-top: 2px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.highlights .tag { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ---------- sections ---------- */
.section {
  padding: 36px 0 40px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 70px;
}
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
  margin-bottom: 18px;
}
.section-head h2 { font-size: 23px; letter-spacing: -.02em; line-height: 1.2; }
.section-head .aside { color: var(--muted); font-size: 13.5px; }
.section-head .aside a { font-weight: 500; }
.section-intro { max-width: 760px; margin: -8px 0 22px; color: var(--muted); font-size: 14.5px; }

/* ---------- research arc (compact strip) ---------- */
.arc {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.arc-stage {
  position: relative;
  padding: 14px 16px 14px 18px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.arc-stage:last-child { border-right: 0; }
.arc-stage.current { background: var(--accent-soft); }
.arc-stage::after {
  content: "";
  position: absolute; top: 50%; right: -7px;
  width: 12px; height: 12px;
  background: #fff;
  border-top: 1px solid var(--line); border-right: 1px solid var(--line);
  transform: translateY(-50%) rotate(45deg);
  z-index: 1;
}
.arc-stage.current::after { display: none; }
.arc-stage:nth-last-child(2)::after { background: var(--accent-soft); }
.arc-stage:last-child::after { display: none; }
.arc-kicker { color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.arc-title { margin-top: 3px; font-size: 14.5px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.arc-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.arc-chips a, .arc-chips span {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px; font-weight: 500; line-height: 1.5;
  white-space: nowrap;
}
.arc-chips a:hover { background: var(--accent); color: #fff; text-decoration: none; }
.arc-stage.current .arc-chips a, .arc-stage.current .arc-chips span { background: #fff; color: var(--accent-ink); }

/* ---------- publications ---------- */
.pub-list { display: block; }
.publication {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 70px;
}
.publication:first-child { border-top: 0; padding-top: 4px; }
.publication-preview { position: relative; width: 100%; max-width: 300px; }
.publication-media {
  position: relative;
  width: 300px;
  aspect-ratio: 16 / 9;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}
.publication-media img, .publication-media video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; object-fit: cover;
}
.publication-media video { cursor: pointer; }
.publication-media.contain video { object-fit: contain; background: #fff; }
.preview-toggle {
  position: absolute; z-index: 1; bottom: 8px; right: 8px;
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 7px;
  border: 1px solid #c3ccd6; border-radius: 6px;
  background: rgba(255, 255, 255, .95); color: #234563;
  cursor: pointer;
}
.preview-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.preview-toggle svg[hidden] { display: none; }
.preview-toggle:hover { background: var(--accent-soft); }
.preview-toggle:focus-visible { outline-offset: -3px; }
@media (pointer: coarse) { .preview-toggle { width: 44px; height: 44px; } }
.preview-error { position: absolute; inset: auto 0 0; margin: 0; padding: 6px; background: #fff; font-size: 12px; }

.pub-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 7px; }
.venue {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap;
}
.venue.review { background: #f3f0e6; color: #6f5a1f; }
.role { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.publication h3 { font-size: 17.5px; line-height: 1.38; letter-spacing: -.012em; font-weight: 650; }
.publication h3 a { color: var(--ink); }
.publication h3 a:hover { color: var(--accent); }
.publication .authors { margin-top: 6px; color: var(--muted); font-size: 13.5px; }
.publication .authors strong { color: var(--ink); font-weight: 600; }
.publication .summary { margin-top: 8px; color: var(--text); font-size: 15px; line-height: 1.5; max-width: 720px; }
.publication-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 9px; }
.publication-links a { font-size: 13.5px; font-weight: 500; }

.all-pubs { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.all-pubs summary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  color: var(--ink); background: #fff;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; list-style: none;
  user-select: none;
}
.all-pubs summary::-webkit-details-marker { display: none; }
.all-pubs summary:hover { border-color: var(--accent); color: var(--accent); }
.all-pubs summary svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .15s ease; }
.all-pubs[open] summary svg { transform: rotate(180deg); }
.all-pubs summary .when-open { display: none; }
.all-pubs[open] summary .when-open { display: inline; }
.all-pubs[open] summary .when-closed { display: none; }
.pub-years { margin: 18px 0 0; padding: 0; list-style: none; }
.pub-years > li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.pub-years > li:first-child { border-top: 0; padding-top: 0; }
.pub-year { color: var(--faint); font-size: 13px; font-weight: 600; padding-top: 2px; }
.pub-compact { margin: 0; padding: 0; list-style: none; }
.pub-compact li + li { margin-top: 10px; }
.pub-compact li { scroll-margin-top: 70px; }
.pub-compact .t { color: var(--ink); font-weight: 600; font-size: 14.5px; }
.pub-compact .t a { color: var(--ink); }
.pub-compact .t a:hover { color: var(--accent); }
.pub-compact .v { color: var(--accent-ink); font-size: 12.5px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.pub-compact .a { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.pub-compact .a strong { color: var(--ink); font-weight: 600; }
.pub-compact .l { margin-left: 8px; font-size: 12.5px; }
.name-note { margin-top: 16px; color: var(--faint); font-size: 12.5px; }

/* ---------- current research ---------- */
.research-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.research-card {
  padding: 18px 18px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-width: 0;
}
/* Optional task illustration at the top of a research card: poster image plus hover-play
   video, reusing the publication preview mechanics (.publication-media / [data-preview-video]). */
.research-card .research-media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: 14px;
}
.research-card .research-media img,
.research-card .research-media video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; object-fit: cover;
}
.research-card .publication-preview { max-width: none; margin-bottom: 14px; }
.research-card .publication-preview .research-media { margin-bottom: 0; }
.research-card .media-credit { margin: -6px 0 12px; color: var(--faint); font-size: 11.5px; line-height: 1.4; }
.research-card h3 { font-size: 16px; line-height: 1.35; letter-spacing: -.01em; }
.research-card .backbone { margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.research-card p.body { margin-top: 10px; font-size: 14.5px; line-height: 1.52; color: var(--text); }

/* ---------- experience ---------- */
.exp-list { border-bottom: 1px solid var(--line); }
.exp-item {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 30px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}
.exp-item h3 { font-size: 16.5px; line-height: 1.35; }
.exp-item .role { display: block; margin-top: 3px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.exp-item .where { display: block; margin-top: 2px; color: var(--faint); font-size: 12.5px; }
.exp-body p { font-size: 15px; color: var(--text); }
.exp-body p + p { margin-top: 8px; }
.exp-body .when { display: inline-block; margin-right: 8px; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.exp-body .note { color: var(--muted); font-size: 13px; }
.exp-item.compact { padding: 16px 0; }
.exp-item.compact p { font-size: 14.5px; }

/* ---------- education / skills / honors ---------- */
.three-col {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 40px;
}
.three-col h2 { font-size: 19px; letter-spacing: -.015em; margin-bottom: 12px; }
.edu + .edu { margin-top: 16px; }
.edu h3 { font-size: 15px; line-height: 1.4; }
.edu h3 a { color: inherit; }
.edu h3 a:hover { color: var(--accent); }
.edu p { margin-top: 3px; color: var(--muted); font-size: 13.5px; }
.skills p { color: var(--text); font-size: 13.5px; line-height: 1.5; }
.skills p + p { margin-top: 8px; }
.skills .k { color: var(--muted); font-weight: 600; }
.honors { margin: 0; padding: 0; list-style: none; }
.honors li { padding-left: 14px; position: relative; color: var(--text); font-size: 13.5px; line-height: 1.45; }
.honors li + li { margin-top: 7px; }
.honors li::before { content: ""; position: absolute; left: 0; top: .6em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.honors .y { color: var(--faint); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 8px; }
.footer-inner {
  min-height: 70px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  color: var(--faint); font-size: 12.5px;
}
.footer-inner a { color: var(--muted); }
.footer-contact { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr) 150px; gap: 32px; }
  .portrait { width: 150px; height: 150px; }
  .arc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arc-stage:nth-child(2) { border-right: 0; }
  .arc-stage:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .arc-stage:nth-child(2)::after { display: none; }
  .publication { grid-template-columns: 260px minmax(0, 1fr); gap: 22px; }
  .publication-media, .publication-preview { width: 260px; }
  .research-grid { grid-template-columns: 1fr; }
  .exp-item { grid-template-columns: 200px minmax(0, 1fr); gap: 22px; }
  .three-col { grid-template-columns: 1fr 1fr; gap: 28px; }
  .three-col > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  :root { --page: calc(100% - 32px); }
  body { font-size: 15px; }
  .header-inner { min-height: 50px; }
  .site-name { display: none; }
  .site-nav { width: 100%; justify-content: space-between; gap: 6px; }
  .site-nav a { font-size: 13.5px; padding-block: 10px; }
  .site-nav .nav-cv { padding: 5px 10px; }
  .hero { grid-template-columns: 1fr; gap: 18px; padding: 26px 0 24px; }
  .portrait-wrap { order: -1; display: flex; align-items: center; gap: 16px; }
  .portrait { width: 92px; height: 92px; }
  .hero h1 { font-size: 30px; }
  .hero-lead { font-size: 15.5px; }
  .status-line .sep { display: none; }
  .status-line > span:last-child { flex-basis: 100%; }
  .highlights { grid-template-columns: 1fr; margin-bottom: 28px; }
  .section { padding: 28px 0 30px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .section-head h2 { font-size: 21px; }
  .hero-links { gap: 6px; }
  .hero-links a { gap: 5px; padding: 5px 9px; font-size: 13px; }
  .hero-links svg { width: 13px; height: 13px; }
  /* 2x2 arc: borders come from the 980px rules (right border on 1 and 3, bottom border on 1 and 2) */
  .arc-stage { padding: 12px 12px 12px 13px; }
  .arc-stage::after { display: none; }
  .arc-kicker { font-size: 10.5px; letter-spacing: .05em; }
  .arc-title { font-size: 13.5px; }
  .arc-chips { gap: 4px; margin-top: 7px; }
  .arc-chips a, .arc-chips span { padding: 1px 7px; font-size: 11.5px; }
  .publication { grid-template-columns: 1fr; gap: 12px; padding: 18px 0; }
  .publication-media, .publication-preview { width: 100%; max-width: 420px; }
  .pub-years > li { grid-template-columns: 1fr; gap: 6px; }
  .exp-item { grid-template-columns: 1fr; gap: 8px; padding: 16px 0; }
  .three-col { grid-template-columns: 1fr; gap: 26px; }
  .footer-inner { flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; min-height: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .all-pubs summary svg { transition: none; }
}

@media print {
  .site-header, .preview-toggle, .publication-preview { display: none; }
  .publication { grid-template-columns: 1fr; }
  a { color: inherit; }
}

/* ---------- research media lightbox ----------
   Current-research previews open enlarged in a modal <dialog class="media-lightbox"> that
   site-v2.js creates once at the end of <body>. role="button" is only set when the browser
   supports dialog.showModal, so the zoom cursor never promises a lightbox that cannot open. */
.research-card .research-media[role="button"] { cursor: zoom-in; }
html.lightbox-open { overflow: hidden; }
.media-lightbox {
  width: min(92vw, 1200px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: visible;
}
.media-lightbox::backdrop { background: rgba(10, 12, 16, .84); }
/* The bar only holds the close button; clicks beside it fall through to the dialog and close it. */
.media-lightbox-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; pointer-events: none; }
.media-lightbox-close {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
}
.media-lightbox-close:hover { background: rgba(255, 255, 255, .28); }
.media-lightbox-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.media-lightbox-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.media-lightbox-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  /* 82vh, but leave room for the close bar and caption on short (landscape) screens */
  max-height: min(82vh, calc(100vh - 120px));
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}
.media-lightbox-caption {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px;
  margin-top: 12px;
  line-height: 1.45;
}
.media-lightbox-title { color: #fff; font-size: 15px; font-weight: 600; }
.media-lightbox-credit { color: #b8c0c9; font-size: 13px; }
@media (max-width: 640px) {
  .media-lightbox { width: calc(100vw - 24px); }
}
