/* Minimal editorial redesign — loaded last to consolidate legacy styles. */
:root {
  --primary-color: #111111;
  --primary-color-rgb: 17, 17, 17;
  --secondary-color: #111111;
  --secondary-color-rgb: 17, 17, 17;
  --accent-color: #111111;
  --accent-rgb: 17, 17, 17;
  --background: #ffffff;
  --surface: #f2f2f2;
  --card-bg: #ffffff;
  --card-bg-color-rgb: 255, 255, 255;
  --text-primary: #111111;
  --text-secondary: #666666;
  --text-tertiary: #8f8f8f;
  --border-color: #e3e3e3;
  --container-width: 1240px;
  --border-radius: 24px;
  --card-shadow: none;
  --hover-shadow: 0 18px 44px rgba(0, 0, 0, 0.08);
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --primary-color: #ffffff;
  --primary-color-rgb: 255, 255, 255;
  --secondary-color: #ffffff;
  --secondary-color-rgb: 255, 255, 255;
  --accent-color: #ffffff;
  --accent-rgb: 255, 255, 255;
  --background: #000000;
  --surface: #101010;
  --card-bg: #1b1b1b;
  --card-bg-color-rgb: 27, 27, 27;
  --text-primary: #ffffff;
  --text-secondary: #d0d0d0;
  --text-tertiary: #9a9a9a;
  --border-color: #3b3b3b;
  --card-shadow: none;
  --hover-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

html {
  scroll-padding-top: 76px;
}

body {
  color: var(--text-primary);
  background: var(--background);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.005em;
}

::selection {
  color: var(--background);
  background: var(--text-primary);
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.container {
  width: 100%;
  max-width: var(--container-width);
  padding-inline: 32px;
  box-sizing: border-box;
  overflow: visible;
}

.section {
  position: relative;
  padding: 112px 0;
  background: transparent !important;
  border-top: 0;
}

.section:first-child {
  border-top: 0;
}

#home-particles,
.home-particles,
.publications-particles,
.timeline-background,
.mobile-dots,
.grid-pattern,
.contact-shapes,
.section-decoration,
.floating-shape {
  display: none !important;
}

.section-title {
  display: block;
  max-width: 760px;
  margin: 0 0 12px;
  color: var(--text-primary);
  font-size: clamp(2.15rem, 4.2vw, 4rem);
  font-weight: 450;
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.section-title::after {
  display: none;
}

.section-subtitle {
  max-width: 680px;
  margin: 0 0 48px;
  color: var(--text-secondary);
  font-size: 1.06rem;
  line-height: 1.6;
}

/* Header */
.header,
.header.scrolled,
[data-theme="dark"] .header,
[data-theme="dark"] .header.scrolled {
  position: fixed;
  z-index: 1000;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  border: 0;
  border-bottom: 0;
  box-shadow: none;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: visible;
}

.header .container {
  max-width: 1400px;
}
.header-content,
.header.scrolled .header-content {
  height: 72px;
}

.navbar-full,
.header.scrolled .navbar-full {
  display: flex;
  align-items: center;
  width: 100%;
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.navbar-pills {
  display: none !important;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text-primary);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.logo:hover {
  color: var(--text-primary);
}

.logo-brand {
  position: relative;
  display: block;
  width: 170px;
  height: 42px;
  flex: 0 0 170px;
}

.logo-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-horizontal-dark,
.logo-mobile {
  display: none;
}

[data-theme="dark"] .logo-horizontal-light {
  display: none;
}

[data-theme="dark"] .logo-horizontal-dark {
  display: block;
}

.nav-menu {
  display: flex;
  align-items: center;
  margin-left: auto;
}
.nav-list {
  gap: 2px;
}

.nav-link {
  padding: 9px 12px;
  color: var(--text-secondary);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 450;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
  background: var(--surface);
  transform: none;
}

.nav-link::after {
  display: none !important;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
}

/* Monochrome compact controls */
.language-toggle,
[data-theme="dark"] .language-toggle {
  width: 64px;
  height: 36px;
  padding: 4px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: none;
  overflow: visible;
}

.language-toggle .toggle-button {
  display: none !important;
}
.language-toggle .lang-text {
  position: static;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  transform: none;
  opacity: 0.45 !important;
  color: var(--text-primary) !important;
  border-radius: 50%;
  font-size: 9px;
}
.language-toggle:not(.it) .lang-text.en,
.language-toggle.it .lang-text.it {
  opacity: 1 !important;
  background: var(--card-bg);
}

.theme-toggle,
.theme-toggle.dark,
[data-theme="dark"] .theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  box-shadow: none;
}
.theme-toggle .toggle-button {
  display: none !important;
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: static;
  transform: none;
}
.theme-toggle:not(.dark) .icon-moon,
.theme-toggle.dark .icon-sun {
  display: none;
}
.theme-toggle .icon-sun svg,
.theme-toggle .icon-moon svg {
  fill: var(--text-primary) !important;
}

.nav-cv {
  padding: 8px 13px;
  color: var(--background);
  background: var(--text-primary);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.nav-cv:hover {
  color: var(--background);
  opacity: 0.84;
}
.menu-toggle {
  display: none;
}
.mobile-only {
  display: none;
}
/* Hero */
#home {
  min-height: 100svh;
  padding-top: 132px;
  padding-bottom: 72px;
  background-image: none !important;
}

#home::before {
  display: none;
}

.hero {
  min-height: calc(100svh - 204px);
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.65fr);
  align-items: center;
  gap: clamp(48px, 8vw, 112px);
  padding: clamp(42px, 6vw, 76px);
  background: var(--surface);
  border-radius: 36px;
}

.hero-content {
  max-width: 760px;
}

.hero h1,
.hero h2,
.hero .lead,
.hero .cta-buttons,
.hero-image {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: none;
}

.hero-content h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(3.6rem, 8vw, 7.2rem);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.075em;
}

.hero-content h1 .highlight {
  color: inherit;
  background: none;
  -webkit-text-fill-color: currentColor;
}

.hero-content h2 {
  max-width: 660px;
  margin: 28px 0 18px;
  color: var(--text-primary);
  font-size: clamp(1.45rem, 2.4vw, 2.2rem);
  font-weight: 450;
  line-height: 1.22;
  letter-spacing: -0.04em;
}

.hero-content .lead {
  max-width: 650px;
  margin: 0;
  color: var(--text-secondary);
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  line-height: 1.7;
}

.research-focus {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 0;
}

.research-focus li,
.tag,
.skill-tag,
.project-tag {
  padding: 6px 10px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 500;
}

.cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 38px;
}

.btn,
[data-theme="dark"] .btn {
  box-sizing: border-box;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 17px;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.btn:hover,
[data-theme="dark"] .btn:hover {
  color: var(--text-primary);
  background: var(--surface);
  border-color: var(--text-tertiary);
  box-shadow: none;
  transform: none;
}

.btn-primary,
[data-theme="dark"] .btn-primary {
  color: var(--background);
  background: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-primary:hover,
[data-theme="dark"] .btn-primary:hover {
  color: var(--background);
  background: var(--text-primary);
  opacity: 0.84;
}

.btn i {
  font-size: 0.78rem;
}
.btn::after {
  display: none;
}

.game-button-row {
  display: block;
  margin-top: 18px;
  text-align: left;
}
.btn-game,
[data-theme="dark"] .btn-game {
  width: auto;
  min-height: auto;
  padding: 0;
  color: var(--text-tertiary);
  background: transparent;
  border: 0;
  text-align: left;
}

.btn-game:hover,
[data-theme="dark"] .btn-game:hover {
  color: var(--text-primary);
  background: transparent;
  border: 0;
}

.game-btn-main {
  font-size: 0.8rem;
  font-weight: 600;
}
.game-btn-subtitle {
  font-size: 0.72rem;
  font-weight: 400;
}

.hero-image {
  position: relative;
}
.profile-image {
  width: min(100%, 360px);
  aspect-ratio: 4 / 5;
  margin-left: auto;
  object-fit: cover;
  object-position: center top;
  border: 1px solid var(--border-color);
  border-radius: 28px;
  filter: none;
  box-shadow: 20px 20px 0
    color-mix(in srgb, var(--text-primary) 8%, transparent);
}

/* About */
#about {
  background: var(--background) !important;
}
.about-text {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 64px;
  max-width: 1040px;
  color: var(--text-secondary);
}

.about-text p {
  margin: 0;
  padding: 24px 0;
  border-top: 0;
  font-size: 1rem;
  line-height: 1.75;
}

.about-text p:first-child {
  grid-column: 1 / -1;
  max-width: 860px;
  padding-top: 0;
  border-top: 0;
  color: var(--text-primary);
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.42;
  letter-spacing: -0.03em;
  padding: clamp(28px, 5vw, 56px);
  background: var(--surface);
  border-radius: 28px;
}

.about-text .about-vision {
  grid-column: 1 / -1;
  color: var(--text-primary);
  font-weight: 550;
  padding: 24px 28px;
  background: var(--surface);
  border-radius: 20px;
}

/* Timeline */
.timeline-container {
  max-width: 940px;
  margin: 0;
  padding: 0;
}
.timeline-line {
  display: none;
}
.timeline-items {
  display: grid;
}
.timeline-item,
.timeline-item:nth-child(odd) {
  display: grid;
  grid-template-columns: 90px 28px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin: 0 0 12px;
  padding: 26px 28px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  opacity: 1;
  transform: none;
}

.timeline-item:last-child {
  border-bottom: 1px solid var(--border-color);
}
.timeline-item::after {
  display: none;
}

.timeline-year,
.timeline-item:hover .timeline-year,
.timeline-year:hover {
  position: static;
  width: auto;
  height: auto;
  justify-content: flex-start;
  color: var(--text-tertiary);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 0.8rem;
  font-weight: 600;
  transform: none;
}

.timeline-icon,
.timeline-item:hover .timeline-icon,
.timeline-icon:hover {
  position: static;
  width: 28px;
  height: 28px;
  color: var(--background);
  background: var(--text-primary);
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  font-size: 0.68rem;
  transform: none;
}

[data-theme="dark"] .timeline-icon i {
  color: var(--background) !important;
}

/* In dark mode the hover surface turns white, so its glyph must turn black. */
[data-theme="dark"] #career .timeline-icon:hover i,
[data-theme="dark"] #career .timeline-item:hover .timeline-icon i,
[data-theme="dark"] #career .timeline-icon.icon-hover i,
[data-theme="dark"] #career .timeline-icon:hover .fas,
[data-theme="dark"] #career .timeline-item:hover .timeline-icon .fas,
[data-theme="dark"] #career .timeline-icon.icon-hover .fas,
[data-theme="dark"] #career .timeline-icon:hover .fab,
[data-theme="dark"] #career .timeline-item:hover .timeline-icon .fab,
[data-theme="dark"] #career .timeline-icon.icon-hover .fab {
  color: #000000 !important;
}

.timeline-content,
.timeline-content:hover,
.timeline-content.hover-effect,
.timeline-item:nth-child(odd) .timeline-content:hover,
.timeline-item:nth-child(even) .timeline-content:hover {
  width: auto;
  padding: 0 0 0 8px;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  overflow: visible;
  transform: none;
}

.timeline-content::before {
  display: none;
}
.timeline-title {
  margin: 0 0 4px;
  color: var(--text-primary);
  background: none;
  -webkit-text-fill-color: currentColor;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.timeline-organization {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-style: normal;
}

.timeline-description {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
}
.timeline-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 12px 0 0;
}
.timeline-highlights li {
  margin: 0;
  padding-left: 12px;
  color: var(--text-tertiary);
  font-size: 0.8rem;
}
.timeline-highlights li::before {
  left: 0;
  top: 0.72em;
  width: 3px;
  height: 3px;
  background: currentColor;
  box-shadow: none;
}

/* Publications and project cards */
#publications {
  background: var(--surface) !important;
}
.publications-filters {
  gap: 6px;
  margin-bottom: 26px;
}
.publication-filter,
[data-theme="dark"] .publication-filter {
  min-width: 0;
  min-height: 34px;
  padding: 6px 12px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: none;
  backdrop-filter: none;
}

.publication-filter.active,
.publication-filter:hover,
[data-theme="dark"] .publication-filter.active,
[data-theme="dark"] .publication-filter:hover {
  color: var(--background);
  background: var(--text-primary);
  border-color: var(--text-primary);
  box-shadow: none;
  transform: none;
}

.publications-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  background: transparent;
  border: 0;
}
.publication-item,
.publication-item.featured,
[data-theme="dark"] .publication-item,
[data-theme="dark"] .publication-item.featured {
  position: relative;
  min-width: 0;
  padding: 30px;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 26px;
  box-shadow: none;
}

