:root {
  --primary-color: #4a90e2;
  --secondary-color: #333;
  --light-color: #f4f4f4;
  --dark-color: #24292e;
}

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

body {
  font-family: 'Montserrat', sans-serif;
  background: var(--light-color);
  color: var(--secondary-color);
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* HEADER */
header {
  background: linear-gradient(135deg, var(--primary-color), #306ab3);
  color: #fff;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

header h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-right: 2rem;
}

nav {
  position: relative;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 2rem;
  align-items: center;
}

nav ul li { display: flex; align-items: center; }

nav ul li a {
  font-weight: 600;
  padding: 0.5rem;
  transition: opacity 0.3s;
}

nav ul li a:hover { opacity: 0.8; }

/* LANG SWITCH */
.lang-switch {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-left: 2rem;
}

.lang-switch .flag {
  font-size: 1.3rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 0.2s;
  line-height: 1;
}

.lang-switch .flag:hover { transform: scale(1.2); }

/* HAMBURGER base (nascosto su desktop) */
.hamburger {
  display: none;
}

#nav-toggle { display: none; }

/* HERO */
.hero {
  background: linear-gradient(135deg, #306ab3, var(--primary-color));
  color: #fff;
  text-align: center;
  padding: 5rem 1rem;
}

.hero h2 { font-size: 3rem; margin-bottom: 1rem; }
.hero p { font-size: 1.5rem; }
.hero a { color: #fff; text-decoration: underline; }

/* CONTAINER */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 3rem auto;
}

.container h2 {
  margin-bottom: 2rem;
}

section { padding: 3rem 0; }

section h2 {
  margin-bottom: 2rem;
}

/* PROJECTS GRID */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.project-card {
  background: #fff;
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.project-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.project-card h3 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
  color: var(--primary-color);
}

.project-card p { margin-bottom: 1.5rem; text-align: start; }

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

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.2rem;
  border-radius: 50px;
  font-size: 1rem;
  color: #fff;
  width: fit-content;
  transition: background 0.3s;
}

.btn i { margin-right: 0.5rem; font-size: 1.2rem; }

.github-btn { background: var(--dark-color); }
.github-btn:hover { background: #3c4147; }

.cv-btn { background: #e53935; }
.cv-btn:hover { background: #b71c1c; }

.scholar-btn { background: #4285f4; color: #fff; }
.scholar-btn:hover { background: #3367d6; }

/* FOOTER */
footer {
  background: var(--secondary-color);
  color: #fff;
  text-align: center;
  padding: 1.5rem 2rem;
}

.social-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 2rem;
  color: #fff;
  transition: transform 0.3s, background 0.3s;
}

.social-link.linkedin {
  background: #0077b5;
}

.social-link.linkedin:hover {
  background: #005582;
  transform: scale(1.1);
}

/* MOBILE MENU (drawer style) */
@media (max-width: 768px) {
  header { flex-direction: row; align-items: center; }

  /* overlay dietro il menu */
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 998;
  }

  nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 75%;
    max-width: 320px;
    height: 100vh;
    background: linear-gradient(135deg, #4a90e2, #306ab3);
    box-shadow: -4px 0 15px rgba(0,0,0,0.4);
    transition: right 0.35s ease-in-out;
    z-index: 999;
    display: flex;
    flex-direction: column;
    padding-top: 5rem;
  }

  nav ul {
    list-style: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.8rem;
    padding-left: 2rem;
  }

  nav ul li a {
    font-size: 1.4rem;
    font-weight: 600;
    color: #fff;
    padding: 0.5rem 0;
    display: block;
    transition: transform 0.2s ease, color 0.3s ease;
  }

  nav ul li a:hover {
    transform: translateX(6px);
    color: #ffeb3b;
  }

  /* attiva menu + overlay */
  #nav-toggle:checked ~ nav {
    right: 0;
  }
  #nav-toggle:checked ~ .overlay {
    opacity: 1;
    pointer-events: auto;
  }

  /* hamburger SOLO su mobile */
  .hamburger {
    display: block;
    width: 30px;
    height: 24px;
    position: fixed;
    top: 2.5rem;
    right: 1.5rem;
    cursor: pointer;
    z-index: 1001;
  }

  .hamburger span {
    position: absolute;
    height: 3px;
    width: 100%;
    background: #fff;
    left: 0;
    transition: all 0.3s ease;
    border-radius: 3px;
  }

  .hamburger span:nth-child(1) { top: 0; }
  .hamburger span:nth-child(2) { top: 10px; }
  .hamburger span:nth-child(3) { top: 20px; }

  /* X animata */
  #nav-toggle:checked + .hamburger span:nth-child(1) {
    transform: rotate(45deg);
    top: 10px;
  }
  #nav-toggle:checked + .hamburger span:nth-child(2) {
    opacity: 0;
  }
  #nav-toggle:checked + .hamburger span:nth-child(3) {
    transform: rotate(-45deg);
    top: 10px;
  }

  /* bandiere lingua */
  .lang-switch {
    margin-top: 3rem;
    justify-content: flex-start;
    padding-left: 2rem;
    gap: 1rem;
  }

  .lang-switch .flag {
    font-size: 1.6rem;
  }
}

/* MULTILINGUA */
.lang { display: none; }
.lang.active { display: block; }
