/* Author: Rui Heng Yang */
:root {
  --bg: #ffffff;
  --text: #222222;
  --muted: #6b6b6b;
  --rule: #e5e5e5;
  --link: #1a4f8b;
  --font: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
}
[data-theme="dark"] { --bg: #161616; --text: #e4e4e4; --muted: #9a9a9a; --rule: #2e2e2e; --link: #8fb8e8; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 var(--font); }
main { max-width: 820px; margin: 0 auto; padding: 72px 24px 48px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 1em; }

header { margin-bottom: 32px; }
h1 { font-size: 32px; font-weight: 400; margin: 0; }
.meta { color: var(--muted); margin: 2px 0 10px; }
.contact a { margin-right: 18px; }
.theme-toggle {
  position: absolute; top: 20px; right: 24px; display: flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 4px; cursor: pointer; color: var(--muted);
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle .icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.track { position: relative; width: 34px; height: 18px; border-radius: 9px; background: var(--rule); transition: background .2s; }
.knob {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s;
}
[data-theme="dark"] .track { background: var(--link); }
[data-theme="dark"] .knob { transform: translateX(16px); }

/* Sidebar: fixed section links, shown only when there is room beside the content column. */
.sidebar {
  position: fixed; top: 72px; left: max(24px, calc(50% - 410px - 200px)); width: 160px;
  display: flex; flex-direction: column; border-left: 1px solid var(--rule); font-size: 15px;
}
.sidebar a { color: var(--muted); padding: 4px 0 4px 14px; margin-left: -1px; border-left: 2px solid transparent; }
.sidebar a:hover { color: var(--text); text-decoration: none; }
.sidebar a.current { color: var(--link); border-left-color: var(--link); }
.sidebar .sidebar-name { color: var(--text); font-size: 16px; margin-bottom: 10px; }
html { scroll-behavior: smooth; }
section { scroll-margin-top: 24px; }
/* Section links under the header replace the sidebar when there is no room for it. */
.topnav { display: none; flex-wrap: wrap; gap: 4px 16px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 15px; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--text); text-decoration: none; }
@media (max-width: 1260px) { .sidebar { display: none; } .topnav { display: flex; } }

h2 {
  font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--link); margin: 48px 0 16px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.note { color: var(--muted); font-size: 14px; margin-top: -6px; }

/* Hobbies photo rows: flex-grow set to each photo's aspect ratio so all photos in a row share one height. */
.album { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.photo-row { display: flex; gap: 8px; margin-bottom: 8px; }
.album:not(:first-of-type) { margin-top: 28px; }
.photo-row a { display: block; min-width: 0; }
.photo-row img { display: block; width: 100%; height: auto; border-radius: 4px; }

/* About: portrait floated beside the bio; the section clears it so the next heading starts below. */
#about { display: flow-root; }
.profile { float: right; width: 170px; height: auto; margin: 4px 0 12px 28px; border-radius: 6px; }

/* Selected work */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card {
  border: 1px solid var(--rule); border-radius: 8px; padding: 0 16px 16px; display: flex; flex-direction: column;
  overflow: hidden; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--link); transform: translateY(-2px); }
.card-fig {
  margin: 0 -16px 14px; height: 150px; background: #fff; border: 0; border-bottom: 1px solid var(--rule);
  display: block; width: calc(100% + 32px); padding: 10px; cursor: zoom-in; font: inherit; overflow: hidden;
}
/* Fixed pixel height: percentage heights inside a <button> do not resolve in Safari. */
.card-fig img { display: block; width: 100%; height: 129px; object-fit: contain; }
#lightbox { border: 0; padding: 36px 16px 16px; background: #fff; border-radius: 8px; max-width: 94vw; max-height: 92vh; cursor: zoom-out; }
#lightbox::backdrop { background: rgba(0, 0, 0, .7); }
#lightbox img { display: block; max-width: calc(94vw - 32px); max-height: calc(92vh - 52px); }
.lightbox-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 28px; line-height: 1; color: #555; cursor: pointer; }
.lightbox-close:hover { color: #000; }
.card-venue { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.card h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px; line-height: 1.3; }
.card p { font-size: 15px; line-height: 1.5; }
.card > p:nth-of-type(2) { flex: 1; }

/* Lists */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { margin-bottom: 18px; font-size: 15px; line-height: 1.5; color: var(--muted); }
.title { color: var(--text); font-weight: 600; font-size: 16px; }
.paper-link { color: inherit; }
.paper-link:hover { color: var(--link); }
.me { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.venue { font-style: italic; }
.extra-links a, .card-links a { color: var(--link); text-decoration: none; font-size: 14px; }
.extra-links a:hover, .card-links a:hover { text-decoration: underline; }
.card-links { margin: 8px 0 0; }
.row { display: flex; justify-content: space-between; gap: 16px; color: var(--text); }
.dates { color: var(--muted); white-space: nowrap; }
.sub { color: var(--muted); }

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

footer { margin-top: 56px; font-size: 13px; color: var(--muted); }

@media (max-width: 720px) {
  .photo-row { flex-direction: column; }
  main { padding-top: 40px; }
  .cards { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
  .profile { width: 120px; margin-left: 18px; }
}