.publication-item .project-content {
  padding: 0;
  background: transparent;
}
.publication-title {
  margin: 0 0 16px;
  font-size: 1.18rem;
  line-height: 1.4;
  letter-spacing: -0.025em;
}
.publication-authors {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
}
.publication-venue {
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
}
.featured-badge {
  top: 16px;
  right: 16px;
  padding: 6px 10px;
  color: var(--background);
  background: var(--text-primary);
  border-radius: 999px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.publication-links {
  margin-top: 20px;
}
.publication-link,
.copy-citation,
[data-theme="dark"] .copy-citation {
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  font-size: 0.78rem;
}
.publication-link:hover,
.copy-citation:hover,
[data-theme="dark"] .copy-citation:hover {
  color: var(--text-primary);
  background: transparent;
  border: 0;
}

/* Light theme: keep publication actions visible against white cards on hover. */
html:not([data-theme="dark"]) .publication-link:hover,
html:not([data-theme="dark"]) .copy-citation:hover {
  color: #ffffff !important;
  background: #111111 !important;
  border-color: #111111 !important;
}

html:not([data-theme="dark"]) .publication-link:hover i,
html:not([data-theme="dark"]) .copy-citation:hover i {
  color: #ffffff !important;
}

.projects-grid,
.hackathons-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.project-card,
.hackathon-card,
[data-theme="dark"] .project-card,
[data-theme="dark"] .hackathon-card {
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  box-shadow: none;
  overflow: hidden;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.project-card::after,
.hackathon-card::after {
  display: none;
}
.project-card:hover,
.hackathon-card:hover,
[data-theme="dark"] .project-card:hover,
[data-theme="dark"] .hackathon-card:hover {
  background: var(--card-bg);
  border-color: var(--text-tertiary);
  box-shadow: var(--hover-shadow);
  transform: translateY(-3px);
}

.project-image,
.hackathon-image {
  height: 260px;
  background: var(--surface);
}
.project-image img,
.hackathon-image img {
  filter: none;
}
.project-card:hover .project-image img,
.hackathon-card:hover .hackathon-image img {
  transform: scale(1.015);
}
.project-content,
.hackathon-content {
  padding: 26px;
  background: var(--card-bg);
}
.project-title,
.hackathon-title {
  color: var(--text-primary);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.project-description,
.hackathon-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.65;
}
.project-read-more,
.hackathon-read-more {
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
}
.project-link {
  color: var(--text-secondary);
  border-color: var(--border-color);
  box-shadow: none;
}
.project-link:hover {
  color: var(--text-primary);
  background: var(--surface);
  transform: none;
}
.hackathon-achievement,
.hackathon-achievement.position-2nd {
  color: #171717;
  background: rgba(255, 255, 255, 0.88);
  border: 0;
  box-shadow: none;
  text-shadow: none;
  font-size: 0.72rem;
}

#mobile-projects,
#other-projects {
  padding-top: 80px;
}

/* Contact */
#contact {
  background: var(--surface) !important;
}
.contact-grid {
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.45fr);
  gap: 18px;
}
.contact-info,
.contact-form-container,
[data-theme="dark"] .contact-info,
[data-theme="dark"] .contact-form-container {
  padding: 28px;
  color: var(--text-primary);
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  box-shadow: none;
  backdrop-filter: none;
  overflow: visible;
}

.contact-info::after,
.contact-form-container::after {
  display: none;
}
.contact-info:hover,
.contact-form-container:hover {
  background: var(--background);
  border-color: var(--border-color);
  box-shadow: none;
  transform: none;
}
.contact-info-item {
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-color: var(--border-color);
}
.contact-info-item:hover {
  transform: none;
}
.contact-info-item i {
  width: 18px;
  color: var(--text-primary);
  font-size: 0.95rem;
}
.contact-info-item:hover i {
  transform: none;
}
.contact-info-item h3,
.contact-social h3 {
  color: var(--text-primary);
  font-size: 0.82rem;
}
.contact-info-item a {
  color: var(--text-secondary);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}
.contact-info-item a::after {
  display: none;
}
.contact-social .social-icons a,
.footer .social-icons a {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
  box-shadow: none;
}
.contact-social .social-icons a::before {
  display: none;
}
.contact-social .social-icons a:hover,
.footer .social-icons a:hover {
  color: var(--text-primary);
  background: var(--surface);
  border-color: var(--text-tertiary);
  box-shadow: none;
  transform: none;
}
.contact-social .social-icons a:hover i {
  color: inherit;
  transform: none;
}

.contact-form {
  gap: 20px;
}
.form-group label {
  color: var(--text-secondary);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}
.form-group input,
.form-group textarea,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea {
  padding: 14px 16px;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: none;
  backdrop-filter: none;
}
.form-group input:hover,
.form-group textarea:hover,
.form-group input:focus,
.form-group textarea:focus,
[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group textarea:focus {
  background: var(--card-bg);
  border-color: var(--text-primary);
  box-shadow: none;
}
.btn-submit {
  padding: 13px 20px;
  color: var(--background);
  background: var(--text-primary);
  border: 0;
  border-radius: 999px;
  box-shadow: none;
}
.btn-submit:hover {
  background: var(--text-primary);
  box-shadow: none;
  transform: none;
  opacity: 0.84;
}

/* Footer */
.footer {
  padding: 72px 0 24px;
  color: #a8a8a8;
  background: #111111;
}
[data-theme="dark"] .footer {
  background: #050505;
}
.footer .container {
  max-width: 1400px;
}
.footer-content {
  display: grid;
  grid-template-columns: minmax(280px, 1.6fr) 1fr 0.6fr;
  gap: 64px;
  padding-bottom: 56px;
}
.footer-name {
  display: inline-block;
  margin-bottom: 14px;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 600;
}
.footer-name:hover {
  color: #ffffff;
}
.footer-about p {
  max-width: 500px;
  color: #949494;
  font-size: 0.88rem;
}
.footer h3 {
  margin-bottom: 14px;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.footer-links ul {
  display: grid;
  gap: 7px;
}
.footer-links a {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}
.footer-links a:hover {
  color: #ffffff;
}
.footer .social-icons {
  gap: 8px;
}
.footer .social-icons a {
  width: 36px;
  height: 36px;
  color: var(--text-tertiary);
  border-color: #3c3c39;
}
.footer-copyright {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-top: 22px;
  border-top: 1px solid #3c3c39;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}
.footer-copyright a {
  color: var(--text-tertiary);
}

/* CV page */
#cv {
  padding-top: 130px;
  background: var(--background) !important;
}
.cv-content,
.cv-section {
  box-shadow: none !important;
}
.cv-section {
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 28px !important;
}
.cv-section h2 {
  color: var(--text-primary) !important;
}
.cv-photo img {
  border-radius: 20px !important;
  filter: none;
}
.back-link {
  color: var(--text-secondary);
}

/* Small utilities */
.scroll-to-top {
  color: var(--background);
  background: var(--text-primary);
  border: 0;
  box-shadow: none;
}
.modal-content {
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  box-shadow: none;
}

/* Spatial system and section-specific editorial layouts */
.container {
  max-width: 1320px;
  padding-inline: 40px;
}
.section {
  padding: 104px 0;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.55fr);
  gap: 48px;
  align-items: end;
  margin-bottom: 48px;
}
.section-heading .section-title,
.section-heading .section-subtitle {
  margin: 0;
}
.section-heading .section-subtitle {
  justify-self: end;
  max-width: 430px;
}

#home {
  min-height: auto;
  padding: 112px 0 48px;
}
.hero {
  min-height: 720px;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: clamp(52px, 8vw, 116px);
  padding: clamp(50px, 7vw, 88px);
  border: 1px solid var(--border-color);
}
.profile-image {
  width: min(100%, 390px);
  filter: none;
  border-radius: 32px;
  box-shadow: 22px 22px 0
    color-mix(in srgb, var(--text-primary) 10%, transparent);
}
.hero-content .lead {
  max-width: 720px;
}
.btn {
  padding-inline: 20px;
}

