/*
  junhoyoon.com
  Roles: serif (Newsreader) for reading, sans (Geist) for interface, mono (Geist Mono) for code.
  Fonts are self-hosted under the SIL Open Font License 1.1; see assets/fonts/.
*/
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* Color. Blue is reserved for things you can click; teal marks distinctions. */
  color-scheme: light;
  --paper: #fafbfc;
  --card: #ffffff;
  --ink: #15171c;
  --ink-2: #464a54;
  --ink-3: #676c77;
  --rule: #e5e7eb;
  --card-line: #e3e6ea;
  --tag: #f1f3f6;
  --accent: #1d4ea6;
  --accent-line: #c3d1ee;
  --link-line: rgba(29, 78, 166, .35);
  --award: #0f6a55;
  --award-bg: #e1f2ec;
  --plate: #ffffff;
  --plate-ink: #5b616c;
  --plate-ink-2: #3f444d;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-hover: 0 6px 18px rgba(16, 24, 40, .07);

  /* Type. Reading sizes (serif) and interface sizes (sans). */
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --t-display: clamp(2.75rem, 6.5vw, 4.25rem);
  --t-title: clamp(1.5rem, 2.8vw, 1.75rem);
  --t-large: 1.375rem;
  --t-body: 1.1875rem;
  --t-small: 1rem;
  --t-ui: .875rem;
  --t-ui-sm: .8125rem;
  --t-label: .75rem;

  /* Space, in 4px steps. */
  --s-1: .25rem;
  --s-2: .5rem;
  --s-3: .75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;
  --s-9: 6rem;

  /* Layout. */
  --margin: 11rem;
  --gutter: 3rem;
  --pad: var(--s-6);
  --radius: 14px;
}

/* Dark theme: no pure black, surfaces get lighter as they rise, accents lighter and calmer.
   Figures keep a dimmed light plate: their labels are black and the colormaps must not be inverted. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1115;
  --card: #16191f;
  --ink: #e7e9ed;
  --ink-2: #b3b8c2;
  --ink-3: #8c929d;
  --rule: #23272f;
  --card-line: #272b34;
  --tag: #1e2229;
  --accent: #8fb4ff;
  --accent-line: #3a5487;
  --link-line: rgba(143, 180, 255, .4);
  --award: #6fd6bd;
  --award-bg: #12302a;
  --plate: #e9ebef;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, .45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #0f1115;
    --card: #16191f;
    --ink: #e7e9ed;
    --ink-2: #b3b8c2;
    --ink-3: #8c929d;
    --rule: #23272f;
    --card-line: #272b34;
    --tag: #1e2229;
    --accent: #8fb4ff;
    --accent-line: #3a5487;
    --link-line: rgba(143, 180, 255, .4);
    --award: #6fd6bd;
    --award-bg: #12302a;
    --plate: #e9ebef;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, .45);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-body)/1.6 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
[hidden] { display: none !important; }
a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--link-line);
  text-underline-offset: .22em;
  transition: color .15s, text-decoration-color .15s;
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.icon { width: 16px; height: 16px; flex: none; fill: currentColor; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page { width: min(100% - 3rem, 57rem); margin-inline: auto; }
.row {
  display: grid;
  grid-template-columns: var(--margin) minmax(0, 1fr);
  column-gap: var(--gutter);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3) var(--s-5);
  padding-block: var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.wordmark { font-size: var(--t-small); font-weight: 560; text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: var(--s-5); margin-left: auto; font: 500 var(--t-ui)/1 var(--sans); }
.topbar nav a { display: inline-flex; align-items: center; color: var(--ink-2); text-decoration: none; }
.topbar nav a:hover { color: var(--accent); }
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--card-line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ---------- Intro ---------- */
.intro { padding-block: var(--s-9) var(--s-6); }
.portrait {
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: #fff;
}
h1 {
  margin: 0 0 var(--s-4);
  font-size: var(--t-display);
  font-weight: 380;
  line-height: 1;
  letter-spacing: -.025em;
}
.role { margin: 0 0 var(--s-6); color: var(--ink-2); }
.role em { color: var(--ink); }
.lede { margin: 0 0 var(--s-5); font-size: var(--t-large); line-height: 1.55; text-wrap: pretty; }
.interests { margin: 0 0 var(--s-6); font-size: var(--t-small); color: var(--ink-2); }
.interests .item { white-space: nowrap; }
.interests .item:not(:last-child)::after { content: " ·"; }
.eyebrow {
  margin-right: var(--s-3);
  font: 600 var(--t-label)/1 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.links li, .email-box { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.email-address { text-transform: none; }
.email-img { height: 2.25rem; width: auto; padding: var(--s-2); border-radius: 9px; background: #fff; }
.links .ext { width: 11px; height: 11px; opacity: .5; }

/* ---------- Shared pieces: buttons, tags, cards ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 2.25rem;
  padding: 0 var(--s-3);
  border: 1px solid var(--card-line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font: 550 var(--t-ui)/1 var(--sans);
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn .icon { width: 14px; height: 14px; }
.btn.sm { min-height: 2rem; border-radius: 8px; font-size: var(--t-ui-sm); }
.btn.sm .icon { width: 12px; height: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.tag {
  padding: var(--s-1) var(--s-2);
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--tag);
  color: var(--ink-2);
  font: 500 var(--t-label)/1.3 var(--sans);
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}
.tag.name { background: transparent; border-color: var(--card-line); color: var(--ink); font-weight: 600; }
.tag.award { background: var(--award-bg); color: var(--award); font-weight: 600; }
.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------- Sections ---------- */
.section { padding-top: var(--s-8); }
.section > h2 {
  margin: 0;
  font: 600 var(--t-label)/1 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  align-self: start;
  position: sticky;
  top: var(--s-6);
}

/* Research cards */
.stack { display: grid; gap: var(--s-5); }
.media { display: grid; gap: var(--s-5); padding: var(--pad) var(--pad) var(--s-5); border-bottom: 1px solid var(--card-line); background: var(--plate); }
.media figure { margin: 0; }
.media a { display: block; cursor: zoom-in; }
.media img { width: 100%; mix-blend-mode: multiply; }
.media figcaption { margin-top: var(--s-3); font: 400 var(--t-ui-sm)/1.45 var(--sans); color: var(--plate-ink); }
.media figcaption b { font-weight: 600; color: var(--plate-ink-2); }
.card-body { padding: var(--pad); }
.card-body p { margin: 0 0 var(--s-4); line-height: 1.6; text-wrap: pretty; }
.card-body .standfirst { font-size: var(--t-large); line-height: 1.5; font-style: italic; color: var(--ink-2); }
.card-body .standfirst i { font-style: normal; }
.project .tags { margin-bottom: var(--s-4); }
.project h3 {
  margin: 0 0 var(--s-3);
  font-size: var(--t-title);
  font-weight: 420;
  line-height: 1.18;
  letter-spacing: -.012em;
  text-wrap: balance;
}
.points { list-style: none; margin: var(--s-5) 0 0; padding: 0; display: grid; gap: var(--s-2); }
.points li { position: relative; padding-left: var(--s-5); line-height: 1.5; }
.points li::before {
  content: "";
  position: absolute;
  left: var(--s-1);
  top: .62em;
  width: 6px;
  height: 6px;
  border-radius: 1.5px;
  background: var(--ink-3);
}
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-5); }
details { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--card-line); }
summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  list-style: none;
  font: 550 var(--t-ui)/1 var(--sans);
  color: var(--ink-2);
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s;
}
details[open] summary::before { transform: rotate(45deg); }
.card-body details p { margin: var(--s-4) 0 0; color: var(--ink-2); }

