:root {
  --accent: #34d399;
  --accent-2: #a3e635;
  --gradient: linear-gradient(120deg, var(--accent), var(--accent-2));

  --bg: #0b0f14;
  --bg-alt: #0f151d;
  --card: #131b25;
  --card-border: rgba(255, 255, 255, 0.07);
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --nav-bg: rgba(11, 15, 20, 0.8);
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-alt: #eef2f5;
  --card: #ffffff;
  --card-border: rgba(0, 0, 0, 0.08);
  --text: #16212b;
  --text-dim: #5b6a78;
  --shadow: 0 12px 32px rgba(20, 40, 60, 0.12);
  --nav-bg: rgba(246, 248, 250, 0.85);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

.container { width: min(1140px, 92%); margin: 0 auto; }
.accent { color: var(--accent); }

/* contorno ben visibile per chi naviga con tab */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* link nascosto, compare solo col focus da tastiera */
.skip-link {
  position: fixed;
  top: -60px;
  left: 1rem;
  z-index: 2000;
  background: var(--accent);
  color: #08130c;
  font-weight: 700;
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  text-decoration: none;
  transition: top 0.25s ease;
}
.skip-link:focus { top: 0.8rem; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* canvas fisso dietro a tutto */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

main, .navbar, .footer { position: relative; z-index: 1; }

.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: var(--gradient);
  z-index: 1000;
}

/* navbar */

.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  backdrop-filter: blur(12px);
  background: var(--nav-bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.navbar.scrolled { border-bottom-color: var(--card-border); box-shadow: 0 4px 24px rgba(0,0,0,0.15); }

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0;
}

.logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  list-style: none;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
  transition: color 0.25s ease;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; bottom: -6px;
  width: 0; height: 2px;
  background: var(--gradient);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.nav-link:hover, .nav-link.active { color: var(--text); }
.nav-link:hover::after, .nav-link.active::after { width: 100%; }

.nav-controls { display: flex; align-items: center; gap: 0.6rem; }

.lang-toggle {
  display: grid;
  place-items: center;
  min-width: 38px; height: 38px;
  padding: 0 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.lang-toggle:hover { transform: translateY(-2px); border-color: var(--accent); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.theme-toggle:hover { transform: rotate(20deg) scale(1.08); box-shadow: 0 0 16px rgba(52, 211, 153, 0.35); }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.nav-toggle span {
  width: 24px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* hero */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 7rem 0 4rem;
  position: relative;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 3rem;
  align-items: center;
}

.hero-hello { color: var(--accent); font-weight: 600; letter-spacing: 2px; text-transform: uppercase; font-size: 0.9rem; }

.hero-name {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 0.4rem 0 0.8rem;
}

.hero-role {
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  font-weight: 600;
  color: var(--text-dim);
  min-height: 2.2em;
}
.cursor-blink { color: var(--accent); animation: blink 0.9s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.hero-desc { max-width: 540px; margin: 1rem 0 1.8rem; color: var(--text-dim); font-size: 1.05rem; }

.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.btn-primary {
  background: var(--gradient);
  color: #08130c;
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.3);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(52, 211, 153, 0.45); }
.btn-ghost {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
}
.btn-ghost:hover { background: rgba(52, 211, 153, 0.1); transform: translateY(-3px); }
.btn-lg { padding: 1rem 2.2rem; font-size: 1.05rem; }

.hero-stats {
  display: flex;
  gap: 2.2rem;
  margin-top: 2.4rem;
  flex-wrap: wrap;
}
.stat p { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.15rem; }
.stat-num, .stat-plus {
  font-size: 1.9rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-photo { position: relative; display: grid; place-items: center; }

.photo-ring {
  position: relative;
  width: min(340px, 78vw);
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 8px;
  background: conic-gradient(from var(--ring-angle, 0deg), var(--accent), var(--accent-2), transparent 40%, var(--accent));
  animation: spin-ring 6s linear infinite;
}
@property --ring-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
@keyframes spin-ring {
  to { --ring-angle: 360deg; }
}
.photo-ring img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top;
  border-radius: 50%;
  display: block;
  background: var(--card);
  animation: float 5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.badge-float {
  position: absolute;
  padding: 0.45rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: float 4.5s ease-in-out infinite;
}
.badge-1 { top: 6%; left: -4%; animation-delay: 0.4s; }
.badge-2 { bottom: 12%; right: -6%; animation-delay: 1.2s; }
.badge-3 { bottom: -3%; left: 8%; animation-delay: 2s; }

.scroll-hint {
  position: absolute;
  bottom: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
}
.mouse {
  display: block;
  width: 26px; height: 42px;
  border: 2px solid var(--text-dim);
  border-radius: 14px;
  position: relative;
}
.wheel {
  position: absolute;
  top: 7px; left: 50%;
  width: 4px; height: 8px;
  margin-left: -2px;
  background: var(--accent);
  border-radius: 2px;
  animation: wheel 1.6s ease infinite;
}
@keyframes wheel {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(14px); }
}

/* sezioni */

.section { padding: 6rem 0; }
.section-alt { background: var(--bg-alt); transition: background 0.4s ease; }

.section-title {
  font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  font-weight: 800;
  margin-bottom: 3rem;
}
.section-title .accent { font-family: Consolas, monospace; font-size: 0.75em; margin-right: 0.4rem; }

/* elementi che compaiono allo scroll, la classe .visible la mette il js */
.reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }
.delay-5 { transition-delay: 0.5s; }

/* chi sono */

.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 3rem;
  align-items: start;
}
.about-text p { margin-bottom: 1rem; color: var(--text-dim); }
.about-text strong { color: var(--text); }

.about-facts {
  list-style: none;
  margin-top: 1.4rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.about-facts li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }

.about-cards { display: grid; gap: 1.2rem; }

.mini-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.mini-card:hover { border-color: var(--accent); }
.mini-card h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.mini-card p { color: var(--text-dim); font-size: 0.95rem; }

/* competenze */

.skills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}
.skill-cat { font-size: 1.1rem; margin-bottom: 1.4rem; color: var(--text); }

