/* ========================================
   Theme Variables
======================================== */

:root {
  /* Typography */
  --font-hero: clamp(30px, 7.2vw, 72px);
  --font-section: clamp(24px, calc(17.677px + 2.258vw), 38px);
  --font-title: clamp(14px, calc(9.484px + 1.613vw), 24px);
  --font-school: clamp(14px, calc(9.484px + 1.613vw), 24px);
  --font-body: clamp(11px, calc(8.742px + 0.806vw), 16px);
  --font-description: clamp(10px, calc(8.194px + 0.645vw), 14px);
  --font-small: clamp(8px, calc(5.742px + 0.806vw), 13px);
  --font-project: clamp(10px, calc(7.290px + 0.968vw), 16px);
  --font-meta: clamp(8px, calc(5.742px + 0.806vw), 13px);
  --font-subdate: clamp(7px, calc(4.742px + 0.806vw), 12px);
  --font-entry-year: clamp(10px, calc(7.290px + 0.968vw), 16px);
  --font-link: clamp(7px, calc(4.290px + 0.968vw), 13px);
  --font-paper-link: clamp(7px, calc(3.839px + 1.129vw), 14px);
  --font-award: clamp(8px, calc(5.742px + 0.806vw), 13px);
  --font-footer: clamp(8px, calc(5.742px + 0.806vw), 13px);

  color-scheme: light;

  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #172c45;
  --muted: #657385;
  --accent: #357f86;
  --accent-soft: #e4f0ef;
  --border: #e1e8ed;
  --shadow: 0 12px 32px rgba(23,44,69,.06);
  --grid-color: rgba(53, 127, 134, 0.035);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #101923;
  --surface: #192633;
  --text: #edf3f7;
  --muted: #a3b2bf;
  --accent: #80c9ce;
  --accent-soft: #253f44;
  --border: #304151;
  --shadow: 0 12px 32px rgba(0,0,0,.2);
  --grid-color: rgba(160, 205, 210, 0.025);
}

/* ========================================
   Base Styles
======================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;

  background-color: var(--bg);
  background-image:
    linear-gradient(
      to right,
      var(--grid-color) 1px,
      transparent 1px
    ),
    linear-gradient(
      to bottom,
      var(--grid-color) 1px,
      transparent 1px
    );

  background-size: 48px 48px;

  color: var(--text);
  font-family: "Inter", -apple-system,
    BlinkMacSystemFont, "Segoe UI",
    Arial, sans-serif;
  line-height: 1.75;

  transition: background-color .25s, color .25s;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

button {
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.container {
  width: min(1080px, calc(100% - 48px));
  margin: 0 auto;
}

h1, h2, h3 {
  line-height: 1.25;
}

h2 {
  margin: 0 0 20px;
  font-size: var(--font-section);
  letter-spacing: -1px;
}

h3 {
  margin: 12px 0;
  font-size: var(--font-title);
}

p {
  color: var(--muted);
  margin: 10px 0;
  font-size: var(--font-body);
}

/* ========================================
   Navigation
======================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: clamp(52px, calc(45px + 2.5vw), 72px);
  user-select: none;
  -webkit-user-select: none;
}

.logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  width: clamp(60px, calc(53px + 2.5vw), 72px);

  padding:
    clamp(5px, calc(3.25px + 0.625vw), 8px)
    clamp(5px, calc(2.08px + 1.042vw), 10px);

  flex-shrink: 0;

  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.15;

  border-radius: 10px;

  /* Prevent text selection */
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;

  /* Hover animation */
  transition: background 0.2s ease;
}

.logo:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.logo-zh,
.logo-en {
  display: block;
  width: 100%;
  text-align: center;
}

.logo-zh {
  font-family: "Noto Serif TC", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.logo-en {
  margin-top: 3px;
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-nav a {
  font-size: clamp(10px, calc(8.194px + 0.645vw), 14px);
  font-weight: 550;
  transition: color .2s;
}

.site-nav a.active {
  color: var(--accent);
}

.nav-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(32px, calc(27.33px + 1.667vw), 40px);
  height: clamp(32px, calc(27.33px + 1.667vw), 40px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface);
}

/* SVG Icons */
.theme-icon,
.menu-icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;

  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

/* Theme Icons */
.theme-icon .sun-shape {
  display: none;
}

:root[data-theme="dark"] .theme-icon .moon-shape {
  display: none;
}

:root[data-theme="dark"] .theme-icon .sun-shape {
  display: inline;
}

/* Menu Icons */
.menu-icon .close-shape {
  display: none;
}

#menu-toggle[aria-expanded="true"] .menu-icon .menu-shape {
  display: none;
}

