:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #10b981;
  --accent: #f59e0b;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border: #334155;
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 35px 60px -12px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

/* Navigation */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
}

.nav.scrolled {
  background: rgba(15, 23, 42, 0.95);
  box-shadow: var(--shadow);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  overflow: hidden;
  font-family: inherit;
  position: relative;
  border-right: none;
}
.logo.typewriter-cursor {
  border-right: 1.5px solid var(--primary);
  animation: blink-cursor 0.7s steps(1) infinite;
}
@keyframes blink-cursor {
  0%,
  49% {
    border-color: var(--primary);
  }
  50%,
  100% {
    border-color: transparent;
  }
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
}

.nav-links a::after {
  content: "";
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -4px;
  left: 0;
  background: var(--gradient);
  transition: width 0.3s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

.mobile-toggle {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-toggle span {
  width: 25px;
  height: 3px;
  background: var(--text-primary);
  margin: 3px 0;
  transition: 0.3s;
  border-radius: 2px;
}

/* Hero Section */
.hero {
  min-height: 100vh;
  padding-top: 100px;
  display: flex;
  align-items: center;
  position: relative;
  background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
}

.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="%23334155" stroke-width="0.5" opacity="0.3"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  opacity: 0.3;
}

.hero-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  position: relative;
  z-index: 1;
}
.hero-container404 {
  gap: 4rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.hero-content h1 {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeInUp 1s ease-out;
}

.hero-content .subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  animation: fadeInUp 1s ease-out 0.2s both;
}

.hero-content .description {
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.8;
  animation: fadeInUp 1s ease-out 0.4s both;
}

.hero-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  animation: fadeInUp 1s ease-out 0.6s both;
}

.stat {
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  animation: fadeInUp 1s ease-out 0.8s both;
}

.btn {
  padding: 0.75rem 2rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-light);
  transform: translateY(-2px);
}

.hero-image {
  position: relative;
  animation: fadeInRight 1s ease-out 0.4s both;
}

.hero-avatar {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: var(--gradient);
  padding: 4px;
  margin: 0 auto;
  position: relative;
  animation: float 6s ease-in-out infinite;
}

.hero-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
}

.floating-elements {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.floating-element {
  position: absolute;
  background: var(--gradient);
  border-radius: 50%;
  opacity: 0.1;
  animation: float 8s ease-in-out infinite;
}

.floating-element:nth-child(1) {
  width: 80px;
  height: 80px;
  top: 20%;
  left: 10%;
  animation-delay: 0s;
}

.floating-element:nth-child(2) {
  width: 60px;
  height: 60px;
  top: 60%;
  right: 15%;
  animation-delay: 2s;
}

.floating-element:nth-child(3) {
  width: 40px;
  height: 40px;
  bottom: 20%;
  left: 20%;
  animation-delay: 4s;
}

/* Sections */
.section {
  padding: 3rem 0 3rem 0;
  position: relative;
  border-radius: 1.5rem;
  margin-bottom: 1rem;

  transition: background 0.3s;
  scroll-margin-top: 90px;
}
.section:nth-of-type(odd) {
  color: #1e293b;
}
.section:nth-of-type(odd) a {
  color: var(--primary);
}
.section:nth-of-type(even) {
  color: var(--text-primary);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}
@media (max-width: 768px) {
  .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
  }
}
.section-header {
  text-align: center;
  margin-bottom: 4rem;
}

.section-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-subtitle {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Experience Cards */
.experience-grid {
  display: grid;
  gap: 2rem;
}
.experience-card {
  background: var(--surface);
  border-radius: 1rem;
  padding: 2rem;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
@media (max-width: 768px) {
  .experience-card {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1.3rem;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
  }
}

.experience-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.experience-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.experience-card:hover::before {
  transform: scaleX(1);
}

.experience-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.experience-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.experience-company {
  color: var(--primary);
  font-weight: 500;
}

.experience-date {
  color: var(--text-muted);
  font-size: 0.875rem;
  background: var(--surface-light);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  white-space: nowrap;
}

.experience-description {
  color: var(--text-secondary);
  line-height: 1.7;
}

.experience-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  margin-top: 1rem;
  transition: color 0.3s ease;
}

.experience-link:hover {
  color: var(--primary-dark);
}

/* Skills Section */
.skills-grid {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-top: 2rem;
  width: 100vw;
  max-width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}
.skills-marquee-row {
  overflow: hidden;
  width: 100vw;
  position: relative;
  height: 2.6rem;
}
.skills-marquee-track {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  width: max-content;
}
.skills-marquee-row:nth-child(odd) .skills-marquee-track {
  animation: marquee-left 36s linear infinite;
}
.skills-marquee-row:nth-child(even) .skills-marquee-track {
  animation: marquee-right 36s linear infinite;
}
@keyframes marquee-left {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}
@keyframes marquee-right {
  0% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(0);
  }
}
@media (max-width: 600px) {
  .skills-marquee-row {
    height: 3rem;
  }
}
.skills-grid:hover .skills-marquee-track {
  animation-play-state: paused;
}

/* Tech Stack */
.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.tech-tag {
  background: var(--surface);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.tech-tag:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

/* Contact Section */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}

