/* Base */
:root {
  /* Light theme (default) */
  --primary-color: #1e88e5;
  --primary-dark: #1565c0;
  --secondary-color: #f5f5f5;
  --bg-color: #ffffff;
  --text-color: #333333;
  --light-text: #666666;
  --lightest-text: #999999;
  --border-color: #e0e0e0;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --error-color: #f44336;
  --spacing-unit: 30px;
  --content-width: 1200px;
  --card-bg: #ffffff;
  --header-bg: #ffffff;
  --footer-bg: #f5f5f5;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --dropdown-bg: #ffffff;
  --dropdown-text: #333333;
  --dropdown-hover-bg: #f5f5f5;
}

/* Dark theme */
[data-theme="dark"] {
  --primary-color: #90caf9;
  --primary-dark: #64b5f6;
  --secondary-color: #2d2d2d;
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --light-text: #aaaaaa;
  --lightest-text: #888888;
  --border-color: #333333;
  --success-color: #81c784;
  --warning-color: #ffb74d;
  --error-color: #e57373;
  --card-bg: #1e1e1e;
  --header-bg: #1e1e1e;
  --footer-bg: #1e1e1e;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --dropdown-bg: #1e1e1e;
  --dropdown-text: #e0e0e0;
  --dropdown-hover-bg: #2d2d2d;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--text-color);
  line-height: 1.6;
  background-color: var(--bg-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-color);
}

h1 {
  font-size: 2.5rem;
}
h2 {
  font-size: 2rem;
}
h3 {
  font-size: 1.5rem;
}
h4 {
  font-size: 1.25rem;
}
h5 {
  font-size: 1rem;
}
h6 {
  font-size: 0.875rem;
}

p,
ul,
ol,
dl,
table,
blockquote {
  margin-bottom: 1.5rem;
}

ul,
ol {
  padding-left: 1.5rem;
}

img {
  max-width: 100%;
  height: auto;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--header-bg);
  padding: 1rem 0;
  box-shadow: 0 2px 4px var(--shadow-color);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.3s ease, border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
}

.nav-right {
  display: flex;
  align-items: center;
}

.site-nav {
  display: flex;
  align-items: center;
}

.nav-trigger {
  display: none;
}

.menu-icon {
  display: none;
}

.site-nav .trigger {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.site-nav .page-link {
  color: var(--text-color);
  font-weight: 500;
  transition: color 0.3s ease;
}

.site-nav .page-link:hover {
  color: var(--primary-color);
  text-decoration: none;
}

/* Sistemazione toggle tema per desktop e mobile */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  margin-right: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  transition: background-color 0.3s ease;
}

.theme-toggle:hover {
  background-color: var(--secondary-color);
}

.theme-toggle svg {
  transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
  transform: rotate(30deg);
}

.menu-icon svg path {
  fill: var(--text-color);
  transition: fill 0.3s ease;
}

/* Assicurarsi che lo sfondo dell'icona hamburger sia trasparente */
.menu-icon {
  background-color: transparent;
  transition: background-color 0.3s ease;
}

/* Migliorato il contrasto per il menu dropdown in tema scuro */
[data-theme="dark"] .nav-trigger:checked ~ .trigger {
  background-color: var(--card-bg);
  border-color: var(--border-color);
}

/* Versione desktop */
@media screen and (min-width: 769px) {
  /* Nascondi il toggle mobile */
  #theme-toggle-mobile {
    display: none;
  }

  /* Mostra il toggle desktop */
  #theme-toggle-desktop {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 1rem;
  }

  /* Allinea items nel trigger per posizionare bene il toggle */
  .site-nav .trigger {
    display: flex;
    align-items: center;
  }
}

/* Mobile nav */
@media screen and (max-width: 768px) {
  .site-nav {
    position: relative;
  }

  .menu-icon {
    display: block;
    padding: 10px;
    cursor: pointer;
  }

  .nav-trigger:checked ~ .trigger {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--bg-color);
    width: 200px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px var(--shadow-color);
    margin-top: 10px;
  }

  .nav-trigger ~ .trigger {
    display: none;
  }

  /* Nascondi il toggle desktop */
  #theme-toggle-desktop {
    display: none;
  }

  /* Mostra il toggle mobile */
  #theme-toggle-mobile {
    display: flex;
    order: 1;
  }

  .site-nav {
    order: 2;
  }

  /* Allineamento verticale dei componenti del menu */
  .theme-toggle,
  .menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px; /* Altezza fissa per entrambi gli elementi */
  }

  .menu-icon {
    padding: 0;
    margin: 0;
  }

  .theme-toggle {
    position: relative;
    padding: 0;
    margin: 0;
    top: 0; /* Rimuove qualsiasi offset */
  }

  .theme-toggle svg,
  .menu-icon svg {
    vertical-align: middle; /* Allineamento verticale corretto */
  }

  /* Miglioramento spazio nel menu hamburger */
  .nav-trigger:checked ~ .trigger {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
  }

  .nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
  }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  padding: 3rem 0;
  background-color: var(--footer-bg);
  margin-top: 3rem;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.footer-col-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.footer-col {
  flex: 1;
  min-width: 250px;
  padding-right: 1rem;
  margin-bottom: 2rem;
}

.footer-heading {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-color);
}

.contact-list,
.social-media-list {
  list-style: none;
  padding-left: 0;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  text-align: center;
  color: var(--light-text);
}

/* Dropdown menu */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem; /* Spazio ridotto tra il testo e la freccia */
}

