/* ==========================================================================
   Portfolio styles
   Contents: tokens · base · layout · components · header · hero & about ·
             projects · research · experience · skills · contact · footer ·
             motion · print
   ========================================================================== */

/* Tokens ------------------------------------------------------------------- */

:root {
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;

  --container: 72rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --header-h: 4rem;

  --radius-sm: 0.5rem;
  --radius: 0.75rem;
  --radius-lg: 1.125rem;
  --radius-full: 999px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Light theme. EDIT: change the --accent* and --gradient values to re-colour the site. */
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-muted: #52525b;
  --text-subtle: #68686f;
  --accent: #047857;
  --accent-hover: #065f46;
  --accent-contrast: #ffffff;
  --accent-soft: rgb(16 185 129 / 0.12);
  --accent-border: rgb(4 120 87 / 0.28);
  --gradient: linear-gradient(120deg, #047857, #0e7490);
  --header-bg: rgb(250 250 250 / 0.8);
  --grid-line: rgb(24 24 27 / 0.06);
  --glow: rgb(16 185 129 / 0.2);
  --danger: #b91c1c;
  --danger-soft: rgb(220 38 38 / 0.08);
  --warning: #92400e;
  --warning-soft: rgb(245 158 11 / 0.12);
  --shadow-sm: 0 1px 2px rgb(24 24 27 / 0.05);
  --shadow-md: 0 12px 28px -14px rgb(24 24 27 / 0.2);
  --shadow-lg: 0 28px 56px -28px rgb(24 24 27 / 0.32);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #111114;
  --surface-2: #18181b;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-subtle: #8b8b94;
  --accent: #34d399;
  --accent-hover: #6ee7b7;
  --accent-contrast: #022c22;
  --accent-soft: rgb(52 211 153 / 0.12);
  --accent-border: rgb(52 211 153 / 0.3);
  --gradient: linear-gradient(120deg, #34d399, #22d3ee);
  --header-bg: rgb(9 9 11 / 0.72);
  --grid-line: rgb(250 250 250 / 0.06);
  --glow: rgb(52 211 153 / 0.16);
  --danger: #f87171;
  --danger-soft: rgb(248 113 113 / 0.1);
  --warning: #fbbf24;
  --warning-soft: rgb(251 191 36 / 0.1);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 12px 28px -14px rgb(0 0 0 / 0.65);
  --shadow-lg: 0 28px 56px -28px rgb(0 0 0 / 0.75);
}

/* Without JavaScript there is no data-theme attribute, so follow the OS setting (keep in sync with the block above) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #09090b;
    --surface: #111114;
    --surface-2: #18181b;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-subtle: #8b8b94;
    --accent: #34d399;
    --accent-hover: #6ee7b7;
    --accent-contrast: #022c22;
    --accent-soft: rgb(52 211 153 / 0.12);
    --accent-border: rgb(52 211 153 / 0.3);
    --gradient: linear-gradient(120deg, #34d399, #22d3ee);
    --header-bg: rgb(9 9 11 / 0.72);
    --grid-line: rgb(250 250 250 / 0.06);
    --glow: rgb(52 211 153 / 0.16);
    --danger: #f87171;
    --danger-soft: rgb(248 113 113 / 0.1);
    --warning: #fbbf24;
    --warning-soft: rgb(251 191 36 / 0.1);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 12px 28px -14px rgb(0 0 0 / 0.65);
    --shadow-lg: 0 28px 56px -28px rgb(0 0 0 / 0.75);
  }
}

/* Base --------------------------------------------------------------------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
video {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

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

ul,
ol {
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4 {
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Layout & utilities ------------------------------------------------------- */

.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

.section {
  padding-block: clamp(3.5rem, 7vw, 5.5rem);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease-out);
}

.skip-link:focus {
  transform: none;
}

.section-head {
  max-width: 42rem;
  margin-bottom: clamp(2.25rem, 5vw, 3.25rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 1.5rem;
  height: 1px;
  background: currentColor;
}

.section-title {
  font-size: clamp(2rem, 1.4rem + 2.4vw, 2.875rem);
  letter-spacing: -0.03em;
}

.section-desc {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 1.0625rem;
}

/* Components --------------------------------------------------------------- */

.icon {
  display: inline-block;
  flex-shrink: 0;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-filled {
  fill: currentColor;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    color 0.2s,
    box-shadow 0.2s,
    transform 0.2s var(--ease-out);
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 10px 24px -12px var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--text-subtle);
  background: var(--surface-2);
}

.btn-ghost {
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  min-height: 2.25rem;
  padding: 0.4rem 0.95rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.icon-arrow {
  transition: transform 0.2s var(--ease-out);
}

a:hover > .icon-arrow {
  transform: translateX(3px);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition:
    color 0.2s,
    background-color 0.2s,
    border-color 0.2s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.icon-tile {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-tile .icon {
  width: 1.3rem;
  height: 1.3rem;
}

.card {
  position: relative;
  padding: clamp(1.25rem, 3vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
}

.badge .icon {
  width: 0.8rem;
  height: 0.8rem;
}

.badge-accent {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
}

.tag-accent {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
}

.tag-dashed {
  border-style: dashed;
  border-color: var(--border-strong);
  background: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2rem;
  padding: 0.25rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  transition:
    color 0.2s,
    border-color 0.2s,
    background-color 0.2s;
}

.chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.chip .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  font-weight: 550;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.25em;
  transition:
    color 0.2s,
    text-decoration-color 0.2s;
}

.text-link:hover {
  text-decoration-color: currentColor;
}

.gradient-text {
  padding-right: 0.06em;
  margin-right: -0.06em;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Header ------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}

.site-header.is-scrolled {
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-right: auto;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  background: var(--gradient);
  color: var(--accent-contrast);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  transition:
    color 0.2s,
    background-color 0.2s,
    border-color 0.2s;
}

.nav-link:hover,
.nav-link[aria-current="true"] {
  color: var(--text);
}

.nav-link[aria-current="true"]::after {
  content: "";
  position: absolute;
  right: 0.75rem;
  bottom: 0.15rem;
  left: 0.75rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.nav-cta {
  margin-left: 0.5rem;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-cta:hover,
.nav-cta[aria-current="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

.nav-cta[aria-current="true"]::after {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-moon,
.menu-toggle .icon-close,
.menu-toggle[aria-expanded="true"] .icon-menu {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun,
.menu-toggle[aria-expanded="true"] .icon-close {
  display: inline-block;
}

.menu-toggle,
html:not(.js) .theme-toggle {
  display: none;
}

@media (max-width: 53.99rem) {
  html.js .menu-toggle {
    display: inline-grid;
  }

  .site-nav {
    position: absolute;
    top: var(--header-h);
    right: 0;
    left: 0;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.75rem var(--gutter) 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition:
      opacity 0.2s,
      transform 0.25s var(--ease-out),
      visibility 0s 0.25s;
  }

  .site-header.menu-open .nav-list {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition:
      opacity 0.2s,
      transform 0.25s var(--ease-out),
      visibility 0s;
  }

  .nav-link {
    display: flex;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
  }

  .nav-link[aria-current="true"] {
    background: var(--surface-2);
  }

  .nav-link[aria-current="true"]::after {
    display: none;
  }

  .nav-cta {
    justify-content: center;
    margin: 0.5rem 0 0;
  }
}

/* Hero & about ------------------------------------------------------------- */

.hero {
  position: relative;
  isolation: isolate;
  overflow: clip;
  padding-block: clamp(3.5rem, 9vw, 6.5rem) clamp(3.5rem, 8vw, 6rem);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-position: center top;
  background-size: 3.5rem 3.5rem;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 30%, transparent 75%);
}

.hero::after {
  content: "";
  position: absolute;
  top: -32rem;
  left: 50%;
  z-index: -1;
  width: min(64rem, 150vw);
  aspect-ratio: 1;
  background: radial-gradient(closest-side, var(--glow), transparent);
  transform: translateX(-50%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: clamp(2.5rem, 6vw, 4rem);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.85rem 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #22c55e;
}

.hero-title {
  margin-top: 1.5rem;
  font-size: clamp(2.75rem, 1.6rem + 5vw, 4.75rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.hero-role {
  margin-top: 0.85rem;
  color: var(--text-muted);
  font-size: clamp(1.25rem, 1rem + 1vw, 1.625rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.hero-lead {
  max-width: 36rem;
  margin-top: 1.25rem;
  color: var(--text-muted);
  font-size: 1.0625rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.social-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2rem;
}

.social-list .icon-btn {
  border-color: var(--border);
  background: var(--surface);
}

.social-list .icon-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

.hero-visual {
  position: relative;
}

.hero-visual::before {
  content: "";
  position: absolute;
  inset: 12% 4%;
  z-index: -1;
  background: var(--gradient);
  border-radius: 50%;
  filter: blur(64px);
  opacity: 0.22;
}

.code-window {
  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid #27272a;
  border-radius: var(--radius-lg);
  background: #0f0f12;
  box-shadow: var(--shadow-lg);
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #27272a;
  background: #141418;
}

.code-dots {
  display: flex;
  gap: 0.4rem;
}

.code-dots span {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: #ff5f57;
}

.code-dots span:nth-child(2) {
  background: #febc2e;
}

.code-dots span:nth-child(3) {
  background: #28c840;
}

.code-file {
  color: #8b8b94;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.code-body {
  display: block;
  padding: 1.25rem 1.25rem 1.5rem 0.75rem;
  overflow-x: auto;
  color: #e4e4e7;
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  line-height: 1.8;
  counter-reset: line;
}

.line {
  display: block;
  white-space: pre;
}

.line::before {
  content: counter(line);
  counter-increment: line;
  display: inline-block;
  width: 1.75rem;
  margin-right: 1rem;
  color: #71717a;
  text-align: right;
  user-select: none;
}

.tok-com {
  color: #8b8b94;
  font-style: italic;
}

.tok-key {
  color: #c4b5fd;
}

.tok-var {
  color: #f4f4f5;
}

.tok-prop {
  color: #7dd3fc;
}

.tok-str {
  color: #86efac;
}

.tok-bool {
  color: #fdba74;
}

.tok-pun {
  color: #a1a1aa;
}

.caret {
  display: inline-block;
  width: 0.55em;
  height: 1.15em;
  margin-left: 0.2em;
  vertical-align: -0.2em;
  background: #34d399;
}

.about {
  padding-bottom: clamp(3.5rem, 7vw, 5.5rem);
}

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

.about-bio > p {
  color: var(--text-muted);
  font-size: 1.0625rem;
}

.about-bio > p + p {
  margin-top: 1rem;
}

.profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--gradient);
  box-shadow:
    0 0 0 4px var(--bg),
    0 0 0 5px var(--accent-border);
  color: var(--accent-contrast);
  font-size: 1.75rem;
  font-weight: 700;
  object-fit: cover;
}

.profile-name {
  font-size: 1.125rem;
  font-weight: 650;
}

.profile-meta {
  color: var(--text-subtle);
  font-size: 0.9375rem;
}

.fact-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.fact-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
}

.fact-list .icon {
  color: var(--accent);
}

.fact-list strong {
  color: var(--text);
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.stat {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-value {
  display: inline-block;
  font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.stat-label {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

@media (min-width: 60rem) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }

  .about-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    align-items: start;
    gap: 3.5rem;
  }
}

/* Projects ----------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

html:not(.js) .filters {
  display: none;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.375rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition:
    color 0.2s,
    border-color 0.2s,
    background-color 0.2s;
}

.filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-btn[aria-pressed="true"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.filter-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 1.25rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition:
    transform 0.3s var(--ease-out),
    border-color 0.3s,
    box-shadow 0.3s;
}

.project-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.project-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.project-year {
  margin-left: auto;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.project-title {
  margin-top: 0.35rem;
  font-size: 1.1875rem;
}

.project-desc {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.project-card .tag-list {
  margin-top: auto;
  padding-top: 0.35rem;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.section-more {
  margin-top: 2.5rem;
  text-align: center;
}

/* Research ----------------------------------------------------------------- */

.research-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

.research-intro .section-head {
  margin-bottom: 2rem;
}

.interests {
  display: grid;
  justify-items: start;
  gap: 1rem;
}

.mini-title {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.interests .btn {
  margin-top: 0.5rem;
}

.pub-list {
  display: grid;
  gap: 1rem;
}

.pub {
  padding: clamp(1.25rem, 3vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}

.pub:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  color: var(--text-subtle);
  font-size: 0.8125rem;
}

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

.pub-year {
  margin-left: auto;
  font-family: var(--font-mono);
}

.pub-title {
  margin-top: 0.85rem;
  font-size: 1.125rem;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.pub-authors {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.pub-authors .me {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.pub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

html:not(.js) [data-copy] {
  display: none;
}

.pub-abstract {
  margin-top: 1rem;
}

.pub-abstract summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 550;
  list-style: none;
  cursor: pointer;
}

.pub-abstract summary::-webkit-details-marker {
  display: none;
}

.pub-abstract summary::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s var(--ease-out);
}

.pub-abstract[open] summary::before {
  transform: rotate(45deg);
}

.pub-abstract p {
  margin-top: 0.75rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9375rem;
}

@media (min-width: 60rem) {
  .research-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr);
    align-items: start;
    gap: 4rem;
  }

  .research-intro {
    position: sticky;
    top: calc(var(--header-h) + 2rem);
  }
}

/* Experience --------------------------------------------------------------- */

.experience-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}

.col-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  font-size: 1.125rem;
}

.col-title .icon {
  color: var(--accent);
}

.timeline {
  --tl-indent: 1.75rem;
  --tl-line-x: 0.45rem;
  position: relative;
  display: grid;
  gap: 1.25rem;
  padding-left: var(--tl-indent);
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0.75rem;
  bottom: 0.75rem;
  left: calc(var(--tl-line-x) - 1px);
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(var(--accent-border), var(--border) 45%, var(--border) 85%, transparent);
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 1.65rem;
  left: calc(var(--tl-line-x) - var(--tl-indent) - 0.375rem);
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
}

.timeline-item:first-child::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.timeline-card {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}

.timeline-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.timeline-date {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.timeline-role {
  margin-top: 0.35rem;
  font-size: 1.125rem;
  letter-spacing: -0.015em;
}

.timeline-org {
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.timeline-org strong {
  color: var(--text);
  font-weight: 600;
}

.timeline-points {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.timeline-points li {
  position: relative;
  padding-left: 1.25rem;
}

.timeline-points li::before {
  content: "";
  position: absolute;
  top: calc(0.825em - 0.1875rem);
  left: 0.2rem;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-card .tag-list {
  margin-top: 1rem;
}

.timeline-note {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

@media (min-width: 60rem) {
  .experience-grid {
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    gap: 3.5rem;
  }
}

/* Skills ------------------------------------------------------------------- */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18.5rem), 1fr));
  gap: 1.25rem;
}

.skill-card {
  transition:
    transform 0.3s var(--ease-out),
    border-color 0.3s,
    box-shadow 0.3s;
}

.skill-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.skill-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.skill-title {
  font-size: 1.0625rem;
}

.exploring {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 1.5rem;
  padding: 1.1rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.exploring-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.exploring-label .icon {
  color: var(--accent);
}

/* Contact ------------------------------------------------------------------ */

.section-contact {
  position: relative;
  isolation: isolate;
  overflow: clip;
}

.section-contact::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: -30%;
  left: 0;
  z-index: -1;
  height: 80%;
  background: radial-gradient(ellipse 55% 50% at 50% 100%, var(--glow), transparent 70%);
  pointer-events: none;
}

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

.contact-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 2rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

a.contact-item:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-md);
}

.contact-label {
  display: block;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-value {
  display: block;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.contact-form {
  padding: clamp(1.5rem, 4vw, 2.25rem);
  box-shadow: var(--shadow-lg);
}

.contact-form > * + * {
  margin-top: 1.25rem;
}

.form-title {
  font-size: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 550;
}

.optional {
  color: var(--text-subtle);
  font-weight: 400;
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.field textarea {
  min-height: 9rem;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-subtle);
  opacity: 1;
}

.field input:hover,
.field textarea:hover {
  border-color: var(--text-subtle);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: 2px solid transparent;
}

.field [aria-invalid="true"] {
  border-color: var(--danger);
}

.field [aria-invalid="true"]:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.field-error {
  color: var(--danger);
  font-size: 0.8125rem;
}

.field-error:empty {
  display: none;
}

.field-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.char-count {
  margin-left: auto;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.char-count.is-near-limit {
  color: var(--warning);
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.spinner {
  display: none;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.is-loading {
  cursor: progress;
  opacity: 0.85;
}

.btn.is-loading .spinner {
  display: inline-block;
}

.btn.is-loading .icon-send {
  display: none;
}

.form-status {
  padding: 0.85rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

/* Kept in the layout while empty so screen readers keep tracking the live region */
.contact-form > .form-status:empty {
  margin-top: 0;
  padding: 0;
  border: 0;
}

.form-status[data-state="success"] {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.form-status[data-state="error"] {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.form-status[data-state="info"] {
  border-color: var(--warning);
  background: var(--warning-soft);
  color: var(--warning);
}

.form-note {
  color: var(--text-subtle);
  font-size: 0.8125rem;
  text-align: center;
}

@media (min-width: 36rem) {
  .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 60rem) {
  .contact-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
    gap: 4rem;
  }
}

/* Footer ------------------------------------------------------------------- */

.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 0.875rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Motion ------------------------------------------------------------------- */

@keyframes fade-up {
  from {
    opacity: 0;
    translate: 0 1rem;
  }
  to {
    opacity: 1;
    translate: none;
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    translate: 0 1.5rem;
  }
  to {
    opacity: 1;
    translate: none;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgb(34 197 94 / 0.5);
  }
  70%,
  100% {
    box-shadow: 0 0 0 0.5rem rgb(34 197 94 / 0);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .hero-content > *,
  .hero-visual {
    animation: fade-up 0.8s var(--ease-out) both;
  }

  .hero-content > :nth-child(2) {
    animation-delay: 0.06s;
  }

  .hero-content > :nth-child(3) {
    animation-delay: 0.12s;
  }

  .hero-content > :nth-child(4) {
    animation-delay: 0.18s;
  }

  .hero-content > :nth-child(5) {
    animation-delay: 0.24s;
  }

  .hero-content > :nth-child(6) {
    animation-delay: 0.3s;
  }

  .hero-visual {
    animation-delay: 0.2s;
  }

  .status-dot {
    animation: pulse 2.2s ease-out infinite;
  }

  .caret {
    animation: blink 1.1s steps(1) infinite;
  }

  /* Scroll-driven reveal: CSS only, and simply skipped by browsers without support */
  @supports (animation-timeline: view()) {
    .reveal {
      animation: reveal 1ms linear both; /* Firefox needs a non-zero duration */
      animation-timeline: view();
      animation-range: entry 0% entry 85%;
    }
  }
}

/* Theme switch: the new theme is revealed by a growing circle (see script.js) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-group(*) {
  animation-duration: 0.35s;
  animation-timing-function: var(--ease-out);
}

@media (forced-colors: active) {
  .gradient-text {
    background: none;
    color: CanvasText;
  }

  .avatar,
  .brand-mark {
    border: 1px solid CanvasText;
  }
}

/* Print -------------------------------------------------------------------- */

@media print {
  :root,
  :root[data-theme],
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --border: #d4d4d8;
    --border-strong: #a1a1aa;
    --text: #000000;
    --text-muted: #27272a;
    --text-subtle: #3f3f46;
    --accent: #065f46;
    --accent-soft: transparent;
    --accent-border: #a1a1aa;
    --gradient: linear-gradient(#000000, #000000);
  }

  .site-header,
  .skip-link,
  .hero-visual,
  .hero-actions,
  .filters,
  .section-more,
  .contact-form,
  .pub-actions {
    display: none !important;
  }

  .hero::before,
  .hero::after,
  .section-contact::before {
    display: none;
  }

  .hero,
  .section,
  .about {
    padding-block: 1.25rem;
  }

  .card,
  .pub,
  .stat,
  .timeline-card,
  .contact-item {
    box-shadow: none;
    break-inside: avoid;
  }

  /* Browsers drop backgrounds when printing, which would hide gradient-clipped text */
  .gradient-text {
    background: none;
    color: var(--text);
  }

  .avatar,
  .brand-mark {
    border: 1px solid var(--text);
    color: var(--text);
  }

  .reveal,
  .hero-content > * {
    animation: none !important;
  }
}
