/* ================ VARIABILI ================ */
:root {
  --bg-primary: #f4f6f9;
  --text-primary: #1a202c;
  --text-secondary: #2c3e50;
  --text-tertiary: #34495e;
  --accent-color: #3182ce;
  --success-color: #38a169;
  --success-dark: #2c7a5b;
  --card-bg: white;
  --border-color: #e5e7eb;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --text-gradient: linear-gradient(135deg, #3182ce 0%, #805ad5 100%);
}

/* ================ BASE STYLES ================ */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.7;
}

.container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 3rem 1rem;
}

/* ================ TIPOGRAFIA ================ */
.prose {
  max-width: 100%;
  line-height: 1.8;
  font-size: 1.125rem;
}

.prose h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 1.5rem; }
.prose h2 { font-size: 1.8rem; font-weight: 600; margin: 2rem 0 1rem; color: var(--accent-color); border-bottom: 2px solid var(--accent-color); padding-bottom: 0.5rem; }
.prose h3 { font-size: 1.5rem; font-weight: 600; margin: 1.5rem 0 0.8rem; color: var(--text-secondary); }
.prose h4 { font-size: 1.3rem; font-weight: 500; margin: 1.2rem 0 0.6rem; color: var(--text-tertiary); }

.prose pre {
  background-color: #f8f9fa;
  border-radius: 0.5rem;
  padding: 1rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.prose code {
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9rem;
}

.prose table {
  border-collapse: collapse;
  margin: 1.5em 0;
  width: 100%;
  overflow-x: auto;
}

.prose table th,
.prose table td {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  vertical-align: top;
}

.prose table th {
  background-color: #f3f4f6;
  font-weight: 600;
  text-align: left;
}

/* ================ LINK ================ */
.article-link {
  position: relative;
  display: inline-block;
  padding: 0.5rem 0;
  font-size: 1.125rem;
  color: var(--accent-color);
  text-decoration: none;
  transition: padding-left 0.3s ease;
}

.article-link::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: var(--accent-color);
  transition: width 0.3s ease;
}

.article-link:hover { padding-left: 1rem; }
.article-link:hover::after { width: 100%; }

.back-link {
  display: inline-block;
  margin-top: 2rem;
  color: var(--accent-color);
  text-decoration: none;
  transition: transform 0.3s ease;
}

.back-link:hover { transform: translateX(-5px); }

