/* ============================================================
   Tingyu Dai — Sociology of AI
   Layout & typesetting adapted from xuanyouliu.com's academic
   structure (round portrait hero, animated section-title
   underline, 2-col about+news, 3-col research grid, badge
   publication cards, simple teaching list, 2-col contact),
   while preserving the "重写 Future" visual identity:
   electric blue + fluorescent green, interactive dot field,
   custom cursor blob, expandable pub abstracts.
   ============================================================ */

:root {
  /* surfaces */
  --color-bg:        #f7f7f9;
  --color-bg-alt:    #eef0fa;
  --color-surface:   #ffffff;

  /* ink — blue-black family */
  --color-text:       #0a0d2c;
  --color-text-muted: #555a78;
  --color-text-light: #8b8fa7;

  /* hairlines */
  --color-border:       #d6d8e6;
  --color-border-light: #e8e9f2;

  /* electric blue (replaces purple accent) */
  --color-accent:        #1b30ff;
  --color-accent-hover:  #0014dd;
  --color-accent-deep:   #0a18b8;
  --color-accent-light:  rgba(27, 48, 255, 0.10);
  --color-on-accent:     #ffffff;

  /* fluorescent green — highlight & hover pop */
  --color-green:       #d2ff3d;
  --color-green-soft:  #e6ff80;
  /* text color that always reads on the green chip — same in both themes */
  --color-on-green:    #0a0d2c;

  /* type */
  --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif:   var(--font-display);   /* xuanyouliu uses Merriweather for the academic feel —
                                            we substitute Space Grotesk for the poster look */

  /* spacing scale */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.5rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;

  /* layout */
  --max-width:    min(92vw, 1320px);
  --content-width: 800px;
  --border-radius: 4px;

  /* easings & transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
  --ease:        cubic-bezier(.4, 0, .2, 1);
  --ease-out:    cubic-bezier(.16, 1, .3, 1);
  --ease-press:  cubic-bezier(.4, 0, .6, 1);

  /* elevation */
  --shadow-soft: 0 1px 2px rgba(10, 13, 44, 0.04), 0 12px 32px -16px rgba(10, 13, 44, 0.12);
  --shadow-lift: 0 2px 6px rgba(10, 13, 44, 0.06), 0 26px 56px -22px rgba(10, 13, 44, 0.20);
  --shadow-blue: 0 1px 2px rgba(10, 13, 44, 0.08), 0 14px 32px -10px rgba(27, 48, 255, 0.45);

  /* nav surface — overridden per theme */
  --nav-bg: rgba(247, 247, 249, 0.92);
}

/* ============================================
   Dark mode — applied when [data-theme="dark"]
   is set on <html>, OR via prefers-color-scheme
   when no explicit override.
   ============================================ */
:root[data-theme="dark"],
:root:not([data-theme]) {
  /* default: light (the :root block above) */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg:        #0c0f24;
    --color-bg-alt:    #161a3a;
    --color-surface:   #1f2347;

    --color-text:       #f4f5fb;
    --color-text-muted: #c3c7e0;
    --color-text-light: #8b90b2;

    --color-border:       #3a3f70;
    --color-border-light: #262a52;

    --color-accent:        #8a96ff;
    --color-accent-hover:  #a8b1ff;
    --color-accent-deep:   #6c7bff;
    --color-accent-light:  rgba(138, 150, 255, 0.20);

    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.40), 0 12px 32px -16px rgba(0, 0, 0, 0.65);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.45), 0 26px 56px -22px rgba(0, 0, 0, 0.75);
    --shadow-blue: 0 1px 2px rgba(0, 0, 0, 0.40), 0 14px 32px -10px rgba(138, 150, 255, 0.55);

    --nav-bg: rgba(12, 15, 36, 0.88);
  }
}

[data-theme="dark"] {
  --color-bg:        #0c0f24;
  --color-bg-alt:    #161a3a;
  --color-surface:   #1f2347;

  --color-text:       #f4f5fb;
  --color-text-muted: #c3c7e0;
  --color-text-light: #8b90b2;

  --color-border:       #3a3f70;
  --color-border-light: #262a52;

  --color-accent:        #8a96ff;
  --color-accent-hover:  #a8b1ff;
  --color-accent-deep:   #6c7bff;
  --color-accent-light:  rgba(138, 150, 255, 0.20);

  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.40), 0 12px 32px -16px rgba(0, 0, 0, 0.65);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.45), 0 26px 56px -22px rgba(0, 0, 0, 0.75);
  --shadow-blue: 0 1px 2px rgba(0, 0, 0, 0.40), 0 14px 32px -10px rgba(138, 150, 255, 0.55);

  --nav-bg: rgba(12, 15, 36, 0.88);
}

