/* --- INTEGRATED VARIABLES --- */
:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --text-main-landing: #f8fafc;
  --text-muted: #94a3b8;
  --nav-bg: rgba(15, 23, 42, 0.95);

  --font-main: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --brand-dark: #0f172a;
  --brand-primary: #1e40af; /* Blu Scuro */
  --brand-accent: #3b82f6;
  --brand-light: #eff6ff;
  --brand-white: #ffffff;

  --text-main: #334155;
  --text-light: #64748b;

  --container-width: 1024px;
  --section-padding: 80px 0;
  --border-radius: 12px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-main);
  color: var(--text-main);
  background-color: var(--brand-white);
  line-height: 1.6;
  padding-top: 100px;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; transition: color var(--transition-fast); }
ul { list-style: none; }

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

/* --- NAVBAR --- */
.navbar {
  position: fixed; top: 0; width: 100%; z-index: 1000;
  padding: 1.5rem 0; background: var(--nav-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: padding 0.3s ease;
}
.navbar.scrolled { padding: 1rem 0; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.navbar .container {
  max-width: 1200px; margin: 0 auto; padding: 0 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
}
.logo {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 0.5rem; color: white;
  transition: transform var(--transition-fast);
}
.logo:hover { transform: scale(1.02); }
.logo span { color: var(--primary); }

.nav-menu { display: flex; align-items: center; gap: 2.5rem; }
.nav-link {
  font-size: 0.95rem; font-weight: 500; color: var(--text-muted);
  position: relative; padding: 0.2rem 0;
}
.nav-link:hover, .nav-link.active { color: white; }
.nav-link::after {
  content: ''; position: absolute; width: 0; height: 2px;
  bottom: -2px; left: 0; background-color: var(--primary);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-link:hover::after, .nav-link.active::after { width: 100%; }

/* Swipe Button Effect */
.swipe-hover-effect {
  position: relative; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(231, 235, 252, 0.5);
  overflow: hidden; transition: border-color 0.3s; z-index: 1;
}
.swipe-hover-effect::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(59, 130, 246, 0.1); border: 2px solid var(--primary);
  box-sizing: border-box; clip-path: inset(0 100% 0 0);
  transition: clip-path 0.4s cubic-bezier(0.25, 1, 0.5, 1); z-index: -1;
}
.swipe-hover-effect:hover { border-color: transparent; }
.swipe-hover-effect:hover::before { clip-path: inset(0 0 0 0); }

.lang-btn {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.8rem;
  border-radius: 4px; font-size: 0.8rem; font-weight: 600;
  color: rgb(231, 235, 252); cursor: pointer;
}
.lang-btn::before { border-radius: 4px; }

/* --- BUTTONS --- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.9rem 2rem; border-radius: 50px; font-weight: 600;
  font-size: 1rem; text-decoration: none; border: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 1.5rem; cursor: pointer;
}
.btn-primary {
  background-color: var(--brand-primary); color: white;
  box-shadow: 0 4px 15px rgba(30, 64, 175, 0.3);
}
.btn-primary:hover {
  background-color: var(--brand-accent); transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4); color: white;
}

/* Mobile Toggle */
.menu-toggle { display: none; cursor: pointer; z-index: 1100;}
.menu-toggle span {
  display: block; width: 25px; height: 2px; background: white; margin: 6px 0;
  transition: 0.3s;
}
.menu-toggle.active span:nth-child(1) { transform: rotate(-45deg) translate(-6px, 5px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(45deg) translate(-6px, -5px); }

@media (max-width: 768px) {
  .nav-menu {
    position: fixed; top: 0; right: 0; width: 100%; height: 100vh;
    background: #0f172a; flex-direction: column; justify-content: center;
    transform: translateX(100%); transition: 0.4s ease-in-out;
  }
  .nav-menu.active { transform: translateX(0); }
  .menu-toggle { display: block; }

  /* MODIFICA: Regola specifica per centrare il bottone CV su mobile */
  #openCvModalBtn {
    display: flex;
    width: 100%; /* Occupa tutta la larghezza */
    justify-content: center; /* Centra il contenuto */
    margin-left: auto;
    margin-right: auto;
  }
}

/* --- LAYOUT & SECTIONS --- */
.container { max-width: var(--container-width); margin: 0 auto; padding: 0 20px; }
.section { padding: var(--section-padding); position: relative; }
.bg-light { background-color: var(--brand-light); }
.bg-dark { background-color: var(--brand-dark); color: var(--brand-white); }

h2.section-label {
  color: var(--brand-primary); font-size: 1.1rem; text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 700; margin-bottom: 0.5rem;
  display: inline-block; position: relative;
}
h3.section-title {
  font-size: 2.5rem; font-weight: 800; color: #1e293b;
  margin-bottom: 3rem; letter-spacing: -0.03em;
  position: relative; display: inline-block;
}
h3.section-title::after {
  content: ''; position: absolute; bottom: -5px; left: 0;
  width: 60px; height: 4px; background: var(--brand-accent);
  border-radius: 2px; transition: width var(--transition-smooth);
}
.section:hover h3.section-title::after { width: 100px; }
.bg-dark h3.section-title { color: white; }
.text-center { text-align: center; }
.text-center h3.section-title::after { left: 50%; transform: translateX(-50%); }

h4.subsection-title {
  font-size: 1.5rem; font-weight: 700; color: var(--brand-primary);
  margin-bottom: 1.5rem; padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.2); display: inline-block;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
h4.subsection-title:hover {
  color: var(--brand-accent); border-color: var(--brand-accent);
}

/* --- PROFILE --- */
.profile-wrapper {
  display: flex; flex-direction: column; gap: 2rem; perspective: 1000px;
}
.profile-content { font-size: 1.1rem; color: #475569; }
.profile-content p { margin-bottom: 1.5rem; text-align: justify; line-height: 1.8; opacity: 0.9; }
.profile-content strong { color: var(--brand-primary); font-weight: 600; }
@media (min-width: 768px) {
  .profile-wrapper { flex-direction: row; gap: 4rem; }
  .profile-header { width: 33%; }
  .profile-content { width: 66%; }
}

/* --- MODAL (POPUP) STYLES --- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px);
  z-index: 2000; opacity: 0; visibility: hidden;
  transition: all 0.3s ease; display: flex; align-items: center; justify-content: center;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-card {
  background: white; width: 90%; max-width: 500px;
  padding: 2.5rem; border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.modal-overlay.active .modal-card { transform: translateY(0); }

.modal-close {
  position: absolute; top: 1.5rem; right: 1.5rem;
  background: transparent; border: none; font-size: 1.5rem;
  color: var(--text-muted); cursor: pointer; transition: color 0.2s;
}
.modal-close:hover { color: var(--brand-primary); }

.modal-title { font-size: 1.5rem; font-weight: 700; color: #1e293b; margin-bottom: 0.5rem; }
.modal-desc { color: var(--text-light); font-size: 0.95rem; margin-bottom: 1.5rem; }

.form-group { margin-bottom: 1.2rem; }
.form-label { display: block; font-size: 0.9rem; font-weight: 600; color: #334155; margin-bottom: 0.4rem; }
.form-input {
  width: 100%; padding: 0.8rem; border: 1px solid #cbd5e1;
  border-radius: 8px; font-family: var(--font-main); font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  outline: none; border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.btn-full { width: 100%; justify-content: center; margin-top: 1rem; }

/* --- TIMELINE --- */
.timeline { position: relative; margin-top: 4rem; }
.timeline::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 20px; width: 3px;
  background: linear-gradient(to bottom, var(--brand-light), var(--brand-accent), var(--brand-light));
  border-radius: 3px;
}
.timeline-item { position: relative; margin-bottom: 4rem; display: flex; flex-direction: column; perspective: 1000px; }
.timeline-icon {
  position: absolute; left: 0; width: 44px; height: 44px; border-radius: 50%;
  background-color: var(--brand-white); border: 4px solid var(--brand-accent);
  display: flex; align-items: center; justify-content: center; z-index: 10;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); transition: all var(--transition-smooth);
}
.timeline-item:hover .timeline-icon {
  transform: scale(1.15) rotate(10deg); box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.2);
  background-color: var(--brand-accent); border-color: white;
}
.timeline-item:hover .timeline-icon i { color: white; }
.timeline-icon i { color: var(--brand-accent); font-size: 16px; transition: color var(--transition-fast); }

