/* Stile minimal con animazioni fluide */
* { box-sizing: border-box; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInDown {
  from { opacity: 0; }
  to { opacity: 1; }
}

body {
  margin: 0;
  font-family: 'Titillium Web', Arial, Helvetica, sans-serif;
  background: #ffffff;
  color: #111;
  animation: slideInDown 0.5s ease-out;
}

a { color: #111; text-decoration: none; }
.page-wrap { max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; animation: fadeIn 0.6s ease-out; padding: 0 1rem; }
.portfolio-title { margin: 0; font-size: 1.3rem; font-weight: 600; color: #111; text-decoration: none; transition: color 0.3s ease; }
.portfolio-title:hover { color: #666; }
.nav-links a { margin-left: 1.5rem; font-size: 0.95rem; transition: color 0.3s ease; }
.nav-links a:hover { color: #666; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.card { 
  border: none;
  border-radius: 0;
  overflow: hidden; 
  background: transparent;
  animation: fadeIn 0.6s ease-out backwards;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: auto;
}
.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(n+4) { animation-delay: calc(0.05s * (var(--index, 1) - 1)); }
.card:hover { 
  box-shadow: none;
  transform: none;
}
.card-img { 
  width: 100%; 
  height: 400px; 
  object-fit: cover; 
  flex-shrink: 0;
  transition: transform 0.4s ease;
  border-radius: 0;
}
.card:hover .card-img { transform: scale(1.02); }
.card-title { 
  margin: 0.8rem 0 0.3rem 0; 
  font-size: 0.95rem;
  height: auto;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  font-weight: 600;
  letter-spacing: 0.05rem;
}
.card-subtitle { 
  margin: 0;
  font-size: 0.78rem; 
  color: #888;
  height: auto;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.small-meta { font-size: 0.82rem; color: #555; animation: fadeIn 0.7s ease-out; }

article { 
  display: grid; 
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); 
  gap: 3rem;
  align-items: start;
  animation: fadeIn 0.7s ease-out;
}

.article-left {
  display: flex;
  flex-direction: column;
  max-width: 420px;
  margin-top: 1rem;
}

.article-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

article h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.4rem;
  animation: fadeIn 0.7s ease-out;
}

.hero-image { 
  display: none;
}

.project-gallery { 
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}
.project-gallery img { 
  width: 100%; 
  height: auto;
  max-height: 560px;
  object-fit: contain; 
  border-radius: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  animation: fadeIn 0.7s ease-out backwards;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}
.project-gallery video { 
  width: 100%; 
  height: auto;
  max-height: 560px;
  object-fit: contain; 
  border-radius: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  animation: fadeIn 0.7s ease-out backwards;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
  background: #000;
}
.project-gallery img:nth-child(1) { animation-delay: 0.3s; }
.project-gallery img:nth-child(2) { animation-delay: 0.4s; }
.project-gallery img:nth-child(3) { animation-delay: 0.5s; }
.project-gallery img:nth-child(4) { animation-delay: 0.6s; }
.project-gallery img:nth-child(5) { animation-delay: 0.7s; }
.project-gallery img:nth-child(6) { animation-delay: 0.8s; }
.project-gallery video:nth-child(1) { animation-delay: 0.3s; }
.project-gallery video:nth-child(2) { animation-delay: 0.4s; }
.project-gallery video:nth-child(3) { animation-delay: 0.5s; }
.project-gallery video:nth-child(4) { animation-delay: 0.6s; }
.project-gallery video:nth-child(5) { animation-delay: 0.7s; }
.project-gallery video:nth-child(6) { animation-delay: 0.8s; }
.project-gallery img:nth-child(n+7) { animation-delay: calc(0.05s * var(--index, 1)); }
.project-gallery img:hover { 
  transform: scale(1.03);
  opacity: 0.9;
}
.project-gallery video:hover { 
  transform: scale(1.03);
  opacity: 0.9;
}

.video-separator {
  margin-top: 2rem !important;
}

.large-video {
  width: 220% !important;
  height: auto !important;
  aspect-ratio: 16/9 !important;
  object-fit: contain !important;
  margin: 0 -10% !important;
}

.loading-gallery {
  text-align: center;
  padding: 2rem;
  color: #666;
  font-style: italic;
}

.project-gallery {
  transition: opacity 0.3s ease;
}

.project-description { 
  margin-top: 1.5rem;
  animation: fadeIn 0.8s ease-out;
  line-height: 1.7;
  font-size: 1rem;
}

section { animation: fadeIn 0.7s ease-out; }

footer { 
  margin-top: 1.4rem; 
  text-align: center; 
  color: #666; 
  font-size: 0.82rem;
  animation: fadeIn 0.9s ease-out;
}

.me-card { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 0.8rem;
  animation: fadeIn 0.7s ease-out;
}
.me-photo { 
  width: 100%; 
  height: auto; 
  border-radius: 5px;
  animation: fadeIn 0.8s ease-out;
  transition: transform 0.3s ease;
}
.me-photo:hover { transform: scale(1.02); }

@media (min-width: 750px) { 
  .me-card { grid-template-columns: 1fr 1fr; } 
  .project-gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
  .card-img { height: 320px; }
  article { grid-template-columns: 1fr; gap: 2rem; }
  .hero-image { height: 320px; }  .large-video { 
    width: 110% !important;
    height: auto !important;
    aspect-ratio: 16/9 !important;
    object-fit: contain !important;
    margin: 0 -5% !important;
  }}

@media (max-width: 680px) {
  .grid { grid-template-columns: 1fr; gap: 1rem; }
  .card-img { height: 280px; }
  .page-wrap { padding: 1.5rem 1rem; }
  .header { padding: 0; flex-direction: column; align-items: flex-start; }
  .nav-links { margin-top: 0.5rem; }
  .nav-links a { margin-left: 0; margin-right: 1rem; }
  article { grid-template-columns: 1fr; gap: 1.5rem; }
  .project-gallery { grid-template-columns: 1fr; }
  .project-gallery img { height: 200px; }
  .project-gallery video { height: 200px; }
  .hero-image { height: 280px; }
  .large-video { 
    width: 105% !important;
    height: auto !important;
    aspect-ratio: 16/9 !important;
    object-fit: contain !important;
    margin: 0 -2.5% !important;
  }
}

/* Lightbox Modal */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90%;
  max-width: 1000px;
  height: 80vh;
  position: relative;
}

#lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  animation: fadeIn 0.3s ease;
}

#lightbox-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  animation: fadeIn 0.3s ease;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 2rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: background 0.3s ease;
  z-index: 10000;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.4);
}