/* dark-mode component overrides */
[data-theme="dark"] .hero-text::before,
[data-theme="dark"] .hero::before { background: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-text::before,
  :root:not([data-theme="light"]) .hero::before { background: none; }
}

/* Cursor blob: multiply blend disappears on dark bg → use screen so the
   solid dot lightens the dark canvas instead of being absorbed. The
   merged-state tint also swaps to green for clearer contrast on dark. */
/* dark mode: brighter translucent green so it pops on dark bg without
   any mix-blend-mode (which was Safari's primary cursor-lag cause) */
[data-theme="dark"] .cursor-blob::before { background: rgba(210, 255, 61, 0.55); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cursor-blob::before { background: rgba(210, 255, 61, 0.55); }
}

/* In dark mode, partial green highlighters become full green chips with
   dark text — light text was unreadable on the bright green band. */
[data-theme="dark"] .hl-title,
[data-theme="dark"] .contact-note h3 {
  background-image: none;
  background-color: var(--color-green);
  color: var(--color-on-green);
  padding: 0.05em 0.4em;
  border-radius: 2px;
}
[data-theme="dark"] .pub-cue {
  background-image: linear-gradient(var(--color-green), var(--color-green));
  padding: 2px 8px;
  border-radius: 2px;
}
[data-theme="dark"] .pub:hover .pub-cue,
[data-theme="dark"] .pub.open .pub-cue {
  color: var(--color-on-green);
}
/* Section-title highlight: push the green band entirely BELOW the text
   in dark mode so it reads as a chunky underline accent instead of
   overlapping the white letters. */
[data-theme="dark"] .section-title::after {
  bottom: -10px;
  height: 6px;
  z-index: 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hl-title,
  :root:not([data-theme="light"]) .contact-note h3 {
    background-image: none;
    background-color: var(--color-green);
    color: var(--color-on-green);
    padding: 0.05em 0.4em;
    border-radius: 2px;
  }
  :root:not([data-theme="light"]) .pub-cue {
    background-image: linear-gradient(var(--color-green), var(--color-green));
    padding: 2px 8px;
    border-radius: 2px;
  }
  :root:not([data-theme="light"]) .pub:hover .pub-cue,
  :root:not([data-theme="light"]) .pub.open .pub-cue {
    color: var(--color-on-green);
  }
  :root:not([data-theme="light"]) .section-title::after {
    bottom: -10px;
    height: 6px;
    z-index: 0;
  }
}

/* smooth theme transitions on the colors that flip */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition:
    background-color 0.4s ease,
    border-color 0.4s ease,
    color 0.4s ease,
    fill 0.4s ease,
    stroke 0.4s ease,
    box-shadow 0.4s ease !important;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  scrollbar-gutter: stable;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  cursor: none;
}

/* hide OS cursor on interactive elements too, otherwise the hand
   cursor overrides our blob the moment you reach a link/button */
a, button, [role="button"], [data-cursor="grow"],
.pub, .project-card, .course-item, .contact-item {
  cursor: none;
}

@media (hover: none), (max-width: 880px) {
  body, a, button, [role="button"], [data-cursor="grow"],
  .pub, .project-card, .course-item, .contact-item { cursor: auto; }
  .cursor-blob { display: none !important; }
}

::selection {
  background: var(--color-green);
  color: var(--color-on-green);
}
::-moz-selection {
  background: var(--color-green);
  color: var(--color-on-green);
}

/* suppress Safari's default focus ring after a mouse click — that's
   what was painting the dark rectangle around the EMAIL button. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  border-radius: var(--border-radius);
}
/* also kill iOS / Safari tap highlight flashes */
* { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-text);
  color: #fff;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius);
  z-index: 10000;
  font-weight: 500;
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: var(--space-md); color: #fff; }

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }

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

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-accent-hover); }

strong { font-weight: 600; }
em { font-style: italic; color: var(--color-text); }

/* fluorescent green highlight (kept from Tami's identity) */
.hl-title {
  display: inline;
  background-image: linear-gradient(transparent 62%, var(--color-green) 62%, var(--color-green) 96%, transparent 96%);
  padding: 0 8px;
  font-style: italic;
  font-weight: 700;
}

/* ============================================
   Cursor blob (preserved from Tami's identity)
   ============================================ */