#menu-toggle[aria-expanded="true"] .menu-icon .close-shape {
  display: inline;
}

.icon-button:hover {
  border-color: var(--accent);
}

.menu-toggle {
  display: none;
}

/* ========================================
   Hero
======================================== */

.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  align-items: center;
  gap: 70px;
  padding: 100px 0;
}

.eyebrow {
  color: var(--accent);
  font-size: clamp(7.5px, 1.9vw, 12px);
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.hero h1 {
  margin: 16px 0;
  font-size: var(--font-hero);
  letter-spacing: -2.5px;
}

.hero-description {
  max-width: 580px;
  margin-top: 20px;
}

.hero-visual {
  text-align: center;
  width: min(85%, 360px);
}

.portrait-placeholder {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  min-height: 0;
  overflow: hidden;

  border: 2px solid var(--accent);
  border-radius: 18px;

  background: var(--surface);

  box-shadow:
    10px 10px 0 var(--accent-soft),
    0 14px 35px rgba(23, 44, 69, 0.10);

  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.profile-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;

  transition: transform 0.4s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;

  pointer-events: none;
  -webkit-touch-callout: none;
}

/* Hover Animation */

.portrait-placeholder:hover .profile-photo {
  transform: scale(1.035);
}

/* CV link next to name */

.hero-cv-link {
  display: inline-flex;
  align-items: center;
  padding:
    clamp(2px, calc(0.38px + 0.58vw), 5px)
    clamp(5px, calc(2.31px + 0.96vw), 10px);

  margin-left: clamp(3px, calc(0.31px + 0.96vw), 8px);

  border: 1px solid var(--border);
  border-radius: clamp(4px, calc(2.92px + 0.38vw), 6px);
  background: var(--surface);

  color: var(--accent);
  font-size: clamp(9px, calc(6.85px + 0.77vw), 13px);

  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  -webkit-user-select: none;

  transition:
    border-color 0.2s,
    background 0.2s;
}

.hero-cv-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ========================================
   Sections
======================================== */

section {
  padding: 70px 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: 95px;
}

.section-heading {
  margin-bottom: 30px;
}

/* ========================================
   Publications
======================================== */

.entry {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 25px;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.entry-year {
  color: var(--accent);
  font-size: var(--font-entry-year);
  font-weight: 700;
}

.entry h3 {
  margin-top: 0;
}

.publication-authors strong {
  font-weight: 700;
  color: inherit;
}

/* Publication award */

.publication-award {
  display: inline-block;
  margin: 12px 0;
  padding: 5px 11px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--font-award);
  font-weight: 650;
  user-select: none;
  -webkit-user-select: none;
}

/* Publication links */

.paper-link {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent);
  font-size: var(--font-paper-link);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: baseline;
  user-select: none;
  -webkit-user-select: none;
}

.paper-link:hover {
  text-decoration: underline;
}

/* ========================================
   Education Timeline
======================================== */

.timeline {
  --tl-line: 2px;
  --tl-indent: 26px;
  --tl-axis: -27px;
  --tl-dot: 10px;
  --tl-branch: 20px;
  --tl-branch-line: 1.5px;

  border-left: var(--tl-line) solid var(--border);
  padding-left: var(--tl-indent);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 35px;
}

.timeline-date {
  position: relative;
  align-self: start;

  color: var(--accent);
  font-size: var(--font-small);
  font-weight: 650;
  white-space: nowrap;
}

/* Timeline dot */

.timeline-date::before {
  content: "";
  position: absolute;

  left: var(--tl-axis);
  top: 50%;

  width: var(--tl-dot);
  height: var(--tl-dot);
  border-radius: 50%;
  background: var(--accent);

  transform: translate(-50%, -50%);
}

/* Main Timeline Branch */

.timeline-date::after {
  content: "";
  position: absolute;

  left: var(--tl-axis);
  top: 50%;

  width: var(--tl-branch);
  height: var(--tl-branch-line);

  background: var(--accent);
  opacity: 0.75;

  transform: translateY(-50%);
}

.timeline-item h3 {
  margin-top: 0;
}

.timeline-item p {
  margin: 4px 0;
}

/* Timeline Heading with Location */

