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

:root {
  --bg:           #0F0E16;
  --accent:       #4A7FD4;
  --accent-light: #6B9FE4;
  --text:         #E8E8F0;
  --text-muted:   #8888A8;
  --nav-h:        64px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── LOAD ANIMATIONS ─── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.navbar        { animation: fade-down 0.5s ease-out both; }
.hero-tag      { animation: fade-up 0.55s ease-out 0.15s both; }
.hero h1       { animation: fade-up 0.6s  ease-out 0.3s  both; }
.hero-role     { animation: fade-up 0.55s ease-out 0.45s both; }
.hero-desc     { animation: fade-up 0.55s ease-out 0.6s  both; }
.btn-projects  { animation: fade-up 0.55s ease-out 0.75s both; }
.code-window   { animation: fade-up 0.65s ease-out 0.5s  both; }

@media (prefers-reduced-motion: reduce) {
  .navbar, .hero-tag, .hero h1,
  .hero-role, .hero-desc, .btn-projects, .code-window {
    animation: none;
  }
}

/* ─── SCROLL REVEAL ─── */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s ease-out, transform 0.65s ease-out;
}

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

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ─── NAVBAR ─── */
.navbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: rgba(15, 14, 22, 0.80);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 100;
}

/* Logo cerchio */
.logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  user-select: none;
}
.logo:hover {
  background: var(--accent);
  color: #fff;
}

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

/* Menu a tendina — mobile */
.nav-menu {
  position: absolute;
  top: var(--nav-h);
  left: 0;
  right: 0;
  background: rgba(13, 12, 20, 0.97);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  padding: 0.5rem 1.25rem 1rem;
  gap: 0;
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.nav-menu.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}
.nav-menu a {
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  padding: 0.85rem 0.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  transition: color 0.2s, padding-left 0.2s;
}
.nav-menu a:last-child { border-bottom: none; }
.nav-menu a:hover {
  color: var(--accent-light);
  padding-left: 0.5rem;
}

/* ─── HERO ─── */
.hero {
  min-height: 100vh;
  padding: calc(var(--nav-h) + 3.5rem) 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Chiazze di sfumatura */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 65% 45% at 85% 15%, rgba(74,127,212,0.13) 0%, transparent 65%),
    radial-gradient(ellipse 55% 40% at 5%  75%, rgba(100,80,210,0.10) 0%, transparent 65%),
    radial-gradient(ellipse 45% 35% at 55% 95%, rgba(50,160,230,0.07) 0%, transparent 65%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3rem;
  width: 100%;
}

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

.hero-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2.6rem, 11vw, 5rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: #fff;
  margin-bottom: 1rem;
}

.hero-role {
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 1.25rem;
  letter-spacing: 0.01em;
}

.hero-desc {
  font-size: clamp(0.88rem, 3vw, 1rem);
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 2.5rem;
  max-width: 500px;
}

/* Pulsante CTA */
.btn-projects {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.8rem 1.75rem;
  border-radius: 8px;
  box-shadow: 0 4px 22px rgba(74,127,212,0.30);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-projects:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(74,127,212,0.45);
}
.btn-projects:active { transform: translateY(0); }
.btn-projects svg { transition: transform 0.2s; }
.btn-projects:hover svg { transform: translateX(4px); }

/* ─── CODE WINDOW ─── */
.code-window {
  display: none;
  flex-shrink: 0;
  width: 100%;
  max-width: 420px;
  background: #1E1E1E;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.09);
  box-shadow:
    0 20px 56px rgba(0,0,0,0.55),
    0 0 0 1px rgba(255,255,255,0.04),
    0 0 48px rgba(74,127,212,0.09);
}

.code-body {
  padding: 1.6rem 1.6rem 1.8rem;
}

.code-anim {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 0.97rem;
  line-height: 2;
  color: #D4D4D4;
}

.code-anim > div {
  white-space: pre;
}