.cursor-blob {
  position: fixed;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  overflow: visible;
  background: transparent;
  transform: translate3d(0, 0, 0);
  transition: opacity 0.22s var(--ease);
}
.cursor-blob::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(27, 48, 255, 0.55);
  transform: scale(1);
  transform-origin: center;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.28s var(--ease-out);
}
.cursor-blob.visible { opacity: 1; }

/* Grow: for cards / links / nav — cursor swells into a soft green disc */
.cursor-blob.grow::before {
  transform: scale(3.142857);
  background: rgba(210, 255, 61, 0.6);
}

/* iPadOS-style: cursor disappears completely when it lands on a
   button/chip — element's own hover + magnet pull do the work.
   Instant fade-out so no translucent blue dot lingers over the
   button while the cursor crosses its edge. */
.cursor-blob.hidden {
  opacity: 0 !important;
  transition: opacity 0s !important;
}

/* ============================================
   Hover-wipe overlay — INCITE-style.
   Two colored layers + a clone of the thumbnail
   image cascade in from the top-left after a dwell.
   The final (image) layer reveals the picture from
   the corner. Shared by .pub-thumb and .project-image.
   ============================================ */
.pub-thumb, .project-image { overflow: hidden; }

.wipe-layer {
  position: absolute;
  inset: 0;
  transform-origin: top left;
  transform: scale(0);
  transition: transform 0.55s cubic-bezier(0.5, 0, 0.2, 1);
  pointer-events: none;
  will-change: transform;
}
.wipe-layer.in { transform: scale(1); }
.wipe-layer.color-1 { background: var(--color-accent); z-index: 2; }
.wipe-layer.color-2 { background: var(--color-green);  z-index: 3; }
.wipe-layer.image {
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   Dot canvas — fixed full-page backdrop.
   Visible behind transparent sections (About,
   Publications, Contact); covered by section-alt
   (Research, Teaching) for an alternating rhythm.
   ============================================ */
.dot-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  contain: strict;
  transform: translate3d(0, 0, 0);
}

/* ============================================
   Scroll progress
   ============================================ */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: var(--color-accent);
  z-index: 1001;
  transition: width .08s linear;
}

/* ============================================
   Navigation
   ============================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background var(--transition-base),
              border-color var(--transition-base);
}

/* Solid translucent bg instead of backdrop-filter blur — the blur is
   Safari's #1 performance killer on fixed bars (full-width compositing
   pass every frame). The visual cost is tiny, the perf win is big. */
.nav.scrolled {
  background: var(--color-bg);
  border-bottom-color: var(--color-border-light);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: block;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--color-accent);
  transition: transform 0.4s var(--ease-press), background 0.25s var(--ease);
}
.nav-logo:hover {
  transform: rotate(-90deg);
  background: var(--color-green);
}

.nav-links {
  display: flex;
  gap: var(--space-lg);
  margin-left: auto;
  margin-right: var(--space-lg);
  list-style: none;
}
.nav-links li { display: flex; align-items: center; }

.nav-link {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  position: relative;
  padding: 4px 0;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 0;
  height: 5px;
  background-color: var(--color-accent);
  transition: width var(--transition-base);
}
[data-theme="dark"] .nav-link::after { background-color: var(--color-green); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nav-link::after { background-color: var(--color-green); }
}
.nav-link:hover {
  color: var(--color-text);
}
.nav-link:hover::after { width: 100%; }

.nav-link.active {
  color: var(--color-text);
  font-weight: 600;
}
.nav-link.active::after { width: 100%; }

.nav-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-xs);
  margin-right: -8px;
  color: var(--color-text);
}
.nav-toggle span {
  width: 24px;
  height: 2px;
  background-color: currentColor;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}
.nav-toggle.active span:first-child {
  transform: rotate(45deg) translate(5px, 5px);
}
.nav-toggle.active span:last-child {
  transform: rotate(-45deg) translate(5px, -5px);
}

body.no-scroll {
  overflow: hidden;
}

/* circular icon button for theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition-base),
              background-color var(--transition-base),
              color var(--transition-base),
              transform 0.15s var(--ease-press);
  overflow: hidden;
}
.theme-toggle:hover {
  border-color: var(--color-accent);
  background-color: var(--color-accent-light);
}
.theme-toggle:active { transform: scale(0.92); }

/* theme-toggle: swap sun/moon icons based on data-theme + system pref */
.theme-toggle svg { transition: transform 0.4s var(--ease-out); }
.theme-toggle:hover svg { transform: rotate(15deg); }

