:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: #0d1b2e;
  --surface: rgba(255, 255, 255, 0.08);
  --surface-strong: rgba(255, 255, 255, 0.13);
  --text: #f6f8fb;
  --muted: #aab7c8;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #44d7b6;
  --accent-strong: #6be4ff;
  --accent-warm: #f0b86c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  --radius-lg: 16px;
  --max: 1180px;
}

body.light-theme {
  color-scheme: light;
  --bg: #f7fafc;
  --bg-soft: #eef4f8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --text: #101827;
  --muted: #516071;
  --line: rgba(15, 23, 42, 0.13);
  --shadow: 0 24px 70px rgba(33, 55, 85, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 220ms ease, color 220ms ease;
}

body::selection {
  background: rgba(68, 215, 182, 0.32);
}

a {
  color: inherit;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(68, 215, 182, 0.16), transparent 30%),
    radial-gradient(circle at 86% 24%, rgba(107, 228, 255, 0.12), transparent 26%),
    linear-gradient(135deg, var(--bg), var(--bg-soft));
}

.orb {
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 999px;
  filter: blur(42px);
  opacity: 0.2;
  animation: drift 14s ease-in-out infinite alternate;
}

.orb-a {
  left: -110px;
  top: 18%;
  background: var(--accent);
}

.orb-b {
  right: -130px;
  bottom: 10%;
  background: var(--accent-strong);
  animation-delay: -4s;
}

.grid-fade {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 72%);
}

