@font-face {
  font-family: 'AdelleMono';
  src:
    url('../fonts/AdelleMonoFlex-Light.otf') format('opentype'),
    url('../fonts/AdelleMonoFlex-Light.woff') format('woff'),
    url('../fonts/AdelleMonoFlex-Light.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
}

:root {
  color-scheme: light dark;
  --bg: #ebebeb;
  --bg-alt: #ebebeb;
  --text: #21201E;
  --muted: #21201E;
  --accent: #326bfc;
  --accent-dark: #000000;
  --accent-light: #F0F0F0;
  --border: #21201E;
  --shadow: none;
  --link: var(--accent-dark);
  --link-hover: var(--accent);
  --link-underline: currentColor; /* underline color */
  font-size: 16px;
}

::-webkit-scrollbar {
  width: 6px; /* Set the width of the scrollbar */
  background-color: var(--bg); /* Set the background color of the scrollbar */
}

/* Customize the scrollbar track */
::-webkit-scrollbar-track {
  background: none;
}

/* Customize the scrollbar thumb */
::-webkit-scrollbar-thumb {
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--border);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "AdelleMono", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  scrollbar-gutter: stable;
}

.hero canvas { will-change: filter; }

.cv-page embed, iframe {
  width: 100%;
  height: 80vh; /* dynamic height, fills most of viewport */
  border: 1px solid var(--border);
  border-radius: 4px;
  flex: 1;
}

.accent-dark {
  color: var(--accent-dark);
  font-weight: 600; /* optional — adds a subtle emphasis */
}

a {
  color: var(--accent-dark);
  text-decoration: underline;
}

a:hover,
a:focus {
  color: var(--accent);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.navbar {
  width: min(1200px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  gap: 1.5rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
}

.brand:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: none;
}

.brand span {
  font-size: 0.9rem;
  color: var(--muted);
}


.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  text-decoration: none;
}

.nav-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  transition: color 0.2s ease;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus {
  color: var(--accent-dark);
  text-decoration: underline;
}

.nav-links a.active {
  color: var(--text);
  text-decoration: none;
}

/* Arrow for the active link */
.nav-links a.active::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;               /* anchor arrow just above the text */
  transform: translate(-50%, 4px);  /* adjust vertical offset */
  width: 14px;
  height: 10px;
  z-index: 10;                /* ensures it appears above other elements */
  pointer-events: none;       /* don’t block clicks */

  background-color: currentColor;

  /* Masked SVG so the arrow tints perfectly */
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 16'><path d='M4 4l8 8 8-8' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 16'><path d='M4 4l8 8 8-8' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / contain;
}

.social-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.social-links a {
  color: var(--accent-dark);
  transition: color 0.2s ease;
}

.social-links a:hover,
.social-links a:focus {
  color: var(--accent);
}

main {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.hero {
  position: relative;
  min-height: clamp(420px, 60vh, 720px);
  height: 100%; /* Fill entire viewport */
  width: 100%;
  margin-top: -1px;
  border-radius: 0;
  overflow: hidden;
  background: var(--bg-alt);
  box-shadow: none;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  padding: clamp(2.5rem, 6vw, 4rem);
}

.hero canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none; /* clicks go to your links/text */
  padding: 0;
}

#hero-p5 {
  position: absolute;
  inset: 0;
  z-index: 0; /* behind text */
}

.hero-content {
  position: relative;
  max-width: 900px;
  text-align: center;
  z-index: 1;
  color: var(--text);
}