/* Alternating section rhythm */
#about,
#publications,
#hackathons,
#other-projects {
  background: var(--background) !important;
}
#career,
#projects,
#mobile-projects,
#contact {
  background: var(--surface) !important;
}

/* About: asymmetric narrative bento */
.about-text {
  max-width: none;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}
.about-text p,
.about-text p:first-child,
.about-text .about-vision {
  grid-column: auto;
  margin: 0;
  padding: 30px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  font-size: 0.96rem;
  line-height: 1.72;
}
.about-text p:first-child {
  grid-column: span 8;
  color: var(--background);
  background: var(--text-primary);
  border-color: var(--text-primary);
  font-size: clamp(1.4rem, 2.35vw, 2.05rem);
  line-height: 1.38;
}
.about-text p:nth-child(2) {
  grid-column: span 4;
}
.about-text p:nth-child(3) {
  grid-column: span 5;
}
.about-text p:nth-child(4) {
  grid-column: span 7;
}
.about-text .about-vision {
  grid-column: 1 / -1;
  padding: 24px 30px;
  color: var(--text-primary);
  font-size: 1.08rem;
}

/* Experience: dense, readable two-column cards */
.timeline-container {
  max-width: none;
}
.timeline-items {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.timeline-item,
.timeline-item:nth-child(odd) {
  grid-template-columns: 68px 28px minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  margin: 0;
  padding: 28px;
  background: var(--card-bg);
  border-radius: 28px;
}
.timeline-item:first-child {
  grid-column: 1 / -1;
  grid-template-columns: 90px 32px minmax(0, 1fr);
  padding: 34px;
}
.timeline-item:last-child {
  border-bottom: 1px solid var(--border-color);
}
.timeline-content,
.timeline-content:hover,
.timeline-content.hover-effect,
.timeline-item:nth-child(odd) .timeline-content:hover,
.timeline-item:nth-child(even) .timeline-content:hover {
  padding-left: 2px;
}
.timeline-description {
  max-width: 720px;
}
.timeline-item:first-child .timeline-title {
  font-size: 1.45rem;
}

/* Publications: featured paper leads the grid */
.publications-filters {
  margin-bottom: 32px;
}
.publications-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.publication-item,
.publication-item.featured,
[data-theme="dark"] .publication-item,
[data-theme="dark"] .publication-item.featured {
  min-height: 310px;
  padding: 30px;
  border-radius: 28px;
}
.publication-item.featured {
  grid-column: span 2;
}
.publication-item .project-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.publication-links {
  margin-top: auto;
  padding-top: 22px;
}
.publication-title {
  padding-right: 44px;
  font-size: 1.22rem;
}
.publication-item.featured .publication-title {
  max-width: 760px;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}

/* Research and product cards */
.projects-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.project-card,
.hackathon-card,
[data-theme="dark"] .project-card,
[data-theme="dark"] .hackathon-card {
  border-radius: 30px;
}
.project-image,
.hackathon-image {
  height: 230px;
}
.project-image img,
.hackathon-image img {
  filter: none;
}
.project-content {
  padding: 28px;
}
.project-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}
.project-tags {
  margin-top: 18px;
}
.project-links {
  margin-top: auto;
  padding-top: 18px;
}
.project-card {
  display: flex;
  flex-direction: column;
}
.project-card .project-content {
  display: flex;
  flex: 1;
  flex-direction: column;
}

/* Hackathon: one panoramic story card */
.hackathons-grid {
  grid-template-columns: 1fr;
}
.hackathon-card {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr);
}
.hackathon-image {
  height: 100%;
  min-height: 480px;
}
.hackathon-content {
  padding: clamp(32px, 5vw, 56px);
}
.hackathon-title {
  font-size: clamp(1.5rem, 2.4vw, 2.15rem);
}
.hackathon-description {
  font-size: 1rem;
}

/* Mobile work: horizontal product feature */
#mobile-projects .projects-grid {
  grid-template-columns: 1fr;
}
#mobile-projects .project-card {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
}
#mobile-projects .project-image {
  height: 100%;
  min-height: 430px;
}
#mobile-projects .project-content {
  padding: clamp(34px, 5vw, 60px);
}
#mobile-projects .project-title {
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
}

/* Client work: compact four-column gallery */
#other-projects .projects-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#other-projects .project-image {
  height: 180px;
}
#other-projects .project-content {
  padding: 22px;
}
#other-projects .project-description {
  -webkit-line-clamp: 4;
}

/* Contact: generous, high-contrast input surfaces */
.contact-grid {
  grid-template-columns: minmax(310px, 0.72fr) minmax(0, 1.28fr);
  gap: 20px;
}
.contact-info,
.contact-form-container,
[data-theme="dark"] .contact-info,
[data-theme="dark"] .contact-form-container {
  padding: clamp(30px, 4vw, 48px);
  background: var(--card-bg);
  border-radius: 30px;
}
.contact-info-item {
  margin-bottom: 24px;
  padding-bottom: 24px;
}
.contact-form {
  gap: 22px;
}
.form-group input,
.form-group textarea,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea {
  background: var(--background);
  border-color: var(--border-color);
}
.btn-submit {
  min-height: 48px;
  padding-inline: 24px;
}

