/* Tokens ------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* color */
  --ink: #14213a;
  --paper: #f3f5f2;
  --board: #1e5b4c;
  --rule: #c9d1cc;
  --muted: #56646a;
  --mark: #e9c83c;      /* highlighter under summary numbers */
  --flag: #c79a00;      /* upcoming sessions on the ledger */

  /* type: six sizes, two families */
  --serif: 'Hahmlet', 'Noto Serif KR', serif;
  --sans: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', sans-serif;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-lg: 20px;
  --fs-xl: 30px;
  --fs-2xl: 44px;

  /* space */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 20px;
  --s5: 32px;
  --s6: 64px;

  --radius: 2px;
  --date-col: 148px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7ebee;
    --paper: #101a2c;
    --board: #7fc7b2;
    --rule: #2b3a52;
    --muted: #9eabb8;
    --mark: #6b5a14;
    --flag: #e9c83c;
  }
}

/* Base --------------------------------------------------------------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.7;
  word-break: keep-all;
}

a { color: inherit; text-decoration-color: var(--board); text-underline-offset: 3px; }
a:hover { color: var(--board); }

:focus-visible { outline: 2px solid var(--board); outline-offset: 3px; }

button { font: inherit; color: inherit; }

/* Layout ------------------------------------------------------------- */
.page {
  display: grid;
  grid-template-columns: 260px minmax(0, 680px);
  justify-content: center;
  gap: 72px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 72px var(--s5) 96px;
}

.side { position: sticky; top: 72px; align-self: start; }

.main > section { scroll-margin-top: var(--s5); }
.main > section + section { margin-top: var(--s6); }

/* Side column -------------------------------------------------------- */
.portrait {
  display: block;
  width: 168px;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius);
}

.name {
  margin: 28px 0 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--fs-2xl);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.name-sub {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}

.role { margin: var(--s4) 0 0; font-size: var(--fs-sm); line-height: 1.6; }
.role span { display: block; }

.contact { list-style: none; margin: var(--s3) 0 0; padding: 0; font-size: var(--fs-sm); }

.toc { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--rule); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  padding: var(--s1) 0 var(--s1) var(--s3);
  border-left: 2px solid transparent;
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
}
.toc a:hover { color: var(--ink); }
.toc a[aria-current='true'] { color: var(--ink); font-weight: 600; border-left-color: var(--board); }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s5); }

.btn {
  min-height: 40px;
  padding: 0 14px;
  font-size: var(--fs-sm);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--paper); }

.lang { display: inline-flex; margin-top: var(--s3); border: 1px solid var(--rule); border-radius: var(--radius); }
.lang button {
  min-height: 32px;
  padding: 0 var(--s3);
  font-size: var(--fs-xs);
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.lang button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }

.toast { min-height: 1.6em; margin: var(--s2) 0 0; font-size: var(--fs-sm); color: var(--board); }

/* Main column -------------------------------------------------------- */
.statement {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: var(--fs-xl);
  line-height: 1.45;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.bio { margin: 24px 0 0; max-width: 38em; }

h2 {
  margin: 0 0 var(--s4);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--fs-lg);
}