.dropdown-toggle::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 0;
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-left: 0.3em solid transparent;
  transition: transform 0.2s;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: var(--dropdown-bg);
  min-width: 180px;
  box-shadow: 0 4px 8px var(--shadow-color);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  z-index: 100;
  padding: 0.5rem 0;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.dropdown-content a {
  color: var(--dropdown-text);
  padding: 0.5rem 1rem;
  text-decoration: none;
  display: block;
  font-size: 0.9rem;
  transition: background-color 0.2s, color 0.2s;
}

.dropdown-content a:hover {
  background-color: var(--dropdown-hover-bg);
  text-decoration: none;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* Dropdown mobile migliorato con animazioni */
@media screen and (max-width: 768px) {
  /* Contenitore dropdown */
  .dropdown {
    position: relative;
    width: 100%;
    text-align: center;
  }

  /* Toggle dropdown */
  .dropdown-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 0.25rem;
    cursor: pointer;
    user-select: none;
  }

  /* Animazione rotazione freccia */
  .dropdown-toggle::after {
    transition: transform 0.3s ease;
  }

  /* Contenuto dropdown */
  .dropdown-content {
    display: block;
    position: static;
    background-color: transparent;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0 auto;
    text-align: center;
  }

  /* Link nel dropdown */
  .dropdown-content a {
    padding: 0.75rem 1rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  /* Classe per il toggle dropdown attivo */
  .dropdown.active .dropdown-toggle::after {
    transform: rotate(180deg);
  }

  .dropdown.active .dropdown-content {
    max-height: 200px; /* Altezza massima sufficiente per il contenuto */
    opacity: 1;
    padding: 0.5rem 0;
  }

  .dropdown.active .dropdown-content a {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Profile section */
.profile-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 3rem;
  padding: 2rem;
  background-color: var(--secondary-color);
  border-radius: 5px;
}

.profile-image {
  flex: 0 0 300px;
  margin-right: 2rem;
  margin-bottom: 1rem;
  max-width: 100%;
}

.profile-image img {
  width: 100%;
  max-width: 300px;
  height: auto;
  border-radius: 0%;
  object-fit: cover;
  border: 3px solid white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  display: block;
}

.profile-info {
  flex: 1;
  min-width: 300px;
}

.profile-info h1 {
  margin-bottom: 0.5rem;
  font-size: 2.5rem;
}

.profile-position {
  font-size: 1.2rem;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.profile-institution {
  font-size: 1rem;
  color: var(--light-text);
  margin-bottom: 1rem;
}

.social-links {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: white;
  color: var(--primary-color);
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.social-links a:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.content-section {
  margin-bottom: 3rem;
}

.content-section h2 {
  position: relative;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.content-section h2:after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 50px;
  background-color: var(--primary-color);
}

/* Posts Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.post-card {
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 1.5rem;
  background-color: var(--card-bg);
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s ease,
    border-color 0.3s ease;
  box-shadow: 0 2px 4px var(--shadow-color);
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px var(--shadow-color);
}

.post-meta {
  color: var(--lightest-text);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.read-more {
  display: inline-block;
  margin-top: 0.5rem;
  font-weight: 500;
}

/* Research areas and interests */
.research-areas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.research-area {
  background-color: var(--secondary-color);
  border-radius: 5px;
  padding: 1.5rem;
}

.research-interests ul {
  list-style-type: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.research-interests li {
  background-color: var(--secondary-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

/* Bio section */
.bio {
  line-height: 1.8;
  font-size: 1.05rem;
}

/* Teams */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 2rem;
}

.team-member {
  text-align: center;
}

.team-member img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1rem;
}

.team-member h3 {
  margin-bottom: 0.25rem;
}

.team-member .title {
  color: var(--light-text);
  margin-bottom: 1rem;
}

/* Publications */
.publication-list {
  list-style-type: none;
  padding: 0;
}

.publication-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.publication-item:last-child {
  border-bottom: none;
}

.publication-title {
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.publication-meta {
  color: var(--light-text);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.publication-abstract {
  margin-bottom: 1rem;
  color: var(--text-color);
}

.publication-links a {
  margin-right: 1rem;
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 3px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--bg-color);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  text-decoration: none;
  color: var(--bg-color);
}

/* CV Download Button */
.cv-download {
  margin: 2rem 0;
  text-align: center;
}

.cv-download .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1.1rem;
}

/* Page & Post Content */
.page-title,
.post-title {
  margin-top: 2rem;
  margin-bottom: 1.5rem;
}

.post-meta {
  margin-bottom: 2rem;
}

.post-content {
  margin-bottom: 2rem;
}

/* Media query per dispositivi mobili */
@media screen and (max-width: 768px) {
  .profile-section {
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
  }

  .profile-image {
    flex: 0 0 100%;
    margin-right: 0;
    text-align: center;
    max-width: 100%;
  }

  .profile-image img {
    max-width: 250px;
    margin: 0 auto 1.5rem;
  }

  .profile-info {
    text-align: center;
    min-width: auto;
    width: 100%;
  }

  .social-links {
    justify-content: center;
  }

  .content-section h2:after {
    left: 50%;
    transform: translateX(-50%);
  }

  .footer-col-wrapper {
    flex-direction: column;
  }
}

/* Media query per dispositivi molto piccoli */
@media screen and (max-width: 480px) {
  .profile-image img {
    max-width: 200px;
  }

  .profile-section {
    padding: 1rem;
  }
}