.timeline-heading {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.timeline-heading > h3,
.timeline-heading > p {
  flex: 1 1 240px;
  min-width: 0;
  margin: 0 0 8px;
}

.timeline-location {
  margin-left: auto;
  padding-top: 2px;

  color: var(--muted);
  opacity: 0.75;

  font-size: 11px;
  font-weight: 400;
  line-height: 1.75;
  text-align: right;
  white-space: nowrap;
}

.school-title {
  display: flex;
  align-items: center;
  gap: clamp(6px, calc(2.77px + 1.154vw), 12px);
  margin: 0 0 10px;
}

/* Higher specificity keeps school font independent of other h3 titles. */
.timeline-item h3.school-title {
  font-size: var(--font-school);
}

.school-logo {
  --logo-size: clamp(18px, calc(13.7px + 1.54vw), 28px);

  width: var(--logo-size);
  height: var(--logo-size);

  object-fit: contain;
  flex-shrink: 0;

  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  -webkit-touch-callout: none;
}

.school-title span {
  min-width: 0;
}

/* ========================================
   Nested Research Timeline
======================================== */

.research-subtimeline {
  --sub-line: 1px;
  --sub-indent: 24px;
  --sub-axis: -24.5px;
  --sub-branch-left: -27px;
  --sub-dot: 7px;
  --sub-branch: 17px;

  position: relative;
  margin-top: 20px;
  margin-left: 6px;
  padding-left: var(--sub-indent);
  border-left: var(--sub-line) solid var(--border);
}

.research-subitem {
  position: relative;
  padding-bottom: 22px;
}

.research-subitem:last-child {
  padding-bottom: 0;
}

/* Date */

.research-subdate {
  position: relative;
  display: block;

  color: var(--accent);
  font-size: var(--font-subdate);
  font-weight: 600;
  line-height: 1.6;
}

/* Horizontal branch */

.research-subdate::before {
  content: "";
  position: absolute;

  left: var(--sub-branch-left);
  top: 50%;

  width: var(--sub-branch);
  height: var(--sub-line);

  background: var(--accent);
  transform: translateY(-50%);
}

/* Timeline dot */

.research-subdate::after {
  content: "";
  position: absolute;

  left: var(--sub-axis);
  top: 50%;

  width: var(--sub-dot);
  height: var(--sub-dot);
  border-radius: 50%;

  background: var(--accent);
  transform: translate(-50%, -50%);
}

/* Project titles */
.research-subitem h4 {
  margin: 5px 0 8px;

  color: var(--text);
  font-size: var(--font-project);
  font-weight: 650;
  line-height: 1.4;
}

/* Research Department */
.research-subitem .research-department {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--font-meta);
  font-weight: 400;
  line-height: 1.6;
}

/* Teaching Assistant Course */
.timeline-item .experience-course {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: var(--font-meta);
  font-style: italic;
  line-height: 1.5;
}

/* Experience Descriptions */
.timeline-item p.experience-description,
.research-subitem p.experience-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--font-description);
  font-weight: 400;
  line-height: 1.65;
}

/* ========================================
   Experience Links
======================================== */

.experience-link {
  display: inline-block;
  margin-left: 5px;

  color: var(--accent);
  font-size: var(--font-link);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: baseline;
  user-select: none;
  -webkit-user-select: none;

  transition: opacity 0.2s ease;
}