.theme-toggle .sun-icon  { display: none; }
.theme-toggle .moon-icon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun-icon  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon-icon { display: none; }
}
[data-theme="dark"] .theme-toggle .sun-icon  { display: block; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
[data-theme="light"] .theme-toggle .sun-icon  { display: none; }
[data-theme="light"] .theme-toggle .moon-icon { display: block; }

/* ============================================
   Hero
   ============================================ */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
  isolation: isolate;
  z-index: 2;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(135deg, transparent 0%, var(--color-bg-alt) 100%);
  opacity: 0.45;
  z-index: -1;
}

.hero-content {
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: calc(var(--space-xl) + 1rem);
  align-items: center;
}

/* round portrait — adopted from xuanyouliu */
.hero-image-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.hero-image-accent {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--color-accent);
  opacity: 0.4;
  transform: translate(14px, 14px) scale(0.94);
  pointer-events: none;
  transition: transform 0.5s var(--ease-out), opacity 0.4s ease, border-color 0.4s ease;
}
.hero-image-wrapper:hover .hero-image-accent {
  transform: translate(18px, 18px) scale(0.94);
  opacity: 0.6;
}

.hero-image {
  width: 280px;
  height: 280px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--color-text);
  box-shadow: var(--shadow-blue);
  position: relative;
  isolation: isolate;
  transition: transform 0.5s var(--ease-out), box-shadow 0.4s ease;
}
.hero-image:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 2px 4px rgba(10, 13, 44, 0.06),
    0 30px 60px -15px rgba(27, 48, 255, 0.55);
}

/* Safari: percentage-sized img + object-fit inside overflow:hidden often mis-crops;
   absolute fill is reliable across browsers. */
.hero-image img,
.hero-image .profile-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 42%;
  display: block;
}

.hero-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 80% at 25% 18%, rgba(255,255,255,0.55), transparent 55%),
    linear-gradient(165deg, #c7ccff 0%, #d8dcff 100%);
}
.hero-image-initials {
  font-family: var(--font-display);
  font-size: 96px;
  font-weight: 700;
  letter-spacing: -0.05em;
  color: var(--color-accent);
  user-select: none;
}
.hero-image-corner {
  position: absolute;
  bottom: 10px; right: 10px;
  width: 24px; height: 24px;
  background: var(--color-green);
  border: 2px solid var(--color-text);
  border-radius: 50%;
  z-index: 3;
}

/* hero text */
.hero-text {
  max-width: 620px;
  position: relative;
  isolation: isolate;
}
.hero-text::before {
  content: '';
  position: absolute;
  inset: -1.1rem -1.4rem;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(247,247,249,0.92) 0%, transparent 72%);
  pointer-events: none;
}

.hero-greeting {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.hero-greeting::before {
  content: '';
  width: 32px;
  height: 8px;
  background-color: var(--color-green);
  display: inline-block;
  flex-shrink: 0;
}

.hero-name {
  margin-bottom: var(--space-md);
  color: var(--color-text);
  display: inline-block;
  font-weight: 700;
  letter-spacing: -0.035em;
  transition: color 0.4s ease, transform 0.4s ease;
}
.hero-name:hover {
  color: var(--color-accent);
  transform: scale(1.01);
}
.hero-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: var(--space-xs);
  letter-spacing: -0.012em;
}

.hero-affiliation {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: 1.65;
  margin-bottom: var(--space-md);
}
.hero-affiliation a {
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  transition: color 0.25s ease, border-color 0.25s ease;
}
.hero-affiliation a:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* interest chips — preserved Tami style (border + green hover) */
.hero-interests {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: var(--space-lg);
}
.hero-interests .interest-chip {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.85rem;
  border: 1.5px solid var(--color-text);
  border-radius: 999px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
/* chip activates on hover — cursor itself disappears (iPad behaviour);
   the green fill + colour swap is the cursor's "merged" state */
.hero-interests .interest-chip:hover {
  background: var(--color-green);
  color: var(--color-on-green);
  border-color: var(--color-on-green);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--border-radius);
  /* explicit list — `transition: all` was making Safari re-evaluate
     background-color / box-shadow / color every paint, contributing to
     the EMAIL button's flicker on hover */
  transition: background-color var(--transition-fast),
              color var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast);
  border: 1.5px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:focus-visible {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
  border-color: var(--color-accent);
  box-shadow: none;
  opacity: 1;
}
/* btn-primary stays in its baseline blue on hover — only the magnet
   pull provides feedback (per user request, no colour change). */
.btn-primary:active { transform: translateY(2px) scale(0.97); }

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-text);
}
.btn-secondary:hover {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
  border-color: var(--color-text);
}

