@font-face {
  font-family: 'Stack Sans Notch';
  src: url('/fonts/StackSansNotch-VariableFont_wght.ttf') format('truetype-variations'),
       url('/fonts/StackSansNotch-VariableFont_wght.ttf') format('truetype');
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f3ed;
  --surface: #fffdf9;
  --surface-soft: #faf8f2;
  --text: #1f1c18;
  --text-soft: #5e5951;
  --line: rgba(0, 0, 0, 0.12);
  --accent: #5d4bd8;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Stack Sans Notch', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  font-feature-settings: normal;
  font-variation-settings: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.6;
}

a {
  color: inherit;
}

.container {
  width: 100%;
  max-width: 1536px;
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

@media (min-width: 768px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Narrower measure for pages that read as prose rather than as a dense CV.
   At the full 1536px the paragraphs run far too long and the picture grids
   leave big empty gutters inside their section cards. */
.container--reading {
  max-width: 880px;
}

/* Navbar styles live in /partials/nav.css — single source of truth. */

main {
  padding-top: 104px;
  padding-bottom: 60px;
}

.page-hero {
  padding: 24px 0 14px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.52);
}

h1 {
  margin: 12px 0 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero-copy {
  margin: 0;
  max-width: 820px;
  color: var(--text-soft);
}

.section {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: clamp(1rem, 2.1vw, 1.6rem);
}

.section h2 {
  margin: 0 0 0.9rem;
  font-size: 1.4rem;
  letter-spacing: 0.01em;
}

.section-lead {
  margin: 0 0 1rem;
  color: var(--text-soft);
}

.card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 14px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.06);
}

.card h3 {
  margin: 0;
  line-height: 1.35;
  font-size: 1.05rem;
}