.experience-link:hover {
  opacity: 0.7;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ========================================
   Footer
======================================== */

.footer {
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 25px 0;
  user-select: none;
  -webkit-user-select: none;
}

.footer p {
  font-size: var(--font-footer);
}

/* Footer Links */

.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 22px;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: clamp(4px, calc(2.38px + 0.577vw), 7px);

  color: var(--muted);
  font-size: var(--font-footer);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;

  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-icon {
  width: clamp(11px, calc(8.31px + 0.962vw), 16px);
  height: clamp(11px, calc(8.31px + 0.962vw), 16px);
  flex-shrink: 0;
}

/* ========================================
   Back to Top
======================================== */

.back-to-top {
  --backtop-offset: clamp(12px, calc(3.385px + 3.077vw), 28px);
  position: fixed;
  right: var(--backtop-offset);
  bottom: var(--backtop-offset);
  z-index: 80;
  width: clamp(32px, calc(24.462px + 2.692vw), 46px);
  height: clamp(32px, calc(24.462px + 2.692vw), 46px);
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: clamp(16px, calc(12.769px + 1.154vw), 22px);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  user-select: none;
  -webkit-user-select: none;

  transition:
    opacity .2s,
    transform .2s,
    visibility .2s;
}

.back-to-top.is-visible {
  opacity: 0.85;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top.is-visible:hover {
  opacity: 1;
}

/* ========================================
   Responsive Design
======================================== */

@media (max-width: 760px) {

  .container {
    width: min(100% - 32px, 1080px);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .site-nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;

    width: calc(100vw - 24px);
    transform: translateX(-50%);

    flex-direction: column;
    align-items: stretch;
    gap: 0;

    padding: 0 15px;
    max-height: 0;
    overflow: hidden;

    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);

    visibility: hidden;
    pointer-events: none;

    transition:
      max-height 0.25s ease,
      padding 0.25s ease,
      visibility 0s linear 0.25s;
  }

  .site-nav.is-open {
    max-height: 600px;
    padding:
      clamp(8px, calc(3.917px + 1.458vw), 15px)
      15px;

    visibility: visible;
    pointer-events: auto;

    transition:
      max-height 0.25s ease,
      padding 0.25s ease,
      visibility 0s;
  }

  .site-nav a {
    padding: clamp(12px, calc(7.333px + 1.667vw), 20px) 12px;
    text-align: center;
  }

  .site-nav a + a {
    position: relative;
  }

  .site-nav a + a::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);

    width: 75%;
    height: 1px;
    background: var(--border);
  }

  .entry,
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  section {
    padding: 55px 0;
    scroll-margin-top: 85px;
  }
}

/* ========================================
   Accessibility
======================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

#publications .entry:last-child,
#honors .entry:last-child {
  border-bottom: none;
}

/* Responsive Hero */

@media (max-width: 1100px) {
  .hero {
    grid-template-columns:
      minmax(0, 1.5fr)
      minmax(0, 1fr);
    column-gap: clamp(
      24px,
      calc(15.333vw - 98.667px),
      70px
    );
    row-gap: 30px;
  }

  .hero-content {
    display: contents;
  }

  /* Full-width heading */
  .hero-heading {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
  }

  .hero-heading h1 {
    white-space: nowrap;
  }

  /* Biography on the left */
  .hero-bio {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
  }

  /* Portrait on the right */
  .hero-visual {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    min-width: 0;
  }
}

/* ========================================
   Mobile Hero: Heading + Circular Portrait
======================================== */