/* Dark mode gets deliberate separation, not muddy grays */
[data-theme="dark"] .hero {
  border-color: #343434;
}
[data-theme="dark"] .project-card:hover,
[data-theme="dark"] .hackathon-card:hover,
[data-theme="dark"] .publication-item:hover {
  border-color: #686868;
}
[data-theme="dark"] .research-focus li,
[data-theme="dark"] .tag,
[data-theme="dark"] .skill-tag,
[data-theme="dark"] .project-tag {
  color: #d8d8d8;
  border-color: #484848;
}
[data-theme="dark"] .btn-outline,
[data-theme="dark"] .btn-accent {
  border-color: #505050;
}
[data-theme="dark"] .btn-outline:hover,
[data-theme="dark"] .btn-accent:hover {
  background: #292929;
  border-color: #777777;
}
[data-theme="dark"] .publication-filter {
  border-color: #484848;
}

@media (max-width: 1120px) {
  .publications-list,
  .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #other-projects .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .publication-item.featured {
    grid-column: span 2;
  }
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 48px;
  }
  .hero-content h1 {
    font-size: clamp(3.5rem, 9vw, 6rem);
  }
  .section-heading {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 0.55fr);
    gap: 28px;
  }
  .hackathon-card,
  #mobile-projects .project-card {
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  }
  .nav-link {
    padding-inline: 8px;
  }
  .language-toggle {
    display: none;
  }
}

@media (max-width: 768px) {
  .container {
    padding-inline: 20px;
  }
  .section {
    padding: 80px 0;
  }
  .section-heading {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 34px;
  }
  .section-heading .section-subtitle {
    justify-self: start;
    max-width: 560px;
  }
  .about-text {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .about-text p,
  .about-text p:first-child,
  .about-text p:nth-child(2),
  .about-text p:nth-child(3),
  .about-text p:nth-child(4),
  .about-text .about-vision {
    grid-column: 1;
  }
  .timeline-items {
    grid-template-columns: 1fr;
  }
  .timeline-item,
  .timeline-item:nth-child(odd) {
    grid-template-columns: 62px 24px minmax(0, 1fr);
    gap: 10px;
  }
  .timeline-item:first-child {
    grid-column: 1;
    grid-template-columns: 62px 24px minmax(0, 1fr);
    padding: 28px;
  }
  .publications-list {
    grid-template-columns: 1fr;
  }
  .publication-item.featured {
    grid-column: 1;
  }
  .projects-grid,
  .hackathons-grid {
    grid-template-columns: 1fr;
  }
  #other-projects .projects-grid {
    grid-template-columns: 1fr;
  }
  .hackathon-card,
  #mobile-projects .project-card {
    display: flex;
    flex-direction: column;
  }
  .hackathon-image,
  #mobile-projects .project-image {
    width: 100%;
    height: 280px;
    min-height: 0;
  }
  .contact-grid {
    grid-template-columns: 1fr;
  }
  .contact-form {
    grid-template-columns: 1fr;
  }
  .form-group.full-width {
    grid-column: 1;
  }
  .footer-content {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
  }
  .footer-about {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .btn {
    width: 100%;
  }
  .timeline-item,
  .timeline-item:nth-child(odd) {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .timeline-item:first-child {
    grid-template-columns: 1fr;
  }
  .timeline-icon {
    display: none;
  }
  .timeline-content {
    padding-left: 0;
  }
  .publication-item,
  .publication-item.featured {
    padding: 24px 20px;
  }
  .footer-content {
    grid-template-columns: 1fr;
  }
  .footer-about {
    grid-column: auto;
  }
  .footer-copyright {
    flex-direction: column;
    gap: 7px;
  }
}

/* Final contrast and legacy-style resets */
.section-heading .animate-on-scroll,
.section-heading .section-title,
.section-heading .section-subtitle {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

.about-text .about-vision {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  color: var(--text-primary) !important;
  background: var(--surface) !important;
  background-image: none !important;
  background-clip: border-box !important;
  -webkit-background-clip: border-box !important;
  -webkit-text-fill-color: currentColor !important;
  animation: none !important;
  transform: none !important;
}

#career .timeline-content,
#career .timeline-content:hover,
#career .timeline-content.hover-effect,
#career .timeline-item:nth-child(odd) .timeline-content:hover,
#career .timeline-item:nth-child(even) .timeline-content:hover,
[data-theme="dark"] #career .timeline-content,
[data-theme="dark"] #career .timeline-content:hover {
  width: auto !important;
  margin: 0 !important;
  padding: 0 0 0 2px !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible !important;
  transform: none !important;
}

#career .timeline-content::before {
  display: none !important;
}

/* Refined hero portrait and secondary interactive CTA */
.hero-aside {
  display: grid;
  min-width: 0;
  justify-items: center;
  align-content: center;
  gap: 20px;
}

.hero-aside .hero-image {
  width: min(100%, 380px);
  display: grid;
  place-items: center;
}

.hero-aside .profile-image {
  width: 100%;
  aspect-ratio: 1;
  margin: 0;
  object-fit: cover;
  object-position: 50% 38%;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
}

.hero-aside .game-button-row {
  width: min(100%, 380px);
  margin: 0;
}

#game-btn.btn-game,
[data-theme="dark"] #game-btn.btn-game {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  text-align: left;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

#game-btn.btn-game:hover,
[data-theme="dark"] #game-btn.btn-game:hover {
  color: var(--background);
  background: var(--text-primary);
  border-color: var(--text-primary);
}

.game-btn-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--background);
  background: var(--text-primary);
  border-radius: 12px;
}

.game-btn-icon i {
  color: inherit !important;
}

#game-btn:hover .game-btn-icon {
  color: var(--text-primary);
  background: var(--background);
}

.game-btn-content {
  display: grid;
  min-width: 0;
  gap: 2px;
}
.game-btn-main {
  color: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.25;
}
.game-btn-subtitle {
  color: inherit;
  font-size: 0.7rem;
  font-weight: 450;
  line-height: 1.35;
  opacity: 0.64;
}
.game-btn-arrow {
  color: inherit;
  font-size: 0.72rem;
}

/* Calm section backgrounds: no particles, grids, or neural-network canvas */
.projects-neural-network,
#publications .section-title::before,
#projects .section-title::before,
.section-title::before,
#publications::before,
#publications::after,
#projects::before,
#projects::after {
  display: none !important;
  content: none !important;
  background: none !important;
  animation: none !important;
}

/* Editorial project stories with uncropped imagery */
#projects .projects-grid {
  grid-template-columns: 1fr;
  gap: 18px;
}