/* Publications and education: list cards with the same inner edge as research cards */
.list { list-style: none; margin: 0; padding: 0; }
.pub {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  column-gap: var(--s-5);
  align-items: baseline;
  padding: var(--s-5) var(--pad);
}
.pub + .pub, .edu li + li { border-top: 1px solid var(--card-line); }
.year { font: 500 var(--t-ui)/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.pub-title { margin: 0 0 var(--s-1); font-weight: 560; line-height: 1.35; text-wrap: pretty; }
.pub-authors, .pub-venue { margin: 0; font-size: var(--t-small); line-height: 1.5; color: var(--ink-2); }
.pub-authors b { color: var(--ink); font-weight: 600; }
.pub-venue i { color: var(--ink); }
.pub .tags { margin-top: var(--s-2); }
.pub .actions { margin-top: var(--s-3); }
.edu li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-5); padding: var(--s-5) var(--pad); }
.edu h3 { margin: 0; font-size: var(--t-body); font-weight: 560; line-height: 1.35; }
.edu p { margin: var(--s-1) 0 0; font-size: var(--t-small); color: var(--ink-2); }

/* Software: columns follow the number of cards (1, 2, 3, or 2+2 for four), so none is left alone on a row */
.repos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.repos:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
.repos:has(> :nth-child(2):last-child),
.repos:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.repo {
  display: flex;
  flex-direction: column;
  padding: var(--s-5);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.repo:hover { color: inherit; border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.repo-path { display: flex; align-items: flex-start; gap: var(--s-2); margin-top: auto; font: 500 var(--t-label)/1.4 var(--mono); color: var(--ink-3); }
.repo-path .icon { width: 14px; height: 14px; margin-top: 1px; color: var(--ink); }
.repo h3 { margin: 0 0 var(--s-1); font-size: var(--t-body); font-weight: 560; line-height: 1.3; }
.repo p { margin: 0 0 var(--s-4); font-size: var(--t-small); line-height: 1.5; color: var(--ink-2); }
.repo .tag { margin-top: var(--s-3); align-self: flex-start; }

/* ---------- Footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-8);
  padding-block: var(--s-6) var(--s-8);
  border-top: 1px solid var(--rule);
  font-size: var(--t-small);
  color: var(--ink-3);
}

/* ---------- Narrower screens: labels move above their content ---------- */
@media (max-width: 60rem) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .section > h2 { position: static; margin-bottom: var(--s-4); }
  .intro { padding-block: var(--s-8) var(--s-4); }
  .portrait { width: 5.5rem; height: 5.5rem; margin-bottom: var(--s-5); }
}
@media (max-width: 40rem) {
  :root { --t-body: 1.125rem; --t-large: 1.25rem; --pad: 1.25rem; }
  .theme-toggle { margin-left: auto; }
  .topbar nav { order: 3; width: 100%; margin-left: 0; gap: var(--s-4); }
  .repos { grid-template-columns: minmax(0, 1fr); }
  .pub { grid-template-columns: minmax(0, 1fr); row-gap: var(--s-2); }
}

/* ---------- Touch screens: 44px targets ---------- */
@media (pointer: coarse) {
  .btn, .btn.sm { min-height: 2.75rem; }
  .topbar nav a { min-height: 2.75rem; }
  .theme-toggle { width: 2.75rem; height: 2.75rem; }
  summary { min-height: 2.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .repo, .theme-toggle, summary::before { transition: none; }
  .repo:hover { transform: none; }
}

/* ---------- 404 page ---------- */
.notfound { padding-block: var(--s-9) var(--s-8); }
.notfound .eyebrow { display: block; margin: 0 0 var(--s-4); }
.notfound h1 { margin-bottom: var(--s-5); }
.notfound p { margin: 0 0 var(--s-6); max-width: 34em; color: var(--ink-2); }