.timeline-date-container { padding-left: 65px; margin-bottom: 0.8rem; transition: transform var(--transition-smooth); }
.timeline-item:hover .timeline-date-container { transform: translateX(5px); }

.company-name { color: var(--brand-primary); font-weight: 700; font-size: 1.2rem; line-height: 1.2; }
.date-location { font-size: 0.9rem; color: var(--text-light); font-weight: 500; margin-top: 0.2rem; }

.timeline-card {
  background: white; padding: 2rem; border-radius: var(--border-radius);
  border: 1px solid rgba(226, 232, 240, 0.8); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  margin-left: 65px; position: relative; overflow: hidden;
  transition: all var(--transition-smooth); border-left: 4px solid transparent;
}
.timeline-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-left-color: var(--brand-accent); border-color: transparent;
}

.role-title {
  font-size: 1.3rem; font-weight: 700; color: #1e293b;
  margin-bottom: 1rem; transition: color var(--transition-fast);
}
.timeline-card:hover .role-title { color: var(--brand-primary); }

.role-list { list-style-type: none; padding-left: 0; font-size: 1rem; color: #475569; }
.role-list li { position: relative; padding-left: 1.5rem; margin-bottom: 0.5rem; }
.role-list li::before {
  content: '•'; color: var(--brand-accent); font-weight: bold;
  position: absolute; left: 0; font-size: 1.2rem; line-height: 1.4rem;
}
.role-sub-item { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px dashed #e2e8f0; }
.role-sub-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.role-sub-title { font-weight: 700; color: #334155; font-size: 1.05rem; margin-bottom: 0.25rem; }

@media (min-width: 768px) {
  .timeline::before { left: 50%; margin-left: -1.5px; }
  .timeline-item { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .timeline-item.left { flex-direction: row-reverse; }
  .timeline-date-container { width: 45%; padding-left: 0; text-align: right; padding-right: 3rem; margin-bottom: 0; }
  .timeline-item:hover .timeline-date-container { transform: translateX(-5px); }
  .timeline-item.left .timeline-date-container { text-align: left; padding-right: 0; padding-left: 3rem; }
  .timeline-item.left:hover .timeline-date-container { transform: translateX(5px); }
  .timeline-card { width: 45%; margin-left: 0; }
  .timeline-icon { left: 50%; transform: translateX(-50%); }
  .timeline-item:hover .timeline-icon { transform: translateX(-50%) scale(1.15) rotate(10deg); }
}

/* --- EDUCATION --- */
.education-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 768px) { .education-grid { grid-template-columns: 1fr 1fr; } }

.edu-card {
  display: flex; align-items: start; padding: 1.5rem; border-radius: var(--border-radius);
  background: white; border: 1px solid #f1f5f9; transition: all var(--transition-smooth);
  position: relative; overflow: hidden;
}
.edu-card:hover {
  transform: translateY(-5px); box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
  border-color: var(--brand-accent);
}
.edu-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, transparent 100%);
  opacity: 0; transition: opacity 0.3s;
}
.edu-card:hover::before { opacity: 1; }

.edu-icon-box {
  background-color: #eff6ff; color: var(--brand-primary);
  min-width: 50px; height: 50px; border-radius: 12px; margin-right: 1.2rem;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  transition: all var(--transition-smooth); z-index: 1;
}
.edu-card:hover .edu-icon-box {
  background-color: var(--brand-primary); color: white;
  transform: rotate(-10deg) scale(1.1);
}
.edu-info { z-index: 1; }
.edu-info h4 { font-size: 1.2rem; font-weight: 700; color: #1e293b; margin-bottom: 0.2rem; }
.edu-info .edu-school { color: var(--brand-primary); font-weight: 600; font-size: 0.95rem; }
.edu-info .edu-year {
  font-size: 0.85rem; color: var(--text-light); margin-top: 0.5rem;
  display: inline-block; background: #f1f5f9; padding: 2px 8px; border-radius: 4px;
}

/* --- SKILLS --- */
.skills-header { text-align: center; margin-bottom: 4rem; }
.skills-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 640px) { .skills-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .skills-grid { grid-template-columns: repeat(4, 1fr); } }

.skill-card {
  background-color: rgba(255, 255, 255, 0.03); backdrop-filter: blur(10px);
  padding: 2rem; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
  position: relative; overflow: hidden; --x: 50%; --y: 50%;
}
.skill-card:hover {
  transform: translateY(-8px); background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(59, 130, 246, 0.3); box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}
.skill-card::after {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(400px circle at var(--x) var(--y), rgba(59, 130, 246, 0.25), transparent 40%);
  opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 0;
}
.skill-card:hover::after { opacity: 1; }
.skill-card > * { position: relative; z-index: 1; }
.skill-icon { font-size: 2rem; color: var(--brand-accent); margin-bottom: 1.5rem; transition: transform 0.3s; }

.skill-title { font-weight: 700; font-size: 1.2rem; margin-bottom: 1.5rem; color: var(--brand-white); }
.skill-list { list-style: none; font-size: 0.95rem; color: #cbd5e1; }
.skill-list li {
  margin-bottom: 0.8rem; display: flex; align-items: center; opacity: 0.9;
  transition: opacity 0.2s, transform 0.2s;
}
.skill-list li:hover { opacity: 1; transform: translateX(5px); }
.skill-list li i { color: var(--brand-accent); margin-right: 0.8rem; font-size: 0.8rem; }
.skill-divider { border-top: 1px solid rgba(255,255,255,0.1); margin-top: 1rem; padding-top: 1rem; }

/* --- FOOTER --- */
.footer { border-top: 1px solid #e2e8f0; padding: 5rem 0 3rem; text-align: center; background: #f8fafc; }
.contact-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; margin-top: 2rem; margin-bottom: 3rem; }
@media (min-width: 768px) { .contact-grid { grid-template-columns: repeat(2, 1fr); max-width: 800px; margin-left: auto; margin-right: auto; } }

.contact-item { display: flex; flex-direction: column; align-items: center; transition: transform 0.3s; }
.contact-item:hover { transform: translateY(-5px); }
.contact-icon {
  width: 56px; height: 56px; background-color: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-primary); margin-bottom: 1rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05); transition: all 0.3s; font-size: 1.2rem;
}
.contact-item:hover .contact-icon {
  background-color: var(--brand-primary); color: white;
  box-shadow: 0 10px 20px rgba(30, 64, 175, 0.2);
}
.contact-link { color: var(--brand-primary); text-decoration: none; font-weight: 600; }
.contact-link:hover { text-decoration: underline; }
.copyright { font-size: 0.875rem; color: var(--text-light); margin-top: 3rem; }

/* --- ANIMATIONS --- */
.fade-in-up {
  opacity: 0; transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.fade-in-up.visible { opacity: 1; transform: translateY(0); }
.delay-100 { transition-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; }