#projects .project-card {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.18fr);
  min-height: 350px;
}

#projects .project-card:nth-child(even) .project-image {
  order: 2;
}

#projects .project-image {
  width: auto;
  height: auto;
  min-height: 0;
  aspect-ratio: 16 / 9;
  align-self: center;
  margin: 14px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 22px;
}

#projects .project-image img,
#hackathons .hackathon-image img,
#mobile-projects .project-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: none !important;
}

#projects .project-content {
  justify-content: center;
  padding: clamp(30px, 5vw, 56px);
}

#projects .project-description {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

#projects .project-card:hover,
#hackathons .hackathon-card:hover,
#mobile-projects .project-card:hover,
[data-theme="dark"] #projects .project-card:hover,
[data-theme="dark"] #hackathons .hackathon-card:hover,
[data-theme="dark"] #mobile-projects .project-card:hover {
  border-color: var(--text-secondary);
  box-shadow: none;
  transform: none;
}

#hackathons .hackathon-card,
#mobile-projects .project-card {
  display: flex;
  flex-direction: column;
}

#hackathons .hackathon-image,
#mobile-projects .project-image {
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 16 / 9;
  background: var(--surface);
}

#hackathons .hackathon-content,
#mobile-projects .project-content {
  padding: clamp(30px, 5vw, 56px);
}

#hackathons .hackathon-description,
#mobile-projects .project-description {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

/* Theme-safe buttons and controls */
.btn-outline,
.btn-accent,
[data-theme="dark"] .btn-outline,
[data-theme="dark"] .btn-accent {
  color: var(--text-primary);
  background: transparent;
  border-color: var(--border-color);
}

.btn-outline:hover,
.btn-accent:hover,
[data-theme="dark"] .btn-outline:hover,
[data-theme="dark"] .btn-accent:hover {
  color: var(--background);
  background: var(--text-primary);
  border-color: var(--text-primary);
  opacity: 1;
}

.btn-primary,
.btn-submit,
.nav-cv,
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-submit,
[data-theme="dark"] .nav-cv {
  color: var(--background);
  background: var(--text-primary);
}

.btn-primary i,
.btn-outline i,
.btn-accent i,
.btn-submit i,
.project-link i {
  color: inherit !important;
}

.project-link:hover,
[data-theme="dark"] .project-link:hover {
  color: var(--background);
  background: var(--text-primary);
  border-color: var(--text-primary);
}

.scroll-to-top,
[data-theme="dark"] .scroll-to-top {
  color: var(--text-primary) !important;
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: none !important;
  backdrop-filter: none;
}

.scroll-to-top i,
[data-theme="dark"] .scroll-to-top i {
  color: inherit !important;
}

.scroll-to-top:hover,
[data-theme="dark"] .scroll-to-top:hover {
  color: var(--background) !important;
  background: var(--text-primary) !important;
  border-color: var(--text-primary) !important;
  box-shadow: none !important;
  transform: translateY(-2px);
}

.theme-toggle svg,
.theme-toggle svg path {
  stroke: var(--text-primary) !important;
  fill: none !important;
}

@media (max-width: 980px) {
  .hero-aside .hero-image,
  .hero-aside .game-button-row {
    width: min(100%, 300px);
  }
  #projects .project-card {
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  }
}

@media (max-width: 768px) {
  #projects .project-card {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }
  #projects .project-card:nth-child(even) .project-image {
    order: 0;
  }
  #projects .project-image {
    width: auto;
    margin: 10px;
  }
  #hackathons .hackathon-image,
  #mobile-projects .project-image {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 480px) {
  #game-btn.btn-game {
    min-height: 68px;
    border-radius: 18px;
  }
  #projects .project-content,
  #hackathons .hackathon-content,
  #mobile-projects .project-content {
    padding: 26px 20px;
  }
}

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

/* Compact portfolio cards and a natural portrait treatment. */
.game-button-row {
  display: none !important;
}

.hero-aside .hero-image {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 1;
  padding: 0;
  background: linear-gradient(180deg, #f7f7f5 0%, #e4e5e5 100%);
  border: 1px solid rgba(17, 17, 17, 0.09);
  border-radius: 30px;
  box-shadow: 0 24px 56px -30px rgba(17, 24, 39, 0.42);
}

.hero-aside .hero-image::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 10% 8% 12%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 50% 42%,
    rgba(255, 255, 255, 0.82) 0%,
    rgba(255, 255, 255, 0.38) 42%,
    transparent 72%
  );
  filter: blur(14px);
}

.hero-aside .hero-image::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: 2%;
  width: 72%;
  height: 12%;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.14);
  filter: blur(18px);
  transform: translateX(-50%);
}

.hero-aside .profile-image {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center bottom;
  border: 0;
  /* Clip the replaced image itself instead of relying on Safari to apply the
     rounded ancestor's overflow clip to a separate image layer. */
  border-radius: inherit;
  filter: none;
  box-shadow: none;
}

[data-theme="dark"] .hero-aside .hero-image {
  background: linear-gradient(180deg, #292a2c 0%, #17181a 100%);
  border-color: rgba(255, 255, 255, 0.11);
  box-shadow: 0 26px 62px -32px rgba(0, 0, 0, 0.9);
}

[data-theme="dark"] .hero-aside .hero-image::before {
  background: radial-gradient(
    ellipse at 50% 42%,
    rgba(255, 255, 255, 0.11) 0%,
    rgba(255, 255, 255, 0.035) 44%,
    transparent 72%
  );
}

[data-theme="dark"] .hero-aside .hero-image::after {
  background: rgba(0, 0, 0, 0.42);
}

[data-theme="dark"] .hero-aside .profile-image {
  filter: none;
}

/* Research projects: repository-style cards. The cover image remains in Read more. */
#projects .projects-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

/* Section-scoped selectors also neutralize stale, pre-redesign card markup. */
#projects .project-card,
#projects .project-card--research {
  display: flex !important;
  grid-template-columns: none !important;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  border-radius: 14px;
  background: var(--card-bg);
}

#projects .project-image {
  display: none !important;
}

#projects .project-card .project-content,
#projects .project-card--research .project-content {
  width: 100%;
  min-width: 0;
  padding: 24px;
  justify-content: flex-start;
}

.project-repository-heading {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  margin-bottom: 12px;
}