.simple-link {
  color: var(--success-color);
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.simple-link::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: var(--success-color);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.simple-link:hover { color: var(--success-dark); transform: translateY(-1px); }
.simple-link:hover::after { transform: scaleX(1); transform-origin: left; }

/* ================ COMPONENTI CARDS ================ */
.category-card {
  background: var(--card-bg);
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all 0.3s ease, z-index 0.1s;
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
  overflow: hidden;
  min-height: 70px;
}

.category-card::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 0;
  height: 100%;
  width: 2px;
  background: var(--border-color);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.category-card:hover::before { opacity: 1; }
.category-card:hover .category-title::after { width: 100%; }

.category-title {
  font-size: 1.75rem;
  font-weight: 700;
  position: relative;
  display: inline-block;
  background: var(--text-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 0.5rem;
  margin-bottom: 0;
}

.card-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
}

.category-card:hover .card-content {
  max-height: 5000px;
  opacity: 1;
  padding-top: 0.5rem;
  z-index: 20;
  overflow: visible;
}

/* Componenti specifici */
.edu-item {
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.project-card {
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover { transform: translateY(-3px); }

.publication-card {
  border-left: 4px solid #4f46e5;
}

.cert-card {
  transition: all 0.3s ease;
}

.cert-card:hover { transform: translateY(-2px); }

.course-card {
  border: 1px solid #e5e7eb;
  min-height: 100%;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.silver-badge {
  background-color: #e5e7eb;
  color: #374151;
  border: 1px solid #d1d5db;
}

/* Layout gerarchico */
.subcategories {
  border-left: 2px solid var(--border-color);
  margin-left: 0.5rem;
  padding-left: 0.1rem;
  position: relative;
}

.subcategories::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 0;
  height: 100%;
  width: 2px;
  background: var(--card-bg);
  z-index: 2;
}

.depth-0 { margin-left: 0 }
.depth-1 { margin-left: 0.8rem }
.depth-2 { margin-left: 1.6rem }
.depth-3 { margin-left: 2.4rem }

/* Animazioni */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes navPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Media Queries */
@media (max-width: 768px) {
  .subcategories {
      margin-left: 0.8rem;
      padding-left: 0.4rem;
  }
  
  .depth-1 { margin-left: 0.8rem }
  .depth-2 { margin-left: 1.6rem }
  .depth-3 { margin-left: 2.4rem }
  
  .subcategories .category-card::before { left: -0.6rem; }
  .publication-card { border-left: none; border-top: 4px solid #4f46e5; }
}

@media (max-width: 640px) {
  .cert-card {
      border-left: none;
      border-top: 4px solid;
  }
  
  .cert-card:nth-child(1) { border-top-color: #3b82f6; }
  .cert-card:nth-child(2) { border-top-color: #10b981; }
  .cert-card:nth-child(3) { border-top-color: #8b5cf6; }
  .cert-card:nth-child(4) { border-top-color: #f97316; }
  
  .course-card { margin-bottom: 1.5rem; }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { 
  .tikz-svg { image-rendering: crisp-edges; }
}

/* Componenti specifici aggiuntivi */
.image-link-box {
  position: relative;
  min-height: 180px;
}

.image-link-box img {
  transition: transform 0.5s ease;
}

.image-link-box:hover img { transform: scale(1.05); }

.image-link-box div {
  position: relative;
  height: 100%;
}

.image-link-box div::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-link-box:hover div::after { opacity: 1; }

.badge-link {
  transition: transform 0.2s ease;
}

.badge-link:hover { transform: scale(1.05); }

.text-accent-color { color: #4f46e5; }

/* ================ ELENCHI STILIZZATI ================ */
.prose ul {
  list-style: none;
  padding-left: 2rem;
  margin: 1.5rem 0;
  position: relative;
}

.prose li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  transition: all 0.3s ease;
}

.prose li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 0.6rem;
  height: 0.6rem;
  background: var(--text-gradient);
  border-radius: 50%;
  transform: scale(0.8);
  transition: transform 0.3s ease;
}

.prose li:hover {
  padding-left: 1.7rem;
}

.prose li:hover::before {
  transform: scale(1);
  box-shadow: 0 0 8px rgba(49, 130, 206, 0.2);
}

/* Elenchi annidati */
.prose ul ul {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}

.prose ul ul li::before {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--text-tertiary);
  box-shadow: none;
}

.prose ul ul ul li::before {
  background: var(--border-color);
}

/* Elenchi speciali */
.prose .checklist li::before {
  content: '✓';
  background: transparent;
  color: var(--success-color);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  top: 0.15em;
}

.prose .highlight-list li {
  padding: 0.8rem 1rem;
  background: var(--card-bg);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.prose .highlight-list li::before {
  left: -0.8rem;
  top: 50%;
  transform: translateY(-50%);
}

/* Aumenta dimensione foto profilo nella versione desktop */
header.text-center img.rounded-full {
  width: 300px;  /* Dimensione aumentata rispetto ai 40px originali */
  height: 300px;
  object-fit: cover;
}

/* Allineamento responsive */
@media (max-width: 768px) {
  /* Riduzione padding generale */
  .prose ul {
    padding-left: 1rem;
  }
  .prose li {
    padding-left: 1rem;
  }
  
  /* Riduzione padding per tutte le card */
  .category-card {
    padding: 1rem 0.75rem;
  }
  
  /* Riduzione padding per card specifiche */
  .project-card, 
  .publication-card, 
  .cert-card, 
  .course-card, 
  .bg-white.p-8 {
    padding: 1rem !important;
  }
  
  /* Riduzione padding interno degli elementi nelle card */
  .project-card > div, 
  .publication-card > div,
  .exp-item,
  .edu-item {
    gap: 0.75rem;
  }
  
  /* Riduzione margini tra elementi */
  .space-y-10 > * + * {
    margin-top: 1.5rem;
  }
  
  /* Riduzione padding degli elementi di intestazione */
  header.text-center {
    margin-bottom: 1.5rem;
  }
  
  /* Riduzione padding per i contenitori principali */
  .container.mx-auto {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  /* Dimensione foto profilo per tablet - dimensione aumentata */
  header.text-center img.rounded-full {
    width:  200px;
    height: 200px;
  }
  
  /* Ottimizzazione delle immagini per riempire completamente i contenitori */
  .image-link-box img,
  .course-card img,
  .publication-card img,
  img.object-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
  }
  
  /* Assicurati che i contenitori delle immagini abbiano altezza sufficiente */
  .image-link-box,
  .image-link-box > div,
  .course-card img {
    height: 200px !important;
    min-height: 200px;
  }
  
  /* Gestione specifica per le card dei progetti su mobile */
  .project-card .flex-col.md\:flex-row {
    flex-direction: column !important;
  }
  
  .project-card .md\:w-4\/5,
  .project-card .md\:w-1\/4,
  .publication-card .md\:w-3\/4,
  .publication-card .md\:w-1\/4 {
    width: 100% !important;
  }
  
  /* Assicurati che le immagini nei progetti abbiano una dimensione adeguata */
  .project-card .image-link-box,
  .project-card .image-link-box > div {
    margin-top: 1rem;
    height: 180px !important;
  }
}

@media (max-width: 480px) {
  /* Riduzione ulteriore per smartphone piccoli */
  .category-card,
  .project-card, 
  .publication-card, 
  .cert-card, 
  .course-card, 
  .bg-white.p-8 {
    padding: 0.75rem !important;
  }
  
  /* Dimensione immagini per schermi molto piccoli */
  .image-link-box,
  .image-link-box > div,
  .course-card img {
    height: 160px !important;
  }
  
  /* Dimensione foto profilo per schermi molto piccoli - dimensione aumentata */
  header.text-center img.rounded-full {
    width:  200px;
    height: 200px;
  }
}