.hero-content h2 {
  margin: 0 0 1rem;
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero-content p {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  line-height: 1.6;
  color: var(--text);
}

.hero .hero-content {
  position: relative;
  z-index: 1;
}

.animation-controls {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  z-index: 2;
  flex-wrap: wrap;
  justify-content: center;
}

.animation-controls button {
  border: 1px solid var(--text);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.animation-controls button:active {
  background: var(--accent-dark);
  color: #fff;
  border-color: #fff;
}

.animation-controls .scroll-down {
  width: 48px;
  height: 48px;
  padding: 0;                 /* override the pill padding */
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.animation-controls .scroll-down svg {
  display: block;
}

.animation-controls .scroll-down[data-active="true"],
.animation-controls .scroll-down:hover,
.animation-controls .scroll-down:focus-visible {
   background: var(--accent-dark);
   color: #fff;
   border-color: #fff;
}
.animation-controls .scroll-down:hover {
  color: #ffffff; /* this automatically recolors the SVG */
}

.animation-controls button.seed-button {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.animation-controls .seed-button svg {
  display: block;
}
.animation-controls .seed-button[data-active="true"],
.animation-controls .seed-button:hover,
.animation-controls .seed-button:focus-visible {
   background: var(--accent-dark);
   color: #fff;
   border-color: #fff;
}
.animation-controls .seed-button:hover {
  color: #ffffff; /* this automatically recolors the SVG */
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  grid-template-rows: auto auto auto; /* 3 rows: research, publications, contact */
  gap: 0;
  margin-top: -1px;
  align-items: stretch;
}

.bio-card {
  position: sticky;
  top: clamp(5rem, 8vh, 7rem);
  align-self: stretch;
  height: 100%;
  min-height: 0;
  padding: 2rem 1.75rem calc(2rem - 2px);
  background: var(--bg-alt);
  border-radius: 0;
  border: 1px solid var(--border);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow: hidden;
}
/* Place bio in col 1, spanning first two rows */
.bio-card {
  grid-column: 1;
  grid-row: 1 / span 2;   /* bio covers rows 1–2 */
  position: relative;
  top: auto;

  /* Critical bits: */
  contain: size;          /* prevent its content from contributing to row sizing */
  min-height: 0;          /* allow the grid to be smaller than the content */
  height: auto;           /* height comes from the two rows (row1 + row2) */
  overflow: auto;         /* scroll inside when content is taller than its area */
}

.bio-card header {
  position: static;
  border: none;
  background: none;
  padding: 0;
}

.bio-card .bio-scroll {
  overflow-y: auto;
  padding-right: 0.5rem;
  flex: 1;
  min-height: 0;
}

.bio-card .bio-scroll::-webkit-scrollbar {
  width: 6px;
}

.bio-card .bio-scroll::-webkit-scrollbar-thumb {
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.bio-card h3 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--accent-dark)
}

.bio-card img {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto;
  border: 4px solid rgba(255, 255, 255, 0.12);
}

.bio-card p {
  margin: 0 0 1rem;
  line-height: 1.65;
  color: var(--muted);
  font-size: 0.95rem;
}

/* New bottom-left animation card */
.animation-card {
  grid-column: 1;
  grid-row: 3;                   /* bottom-left cell */
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;

  contain: size;                 /* don't let content affect row sizing */
  overflow: hidden;

  display: grid;
  grid-template-rows: 1fr;
  align-items: stretch;
  justify-items: stretch;
  border-top-width: 0;
  margin-bottom: 1px;
}

.animation-card canvas {
  width: 100%;
  height: 100%;                  /* fill the contact row's height */
  display: block;
}

#side-canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
}

.content-column {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  grid-template-rows: auto auto auto; /* research, publications, contact */
  row-gap: 0;                         /* ← flush stack: no vertical gap */
  gap: 0;                             /* ensure no implicit grid gap */
  margin-left: -1px;                  /* keep your center seam alignment */
}

.content-column > section {
  align-self: start;
  height: auto;         /* override any "height: 100%" rules */
  min-height: 0;        /* allow rows to be as small as content */
}
.content-column > section {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.section-card {
  padding: clamp(1.75rem, 4vw, 2.5rem);
  background: var(--bg-alt);
  border-radius: 0;
  border: 1px solid var(--border);
  box-shadow: none;
}

.content-column .section-card + .section-card {
  margin-top: -1px;
}

.section-card[aria-labelledby="publications-heading"] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: -1px;
  border-top-width: 0;
}

.section-card[aria-labelledby="publications-heading"] ul {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.75rem;
  scrollbar-width: thin;
}

.section-card[aria-labelledby="contact-heading"] {
  margin-top: -1px;
  border-top-width: 0;
}

.section-card h2 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: clamp(1.3rem, 2.8vw, 1.6rem);
}

.section-card p,
.section-card li {
  color: var(--muted);
  line-height: 1.7;
  font-size: 1rem;
}

.section-card ul {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.75rem;
}

.section-card .tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.section-card .tag {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #ffffff;
  background: var(--accent);
  border-radius: 999px;
  font-size: 0.85rem;
}

.contact-grid {
  display: grid;
  gap: 0.9rem;
}

.contact-grid a {
  font-weight: 500;
  text-decoration: underline;
  color: var(--accent-dark);
}
.contact-grid a:hover,
.contact-grid a:focus {
  color: var(--accent);
  text-decoration: underline;
}

.research-card,
.contact-card {
  height: auto !important;
  min-height: 0 !important;
  align-self: start !important;
}

.publications-card {
  max-height: 400px;        /* or whatever height works for you */
  overflow-y: auto;         /* vertical scroll only when needed */
  padding-right: 1rem;
}

.publications-card .publications-scroll {
  overflow-y: auto;
  padding-right: 0.5rem;
  flex: 1;
  min-height: 0;
}

.publications-card .publications-scroll::-webkit-scrollbar {
  width: 6px;
}

.publications-card .publications-scroll::-webkit-scrollbar-thumb {
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.bio-card,
.animation-card {
  height: auto;      /* JS will set explicit px heights */
  min-height: 0;     /* don’t force taller than needed */
  overflow: auto;    /* show scrollbar if content overflows */
}

.cv-page section-card {
  min-height: 80vh; /* gives it tall space for the PDF */
  height: auto;     /* allows it to expand if PDF is taller */
}

footer {
  margin: 4rem auto 2rem;
  width: min(1200px, 100%);
  padding: 0 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 1024px) {
  .navbar {
    padding: 1rem;
  }
  main {
    padding: 0 1rem 3.5rem;
  }
  .hero {
    margin-top: 0;
    border-radius: 0;
  }
  .layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 0;
  }
}

@media (max-width: 860px) {
  .cv-page iframe,
  .cv-page embed {
    display: none;
  }

  .cv-page .pdf-fallback {
    display: block;
    margin-top: 1rem;
  }

  .hero {
    margin-top: -1px;   /* was 0 on tablet; restore -1px on mobile */
  }

  .navbar {
    display: grid;
    grid-template-columns: 1fr auto; /* brand grows, socials hug right */
    grid-template-rows: auto auto;   /* links live on their own bottom row */
    align-items: end;                /* keep things visually “bottom-aligned” */
    gap: 0.5rem 1rem;
    padding: 0.75rem 1rem;           /* a touch tighter on mobile */
  }

  .brand {
    grid-column: 1 / -1;
    grid-row: 1;
    /* let it breathe more horizontally on mobile */
    max-width: none;
  }

  .social-links {
    grid-column: 2 / 3;
    grid-row: 2;
    justify-self: end;
    align-self: center;
    padding-top: 0.75rem;
  }

  .nav-links {
    grid-column: 1 / 2;   /* span full width under brand/socials */
    grid-row: 2;
    align-self: end;
    display: flex;
    flex-wrap: nowrap;     /* force a single horizontal row */
    gap: 0.75rem;
    justify-content: flex-start;
    /* optional: nudge closer to the header’s bottom edge */
    padding-top: 0.75rem;
  }

  .layout {
    grid-template-columns: 1fr;       /* already there */
    grid-template-rows: auto auto auto auto; /* bio, content, animation, (footer outside) */
  }

  .content-column {
    grid-column: 1;
    grid-row: 2;                      /* right stack next */
    display: flex;                    /* you already switch to flex; keep it */
    flex-direction: column;
    margin-left: 0;
  }

  .animation-card {
    grid-column: 1;
    grid-row: 3;                      /* animation follows under content */
  }
  .animation-card {
    scrollbar-width: none;        /* Firefox */
  }
  .animation-card::-webkit-scrollbar {
    display: none;                /* Chrome/Safari */
  }

  .animation-card,
  #side-canvas,
  .aniamtion-card canvas {
    overflow: hidden !important;
    overscroll-behavior: contain; 
  }

  .bio-card {
    grid-column: 1;
    grid-row: 1;
    position: relative;               /* ensure not sticky on mobile */
    top: auto;
    height: auto;
    margin-bottom: -1px;
    max-height: 68vh;            /* adjust to taste */
    display: flex;               /* already flex; keep it explicit */
    gap: 1rem;                   /* slightly tighter */
    padding-bottom: 1rem;        /* trim bottom space */
  }
  .bio-card img {
    flex: 0 0 auto;              /* don’t let headshot steal flex height */
    margin-bottom: 0.25rem;
  }
}

@media (max-width: 560px) {
  .hero {
    padding: 2.25rem 1.75rem 3.5rem;
    margin-top: -1px;
  }
  .animation-controls {
    position: static;
    transform: none;
    margin-top: 1.75rem;
  }
  .hero-content p {
    font-size: 1rem;
  }
  .section-card {
    padding: 1.5rem;
    border-radius: 0;
  }
  .bio-card {
    padding: 1.5rem;
    border-radius: 0;
    margin-bottom: -1px;
  }
}