/* VS Code Dark+ syntax colors */
.kw   { color: #569CD6; }
.prop { color: #9CDCFE; }
.str  { color: #CE9178; }
.fn   { color: #DCDCAA; }

/* Cursore lampeggiante */
.cursor {
  display: inline-block;
  width: 2px;
  height: 0.92em;
  background: #AEAFAD;
  vertical-align: text-bottom;
  animation: cur-blink 1s step-end infinite;
}

@keyframes cur-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.code-anim.fade-out {
  transition: opacity 0.45s ease;
  opacity: 0;
}

/* ─── DESKTOP ─── */
@media (min-width: 768px) {
  .navbar { padding: 0 3rem; }
  .hamburger { display: none; }

  .nav-menu {
    position: static;
    flex-direction: row;
    background: none;
    backdrop-filter: none;
    border: none;
    padding: 0;
    gap: 2.25rem;
    transform: none;
    opacity: 1;
    pointer-events: all;
  }
  .nav-menu a {
    font-size: 0.9rem;
    padding: 0;
    border: none;
    color: var(--text-muted);
  }
  .nav-menu a:hover {
    color: var(--text);
    padding-left: 0;
  }

  .hero {
    padding: calc(var(--nav-h) + 5rem) 2.5rem 6rem;
  }

  .hero-inner {
    flex-direction: row;
    align-items: center;
    gap: 4rem;
    max-width: 860px;
    margin: 0 auto;
  }

  .hero-content {
    flex: 1;
    max-width: none;
  }

  .code-window {
    display: block;
    flex: 0 0 430px;
  }
}

@media (min-width: 1024px) {
  .hero { padding: calc(var(--nav-h) + 5rem) 3.5rem 6rem; }

  .hero-inner { max-width: 1040px; }

  .code-window { flex-basis: 490px; }
}

/* ─── ABOUT ─── */
.about {
  padding: 5rem 1.5rem 4rem;
}

.about-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

/* Foto + bio — mobile: colonna centrata */
.about-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  text-align: center;
}

.photo-placeholder {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: radial-gradient(circle at 40% 35%, rgba(74,127,212,0.18), rgba(74,127,212,0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 32px rgba(74,127,212,0.18);
}

.about-bio {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-light);
}

.section-title {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
}

.about-bio p {
  color: var(--text-muted);
  line-height: 1.8;
  font-size: clamp(0.88rem, 3vw, 1rem);
}

.about-bio strong {
  color: var(--accent-light);
  font-weight: 600;
}

/* ─── SKILLS ─── */
.skills-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2.5rem;
}

/* Divisore — orizzontale su mobile */
.skills-divider {
  height: 1px;
  width: 100%;
  background: linear-gradient(to right, transparent, rgba(74,127,212,0.35), transparent);
}

.skills-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.skills-title {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 1.25rem 1rem;
  width: 100%;
}

.skill-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

/* Icone Devicon */
.skill-item i {
  font-size: 2.6rem;
  line-height: 1;
}

.skill-item span {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

/* Badge Adobe / DaVinci */
.skill-badge {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.badge-ps { background: #001E36; color: #31A8FF; }
.badge-lr { background: #001D26; color: #4AABDB; }
.badge-pr { background: #0D0047; color: #9999FF; }
.badge-id { background: #1C0013; color: #FF3366; }
.badge-ae { background: #1B002D; color: #9999FF; }
.badge-ai { background: #1C0B00; color: #FF9A00; }
.badge-dv { background: #1A1A1A; color: #F7A500; }

/* ─── ABOUT — Tablet ─── */
@media (min-width: 768px) {
  .about {
    padding: 6rem 2.5rem 5rem;
  }

  /* Foto a sinistra, bio a destra */
  .about-top {
    flex-direction: row;
    align-items: flex-start;
    text-align: left;
  }

  /* Divisore verticale */
  .skills-section {
    flex-direction: row;
    gap: 0;
  }

  .skills-divider {
    width: 1px;
    height: auto;
    align-self: stretch;
    background: linear-gradient(to bottom, transparent, rgba(74,127,212,0.35), transparent);
    margin: 0 2.5rem;
    flex-shrink: 0;
  }

  .skills-col {
    flex: 1;
    align-items: flex-start;
  }
}

/* ─── ABOUT — Desktop ─── */
@media (min-width: 1024px) {
  .about {
    padding: 7rem 3.5rem 6rem;
  }

  .photo-placeholder {
    width: 190px;
    height: 190px;
  }
}

/* ─── PROJECTS ─── */
.projects {
  padding: 5rem 1.5rem 4rem;
}

.projects-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.projects-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 5rem;
}

/* ─── Single project ─── */
.project-item {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Rettangolo decorativo — dimensioni fisse per tutti i progetti */
.project-accent-bar {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
}

.project-item:nth-child(1) .project-accent-bar {
  background: linear-gradient(135deg, #4A7FD4 0%, #6B9FE4 100%);
}
.project-item:nth-child(2) .project-accent-bar {
  background: linear-gradient(135deg, #7B5EA7 0%, #9B7FC7 100%);
}
.project-item:nth-child(3) .project-accent-bar {
  background: linear-gradient(135deg, #3A9DC0 0%, #5ABDE0 100%);
}
.project-item:nth-child(4) .project-accent-bar {
  background: linear-gradient(135deg, #5865C8 0%, #7885E8 100%);
}
.project-item:nth-child(5) .project-accent-bar {
  background: linear-gradient(135deg, #2E8B6E 0%, #4EAB8E 100%);
}

.project-title {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

/* Lista tecnologie in orizzontale */
.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

.project-tech li {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-light);
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(74, 127, 212, 0.3);
  border-radius: 4px;
  background: rgba(74, 127, 212, 0.08);
}

.project-desc {
  color: var(--text-muted);
  line-height: 1.8;
  font-size: clamp(0.88rem, 3vw, 1rem);
}

/* Immagine / placeholder */
.project-image {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

.project-image img {
  width: 100%;
  height: auto;
  display: block;
}

.img-placeholder {
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(ellipse 60% 50% at 30% 40%, rgba(74, 127, 212, 0.15) 0%, transparent 70%),
    linear-gradient(135deg, #131220 0%, #1a1730 50%, #111020 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-placeholder span {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ─── PROJECTS — Tablet ─── */
@media (min-width: 768px) {
  .projects {
    padding: 6rem 2.5rem 5rem;
  }

  .project-item {
    flex-direction: row;
    align-items: center;
    gap: 4rem;
  }

  .project-info {
    flex: 1;
    min-width: 0;
  }

  .project-image {
    flex: 1;
    min-width: 0;
  }

  /* Inverte: testo dx, immagine sx */
  .project-item--reversed {
    flex-direction: row-reverse;
  }
}

/* ─── PROJECTS — Desktop ─── */
@media (min-width: 1024px) {
  .projects {
    padding: 7rem 3.5rem 6rem;
  }

  .project-list {
    gap: 6rem;
  }
}

/* ─── CONTACT ─── */
.contact {
  padding: 5rem 1.5rem 5rem;
}

.contact-container {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3.5rem;
}

.contact-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.contact-title {
  font-size: clamp(2.4rem, 9vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: #fff;
}

.contact-subtitle {
  font-size: clamp(0.88rem, 3vw, 1rem);
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 420px;
}

/* Griglia cards */
.contact-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
}

.contact-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.contact-card:hover {
  border-color: rgba(74, 127, 212, 0.4);
  background: rgba(74, 127, 212, 0.06);
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

.contact-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(74, 127, 212, 0.1);
  border: 1px solid rgba(74, 127, 212, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  margin-bottom: 0.25rem;
}

.contact-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.contact-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── CONTACT — Tablet ─── */
@media (min-width: 768px) {
  .contact {
    padding: 6rem 2.5rem 5rem;
  }

  .contact-card {
    width: calc(50% - 0.625rem);
  }
}

/* ─── CONTACT — Desktop ─── */
@media (min-width: 1024px) {
  .contact {
    padding: 7rem 3.5rem 6rem;
  }

  .contact-card {
    width: calc(33.33% - 0.84rem);
  }
}

/* ─── FOOTER ─── */
.footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 2rem 1.5rem;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-logo {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.footer-copy {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

@media (min-width: 768px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
  }
}