.project-repository-icon {
  display: inline-grid;
  width: 20px;
  height: 24px;
  place-items: center start;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.project-repository-visibility {
  padding: 2px 7px;
  color: var(--text-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.35;
}

#projects .project-card .project-title,
#projects .project-card--research .project-title {
  margin: 1px 0 0;
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#projects .project-card .project-description,
#projects .project-card--research .project-description {
  display: -webkit-box;
  flex-grow: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

#projects .project-card .project-tags,
#projects .project-card--research .project-tags {
  margin: 16px 0 0;
  overflow: visible;
}

#projects .project-card .project-links,
#projects .project-card--research .project-links {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

#projects .project-card .project-read-more,
#projects .project-card--research .project-read-more {
  width: fit-content;
  margin: 14px 0 0;
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Hackathon: concise editorial card with a clearly separated team block. */
#hackathons .hackathon-card {
  display: grid;
  grid-template-columns: minmax(420px, 0.88fr) minmax(0, 1.12fr);
  align-items: stretch;
  min-height: 0;
  border-radius: 20px;
}

#hackathons .hackathon-image {
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  background: #171717;
}

#hackathons .hackathon-image img {
  object-fit: contain;
  object-position: center;
}

#hackathons .hackathon-achievement,
#hackathons .hackathon-achievement.position-2nd {
  top: 18px;
  right: auto;
  left: 18px;
  max-width: calc(100% - 36px);
  padding: 7px 11px;
  color: #fff;
  background: rgba(17, 17, 17, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 9px;
  box-shadow: none;
  backdrop-filter: blur(10px);
  text-shadow: none;
  font-size: 0.72rem;
  line-height: 1.35;
}

#hackathons .hackathon-content {
  padding: 34px 36px;
  justify-content: center;
}

#hackathons .hackathon-header {
  align-items: baseline;
  margin-bottom: 18px;
}

#hackathons .hackathon-title {
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}
#hackathons .hackathon-date {
  padding-top: 3px;
}
#hackathons .hackathon-description {
  display: -webkit-box;
  flex-grow: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  margin-bottom: 0;
  font-size: 0.95rem;
  line-height: 1.65;
}

#hackathons .hackathon-read-more {
  display: none;
}

#hackathons .hackathon-team {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 22px 0 18px;
  padding: 17px 0 0;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border-color);
  border-radius: 0;
}

#hackathons .hackathon-team strong {
  flex: 0 0 auto;
  margin: 1px 0 0;
  font-size: 0.76rem;
}
#hackathons .team-members {
  gap: 4px 9px;
  margin: 0;
}
#hackathons .team-member-link,
#hackathons .team-member {
  font-size: 0.82rem;
  line-height: 1.4;
}
#hackathons .hackathon-tags {
  margin: 0 0 20px;
}
#hackathons .hackathon-links {
  gap: 9px 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

#hackathons .hackathon-links .project-link {
  min-height: 36px;
  padding: 7px 10px;
}

#hackathons .hackathon-links .project-link-primary {
  padding-inline: 14px;
  color: var(--background) !important;
  background: var(--text-primary);
  border-color: var(--text-primary);
  border-radius: 9px;
  box-shadow: none;
}

#hackathons .hackathon-links .project-link-primary:hover,
[data-theme="dark"] #hackathons .hackathon-links .project-link-primary:hover {
  color: var(--background) !important;
  background: var(--text-primary);
  border-color: var(--text-primary);
}

/* Keep secondary project-link hover surfaces padded and button-shaped. */
#projects .project-link,
#hackathons .project-link,
#mobile-projects .project-link,
#other-projects .project-link {
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  line-height: 1.25;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

/* Mobile work: smaller product cards, aligned with the rest of the site. */
#mobile-projects .projects-grid {
  gap: 16px;
}
#mobile-projects .project-card {
  display: grid;
  grid-template-columns: minmax(420px, 0.88fr) minmax(0, 1.12fr);
  align-items: stretch;
  min-height: 0;
  height: auto;
  border-radius: 20px;
}

#mobile-projects .project-image {
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  padding: 28px;
  background: #ffffff;
}
#mobile-projects .project-image img {
  object-fit: contain;
}
#mobile-projects .project-content {
  padding: 34px 36px;
  justify-content: center;
}
#mobile-projects .project-title {
  margin-bottom: 16px;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}
#mobile-projects .project-description {
  display: -webkit-box;
  flex-grow: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  margin-bottom: 0;
  font-size: 0.95rem;
  line-height: 1.65;
}
#mobile-projects .project-read-more {
  display: none;
}
#mobile-projects .project-tags {
  max-height: none;
  margin: 22px 0 20px;
  overflow: visible;
}
#mobile-projects .project-links {
  flex-wrap: wrap;
  gap: 9px 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

@media (max-width: 768px) {
  #projects .projects-grid {
    grid-template-columns: 1fr;
  }
  #hackathons .hackathon-card,
  #mobile-projects .project-card {
    display: flex;
    flex-direction: column;
  }
  #hackathons .hackathon-image {
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }
  #mobile-projects .project-image {
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
    padding: 22px;
  }
  #hackathons .hackathon-content,
  #mobile-projects .project-content {
    padding: 22px;
  }
}

@media (max-width: 480px) {
  #hackathons .hackathon-team {
    display: grid;
    gap: 7px;
  }
}

