/* ==========================================================================
   jsong.net — Jun Song, Korea University
   Modern, dependency-free stylesheet. Light & dark via prefers-color-scheme.
   ========================================================================== */

:root {
  color-scheme: light dark;
  --bg: #faf9f7;
  --bg-sidebar: #f2efea;
  --text: #201d1b;
  --muted: #5f5a54;
  --faint: #8a847c;
  --accent: #8e1f2f;          /* KU crimson */
  --accent-soft: #8e1f2f14;
  --line: #e3ded7;
  --card: #ffffff;
  --chip-bg: #f0ece6;
  --chip-text: #4c463f;
  --shadow: 0 1px 2px rgba(30, 20, 10, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --bg-sidebar: #1d1915;
    --text: #eae6df;
    --muted: #b0a89d;
    --faint: #857d72;
    --accent: #e58c99;
    --accent-soft: #e58c9917;
    --line: #322c26;
    --card: #1f1b16;
    --chip-bg: #2a251f;
    --chip-text: #cfc7bb;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               Arial, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  padding: 3rem 2rem;
}

.sidebar-inner {
  position: sticky;
  top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.portrait {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 20%;
  border: 3px solid var(--card);
  box-shadow: 0 2px 10px rgba(20, 12, 6, 0.14);
}

.brand h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.brand .role {
  margin: 0.45rem 0 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

.brand .role a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.brand .role a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.site-nav { display: flex; flex-direction: column; gap: 0.1rem; }

.site-nav a {
  display: block;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }

.site-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.sidebar-actions { display: flex; flex-direction: column; gap: 0.7rem; }

.btn-cv {
  display: inline-block;
  text-align: center;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.btn-cv:hover { text-decoration: none; filter: brightness(1.1); }

@media (prefers-color-scheme: dark) {
  .btn-cv { color: #1c1013; }
}

.social { display: flex; gap: 0.9rem; align-items: center; }

.social a {
  display: inline-flex;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--chip-text);
}

.social a:hover { background: var(--accent); color: #fff; text-decoration: none; }

.social svg { width: 18px; height: 18px; fill: currentColor; }

.sidebar-foot { font-size: 0.8rem; color: var(--faint); }

/* ---------- Main content ---------- */

main { padding: 3.2rem clamp(1.3rem, 5vw, 4.5rem); max-width: 60rem; }

section { padding: 1.2rem 0 2.2rem; scroll-margin-top: 1.5rem; }

section + section { border-top: 1px solid var(--line); }

.section-title {
  font-size: 1.55rem;
  letter-spacing: -0.01em;
  margin: 1rem 0 1.4rem;
}

.section-title::after {
  content: "";
  display: block;
  width: 2.2rem;
  height: 4px;
  margin-top: 0.5rem;
  border-radius: 2px;
  background: var(--accent);
}

h3.subhead {
  font-size: 1.08rem;
  margin: 2rem 0 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.92rem;
  color: var(--muted);
}

h4 { margin: 1.4rem 0 0.6rem; font-size: 1.02rem; }

.lead { font-size: 1.05rem; max-width: 44rem; }

.contact-line { color: var(--muted); font-size: 0.98rem; margin: 0.2rem 0; }

.updated { color: var(--faint); font-size: 0.85rem; font-style: italic; }

/* ---------- Resume rows (education / positions / experience) ---------- */

.rows { display: flex; flex-direction: column; gap: 1.1rem; margin: 0; padding: 0; list-style: none; }

.row { display: flex; justify-content: space-between; gap: 1.5rem; }

.row .what { min-width: 0; }

.row .what strong { font-size: 1.02rem; }

.row .what .detail { color: var(--muted); font-size: 0.95rem; }

.row .when {
  flex: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  padding-top: 0.15rem;
}

/* ---------- Generic lists ---------- */

ul.plain { padding-left: 1.15rem; margin: 0.4rem 0 1rem; }
ul.plain li { margin: 0.35rem 0; }

/* ---------- Publications ---------- */

.pub-legend { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.1rem; }

ol.pubs { list-style: none; margin: 0; padding: 0; counter-reset: pub; display: flex; flex-direction: column; gap: 1.05rem; }

ol.pubs > li {
  padding: 0.9rem 1.05rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.pub-title { font-weight: 650; }

.pub-authors { font-size: 0.95rem; color: var(--muted); }

.pub-venue { font-size: 0.95rem; }
.pub-venue em { color: var(--text); }

.pub-links { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.45rem; }

.pub-links a {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  padding: 0.14rem 0.6rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  border: 1px solid var(--line);
}

.pub-links a:hover { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; }

/* ---------- Teaching ---------- */

.course-list { list-style: none; padding: 0; margin: 0.3rem 0 1.2rem; }

.course-list li { padding: 0.34rem 0; border-bottom: 1px dashed var(--line); }

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

.course-list .terms { display: block; color: var(--faint); font-size: 0.85rem; }

.course-list .code { color: var(--accent); font-weight: 650; font-size: 0.9rem; margin-right: 0.35rem; }

/* ---------- Students ---------- */

.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 0.7rem;
  margin: 0.5rem 0 1.2rem;
  padding: 0;
  list-style: none;
}

.students-grid li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  box-shadow: var(--shadow);
}

.students-grid .name { font-weight: 650; font-size: 0.97rem; }

.students-grid .name .ko { font-weight: 500; color: var(--muted); }

.students-grid .mail, .students-grid .note { display: block; font-size: 0.82rem; color: var(--faint); overflow-wrap: anywhere; }

.alumni { list-style: none; margin: 0.4rem 0 1rem; padding: 0; }

.alumni li { padding: 0.55rem 0; border-bottom: 1px dashed var(--line); }

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

.alumni .who { font-weight: 600; }

.alumni .who .ko { font-weight: 500; color: var(--muted); }

.alumni .dest { color: var(--accent); font-size: 0.92rem; font-weight: 550; }

.alumni .thesis { display: block; color: var(--faint); font-size: 0.87rem; }

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.85rem;
  padding: 1.4rem 0 0.4rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 899px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar { border-right: none; border-bottom: 1px solid var(--line); padding: 2rem 1.4rem 1.2rem; }

  .sidebar-inner { position: static; }

  .portrait { width: 110px; height: 110px; }

  .site-nav { flex-direction: row; flex-wrap: wrap; gap: 0.15rem; }

  .site-nav a { padding: 0.3rem 0.6rem; font-size: 0.9rem; }

  .sidebar-actions { flex-direction: row; align-items: center; }

  .row { flex-direction: column; gap: 0.1rem; }

  .row .when { padding-top: 0; }

  main { padding-top: 1.6rem; }
}

@media print {
  .sidebar { display: none; }
  .layout { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
}