.btn-icon {
  padding: var(--space-sm);
  background-color: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn-icon:hover {
  color: var(--color-accent);
  background-color: var(--color-accent-light);
}
.btn-icon:active { transform: scale(0.9); }

/* ============================================
   Sections
   ============================================ */
.section {
  position: relative;
  padding: var(--space-2xl) var(--space-lg);
  z-index: 2;
  /* skip rendering/layout when off-screen — huge scroll-perf win
     on Safari, especially while the dot canvas is repainting */
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}

.section-alt {
  background-color: var(--color-bg-alt);
}

.section-inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
}

/* section title — partial fluorescent-green highlighter band */
h2.section-title {
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  margin-bottom: calc(var(--space-lg) + 10px);
  position: relative;
  display: inline-block;
  isolation: isolate;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: 0 50%;
  will-change: transform;
}
h2.section-title.active {
  transform: scale(1.06);
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: 0.22em;
  left: -0.15em;
  width: 0;
  height: 0.42em;
  background-color: var(--color-green);
  z-index: -1;
  transition: width 0.7s var(--ease-out);
}
.section-title.active::after {
  width: 80%;
}

.section-subtitle {
  margin-top: calc(var(--space-md) * -1);
  margin-bottom: var(--space-xl);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  max-width: 64ch;
  line-height: 1.6;
}

/* ============================================
   About
   ============================================ */
.about-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-xl);
  align-items: start;
}

.about-text .lead {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.about-text p {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}
.about-text p:last-child { margin-bottom: 0; }
.about-text strong { color: var(--color-text); }

.about-text a {
  color: var(--color-accent);
  position: relative;
  transition: color 0.3s ease;
}
.about-text a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background-color: var(--color-accent);
  transition: width 0.3s ease;
}
.about-text a:hover { color: var(--color-accent-hover); }
.about-text a:hover::after { width: 100%; }

/* about-news sidebar */
.about-news {
  position: sticky;
  top: 88px;
}
.about-news h3 {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-accent);
  margin-bottom: var(--space-md);
}

.news-list {
  list-style: none;
}
.news-list li {
  padding: var(--space-sm) var(--space-sm);
  margin: 0 calc(var(--space-sm) * -1);
  border-bottom: 1px solid var(--color-border-light);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  transition: background-color 0.2s ease, transform 0.2s ease,
              color 0.2s ease, box-shadow 0.2s ease;
  border-radius: var(--border-radius);
  position: relative;
}
.news-list li:last-child { border-bottom: none; }
.news-list li a {
  color: var(--color-text);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-fast);
}
.news-list li a:hover { border-bottom-color: var(--color-accent); }

@media (hover: hover) {
  .news-list li:hover {
    background-color: var(--color-surface);
    transform: translateX(4px);
    color: var(--color-text);
    border-bottom-color: transparent;
    box-shadow: 0 2px 8px rgba(10,13,44,0.06);
  }
  .news-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 70%;
    background-color: var(--color-green);
    border-radius: 2px;
    transition: transform 0.2s ease;
    opacity: 0;
  }
  .news-list li:hover::before {
    transform: translateY(-50%) scaleY(1);
    opacity: 1;
  }
}

.news-date {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--color-accent);
  margin-right: var(--space-sm);
  letter-spacing: 0.04em;
}

/* ============================================
   Research (projects-grid)
   ============================================ */
#research.section-alt {
  /* Gaps and margins show the dot field at full strength */
  background-color: transparent;
}

#research .project-card {
  background-color: transparent;
}

#research .project-content {
  background-color: transparent;
}

@media (hover: hover) {
  #research .project-card:hover .project-content {
    background-color: transparent;
  }
  #research .project-card:hover .project-desc::after {
    background: linear-gradient(transparent, var(--color-bg));
  }
}

#research .project-desc::after {
  background: linear-gradient(transparent, var(--color-bg));
}

.projects-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
  align-items: start;
}

.project-card {
  background-color: var(--color-surface);
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid var(--color-border-light);
  transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1),
              box-shadow 0.6s cubic-bezier(0.165, 0.84, 0.44, 1),
              border-color 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (hover: hover) {
  .project-card:hover {
    box-shadow: var(--shadow-lift);
    transform: translateY(-6px) scale(1.01);
    border-color: var(--color-accent);
    z-index: 10;
  }
  .project-card:active {
    transform: translateY(2px) scale(0.97);
    box-shadow: var(--shadow-soft);
    transition: transform 0.05s var(--ease), box-shadow 0.05s var(--ease);
  }
}

