:root {
  --bg: #0a0e1f;
  --fg: #f5f7fa;
  --muted: #a6adc4;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --navbar-bg: rgba(10, 14, 31, 0.5);
  --navbar-bg-scrolled: rgba(10, 14, 31, 0.85);

  /* knowledge-areas categorical palette — validated adjacent-CVD order for this bg */
  --thread-perception: #3987e5;
  --thread-embedded: #d95926;
  --thread-coordination: #199e70;
  --thread-navigation: #c98500;
  --thread-control: #d55181;
  --thread-ai: #008300;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- animated background ---------- */

.bg-animated {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 45vmax;
  height: 45vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.45;
  mix-blend-mode: screen;
  will-change: transform;
}

.blob-a {
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  top: -10%;
  left: -10%;
  animation: drift-a 26s ease-in-out infinite;
}

.blob-b {
  background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
  bottom: -15%;
  right: -10%;
  animation: drift-b 34s ease-in-out infinite;
}

.blob-c {
  background: radial-gradient(circle, #7c6cf1 0%, transparent 70%);
  top: 30%;
  left: 40%;
  animation: drift-c 42s ease-in-out infinite;
}

@keyframes drift-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(15vw, 10vh) scale(1.15); }
}

@keyframes drift-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-12vw, -14vh) scale(1.1); }
}

@keyframes drift-c {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-40%, -60%) scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
  .blob {
    animation: none;
  }
}

/* ---------- navbar ---------- */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  background: var(--navbar-bg);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.navbar.scrolled {
  background: var(--navbar-bg-scrolled);
  border-bottom-color: var(--glass-border);
}

.navbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--fg);
}

/* ---------- hero ---------- */

.hero {
  min-height: 100vh;
  max-width: 860px;
  margin: 0 auto;
  padding: 5rem 1.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.hero-figure {
  /* capped by viewport height too, so the hero still fits one screen on short laptops */
  width: min(100%, 720px, 90vh);
  height: auto;
  margin: 0 0 2.75rem;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(56, 189, 248, 0.18);
}

.hero-greeting {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 1.05rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--muted);
  margin: 0 0 2.25rem;
  font-size: 1.1rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem;
}

.hero-link {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.hero-link:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.scroll-cue {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  animation: bounce 2.2s ease-in-out infinite;
}

.scroll-cue svg {
  width: 24px;
  height: 24px;
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-cue {
    animation: none;
  }
}

/* ---------- layout ---------- */

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  position: relative;
}

section {
  margin-bottom: 2rem;
}

.section-divider {
  position: relative;
  height: 1px;
  margin: 0.5rem auto 4rem;
  max-width: 320px;
  background: linear-gradient(90deg, transparent, var(--glass-border) 50%, transparent);
}

.section-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 72%);
  filter: blur(6px);
  opacity: 0.5;
  animation: divider-glow 5s ease-in-out infinite;
}

@keyframes divider-glow {
  0%, 100% {
    opacity: 0.32;
    transform: translate(-50%, -50%) scale(0.85);
  }
  50% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  .section-divider::before {
    animation: none;
    opacity: 0.45;
  }
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.section-heading .external {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.section-heading .external:hover {
  text-decoration: underline;
}

.loading {
  color: var(--muted);
}

/* ---------- glass card (shared) ---------- */

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 1.75rem;
  transition: background 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
  background: var(--glass-bg-hover);
}

/* ---------- projects ---------- */

.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.project-card--media {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.project-media {
  flex: 0 0 220px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.project-media img {
  width: 100%;
  display: block;
}

.project-body {
  flex: 1;
  min-width: 0;
}

.project-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.project-card p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tag {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.project-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  margin-right: 1rem;
  font-weight: 500;
}

.project-links a:hover {
  text-decoration: underline;
}

/* ---------- teaching ---------- */

.teaching-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.course-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.course-banner {
  height: 100px;
  overflow: hidden;
}

.course-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.course-banner--code {
  background: linear-gradient(135deg, #1d4ed8, #38bdf8);
}

.course-banner--logic {
  background: linear-gradient(135deg, #0891b2, #22d3ee);
}

.course-banner--circuit {
  background: linear-gradient(135deg, #7c3aed, #38bdf8);
}

.course-banner--signal {
  background: linear-gradient(135deg, #0e7490, #7c6cf1);
}

.course-banner--probability {
  background: linear-gradient(135deg, #6d28d9, #0891b2);
}

.course-card .course-code {
  margin: 1.25rem 1.5rem 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.course-card h3 {
  margin: 0.35rem 1.5rem 0.5rem;
  font-size: 1.1rem;
}

.course-card p {
  margin: 0 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.course-institution {
  margin: 0 1.5rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- publications ---------- */

.year-group {
  margin-bottom: 1.25rem;
  padding: 1.75rem;
}

.year-heading {
  font-size: 0.85rem;
  color: var(--accent);
  margin: 0 0 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.pub-item {
  padding-top: 1.1rem;
  border-top: 1px solid var(--glass-border);
}

.pub-item:first-child {
  padding-top: 0;
  border-top: none;
}

.pub-title {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  display: inline-block;
}

.pub-title:hover {
  color: var(--accent);
}

.pub-title--nolink {
  cursor: default;
}

.pub-title--nolink:hover {
  color: var(--fg);
}

.pub-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.pub-meta strong {
  color: var(--fg);
}

.pub-venue {
  font-style: italic;
}

.badge {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  text-decoration: none;
}

.badge:hover {
  background: var(--glass-bg-hover);
}

/* ---------- knowledge areas ---------- */

.knowledge-areas-card {
  padding: 1.75rem 1.75rem 1.25rem;
  margin-bottom: 1.75rem;
}

.knowledge-areas-heading {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.section-sub {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 62ch;
  font-size: 0.92rem;
}

.chart-scroll {
  overflow-x: auto;
}

.chart-scroll svg {
  display: block;
  min-width: 720px;
  width: 100%;
  height: auto;
}

.lane-label {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  fill: var(--fg);
}

.lane-count {
  font-size: 0.85rem;
  fill: var(--muted);
}

.axis-tick {
  font-size: 0.85rem;
  fill: var(--muted);
  font-variant-numeric: tabular-nums;
}

.thread-path {
  stroke-linecap: round;
  fill: none;
}

.thread-stub {
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 1 7;
}

.thread-node {
  transition: filter 0.15s ease;
}

.node-hit {
  fill: transparent;
  cursor: pointer;
}

.node-hit:focus {
  outline: none;
}

.node-hit:focus + .thread-node,
.node-hit:hover + .thread-node {
  filter: brightness(1.35);
}

.bridge-link {
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 1.5;
}

#thread-tooltip {
  position: fixed;
  z-index: 200;
  max-width: 300px;
  pointer-events: none;
  background: rgba(15, 19, 38, 0.92);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

#thread-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

#thread-tooltip .tt-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 0.3rem;
  color: var(--fg);
}

#thread-tooltip .tt-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.55rem;
}

#thread-tooltip .tt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

#thread-tooltip .tt-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--fg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem 0.15rem 0.4rem;
}

#thread-tooltip .tt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--glass-border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.pub-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.pub-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem 0.15rem 0.45rem;
}

.pub-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .thread-node,
  .node-hit {
    transition: none;
  }
}

/* ---------- footer ---------- */

.site-footer {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  position: relative;
}

@media (max-width: 600px) {
  .project-card--media {
    flex-direction: column;
    align-items: stretch;
  }

  .project-media {
    flex-basis: auto;
  }

  .hero {
    padding-top: 7.5rem;
  }

  .nav-links {
    gap: 1rem;
  }
}