/* Definitive compact navigation and hero layout for phones and tablets. */
@media (max-width: 900px) {
  .header .container {
    padding-inline: 18px;
  }
  .header-content,
  .header.scrolled .header-content {
    height: 64px;
  }
  .navbar-full,
  .header.scrolled .navbar-full {
    position: relative;
    display: flex;
    justify-content: space-between;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
  }
  .logo-brand {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
  .logo-horizontal {
    display: none !important;
  }
  .logo-mobile-light {
    display: block;
  }
  [data-theme="dark"] .logo-mobile-light {
    display: none;
  }
  [data-theme="dark"] .logo-mobile-dark {
    display: block;
  }
  .menu-toggle {
    position: fixed !important;
    top: 11px;
    right: 18px;
    z-index: 1100;
    display: inline-grid !important;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-content: center;
    gap: 6px;
    margin-left: auto;
    padding: 0;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
  }
  .menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 160ms ease;
  }
  .menu-toggle.active span:first-child,
  .menu-toggle[aria-expanded="true"] span:first-child {
    transform: translateY(4px) rotate(45deg);
  }
  .menu-toggle.active span:last-child,
  .menu-toggle[aria-expanded="true"] span:last-child {
    transform: translateY(-4px) rotate(-45deg);
  }
  .navbar-full .nav-menu {
    position: fixed;
    inset: 74px 16px auto;
    z-index: 1001;
    display: block !important;
    max-height: 0;
    margin: 0;
    padding: 0 18px;
    background: var(--card-bg);
    border: 1px solid transparent;
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition:
      max-height 220ms ease,
      opacity 160ms ease,
      padding 220ms ease,
      transform 160ms ease,
      visibility 160ms ease;
  }
  .navbar-full .nav-menu.active {
    max-height: calc(100svh - 94px);
    padding-block: 8px 16px;
    border-color: var(--border-color);
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
  .navbar-full .nav-list {
    display: grid;
    gap: 0;
  }
  .navbar-full .mobile-only {
    display: list-item;
  }
  .navbar-full .nav-menu .nav-actions {
    display: flex !important;
    justify-content: flex-start;
    gap: 12px;
    margin: 14px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
  }
  .navbar-full .nav-menu .nav-cv {
    display: none;
  }
  #language-toggle.site-language-toggle {
    position: static !important;
    display: inline-grid !important;
    grid-template-columns: 1fr 1fr;
    width: 82px !important;
    min-width: 82px !important;
    max-width: 82px !important;
    height: 38px !important;
    padding: 4px !important;
    gap: 3px !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: var(--text-primary) !important;
    background: var(--surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 999px !important;
  }
  #language-toggle.site-language-toggle .lang-text {
    position: static !important;
    display: grid !important;
    width: auto !important;
    height: 28px !important;
    place-items: center;
    opacity: 0.55 !important;
    visibility: visible !important;
    color: var(--text-primary) !important;
    background: transparent !important;
    border-radius: 999px;
    font-size: 10px !important;
    line-height: 1 !important;
    transform: none !important;
  }
  #language-toggle.site-language-toggle:not(.it) .lang-text.en,
  #language-toggle.site-language-toggle.it .lang-text.it {
    color: var(--background) !important;
    background: var(--text-primary) !important;
    opacity: 1 !important;
  }
  #dark-mode-toggle.site-theme-toggle {
    position: static !important;
    display: inline-grid !important;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    place-items: center;
    padding: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 50% !important;
    box-shadow: none !important;
  }
  #dark-mode-toggle.site-theme-toggle .icon-sun,
  #dark-mode-toggle.site-theme-toggle .icon-moon {
    width: 18px !important;
    height: 18px !important;
    place-items: center;
  }
  #dark-mode-toggle.site-theme-toggle svg {
    width: 16px !important;
    height: 16px !important;
  }
  .navbar-full .nav-link {
    padding: 14px 2px;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 1rem;
  }
  .navbar-full .nav-list li:last-child .nav-link {
    border-bottom: 0;
  }
}

@media (min-width: 901px) {
  .navbar-full .nav-menu .nav-actions {
    display: flex !important;
  }
  .navbar-full .nav-menu .language-toggle {
    display: flex !important;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .navbar-full .logo-text {
    display: none;
  }
}

@media (max-width: 900px) {
  #home {
    min-height: auto;
    padding-top: 96px;
    padding-bottom: 72px;
  }
  #home > .container {
    padding-inline: 20px;
  }
  .hero {
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
  }
  .hero-aside {
    order: -1;
    display: grid;
    width: 100%;
    min-width: 0;
    justify-items: center;
  }
  .hero-aside .hero-image {
    width: 116px;
    min-width: 0;
    box-sizing: border-box;
    aspect-ratio: 1;
    margin: 0 auto;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    box-shadow: none;
  }
  .hero-aside .hero-image::before,
  .hero-aside .hero-image::after {
    display: none;
  }
  .hero-aside .profile-image {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: cover;
    object-position: center top;
    border: 0;
    border-radius: inherit;
    box-shadow: none;
  }
  .hero-content {
    width: 100%;
    max-width: 680px;
    overflow: visible;
  }
  .hero-kicker {
    margin-bottom: 16px;
    font-size: 0.7rem;
    line-height: 1.4;
    letter-spacing: 0.1em;
  }
  .hero-content h1 {
    max-width: 100%;
    font-size: clamp(2.75rem, 12vw, 4.5rem);
    line-height: 0.94;
    letter-spacing: 0;
    overflow-wrap: normal;
  }
  .hero-content h2 {
    margin: 22px 0 14px;
    font-size: clamp(1.3rem, 5vw, 1.8rem);
    line-height: 1.25;
    letter-spacing: 0;
    overflow-wrap: normal;
  }
  .hero-content .lead {
    font-size: 1rem;
    line-height: 1.65;
    overflow-wrap: normal;
  }
  .research-focus {
    margin-top: 24px;
  }
  .cta-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    margin-top: 30px;
  }
  .cta-buttons .btn {
    width: 100%;
  }
  .cta-buttons .btn-primary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .hero-content h1 {
    font-size: clamp(2.65rem, 13.5vw, 3.5rem);
  }
  .cta-buttons {
    grid-template-columns: 1fr;
  }
  .cta-buttons .btn-primary {
    grid-column: auto;
  }
}

/* Compact contact form rhythm on phones and tablets. */
@media (max-width: 768px) {
  #contact .contact-container {
    padding-inline: 0;
  }
  #contact .contact-grid {
    gap: 18px;
  }
  #contact .contact-info {
    margin-bottom: 0;
  }
  #contact .contact-form-container,
  [data-theme="dark"] #contact .contact-form-container {
    width: 100%;
    padding: 22px;
    border-radius: 22px;
  }
  #contact .contact-form {
    gap: 16px;
  }
  #contact .form-group {
    gap: 7px;
    margin-bottom: 0;
  }
  #contact .form-group label {
    margin-bottom: 0;
  }
  #contact .form-group input,
  #contact .form-group textarea,
  [data-theme="dark"] #contact .form-group input,
  [data-theme="dark"] #contact .form-group textarea {
    padding: 13px 14px;
    border-radius: 13px;
  }
  #contact .form-group textarea {
    min-height: 132px;
  }
  #contact .validation-message:empty,
  #contact .form-status:not(.visible) {
    display: none;
  }
  #contact .form-submit {
    margin-top: 2px;
    justify-content: stretch;
  }
  #contact .btn-submit {
    width: 100%;
    min-height: 48px;
    margin-top: 0;
    padding: 12px 18px;
  }
  #contact .form-status.visible {
    margin-top: 0;
    padding: 12px 14px;
  }
}

@media (max-width: 480px) {
  #contact .contact-form-container,
  [data-theme="dark"] #contact .contact-form-container {
    padding: 18px;
    border-radius: 20px;
  }
  #contact .contact-form {
    gap: 14px;
  }
}
