/* ==========================================================================
   Yen-Jen Wang — personal site
   Clean, modern, tech-minimal.
   ========================================================================== */

:root {
  --bg: #0b0e14;
  --bg-elevated: #11151f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eaf0;
  --text-secondary: #a8b0c0;
  --text-tertiary: #6b7385;
  --accent: #5eead4;          /* teal */
  --accent-dim: rgba(94, 234, 212, 0.12);
  --link: #7dd3fc;            /* sky */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --maxw: 880px;
  --radius: 12px;
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #171b26;
  --text-secondary: #4b5265;
  --text-tertiary: #8a91a3;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.09);
  --link: #0369a1;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle tech grid backdrop */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black 0%, transparent 72%);
  opacity: 0.5;
  pointer-events: none;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover { color: var(--accent); }

::selection {
  background: var(--accent);
  color: #06251f;
}

:root[data-theme="light"] ::selection {
  background: var(--accent);
  color: #ffffff;
}

/* ============================== Nav ============================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.nav-name:hover { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.nav-links a:hover { color: var(--accent); }

.nav-links a.active { color: var(--accent); }

#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

#theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

#theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* show the icon of the mode you'd switch TO */
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }

/* ============================== Layout ============================== */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 48px;
}

section { margin-top: 72px; }

h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 26px;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* trailing rule after section titles */
h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}

/* ============================== Hero ============================== */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 40px;
  align-items: stretch;
  padding-top: 72px;
}