.skill-bar { margin-bottom: 1.1rem; }
.skill-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
}
.skill-info span:last-child { color: var(--accent); font-weight: 700; }

.bar {
  height: 8px;
  border-radius: 8px;
  background: var(--card-border);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 8px;
  background: var(--gradient);
  transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.chips { margin-top: 3rem; }
.chip-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.chip {
  padding: 0.5rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.chip:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(52, 211, 153, 0.2);
}
.chip small { color: var(--text-dim); }

/* timeline esperienze */

.timeline {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  padding-left: 2.2rem;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 8px; top: 4px; bottom: 4px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--accent-2), transparent);
}

.timeline-item { position: relative; margin-bottom: 2.2rem; }

.timeline-dot {
  position: absolute;
  left: -2.2rem;
  top: 6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
}
.timeline-dot.pulse::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.timeline-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem 1.7rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.timeline-card:hover { border-color: var(--accent); }
.timeline-date {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #08130c;
  background: var(--gradient);
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}
.timeline-card h3 { font-size: 1.15rem; }
.timeline-card h4 { color: var(--accent); font-size: 0.98rem; font-weight: 600; margin: 0.15rem 0 0.5rem; }
.timeline-card p { color: var(--text-dim); font-size: 0.95rem; }

/* formazione */

.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}
.edu-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 1.8rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.edu-card:hover { border-color: var(--accent); }
.edu-icon { font-size: 2.2rem; margin-bottom: 0.8rem; }
.edu-card h3 { font-size: 1.02rem; margin-bottom: 0.3rem; }
.edu-card h4 { color: var(--accent); font-size: 0.92rem; font-weight: 600; margin-bottom: 0.6rem; }
.edu-date { font-size: 0.85rem; color: var(--text-dim); }

/* progetti */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}
.project-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 1.7rem 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
  display: flex;
  flex-direction: column;
}
.project-card:hover { border-color: var(--accent); }
.project-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}
.project-emoji { font-size: 1.9rem; }
.project-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
}
.project-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.project-card p { color: var(--text-dim); font-size: 0.93rem; flex: 1; }
.project-tech {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.project-tech li {
  font-size: 0.78rem;
  font-family: Consolas, monospace;
  color: var(--accent);
  background: rgba(52, 211, 153, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
}
.projects-note { text-align: center; margin-top: 2.2rem; color: var(--text-dim); }

.project-card { cursor: pointer; }

/* avviso a scomparsa in basso, usato al click sui progetti */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translate(-50%, 20px);
  max-width: 90vw;
  padding: 0.75rem 1.5rem;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 0.92rem;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* contatti */

.contact-lead { color: var(--text-dim); max-width: 560px; margin-bottom: 2.5rem; font-size: 1.05rem; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.5rem;
}
.contact-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 1.8rem 1.4rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.contact-card:hover { border-color: var(--accent); }
.contact-icon { font-size: 2rem; display: block; margin-bottom: 0.7rem; }
.contact-card h3 { font-size: 1.05rem; margin-bottom: 0.3rem; }
.contact-card p { color: var(--text-dim); font-size: 0.9rem; word-break: break-word; }

.contact-cta { text-align: center; margin-top: 2.8rem; }

/* footer */

.footer {
  border-top: 1px solid var(--card-border);
  padding: 1.6rem 0;
  background: var(--bg);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.footer-note {
  font-size: 0.82rem;
  margin-top: 0.25rem;
  max-width: 60ch;
  font-style: italic;
}
.back-top {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--gradient);
  color: #08130c;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.back-top:hover { transform: translateY(-4px); box-shadow: 0 10px 24px rgba(52, 211, 153, 0.4); }

.tilt { will-change: transform; }

/* responsive */

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero-photo { order: -1; margin-top: 1.5rem; }
  .hero-desc { margin-inline: auto; }
  .hero-cta, .hero-stats { justify-content: center; }
  .about-grid, .skills-grid { grid-template-columns: 1fr; }
  .badge-1 { left: 2%; }
  .badge-2 { right: 0; }
}

/* sotto i 960px il menu esteso non ci sta, si passa all'hamburger */
@media (max-width: 960px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: fixed;
    top: 62px;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--card);
    border-left: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
    width: min(280px, 78vw);
    height: calc(100vh - 62px);
    padding: 1.4rem;
    transform: translateX(105%);
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.35s;
  }
  .nav-links.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
  }
  .nav-links li { width: 100%; }
  .nav-link { display: block; padding: 0.85rem 0.4rem; font-size: 1.05rem; }
  .nav-controls { margin-top: 1rem; }
}

@media (max-width: 760px) {
  .section { padding: 4.2rem 0; }
  .about-facts { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
  .footer-note { margin-inline: auto; }
}

@media (max-width: 400px) {
  .hero { padding-top: 6rem; }
  .hero-stats { gap: 1.4rem; }
  .badge-float { font-size: 0.78rem; padding: 0.35rem 0.7rem; }
  .timeline { padding-left: 1.8rem; }
  .timeline-dot { left: -1.8rem; width: 15px; height: 15px; }
  .timeline-card { padding: 1.2rem 1.1rem; }
  .btn { padding: 0.75rem 1.3rem; }
}

/* niente animazioni per chi le ha disattivate da sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