.card p {
  margin: 0.6rem 0 0;
  color: var(--text-soft);
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.chip {
  color: var(--accent);
}

.status {
  color: rgba(0, 0, 0, 0.5);
}

.list {
  margin: 0.65rem 0 0;
  padding-left: 1.1rem;
  color: var(--text-soft);
}

.list li + li {
  margin-top: 0.45rem;
}

.cta-row {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.58rem 0.95rem;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.cta.primary {
  background: #1f1c18;
  color: #f5f3ed;
  border-color: #1f1c18;
}

.cta[aria-disabled='true'] {
  opacity: 0.6;
  cursor: not-allowed;
}

.split {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Stack Sans Notch has no CJK glyphs — name the fallbacks explicitly so the
   Chinese name renders in a matching system face instead of a random default. */
:lang(zh-Hans),
:lang(zh) {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

/* ---- Lightbox ---- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(20, 18, 15, 0.94);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-image {
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
}

.lightbox button {
  position: absolute;
  border: 0;
  background: none;
  color: #f5f3ed;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.lightbox button:hover,
.lightbox button:focus-visible {
  opacity: 1;
}

.lightbox-close {
  top: 16px;
  right: 20px;
  font-size: 2.4rem;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  padding: 0 14px;
}

.lightbox-prev {
  left: 8px;
}

.lightbox-next {
  right: 8px;
}

/* ---- Project grid: every project shown the same way ---- */

.project-grid {
  display: grid;
  gap: 26px;
  grid-template-columns: 1fr;
}

@media (min-width: 700px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.project-tile {
  display: block;
  text-decoration: none;
}

.project-tile .project-media {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-tile:hover .project-media,
.project-tile:focus-visible .project-media {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.09);
}

.project-tile h3 {
  margin: 0.8rem 0 0;
  font-size: 1.05rem;
  transition: color 0.25s ease;
}

.project-tile:hover h3,
.project-tile:focus-visible h3 {
  color: var(--accent);
}

.project-tile p {
  margin: 0.25rem 0 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.soon {
  color: var(--accent);
}

/* ---- Project entries ---- */

.project-entry {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

/* Only entries that actually carry a preview get the media column; a text-only
   entry would otherwise be squeezed into the 300px slot. */
@media (min-width: 720px) {
  .project-entry:has(.project-media) {
    grid-template-columns: 300px 1fr;
  }
}

.project-entry + .project-entry {
  margin-top: 26px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

/* Preview clips stay still until hovered — see the script in projects/index.html. */
.project-media {
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  line-height: 0;
}

.project-media video,
.project-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Compact list for smaller builds ---- */

.mini-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-list li + li {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.mini-list a,
.mini-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  text-decoration: none;
}

.mini-name {
  font-size: 1rem;
}

.mini-note {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.mini-list a .mini-arrow {
  margin-left: auto;
  color: var(--accent);
  font-size: 0.85rem;
  white-space: nowrap;
}

.mini-list a:hover .mini-name,
.mini-list a:focus-visible .mini-name {
  color: var(--accent);
}

/* ---- Photo timeline ---- */

.timeline {
  position: relative;
  margin-top: 8px;
}

/* The spine. Sits under the date markers, inset far enough on wide screens
   to leave the dates their own column. */
.timeline::before {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 0;
  left: 5px;
  width: 1px;
  background: var(--line);
}

.tl-year {
  position: relative;
  padding-left: 34px;
  margin: 44px 0 6px;
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: rgba(0, 0, 0, 0.14);
}

.tl-year:first-child {
  margin-top: 0;
}

.tl-session {
  position: relative;
  padding-left: 34px;
  padding-bottom: 42px;
}

/* Marker dot, centred on the spine. */
.tl-session::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.tl-date {
  margin: 0 0 14px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(0, 0, 0, 0.5);
}

/* The place name carries the line; the date is the quieter half. */
.tl-date span {
  color: var(--text);
}

/* Photos keep their own proportions — the point of the page is that a square,
   a panorama and a portrait should not all look like the same rectangle. */
.tl-shots {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.tl-shots button {
  padding: 0;
  border: 1px solid var(--line);
  background: none;
  cursor: zoom-in;
  line-height: 0;
  font: inherit;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tl-shots button:hover,
.tl-shots button:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.1);
}

.tl-shots img {
  display: block;
  height: 200px;
  width: auto;
  max-width: 100%;
}

/* One photo alone gets to be big; a four-photo day stays a dense cluster.
   That unevenness is the whole point — it mirrors how the day was shot. */
.tl-session[data-count='1'] .tl-shots img {
  height: 320px;
}

@media (max-width: 600px) {
  .tl-shots img,
  .tl-session[data-count='1'] .tl-shots img {
    height: auto;
    width: 100%;
  }

  .tl-shots button {
    width: 100%;
  }

  .tl-year {
    font-size: 1.8rem;
  }
}

/* ---- Prose ---- */

.prose {
  max-width: 68ch;
}

.prose p {
  margin: 0 0 1rem;
  color: var(--text-soft);
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose-close {
  margin-top: 1.4rem;
  color: var(--text);
}

/* ---- Collapsible section ---- */

.fold {
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.fold > summary {
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
}

/* Hide the native disclosure marker in both engines. */
.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary::marker {
  content: '';
}

/* Chevron drawn from two borders; rotates when the section opens. */
.fold > summary::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: none;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translate(-1px, -1px);
  transition: transform 0.2s ease;
}

.fold[open] > summary::before {
  transform: rotate(45deg) translate(-2px, -2px);
}

.fold > summary:hover,
.fold > summary:focus-visible {
  background: rgba(0, 0, 0, 0.02);
}

.fold-body {
  padding: 0 1.1rem 1.1rem;
}

/* ---- Paired cards: two subjects side by side ---- */

.pair-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .pair-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.pair-item h3 {
  margin: 0 0 0.7rem;
  font-size: 1.15rem;
}

.pair-item figure {
  margin: 0 0 0.75rem;
}

/* Both photos are squared off so the two columns line up regardless of the
   originals' aspect ratios. */
.pair-item img {
  display: block;
  width: 100%;
  /* height:auto is required — the img height attribute maps to a CSS height,
     and a definite width *and* height makes aspect-ratio a no-op. */
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--line);
}

.pair-item figcaption {
  margin-top: 0.45rem;
  color: rgba(0, 0, 0, 0.45);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pair-item p {
  margin: 0 0 0.8rem;
  color: var(--text-soft);
}

.pair-item p:last-child {
  margin-bottom: 0;
}

.pair-item code {
  font-family: 'Ubuntu Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1em;
  color: var(--accent);
}

/* ---- Two landscape photos side by side ---- */

.photo-duo {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  margin-bottom: 1rem;
}

@media (min-width: 720px) {
  .photo-duo {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.photo-duo figure {
  margin: 0;
}

.photo-duo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 1px solid var(--line);
}

/* ---- Media row: a picture beside a paragraph ---- */

.media-row {
  display: grid;
  gap: 18px;
  align-items: start;
  grid-template-columns: 1fr;
}

/* Even split so this row keeps the same rhythm as the two-column picture
   sections above and below it. */
@media (min-width: 720px) {
  .media-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-row.reverse {
    grid-template-columns: 1fr 260px;
  }

  .media-row.reverse .media-figure {
    order: 2;
  }
}

.media-figure {
  margin: 0;
}

.media-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.media-figure figcaption {
  margin-top: 0.5rem;
  color: rgba(0, 0, 0, 0.45);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.media-body p {
  margin: 0 0 0.9rem;
  color: var(--text-soft);
}

.media-body p:last-child {
  margin-bottom: 0;
}

.media-body code {
  font-family: 'Ubuntu Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1em;
  color: var(--accent);
}

/* ---- Hero portrait ---- */

.hero-split {
  display: grid;
  gap: 22px;
  grid-template-columns: 1fr;
  align-items: center;
}

/* Sized against the 880px reading container, not the viewport: a wider photo
   column here would squeeze the intro paragraph below a readable measure. */
@media (min-width: 860px) {
  .hero-split {
    grid-template-columns: 1fr 360px;
  }
}

.hero-portrait {
  margin: 0;
}

.hero-portrait img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.hero-portrait figcaption {
  margin-top: 0.5rem;
  text-align: right;
  color: rgba(0, 0, 0, 0.4);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---- Video ---- */

.video-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.video-card {
  margin: 0;
}

.video-frame {
  position: relative;
  background: #14120f;
  border: 1px solid var(--line);
  line-height: 0;
}

.video-frame video {
  display: block;
  width: 100%;
  height: auto;
}

.video-frame[data-autoplay-clip] video {
  cursor: pointer;
}

.video-card figcaption {
  margin-top: 0.6rem;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.sound-toggle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0.42rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 18, 15, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #f5f3ed;
  font-family: inherit;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  background: rgba(20, 18, 15, 0.85);
  border-color: rgba(255, 255, 255, 0.6);
}

/* Speaker glyph drawn in CSS: a square cone plus a triangular flare. */
.sound-icon {
  position: relative;
  width: 9px;
  height: 9px;
  background: currentColor;
  flex: none;
}

.sound-icon::after {
  content: '';
  position: absolute;
  left: 7px;
  top: -3px;
  border: 7px solid transparent;
  border-left-color: currentColor;
  border-right-width: 0;
}

/* A slash across the speaker while muted. */
.sound-icon::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 3px;
  width: 20px;
  height: 2px;
  background: currentColor;
  transform: rotate(-45deg);
  transform-origin: center;
}

.is-unmuted .sound-icon::before {
  display: none;
}

/* ---- CV / résumé entries ---- */

.entry + .entry {
  margin-top: 26px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

/* Logos are optically balanced by rendered width (~170px), not by height:
   the JHU lockup stacks a shield over two text lines, so matching heights
   would shrink its wordmark below legibility. */
.entry-logo {
  display: block;
  height: 28px;
  width: auto;
  max-width: 100%;
  margin-bottom: 16px;
}

.entry-logo--stacked {
  height: 44px;
}

.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.entry-head h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
}

.entry-date {
  color: rgba(0, 0, 0, 0.5);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  white-space: nowrap;
}

.entry-meta {
  margin: 0.5rem 0 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

/* Utility, deliberately unscoped: accented links also appear inside entry
   headings, not only in .entry-meta. */
.accent {
  color: var(--accent);
}

.pub-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pub-list li + li {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.pub-title {
  display: block;
  margin-top: 0.2rem;
}

.pub-venue {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.pub-venue .under-review {
  color: var(--accent);
}

.skill-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}

.skill-row + .skill-row {
  margin-top: 12px;
}

@media (min-width: 720px) {
  .skill-row {
    grid-template-columns: 170px 1fr;
    gap: 14px;
  }
}

.skill-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: rgba(0, 0, 0, 0.5);
  padding-top: 0.22rem;
}

.skill-value {
  color: var(--text-soft);
  margin: 0;
}

.footer {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  color: rgba(0, 0, 0, 0.56);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