@media (max-width: 800px) {

  .hero {
    grid-template-columns:
      minmax(0, 1fr)
      clamp(80px, 22vw, 115px);

    column-gap: 12px;
    row-gap: 16px;
    padding: 45px 0;
  }

  /* Allow heading and bio to use the Hero Grid */
  .hero-heading {
    display: contents;
  }

  /* Left: Eyebrow */
  .hero-heading .eyebrow {
    grid-column: 1;
    grid-row: 1;

    margin: 0;
    min-width: 0;

    letter-spacing: 0;
    white-space: normal;
  }

  /* Left: Name + CV */
  .hero-heading h1 {
    grid-column: 1;
    grid-row: 2;

    margin: 0;
    line-height: 1.2;
    letter-spacing: -1px;
    white-space: normal;
  }

  /* Right: Portrait spanning eyebrow and name */
  .hero-visual {
    grid-column: 2;
    grid-row: 1 / 3;

    width: 100%;
    justify-self: end;
  }
  
  /* Circular Portrait */
  .portrait-placeholder {
    aspect-ratio: 1 / 1;
    border-radius: 50%;

    box-shadow:
      4px 4px 0 var(--accent-soft),
      0 8px 18px rgba(23, 44, 69, 0.08);
  }

  .profile-photo {
    object-position: center 35%;
  }

  /* Bottom: Full-width Biography */
  .hero-bio {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .hero-description {
    max-width: none;
  }
}

/* ========================================
   Responsive Footer
======================================== */

@media (max-width: 800px) {

  .footer-links a[href*="scholar.google.com"],
  .footer-links a[href*="orcid.org"] {
    display: none;
  }

  .footer-inner {
    align-items: center;
    gap: 16px;
  }

  .footer-inner > p {
    margin: 0;
    white-space: nowrap;
  }

  .footer-links {
    flex-wrap: nowrap;
    gap: 14px;
  }
}

@media (max-width: 520px) {

  .footer-inner {
    flex-direction: column-reverse;
    gap: 8px;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Reduce spacing between Contact and Footer */

#contact {
  padding-bottom: 30px;
}

/* ========================================
   Responsive Typography
======================================== */

@media (max-width: 900px) {

  /* Hide locations */
  .timeline-location {
    display: none;
  }
}

/* ========================================
   Small Screens: 600px and Below
======================================== */

@media (max-width: 600px) {

  /* Hero layout */
  .hero {
    row-gap: 14px;
  }

  .hero-heading h1 {
    align-self: center;
    overflow-wrap: break-word;
  }

  /* Prevent grid content from overflowing */
  .entry,
  .timeline-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry > div,
  .timeline-item > div {
    min-width: 0;
  }
}

/* ========================================
   Very Small Screens: 320px and Below
======================================== */

@media (max-width: 320px) {

  /* Container */
  .container {
    width: calc(100% - 24px);
  }

  /* Navigation */
  .nav-inner {
    gap: 8px;
  }

  .nav-actions {
    gap: 5px;
  }

  /* Very Small Hero */
  .hero {
    row-gap: 12px;
  }

  .hero-heading h1 {
    letter-spacing: -0.5px;
  }

  /* Sections */
  section {
    padding: 40px 0;
  }

  .section-heading {
    margin-bottom: 20px;
  }

  /* Allow timeline dates to wrap on very narrow screens */
  .timeline-date {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Footer */
  .footer-inner {
    padding: 18px 0;
  }

  .footer-links {
    gap: 10px;
  }
}

/* ========================================
   Responsive Timeline
======================================== */

/* Tablet */
@media (max-width: 800px) {
  .timeline {
    --tl-line: 1.5px;
    --tl-indent: 24px;
    --tl-axis: -24.75px;
    --tl-dot: 8px;
    --tl-branch: 16px;
    --tl-branch-line: 1px;
  }

  .research-subtimeline {
    --sub-indent: 22px;
    --sub-axis: -22.5px;
    --sub-branch-left: -25px;
    --sub-dot: 6px;
    --sub-branch: 15px;
  }
}

/* Small Screens */
@media (max-width: 500px) {
  .timeline {
    --tl-line: 1px;
    --tl-indent: 20px;
    --tl-axis: -20.5px;
    --tl-dot: 7px;
    --tl-branch: 13px;
    --tl-branch-line: 1px;
  }

  .research-subtimeline {
    --sub-indent: 18px;
    --sub-axis: -18.5px;
    --sub-branch-left: -21px;
    --sub-dot: 5px;
    --sub-branch: 12px;
  }
}

/* Very Small Screens */
@media (max-width: 320px) {
  .timeline {
    --tl-indent: 16px;
    --tl-axis: -16.5px;
    --tl-dot: 6px;
    --tl-branch: 11px;
  }

  .research-subtimeline {
    --sub-indent: 15px;
    --sub-axis: -15.5px;
    --sub-branch-left: -17px;
    --sub-dot: 4px;
    --sub-branch: 10px;
    margin-left: 0;
  }
}

/* ========================================
   Hero Layout: 987.5px – 1100px
======================================== */

@media (min-width: 987.5px) and (max-width: 1100px) {

  /* Keep heading and biography together */
  .hero-content {
    display: block;
    min-width: 0;
  }

  /* Allow the name to wrap if necessary */
  .hero-heading h1 {
    white-space: normal;
  }

  /* Portrait beside all text */
  .hero-visual {
    grid-column: 2;
    grid-row: 1;
  }
}

/* ========================================
   Hero Layout: 370px and Below
======================================== */

@media (max-width: 370px) {

  /* Single-column layout */
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Centered portrait below biography */
  .hero-visual {
    grid-column: 1;
    grid-row: 4;

    width: min(70%, 220px);
    justify-self: center;
    align-self: start;
  }

  /* Square portrait with rounded corners */
  .portrait-placeholder {
    border-radius: 18px;

    box-shadow:
      6px 6px 0 var(--accent-soft),
      0 10px 25px rgba(23, 44, 69, 0.10);
  }

  .profile-photo {
    object-position: center;
  }
}

/* ========================================
   Minimum Viewport Width: 300px
======================================== */

@media (max-width: 300px) {
  body {
    width: 300px;
  }
}





/* ========================================
   Viewport Debug
======================================== */

/* Width indicator */
/* .viewport-debug {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 9999;

  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;

  background: var(--surface);
  color: var(--accent);

  font-family: monospace;
  font-size: 13px;
  font-weight: 600;

  opacity: 0.85;
  pointer-events: none;
  user-select: none;
} */

/* Background width ruler */
/* body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;

  background-image:
    repeating-linear-gradient(
      to right,
      rgba(53, 127, 134, 0.12) 0 1px,
      transparent 1px 100px
    );
} */
