/* ------------------------------------------------------------
   Gabriel Rongyang Lau — academic site
   Two pages: index.html (profile) and cv.html (curriculum vitae)
   ------------------------------------------------------------ */

:root {
  --ink: #152230;
  --text: #2c3844;
  --muted: #68737f;
  --faint: #a2abb4;
  --rule: #e3e7ec;
  --paper: #ffffff;
  --panel: #f5f7f9;
  --accent: #0f6a62;
  --accent-ink: #0b4f4a;
  --accent-tint: #e4f1ef;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;

  --measure: 66ch;
  --gutter: clamp(20px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.04rem;
  line-height: 1.6;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(15, 106, 98, 0.35);
  text-underline-offset: 0.14em;
  text-decoration-thickness: 1px;
  transition: color 120ms ease, text-decoration-color 120ms ease;
}
a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.005em;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px;
  background: var(--ink); color: #fff;
  padding: 8px 12px; border-radius: 4px;
  z-index: 100; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Header / navigation ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.site-header .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px var(--gutter);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.005em;
}
.wordmark:hover { color: var(--accent-ink); }
.site-nav { display: flex; gap: 26px; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding-bottom: 3px;
  border-bottom: 1.5px solid transparent;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ---------- Page shell ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(36px, 6vw, 72px) var(--gutter) 64px;
}

.profile-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: start;
}

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

.sidebar {
  position: sticky;
  top: 32px;
}

.portrait {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  background: var(--panel);
}
.portrait-fallback {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  background: var(--accent-tint);
  color: var(--accent-ink);
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 4rem;
  letter-spacing: 0.04em;
}
.portrait-wrap.is-missing .portrait { display: none; }
.portrait-wrap.is-missing .portrait-fallback { display: flex; }

.sidebar h1 {
  font-size: 1.75rem;
  margin-top: 22px;
}
.sidebar .role {
  margin-top: 8px;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.5;
}
.sidebar .role span { display: block; color: var(--muted); }

.contact {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.contact h2 {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}
.contact ul { list-style: none; margin: 0; padding: 0; }
.contact li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 0.95rem;
}
.contact li svg {
  width: 17px; height: 17px;
  flex: none;
  color: var(--faint);
}
.contact li a { color: var(--text); text-decoration: none; }
.contact li a:hover { color: var(--accent-ink); text-decoration: underline; }

.cv-button {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 500;
  transition: background 120ms ease;
}
.cv-button:hover { background: var(--accent-ink); color: #fff; }
.cv-button svg { width: 15px; height: 15px; }

/* ---------- Main column ---------- */

.lede {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 2.3vw, 1.9rem);
  line-height: 1.35;
  color: var(--ink);
  max-width: 34ch;
  margin-bottom: 36px;
  text-wrap: balance;
}

.section {
  padding-top: 32px;
  margin-top: 32px;
  border-top: 1px solid var(--rule);
}
.section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.section h2 {
  font-size: 1.35rem;
  margin-bottom: 18px;
}
.section > p,
.section ul.prose { max-width: var(--measure); }
.section > p + p { margin-top: 0.9em; }

/* Interests shown as a flowing list of terms */
.interests {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 10px 10px;
  max-width: var(--measure);
}
.interests li {
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.93rem;
  color: var(--text);
  background: var(--paper);
}

/* Timeline-style records (experience, education, awards) */
.records { list-style: none; margin: 0; padding: 0; max-width: 72ch; }
.records li {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.records li:last-child { border-bottom: 0; }
.records .when {
  color: var(--muted);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.records .what { font-weight: 500; color: var(--ink); }
.records .where { color: var(--muted); font-size: 0.95rem; margin-top: 2px; }
.records .note { font-size: 0.93rem; margin-top: 6px; color: var(--text); }

/* Publications */
.pubs { list-style: none; margin: 0; padding: 0; max-width: 72ch; counter-reset: pub; }
.pubs li {
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.97rem;
}
.pubs li:last-child { border-bottom: 0; }
.pubs .title {
  display: block;
  font-family: var(--serif);
  font-size: 1.12rem;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 4px;
}
.pubs .authors { color: var(--text); }
.pubs .authors b { font-weight: 600; color: var(--ink); }
.pubs .venue { color: var(--muted); font-size: 0.93rem; margin-top: 3px; }
.pubs .venue i { font-style: italic; }
.pubs .venue a { white-space: nowrap; }

.more-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.95rem;
}

.section .legend {
  font-size: 0.86rem;
  color: var(--muted);
  margin-top: 14px;
  max-width: 72ch;
}

/* ---------- CV page ---------- */

.cv-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 32px;
  margin-bottom: 24px;
}
.cv-head h1 { font-size: clamp(1.8rem, 3vw, 2.3rem); }
.cv-head .meta { color: var(--muted); font-size: 0.95rem; margin-top: 6px; }
.cv-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 500;
  border: 1px solid var(--rule);
  color: var(--ink);
  background: var(--paper);
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { border-color: var(--muted); color: var(--ink); background: var(--panel); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn svg { width: 15px; height: 15px; }

.cv-frame {
  width: 100%;
  height: min(88vh, 1200px);
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--panel);
  display: block;
}
.cv-fallback {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--rule);
  border-radius: 6px;
  max-width: 48ch;
  margin: 0 auto;
}
.cv-fallback p { margin-bottom: 14px; }

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

.site-footer {
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.86rem;
}
.site-footer .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px var(--gutter);
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.site-footer a { color: var(--muted); }

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

@media (max-width: 920px) {
  .profile-layout { grid-template-columns: 1fr; gap: 40px; }
  .sidebar { position: static; display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 20px 28px; align-items: start; }
  .portrait-wrap { grid-row: 1 / span 3; }
  .sidebar h1 { margin-top: 0; }
  .contact { grid-column: 1 / -1; }
  .lede { max-width: none; }
}

@media (max-width: 560px) {
  body { font-size: 1rem; }
  .site-header .inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .sidebar { grid-template-columns: 1fr; }
  .portrait-wrap { grid-row: auto; max-width: 220px; }
  .records li { grid-template-columns: 1fr; gap: 2px; }
  .cv-frame { height: 75vh; }
}

@media print {
  .site-header, .site-footer, .cv-button, .cv-actions, .skip-link { display: none; }
  .profile-layout { grid-template-columns: 1fr; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Profile hero (single-screen About page) ---------- */

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(32px, 5vw, 64px) var(--gutter) 64px;
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(280px, 5fr) minmax(0, 6fr);
  gap: clamp(36px, 6vw, 88px);
  align-items: center;
}
.hero-photo { margin: 0; }
.hero-photo .portrait { width: 100%; height: auto; display: block; border-radius: 6px; }
.hero-text h1 { font-size: clamp(2rem, 3.4vw, 2.75rem); }
.hero-text .role { margin-top: 12px; font-size: 1.02rem; line-height: 1.5; }
.hero-text .role span { display: block; color: var(--muted); }
.hero-text .lede {
  margin-top: 28px;
  margin-bottom: 0;
  max-width: 34ch;
  font-size: clamp(1.3rem, 2vw, 1.6rem);
}
.hero-text .contact {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.hero-text .contact ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: 0; align-items: start; gap: 32px; }
  .hero-photo { max-width: 420px; }
  .hero-text .contact ul { grid-template-columns: 1fr; }
}