.contact-info {
  space-y: 2rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.contact-icon {
  width: 50px;
  height: 50px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
}

.contact-details h4 {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.contact-details p {
  color: var(--text-muted);
}

.contact-details a {
  color: var(--primary);
  text-decoration: none;
}

.social-links {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.social-link {
  width: 50px;
  height: 50px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.3s ease;
}

.social-link:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

/* Footer */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 3rem 0;
  margin-top: 5rem;
  text-align: center;
  color: var(--text-muted);
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    right: 2rem;
    left: auto;
    background: var(--surface);
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.5rem 2rem;
    border-radius: 1rem;
    box-shadow: 0 8px 32px 0 rgba(11, 14, 43, 0.653);
    min-width: 180px;
    max-width: 80vw;
    align-items: flex-end;
    transition: opacity 0.3s, transform 0.3s;
    opacity: 0;
    pointer-events: none;
    z-index: 2000;
    transform: translateY(-20px) scale(0.98);
    max-height: 80vh;
    overflow-y: auto;
  }
  .nav-links.open {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }
  .nav-links.closing {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px) scale(0.98);
  }
  .nav-links li {
    width: 100%;
    text-align: right;
    margin: 0.5rem 0;
  }
  .nav-links a {
    padding: 0.75rem 0;
    width: 100%;
    display: block;
  }
  .mobile-toggle {
    display: flex;
  }
  .hero-container {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2rem;
  }

  .hero-content h1 {
    font-size: 2.5rem;
  }

  .hero-stats {
    justify-content: center;
  }

  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-buttons {
    justify-content: center;
  }

  .hero-social {
    justify-content: center !important;
  }
}

/* Scroll animations */
.reveal {
  opacity: 1 !important;
  transform: none !important;
}

html {
  scroll-behavior: smooth;
}

.hero-social {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 2.5rem;
  margin: 1.5rem 0 2rem 0;
}
.hero-social a {
  color: var(--text-muted);
  font-size: 1.5rem;
  transition: color 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  background: var(--surface);
  box-shadow: 0 2px 8px 0 rgba(31, 38, 135, 0.1);
  text-decoration: none;
}
.hero-social a:hover {
  color: #fff;
  background: var(--primary);
  transform: scale(1.12) rotate(-6deg);
}

/* Progetti Privati Section */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}
.project-card {
  background: var(--surface);
  border-radius: 1rem;
  padding: 2rem;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px 0 rgba(31, 38, 135, 0.08);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: transform 0.2s, box-shadow 0.2s;
}
.project-card:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
  border-color: var(--primary);
}
.project-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.project-description {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.project-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  margin-top: auto;
  transition: color 0.2s;
}
.project-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

#status-container {
  margin-top: 1.5rem;
  font-size: 1.1rem;
  color: var(--text-primary);
}
#status-container div {
  margin-bottom: 0.5rem;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--surface);
  border-radius: 1rem;
  box-shadow: 0 4px 16px 0 rgba(31, 38, 135, 0.08);
  padding: 2rem;
  margin: 0 auto;
  max-width: 600px;
  margin-top: 2rem;
}
.status-icon {
  font-size: 2.5rem;
  color: var(--primary);
  background: var(--surface-light);
  border-radius: 50%;
  width: 3.5rem;
  aspect-ratio: 1/1;
  min-width: 2.5rem;
  max-width: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ecg-svg {
  width: 2.5rem;
  height: 2.5rem;
  display: block;
}
.ecg-line {
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  animation: ecg-move 3s linear infinite;
}
@keyframes ecg-move {
  0% {
    stroke-dashoffset: 500;
  }

  100% {
    stroke-dashoffset: 0;
  }
}
.status-info h3 {
  margin: 0 0 0.5rem 0;
  color: var(--primary);
}
.status-info p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
@media (max-width: 600px) {
  .status-card {
    flex-direction: column;
    gap: 1rem;
    padding: 1.2rem;
  }
  .status-icon {
    width: 2.5rem;
    min-width: 2rem;
    font-size: 1.5rem;
  }
}

.press-showcase {
  margin-top: 1.2rem;
}
.press-title {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}
.press-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.press-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  background: var(--surface-light);
  border-radius: 0.7rem;
  box-shadow: 0 2px 8px 0 rgba(31, 38, 135, 0.07);
  padding: 0.8rem 1.1rem;
  text-decoration: none;
  color: var(--primary);
  min-width: 180px;
  max-width: 260px;
  transition: box-shadow 0.2s, transform 0.2s;
}
.press-card:hover {
  box-shadow: 0 6px 18px 0 rgba(99, 102, 241, 0.13);
  transform: translateY(-2px) scale(1.03);
  color: var(--primary-dark);
}
.press-logo {
  font-size: 1.6rem;
  color: var(--primary);
  margin-top: 0.1rem;
}
.press-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}
.press-quote {
  color: var(--text-secondary);
  font-size: 0.93rem;
  line-height: 1.3;
}
@media (max-width: 600px) {
  .press-cards {
    flex-direction: column;
    gap: 0.7rem;
  }
}

.main-404 {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding-top: 0px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
}
.main-404::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="%23334155" stroke-width="0.5" opacity="0.3"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  opacity: 0.3;
}
.error-code {
  font-size: 7rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  letter-spacing: -0.05em;
}
.error-message {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}
.error-desc {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .main-404 {
    padding-top: 90px;
  }
  .error-code {
    font-size: 4rem;
  }
  .error-message {
    font-size: 1.3rem;
  }
}