/* soft accent glow behind the hero to anchor the eye */
.hero::before {
  content: "";
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, 120vw);
  height: 520px;
  background: radial-gradient(ellipse 60% 55% at 50% 30%,
    color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

:root[data-theme="light"] .hero::before {
  background: radial-gradient(ellipse 60% 55% at 50% 30%,
    color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 2.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
}

.name-zh {
  font-weight: 500;
  font-size: 0.62em;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hero-tagline {
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tagline-primary {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.tagline-secondary {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.hero-bio {
  margin-top: 22px;
  color: var(--text-secondary);
  font-size: 0.96rem;
}

.hero-bio p { margin: 0 0 13px; }

.hero-bio strong {
  color: var(--text);
  font-weight: 600;
}

.hero-actions {
  margin-top: 26px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.email {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.email svg {
  width: 15px;
  height: 15px;
}

.email:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.socials {
  display: flex;
  gap: 8px;
}

.socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.socials a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.socials svg {
  width: 16px;
  height: 16px;
}

/* keep the photo's natural aspect ratio (no zoomed-in crop) and center it
   against the text column. a small matte inside the frame makes the subject
   read a touch smaller without changing the overall photo size. */
.hero-photo {
  position: relative;
  align-self: center;
  /* even matte all around; the inset makes the subject read a touch smaller */
  padding: 5.5%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

/* the image drives the height (width × aspect-ratio); the container just wraps
   it with padding. this avoids the Safari bug where an aspect-ratio container
   plus a height:100% child lets the image overflow the frame. */
.hero-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1080 / 1616;
  object-fit: cover;
  object-position: center top;
  border-radius: calc(var(--radius) - 5px);
  /* tone down the green backdrop so it sits well with the teal/dark palette */
  filter: saturate(0.78) contrast(1.02);
}

:root[data-theme="dark"] .hero-photo img {
  filter: saturate(0.7) brightness(0.93) contrast(1.04);
}

/* corner accent brackets on the photo */
.hero-photo::before,
.hero-photo::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid color-mix(in srgb, var(--accent) 80%, transparent);
  pointer-events: none;
}

:root[data-theme="light"] .hero-photo::before,
:root[data-theme="light"] .hero-photo::after {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.hero-photo::before {
  top: -8px;
  left: -8px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 6px;
}

.hero-photo::after {
  bottom: -8px;
  right: -8px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 6px;
}

/* ============================== News ============================== */

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

.news-list li {
  display: flex;
  gap: 22px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.news-list li:last-child { border-bottom: none; }

.news-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  flex: 0 0 90px;
  padding-top: 2px;
  letter-spacing: 0.02em;
}

.news-body {
  font-size: 0.94rem;
  color: var(--text-secondary);
}

.news-body a {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

.news-body a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.news-highlight {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  padding: 1px 7px;
  margin-left: 2px;
  vertical-align: 1px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ============================== Awards ============================== */

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

.awards-list li {
  display: flex;
  gap: 22px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}

.awards-list li:last-child { border-bottom: none; }

.award-year {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  flex: 0 0 44px;
  padding-top: 3px;
}

.award-title {
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--text);
}

.award-links {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.award-links a {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--link);
}

.award-links a::before {
  content: "▸ ";
  color: var(--text-tertiary);
}

.award-links a:hover { color: var(--accent); }

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  padding: 2px 8px;
  vertical-align: 2px;
  white-space: nowrap;
}

/* ============================== Publications ============================== */

.pub-scholar-note {
  margin: -8px 0 22px;
  font-size: 0.88rem;
  color: var(--text-tertiary);
}

.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pub {
  display: grid;
  grid-template-columns: 252px 1fr;
  gap: 24px;
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.pub:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transform: translateY(-2px);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.22),
    0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent),
    0 4px 24px color-mix(in srgb, var(--accent) 10%, transparent);
}

:root[data-theme="light"] .pub:hover {
  box-shadow:
    0 12px 32px rgba(15, 23, 42, 0.08),
    0 4px 24px color-mix(in srgb, var(--accent) 8%, transparent);
}

.pub-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 60%, #000);
  align-self: center;
}

.pub-media img,
.pub-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.pub-media:hover img,
.pub-media:hover video {
  transform: scale(1.04);
}

.pub-media iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.pub-media.playing { cursor: default; }

.play-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  backdrop-filter: blur(4px);
}

.play-badge svg {
  width: 16px;
  height: 16px;
}

.pub-info { min-width: 0; }

.pub-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.04rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }

.pub-authors {
  margin: 7px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pub-authors strong {
  color: var(--text);
  font-weight: 600;
}

/* keep coauthor links quiet inline; reveal on hover so the row stays readable */
.pub-authors a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

.pub-authors a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.pub-venue {
  margin: 5px 0 0;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.pub-venue .badge { margin-left: 4px; }

.badge-link {
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1;
}

.badge-link img {
  display: block;
  height: 18px;
}

.pub-links {
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.pub-links a {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--link);
}

.pub-links a::before {
  content: "▸ ";
  color: var(--text-tertiary);
}

.pub-links a:hover { color: var(--accent); }

.pub-note {
  margin: 3px 0 0;
  font-size: 0.74rem;
  color: var(--text-tertiary);
}

/* ============================== Publications page ============================== */

.pub-page-header {
  padding-top: 64px;
  margin-bottom: 44px;
}

.pub-page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
}

.pub-page-header p {
  margin: 14px 0 0;
  color: var(--text-secondary);
  font-size: 0.96rem;
  max-width: 62ch;
}

.pub-media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  background: color-mix(in srgb, var(--bg-elevated) 70%, transparent);
}

.pub-media-placeholder::before {
  content: "";
  display: block;
  width: 36px;
  height: 36px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  opacity: 0.7;
}

.pub-see-all {
  margin: 32px 0 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.pub-see-all a {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding-bottom: 2px;
  transition: border-color 0.15s ease;
}

.pub-see-all a:hover {
  border-color: var(--accent);
}

/* ============================== Footer ============================== */

.footer {
  margin-top: 84px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
}

.footer p { margin: 0; }

/* barely-there; reveals "built with" on hover or tap */
.footer-fox {
  font-size: 0.72rem;
  opacity: 0.25;
  filter: grayscale(0.6);
  transition: opacity 0.25s ease, filter 0.25s ease;
  cursor: default;
  user-select: none;
}

.footer-fox .fox-text {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.footer-fox:hover,
.footer-fox.revealed {
  opacity: 1;
  filter: none;
}

.footer-fox:hover .fox-text,
.footer-fox.revealed .fox-text {
  opacity: 1;
}

/* ============================== Reveal animation ============================== */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .pub, .socials a { transition: none; }
}

/* ============================== Responsive ============================== */

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-top: 44px;
  }

  .hero-photo {
    order: -1;
    max-width: 200px;
  }

  .nav-inner { padding: 0 16px; }

  .nav-name { font-size: 0.92rem; }

  .nav-links { gap: 14px; }

  .nav-links a { font-size: 0.74rem; }

  .pub {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .pub-media { align-self: stretch; }

  section { margin-top: 56px; }
}