.project-image {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.project-glyph {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 72px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.04em;
  text-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
.project-grad-1 { background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-deep) 100%); }
.project-grad-2 { background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-green) 130%); }
.project-grad-2 .project-glyph { color: var(--color-text); }
.project-grad-3 { background: linear-gradient(135deg, var(--color-text) 0%, var(--color-accent) 100%); }

.project-content {
  padding: var(--space-md) var(--space-md) var(--space-md);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  transition: background-color 0.3s ease;
}
@media (hover: hover) {
  .project-card:hover .project-content { background: var(--color-bg); }
}

.project-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.25;
  margin-bottom: var(--space-sm);
  transition: color 0.3s ease;
}
@media (hover: hover) {
  .project-card:hover .project-title { color: var(--color-accent); }
}

.project-desc {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-sm);
  max-height: 4.6em;
  overflow: hidden;
  position: relative;
  transition: max-height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.project-desc::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.5em;
  background: linear-gradient(transparent, var(--color-surface));
  pointer-events: none;
  transition: opacity 0.5s ease;
}
@media (hover: hover) {
  .project-card:hover .project-desc { max-height: 1000px; }
  .project-card:hover .project-desc::after { opacity: 0; }
  .project-card:hover .project-content { background: var(--color-surface); }
  .project-card:hover .project-desc::after {
    background: linear-gradient(transparent, var(--color-surface));
  }
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-sm);
}
/* Desktop wide only: reveal tags on card hover */
@media (min-width: 901px) and (hover: hover) {
  .project-tags {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 0.5s ease, opacity 0.5s ease, margin-top 0.5s ease;
  }
  .project-card:hover .project-tags {
    max-height: 200px;
    opacity: 1;
    margin-top: var(--space-sm);
  }
}
.project-tags span {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background-color: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.project-tags .tag-blue {
  background-color: var(--color-accent-light);
  color: var(--color-accent);
  border-color: transparent;
}

/* ============================================
   Publications — original Tami expandable rows
   ============================================ */
.pub-list { list-style: none; padding: 0; margin: 0; }

.pub {
  border-top: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: background .25s var(--ease);
}
.pub:first-child { border-top: 2px solid var(--color-text); }
.pub:last-child  { border-bottom: 2px solid var(--color-text); }

.pub:hover, .pub:focus-visible, .pub.open {
  outline: none;
  background: rgba(27, 48, 255, 0.025);
}

.pub-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  padding: 32px 16px;
  align-items: start;
  transition: padding .35s var(--ease);
}
.pub:hover .pub-row,
.pub.open .pub-row { padding-left: 28px; }

.pub-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pub-thumb-num {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
.pub-grad-1 { background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-deep) 100%); }
.pub-grad-2 { background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-green) 130%); }
.pub-grad-2 .pub-thumb-num { color: var(--color-text); }
.pub-grad-3 { background: linear-gradient(135deg, var(--color-text) 0%, var(--color-accent) 100%); }
.pub-grad-4 { background: linear-gradient(135deg, #2a2e58 0%, #6e7185 100%); }

.pub-body { min-width: 0; }

.pub-meta {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.pub-title {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.026em;
  color: var(--color-text);
  margin: 0 0 6px;
  text-wrap: balance;
  transition: color .25s var(--ease);
}
.pub:hover .pub-title,
.pub.open .pub-title { color: var(--color-accent); }

.pub-authors {
  font-size: 15px;
  color: var(--color-text-muted);
  margin: 0 0 10px;
}
.pub-authors strong { color: var(--color-text); }

.pub-snip {
  font-size: 15px;
  color: var(--color-text-muted);
  line-height: 1.55;
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

/* expand */
.pub-expand {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .55s var(--ease-out), opacity .35s var(--ease),
              margin-top .35s var(--ease);
  margin-top: 0;
}
.pub.open .pub-expand {
  max-height: 700px;
  opacity: 1;
  margin-top: 16px;
}
.pub-expand p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text-muted);
  margin: 0 0 12px;
  letter-spacing: -0.012em;
  max-width: 64ch;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 14px 0 0 !important;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
}
.pub-links a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--color-accent);
  position: relative;
}
.pub-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -2px;
  height: 1px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.pub-links a:hover::after { transform: scaleX(1); }
.pub-links .arrow { transition: transform .3s var(--ease); }
.pub-links a:hover .arrow { transform: translateX(3px); }