.rows, .pubs { list-style: none; margin: 0; padding: 0; }
.rows > li, .pubs > li {
  display: grid;
  grid-template-columns: var(--date-col) minmax(0, 1fr);
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--rule);
}
.when, .venue { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.what strong { display: block; font-weight: 600; }
.what > span { display: block; font-size: var(--fs-sm); color: var(--muted); }

.venue { color: var(--board); font-weight: 600; }
.venue i { display: block; font-weight: 400; color: var(--muted); }
.pub cite { display: block; font-style: normal; font-weight: 500; line-height: 1.5; }
.pub cite a { text-decoration-color: var(--rule); }
.pub cite a:hover { text-decoration-color: var(--board); }
.authors { display: block; margin-top: var(--s1); font-size: var(--fs-sm); color: var(--muted); }
.authors b { color: var(--ink); font-weight: 600; }
.note { margin: var(--s3) 0 0; font-size: var(--fs-xs); color: var(--muted); }

/* Teaching ----------------------------------------------------------- */
.summary { margin: 0 0 var(--s4); }
.summary b { font-weight: 600; background: linear-gradient(transparent 62%, var(--mark) 62%); }

.ledger { display: grid; gap: 3px; }
.ledger-row { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: var(--s3); }
.ledger-year { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.ledger-track {
  position: relative;
  height: 18px;
  background: repeating-linear-gradient(to right, var(--rule) 0 1px, transparent 1px calc(100% / 12));
  border-right: 1px solid var(--rule);
}
.ledger-tick { position: absolute; top: 2px; bottom: 2px; width: 3px; margin-left: -1px; background: var(--board); }
.ledger-span { position: absolute; top: 7px; height: 4px; background: var(--board); opacity: .45; }
.ledger-future { background: var(--flag); }
.ledger-months {
  display: grid; grid-template-columns: repeat(12, 1fr);
  margin: var(--s1) 0 0 56px; font-size: var(--fs-xs); color: var(--muted);
}
.ledger-key { margin: var(--s2) 0 0; font-size: var(--fs-xs); color: var(--muted); }
.ledger-key i { display: inline-block; width: 3px; height: 11px; margin: 0 6px -1px 0; background: var(--board); }
.ledger-key i.ledger-future { margin-left: var(--s3); background: var(--flag); }

.orgs { margin: var(--s4) 0 var(--s5); font-size: var(--fs-sm); color: var(--muted); }
.orgs b { color: var(--ink); font-weight: 600; }

.years-head { display: flex; justify-content: flex-end; border-bottom: 1px solid var(--rule); }
.link-btn {
  min-height: 32px;
  padding: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

details.year { border-bottom: 1px solid var(--rule); }
details.year > summary {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--s3) 0; cursor: pointer; list-style: none;
  font-family: var(--serif); font-weight: 600; font-size: var(--fs-lg);
}
details.year > summary::-webkit-details-marker { display: none; }
details.year > summary .count { font-family: var(--sans); font-weight: 400; font-size: var(--fs-sm); color: var(--muted); }
details.year > summary::before { content: '+'; width: 20px; color: var(--board); font-family: var(--sans); }
details.year[open] > summary::before { content: '\2212'; }
details.year > summary .y { flex: 1; }
details.year > summary:hover .y { color: var(--board); }

.talks { list-style: none; margin: 0 0 var(--s4); padding: 0; }
.talks li {
  display: grid; grid-template-columns: var(--date-col) minmax(0, 1fr); gap: var(--s4);
  padding: var(--s2) 0; border-top: 1px dotted var(--rule);
}
.talks .org { display: block; font-weight: 600; }
.talks .course { display: block; font-size: var(--fs-sm); color: var(--muted); }
.talks .meta { display: inline-block; margin-top: var(--s1); padding: 0 6px; font-size: var(--fs-xs); border: 1px solid var(--flag); border-radius: var(--radius); }

.print-only { display: none; }

.foot { margin-top: 72px; padding-top: var(--s4); border-top: 1px solid var(--rule); font-size: var(--fs-sm); color: var(--muted); }

/* Small screens ------------------------------------------------------ */
@media (max-width: 860px) {
  :root { --fs-2xl: 38px; --fs-xl: 24px; }
  .page { grid-template-columns: minmax(0, 1fr); gap: 48px; padding: 40px var(--s4) 72px; }
  .side { position: static; }
  .toc { display: none; }
  .btn { min-height: 44px; }
  .lang button { min-height: 44px; padding: 0 var(--s4); font-size: var(--fs-sm); }
  .link-btn { min-height: 44px; }
  .rows > li, .pubs > li, .talks li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ledger-row { grid-template-columns: 36px 1fr; gap: var(--s2); }
  .ledger-months { margin-left: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* One-page A4 print -------------------------------------------------- */
@page { size: A4; margin: 13mm 14mm; }
@media print {
  /* Same content as the screen, laid out for A4. Only controls are dropped. */
  :root {
    --ink: #14213a; --paper: #fff; --board: #1e5b4c; --rule: #c9d1cc; --muted: #56646a; --mark: #e9c83c; --flag: #c79a00;
  }
  html, body { background: #fff; }
  body { font-size: 8.8pt; line-height: 1.5; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print { display: none !important; }
  .page { display: block; max-width: none; padding: 0; }
  a { text-decoration: none; }

  .side {
    position: static; display: grid; grid-template-columns: 24mm 1fr; column-gap: 6mm;
    padding-bottom: 4mm; border-bottom: 1.5pt solid var(--ink); margin-bottom: 5mm;
  }
  .portrait { width: 24mm; grid-row: 1 / span 3; }
  .name { margin: 0; font-size: 20pt; }
  .name-sub { display: inline; margin-left: 3mm; font-size: 10pt; }
  .role { margin: 1mm 0 0; font-size: 9pt; }
  .role span { display: inline; }
  .role span + span::before { content: ' / '; }
  .contact { margin: 1mm 0 0; display: flex; gap: 5mm; font-size: 8.8pt; }

  .statement { font-size: 13pt; line-height: 1.4; }
  .bio { margin: 2.5mm 0 0; max-width: none; }
  .main > section + section { margin-top: 5mm; }
  h2 { margin-bottom: 1.2mm; padding-bottom: 1mm; border-bottom-width: 0.8pt; font-size: 10.5pt; break-after: avoid; }

  .rows > li, .pubs > li { grid-template-columns: 30mm 1fr; gap: 3mm; padding: 1mm 0; border-bottom: 0; break-inside: avoid; }
  .when, .venue, .authors, .what > span { font-size: 8pt; }
  .what strong, .what > span { display: inline; }
  .what strong::after { content: '  '; white-space: pre; }
  .authors { margin-top: 0; }
  .note { margin-top: 0.5mm; font-size: 7.5pt; }

  .summary { margin-bottom: 2mm; break-after: avoid; }
  .ledger { gap: 1.5pt; break-inside: avoid; }
  .ledger-row { grid-template-columns: 9mm 1fr; gap: 2mm; }
  .ledger-track { height: 3.4mm; }
  .ledger-year, .ledger-months, .ledger-key { font-size: 7pt; }
  .ledger-months { margin-left: 11mm; }
  .ledger-key { margin-top: 1mm; }
  .orgs { margin: 2.5mm 0 3mm; font-size: 8pt; }

  details.year { border-bottom: 0; }
  details.year::details-content { content-visibility: visible; display: block; }
  details.year > summary {
    padding: 2.5mm 0 0.8mm; font-size: 10pt; border-bottom: 0.5pt solid var(--rule); break-after: avoid;
  }
  details.year > summary::before, details.year[open] > summary::before { content: none; }
  details.year > summary .count { font-size: 7.5pt; }
  .talks { margin: 0; }
  .talks li { grid-template-columns: 37mm 1fr; gap: 3mm; padding: 0.7mm 0; border-top: 0; break-inside: avoid; }
  .talks .org, .talks .course { display: inline; }
  .talks .org::after { content: '  '; white-space: pre; }
  .talks .course { font-size: 8pt; }
  .talks .when { white-space: nowrap; }
  .talks .meta { margin: 0 0 0 2mm; font-size: 7pt; }

  .foot { margin-top: 6mm; padding-top: 2mm; font-size: 8pt; }
  .print-only { display: block; margin: 1mm 0 0; font-size: 7.5pt; color: var(--muted); }
}