.lightbox-prev { left: -60px; }
.lightbox-next { right: -60px; }

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  transition: color 0.3s ease;
}

.lightbox-close:hover {
  color: #ccc;
}

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem 1rem;
  border-radius: 20px;
}

@media (max-width: 768px) {
  .lightbox-prev,
  .lightbox-next {
    position: static;
    transform: none;
    background: rgba(255, 255, 255, 0.3);
    font-size: 1.5rem;
    padding: 0.5rem 1rem;
  }

  .lightbox-container {
    flex-direction: column;
    gap: 1rem;
  }

  .lightbox-counter {
    position: static;
    transform: none;
  }
}

/* Project Navigation Arrows */
.project-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 3rem 0 2rem 0;
  padding: 0 1rem;
  animation: fadeIn 0.8s ease-out;
}

.nav-arrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  color: #333;
}

.nav-arrow:hover {
  background: #e9e9e9;
  border-color: #bbb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-arrow.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

.arrow-symbol {
  font-size: 1.2rem;
  font-weight: bold;
}

.prev-arrow {
  margin-right: auto;
}

.next-arrow {
  margin-left: auto;
  flex-direction: row-reverse;
}

@media (max-width: 768px) {
  .project-navigation {
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0 1rem 0;
  }
  
  .nav-arrow {
    width: 100%;
    justify-content: center;
  }
  
  .prev-arrow,
  .next-arrow {
    margin: 0;
  }
}