/* read more / show less cue */
.pub-cue {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.005em;
  background-image: linear-gradient(transparent 58%, var(--color-green) 58%, var(--color-green) 95%, transparent 95%);
  padding: 0 6px;
  background-size: 0% 100%;
  background-repeat: no-repeat;
  transition: background-size .35s var(--ease-out), color .25s var(--ease);
}
.pub:hover .pub-cue,
.pub.open .pub-cue { background-size: 100% 100%; }
.pub-cue::after {
  content: " →";
  display: inline-block;
  transition: transform .35s var(--ease);
  margin-left: 2px;
}
.pub.open .pub-cue::after { transform: rotate(90deg); }
.pub-cue::before { content: attr(data-closed); }
.pub.open .pub-cue::before { content: attr(data-open); }

.dot-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 15px;
  color: var(--color-text-muted);
  line-height: 1.6;
}
.dot-list li {
  position: relative;
  padding-left: 18px;
  margin: 0 0 8px;
}
.dot-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  background: var(--color-accent);
}

/* ============================================
   Teaching
   ============================================ */
.teaching-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.course-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background-color: var(--color-surface);
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border-light);
  transition: border-color var(--transition-base),
              transform var(--transition-base),
              box-shadow var(--transition-base);
  cursor: pointer;
}

@media (hover: hover) {
  .course-item:hover {
    border-color: var(--color-accent);
    transform: translateX(4px);
    box-shadow: var(--shadow-soft);
  }
  .course-item:hover .course-title {
    color: var(--color-accent);
  }
  .course-item:hover .course-desc {
    color: var(--color-text);
  }
  .course-item:active {
    transform: scale(0.98);
    transition: transform 0.05s var(--ease);
  }
}

.course-info { flex: 1; min-width: 0; }

.course-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-xs);
  transition: color 0.25s ease;
}

.course-desc {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 65ch;
}

.course-meta {
  flex-shrink: 0;
  padding-top: 2px;
}
.course-term {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--color-text-light);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ============================================
   Contact
   ============================================ */
.contact-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: start;
}

.contact-lead {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.028em;
  margin-bottom: var(--space-lg);
}

.contact-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* contact items — blue line-icon + label + value, list style */
.contact-details {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
}

.contact-glyph {
  flex-shrink: 0;
  color: var(--color-accent);
  margin-top: 4px;
  transition: transform 0.3s var(--ease);
}
.contact-item:hover .contact-glyph {
  transform: translateY(-2px);
}

.contact-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.contact-label {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-light);
}

.contact-item a {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.012em;
  color: var(--color-text);
  border-bottom: 1px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  align-self: flex-start;
}
.contact-item a:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.contact-note {
  padding: var(--space-lg);
  background-color: var(--color-surface);
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border-light);
  transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1),
              box-shadow 0.6s cubic-bezier(0.165, 0.84, 0.44, 1),
              border-color 0.3s ease;
}
@media (hover: hover) {
  .contact-note:hover {
    box-shadow: var(--shadow-lift);
    transform: translateY(-6px) scale(1.01);
    border-color: var(--color-accent);
    z-index: 1;
  }
  .contact-note:hover h3 { color: var(--color-accent); }
  .contact-note:active {
    transform: translateY(2px) scale(0.97);
    box-shadow: var(--shadow-soft);
    transition: transform 0.05s var(--ease), box-shadow 0.05s var(--ease);
  }
}
@media (hover: none) {
  .contact-note:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-soft);
  }
}

.contact-note h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-md);
  color: var(--color-text);
  display: inline-block;
  background-image: linear-gradient(transparent 55%, var(--color-green) 55%, var(--color-green) 95%, transparent 95%);
  padding: 0 8px;
}
.contact-note p {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: 1.65;
}

/* ============================================
   Back to top
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity var(--transition-base),
              visibility var(--transition-base),
              transform var(--transition-base),
              background-color var(--transition-base),
              border-color var(--transition-base),
              color var(--transition-base);
  z-index: 999;
  box-shadow: var(--shadow-soft);
}
.back-to-top:hover {
  background-color: var(--color-green);
  border-color: var(--color-on-green);
  color: var(--color-on-green);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ============================================
   Footer
   ============================================ */