@keyframes drift {
  to {
    transform: translate3d(42px, -28px, 0) scale(1.08);
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0;
  backdrop-filter: blur(16px);
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 8px -12px;
  z-index: -1;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.93rem;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #06111c;
  font-size: 0.78rem;
  font-weight: 900;
}

.nav {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.nav a {
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 9px 12px;
  text-decoration: none;
  transition: color 180ms ease, background 180ms ease;
}

.nav a:hover,
.nav a.active {
  background: var(--surface);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  justify-self: end;
}

.icon-button,
.top-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.icon-button {
  min-width: 64px;
  height: 42px;
  padding: 0 13px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.lang-button {
  min-width: 116px;
}

.lang-toggle__content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lang-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.6;
  transition: opacity 180ms ease;
}

.lang-option img {
  display: block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.lang-separator {
  color: var(--muted);
}

.lang-button[data-language="en"] .lang-option--en,
.lang-button[data-language="ca"] .lang-option--ca {
  opacity: 1;
}

.icon-button:hover,
.top-button:hover {
  transform: translateY(-2px);
  background: var(--surface-strong);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.section-shell {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 96px 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr);
  gap: 56px;
  align-items: center;
  min-height: calc(100vh - 76px);
  padding-top: 72px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 100%;
  margin-bottom: 24px;
  font-size: clamp(3.2rem, 4vw, 4.85rem);
  line-height: 0.95;
  letter-spacing: 0;
}

html[lang="ca"] h1 {
  max-width: 100%;
  font-size: clamp(3rem, 3.55vw, 4.25rem);
}

html[lang="ca"] .signal-card {
  max-width: 210px;
  padding: 12px 13px;
}

html[lang="ca"] .signal-card p {
  font-size: 0.72rem;
}

h2 {
  margin-bottom: 20px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.03;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.12rem;
  line-height: 1.25;
}

.hero-lede {
  max-width: 700px;
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  padding: 11px 18px;
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
  background: var(--surface-strong);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #06111c;
  box-shadow: 0 12px 28px rgba(68, 215, 182, 0.24);
}

.button.ghost {
  background: transparent;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 36px 0 0;
}

.hero-stats div,
.prose-card,
.focus-card,
.publication-card,
.project-card,
.skill-card,
.education-panel,
.contact-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-stats div {
  padding: 16px;
}

.hero-stats dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-stats dd {
  margin: 5px 0 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.hero-visual {
  position: relative;
}

.portrait-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  aspect-ratio: 0.86;
}

.portrait-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(7, 17, 31, 0.62), transparent 42%);
}

.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.signal-card {
  position: absolute;
  right: -18px;
  bottom: 28px;
  max-width: 300px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(18px);
}

.signal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.signal-dot {
  display: block;
  width: 10px;
  height: 10px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 8px rgba(68, 215, 182, 0.16);
}

.intro-grid,
.split-section,
.credentials-grid {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  gap: 44px;
  align-items: start;
}

.section-heading {
  max-width: 640px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.prose-card,
.contact-card,
.education-panel {
  padding: clamp(24px, 4vw, 42px);
}

.prose-card p,
.contact-card p,
.publication-card p,
.project-card p,
.focus-card p,
.skill-card p,
.education-panel p,
.clean-list {
  color: var(--muted);
}

.prose-card p:last-child,
.contact-card p:last-child {
  margin-bottom: 0;
}

.publication-authors {
  margin-top: -6px;
  margin-bottom: 10px;
  color: var(--text) !important;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.5;
}

.timeline {
  display: grid;
  gap: 18px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.timeline-meta span,
.tag {
  display: block;
  color: var(--accent-warm);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.timeline-meta strong {
  display: block;
  margin-top: 8px;
}

.timeline-content ul,
.clean-list {
  margin: 0;
  padding-left: 20px;
}

.timeline-content li,
.clean-list li {
  margin-bottom: 8px;
  color: var(--muted);
}

.focus-grid,
.project-grid,
.skills-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.project-grid,
.skills-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.focus-card,
.publication-card,
.project-card,
.skill-card {
  padding: 24px;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.focus-card:hover,
.publication-card:hover,
.project-card:hover,
.skill-card:hover {
  transform: translateY(-4px);
  background: var(--surface-strong);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
}

.focus-card span {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 900;
}

.publication-list {
  display: grid;
  gap: 16px;
}

.publication-card a,
.project-card a,
.inline-links a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.publication-card a:hover,
.project-card a:hover,
.inline-links a:hover {
  text-decoration: underline;
}

.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.credentials-grid {
  grid-template-columns: 1fr 1fr;
}

.education-panel article {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 24px;
}

.education-panel span {
  color: var(--accent);
  font-weight: 700;
}

.contact-section {
  padding-bottom: 64px;
}

.contact-card {
  position: relative;
  overflow: hidden;
}

.contact-card::after {
  content: "";
  position: absolute;
  top: -140px;
  right: -100px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(68, 215, 182, 0.22), transparent 66%);
  pointer-events: none;
}

.site-footer {
  position: relative;
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 26px 0 40px;
  color: var(--muted);
}

.footer-note {
  margin-top: 8px;
  font-size: 0.9rem;
}

.footer-note a {
  color: var(--accent-strong);
  text-decoration: none;
}

.footer-note a:hover {
  text-decoration: underline;
}

.top-button {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  opacity: 0;
  pointer-events: none;
}

.top-button.visible {
  opacity: 1;
  pointer-events: auto;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
  }

  .icon-button {
    min-width: 62px;
  }

  .hero,
  .intro-grid,
  .split-section,
  .credentials-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 56px;
  }

  .hero-visual {
    max-width: 520px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .focus-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  html {
    scroll-padding-top: 132px;
  }

  .site-header {
    width: min(100% - 20px, var(--max));
  }

  .site-header::before {
    inset: 8px -4px;
  }

  .brand span:last-child {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }


  .section-shell {
    width: min(100% - 24px, var(--max));
    padding: 62px 0;
  }

  h1 {
    font-size: 3.1rem;
  }

  h2 {
    font-size: 2.15rem;
  }

  .hero-stats,
  .focus-grid,
  .project-grid,
  .skills-grid {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .signal-card {
    position: static;
    margin-top: 14px;
    max-width: none;
  }

  .portrait-frame {
    aspect-ratio: 1;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