.footer {
  position: relative;
  padding: var(--space-lg) var(--space-lg);
  border-top: 1px solid var(--color-border);
  text-align: center;
  background: var(--color-bg);
  z-index: 2;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer p {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}
.footer-note {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: var(--space-xs);
}

/* ============================================
   Reveal-on-scroll
   ============================================ */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.animate-on-scroll.is-visible {
  opacity: 1;
  transform: none;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .about-content {
    grid-template-columns: 1fr;
  }
  .about-news { position: static; }
}

@media (max-width: 900px) {
  .hero { padding: var(--space-2xl) var(--space-lg); }
  .hero-content {
    grid-template-columns: 1fr;
    text-align: center;
    gap: var(--space-xl);
  }
  .hero-image-wrapper { justify-self: center; }
  .hero-image { width: 220px; height: 220px; }
  .hero-image-initials { font-size: 72px; }
  .hero-greeting { justify-content: center; }
  .hero-interests { justify-content: center; }
  .hero-text { max-width: 100%; }
  .hero-text::before { display: none; }
  .hero-links { justify-content: center; }

  .nav-toggle { display: flex; }

  .nav-inner { flex-wrap: wrap; }
  .nav-inner .nav-logo { flex-shrink: 0; }
  .nav-inner .nav-controls {
    order: 2;
    margin-left: auto;
  }
  .nav-inner .nav-links {
    order: 3;
    width: 100%;
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-left: 0;
    margin-right: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height var(--transition-slow), opacity var(--transition-base);
  }
  .nav-inner .nav-links li { display: block; }
  .nav-inner .nav-links .nav-link {
    padding: var(--space-sm) 0;
    width: fit-content;
  }
  .nav-inner .nav-links .nav-link::after { bottom: 4px; }
  .nav-inner .nav-links.active {
    max-height: 320px;
    opacity: 1;
    padding-bottom: var(--space-sm);
  }

  .pub-row {
    grid-template-columns: 1fr;
    gap: 0;
    padding: var(--space-lg) var(--space-sm);
  }
  .pub-thumb { display: none; }
  .pub:hover .pub-row,
  .pub.open .pub-row { padding-left: var(--space-sm); }

  .course-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .contact-content { grid-template-columns: 1fr; }

  /* Research: stacked rows, compact horizontal cards (like xuanyouliu.com) */
  .projects-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  .project-card {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0;
    min-height: 120px;
    align-items: stretch;
    cursor: pointer;
  }
  .project-image {
    width: 120px;
    min-width: 120px;
    height: 100%;
    aspect-ratio: auto;
    flex-shrink: 0;
  }
  .project-glyph { font-size: 40px; }
  .project-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    min-width: 0;
    overflow: hidden;
  }
  .project-title {
    font-size: 1.0625rem;
    margin-bottom: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .project-desc {
    font-size: 0.9rem;
    max-height: 3.2em;
    margin-bottom: 0;
    transition: max-height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .project-tags {
    flex-shrink: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 0.5s ease, opacity 0.5s ease, margin-top 0.5s ease;
  }
  /* Compact: expand desc + tags on tap (.open), not hover */
  @media (hover: hover) {
    .project-card:hover .project-desc {
      max-height: 3.2em;
    }
    .project-card:hover .project-desc::after {
      opacity: 1;
    }
  }
  .project-card.open .project-content {
    overflow: visible;
  }
  .project-card.open .project-desc {
    max-height: 1000px;
  }
  .project-card.open .project-desc::after {
    opacity: 0;
  }
  .project-card.open .project-tags {
    max-height: 200px;
    opacity: 1;
    margin-top: var(--space-xs);
  }
}

@media (max-width: 640px) {
  .section { padding: var(--space-xl) var(--space-md); }
  .hero { padding: var(--space-2xl) var(--space-md) var(--space-xl); }
  .nav-inner { padding: var(--space-sm) var(--space-md); }
}

/* ============================================
   Reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .dot-canvas { display: none; }
  .cursor-blob { display: none !important; }
  body { cursor: auto; }
}

/* ============================================
   Print
   ============================================ */
@media print {
  body { font-size: 11pt; line-height: 1.45; color: #000; background: #fff; cursor: auto; }
  .scroll-progress, .nav, .footer, .dot-canvas, .cursor-blob, .back-to-top,
  .hero-image-wrapper, .pub-thumb, .project-image, .nav-toggle, .pub-cue { display: none !important; }
  .hero { padding: 0 0 12pt; border-bottom: 1px solid #aaa; }
  .hero-content { grid-template-columns: 1fr !important; padding: 0; gap: 8pt; }
  .section { padding: 12pt 0; break-inside: avoid; background: none; }
  .pub-row { grid-template-columns: 1fr !important; padding: 6pt 0 !important; }
  .pub-expand { max-height: none !important; opacity: 1 !important; margin-top: 6pt !important; }
  .about-content, .contact-content, .projects-grid { grid-template-columns: 1fr !important; gap: 8pt; }
  a { color: #000; text-decoration: underline; }
}
