:root {
  /* Minimal Dark Theme Tokens */
  --bg-color: #0b0b0c;
  --text-primary: #f2f2f2;
  --text-muted: #888888;
  --accent: #ffffff;
  
  --font-sans: 'Inter', sans-serif;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 8rem;
  
  --transition-smooth: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Prevent scrollbar jumping during overlay lock */
  overflow-y: scroll; 
  overflow-x: hidden;
}

/* ==================================================
   OVERLAY INTRO (Sipario Svelato)
================================================== */
.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100lvh; /* lvh for mobile better handling */
  background-color: var(--bg-color);
  pointer-events: none; /* Consente di cliccare sui pulsanti sottostanti anche in fase di fade */
  
  /* Sfondo immagine dietro il testo con un leggero overlay per garantire contrasto */
  background-image: 
    linear-gradient(rgba(11, 11, 12, 0.4), rgba(11, 11, 12, 0.7)), 
    url('sfondo-profilo.jpg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  /* Will be manipulated via JS */
  will-change: opacity, transform, backdrop-filter;
}

.welcome-logo {
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.1;
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 1rem;
  display: inline-block;
}

.scroll-indicator {
  position: absolute;
  bottom: var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  opacity: 0.6;
}

.scroll-text {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.scroll-line {
  width: 1px;
  height: 60px;
  background: linear-gradient(to bottom, var(--text-primary), transparent);
  animation: pulseLine 2s infinite;
}

@keyframes pulseLine {
  0% { transform: scaleY(0); transform-origin: top; }
  50% { transform: scaleY(1); transform-origin: top; }
  51% { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}


/* ==================================================
   MAIN CONTENT & HEADER
================================================== */
.main-content {
  opacity: 0.5; /* Starts lower opacity, revealed by JS */
  filter: blur(10px);
  transform: translateY(2rem);
  /* Aggiunto padding-top per controbilanciare l'header fisso */
  padding: 70px 5vw 0 5vw; 
  max-width: 1600px;
  margin: 0 auto;
}

.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 150; /* Sopra a overlay e a tutto il resto */
  pointer-events: auto;
  
  /* Inizia nascosto, verrà rivelato dal GSAP assieme al Main Content */
  opacity: 0;
  transform: translateY(-100%);
  
  /* Glassmorphism background - Più trasparente */
  background-color: rgba(11, 11, 12, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-inner {
  height: 70px; /* Più piccolo */
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 5vw;
  max-width: 1600px;
  margin: 0 auto;
}

.logo {
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.nav a {
  color: var(--text-primary);
  text-decoration: none;
  margin-left: 2rem;
  font-size: 0.875rem;
  font-weight: 400;
  transition: opacity 0.3s ease;
}

.nav a:hover {
  opacity: 0.5;
}

/* ==================================================
   HERO / BIO
================================================== */
.hero {
  position: relative;
  padding: var(--space-xl) 0 calc(var(--space-xl) * 1.5) 0;
  max-width: 100%;
}

.hero::before {
  content: "";
  position: absolute;
  top: -100px;
  left: calc(-50vw + 50%);
  width: 100vw;
  height: calc(100% + 150px);
  background-image: 
    linear-gradient(to right, rgba(11, 11, 12, 0.95) 0%, rgba(11, 11, 12, 0) 90%),
    linear-gradient(to bottom, rgba(11, 11, 12, 1) 0%, rgba(11, 11, 12, 0) 10%, rgba(11, 11, 12, 0) 90%, rgba(11, 11, 12, 1) 100%),
    url('scena2_1.0120.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -1;
  pointer-events: none;
}

.hero-glass-panel {
  background-color: rgba(11, 11, 12, 0.05); /* Quasi impercettibile */
  backdrop-filter: blur(6px) saturate(110%);
  -webkit-backdrop-filter: blur(6px) saturate(110%);
  border: 1px solid rgba(255, 255, 255, 0.08); /* Bordo finissimo stile Apple */
  border-radius: 28px; /* Angoli stondati e morbidi */
  padding: 3.5rem;
  max-width: 950px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.03);
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3rem); /* Ridotto drasticamente per renderlo meno ingombrante */
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 2rem; /* Leggermente aumentato nel glass panel */
  max-width: 900px;
}

.hero-bio {
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  color: rgba(255, 255, 255, 0.85); /* Menos grigio, più vicino al bianco assoluto */
  font-weight: 300;
  max-width: 800px;
  margin-bottom: var(--space-lg);
}

.hero-bio p {
  margin-bottom: 1.5rem;
}

.hero-bio p:last-of-type {
  margin-bottom: 0;
}

.hero-bio ul {
  list-style: none;
  margin-top: 2rem;
}

.hero-bio li {
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
  color: var(--text-primary); /* Bianco pieno per le liste che sono il fulcro */
}

.hero-bio li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: rgba(255, 255, 255, 0.85);
}

/* ==================================================
   BUTTONS
================================================== */
.btn {
  display: inline-block;
  padding: 1.2rem 2.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all var(--transition-smooth);
}

.btn-primary {
  background-color: var(--text-primary);
  color: var(--bg-color);
  border: 1px solid var(--text-primary);
}

.btn-primary:hover {
  background-color: transparent;
  color: var(--text-primary);
}

/* ==================================================
   FILTRI / CATEGORIE
================================================== */
.filters-container {
  position: sticky;
  top: 70px; /* Offsetato per il nuovo header fisso più piccolo */
  background-color: var(--bg-color); /* Colore solido pieno per impedire l'accavallamento testi! */
  padding: var(--space-md) 0;
  z-index: 50;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.filters-list {
  display: flex;
  list-style: none;
  gap: 2rem;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}

.filters-list::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  padding-bottom: 0.25rem;
}

.filter-btn:hover {
  color: var(--text-primary);
}

.filter-btn.active {
  color: var(--text-primary);
}

.filter-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: var(--text-primary);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--transition-smooth);
}

.filter-btn.active::after {
  transform: scaleX(1);
  transform-origin: left;
}


/* ==================================================
   GRIGLIA PORTFOLIO
================================================== */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: var(--space-xl) var(--space-md); /* Huge gaps for negative space */
  padding-bottom: var(--space-xl);
}

/* Progetto Card */
.project-card {
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  cursor: pointer;
  opacity: 1; /* For JS filtering */
  transition: opacity 0.5s ease, filter 0.5s ease, transform 0.5s ease;
}

.project-card.hidden {
  opacity: 0;
  filter: blur(10px);
  pointer-events: none;
  transform: scale(0.95);
  position: absolute; /* Remove from flow to allow masonry adjustment */
  visibility: hidden; 
}

.project-image-wrapper {
  overflow: hidden;
  background-color: #1a1a1b; /* placeholder color while loading */
  aspect-ratio: 4/5;
  width: 100%;
  position: relative;
}

.project-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-smooth), filter var(--transition-smooth);
  filter: grayscale(80%) brightness(0.8);
}

.project-card:hover .project-thumbnail {
  transform: scale(1.05);
  filter: grayscale(0%) brightness(1);
}

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

.project-title {
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.project-tags {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==================================================
   FOOTER
================================================== */
.footer {
  padding: var(--space-xl) 5vw;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.footer-title {
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 500; /* Aumentato il peso per renderlo 'più acceso' */
  letter-spacing: -0.02em;
}

.footer-link {
  font-size: 1.5rem;
  color: var(--text-primary);
  text-decoration: none;
  display: inline-block;
  width: fit-content;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-smooth);
}

.footer-link:hover {
  border-color: var(--text-primary);
}

.footer-socials {
  display: flex;
  gap: 2rem;
  margin-top: var(--space-md);
}

.footer-socials a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.3s ease;
}

.footer-socials a:hover {
  color: var(--text-primary);
}

.footer-copy {
  margin-top: var(--space-xl);
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ==================================================
   CONTACT FORM
================================================== */
.contact-form {
  width: 100%;
  max-width: 800px;
  margin: var(--space-sm) 0 var(--space-lg) 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-row {
  display: flex;
  gap: 1.25rem;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 1.2rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  border-radius: 8px;
  transition: all var(--transition-smooth);
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  background-color: rgba(255, 255, 255, 0.06);
  border-color: var(--text-muted);
}

.contact-form textarea {
  resize: vertical;
  min-height: 120px;
}

.contact-form input::placeholder,
.contact-form textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.submit-btn {
  align-self: flex-start;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
    gap: 1.25rem;
  }
}

/* ==================================================
   PROJECT DETAIL GRID (VIEW INTERMEDIO)
================================================== */
.project-detail-view {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-color);
  z-index: 500; /* Sotto la Modal, ma sopra a tutto il resto */
  overflow-y: auto;
  padding: var(--space-xl) 5vw;
  opacity: 1;
  transform: translateY(0);
  transition: transform var(--transition-smooth), opacity 0.5s;
}
.project-detail-view.hidden {
  opacity: 0;
  transform: translateY(100vh);
  pointer-events: none;
}
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}
.detail-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 300;
  letter-spacing: -0.02em;
}
.detail-close {
  background: none; border: none; color: var(--text-primary);
  font-family: inherit; font-size: 0.85rem; letter-spacing: 0.1em;
  cursor: pointer; padding: 0.5rem 0;
  transition: opacity 0.3s;
}
.detail-close:hover { opacity: 0.5; }
.detail-grid {
  max-width: 1600px;
  margin: 0 auto;
}

/* ==================================================
   RESPONSIVE OVERRIDES
================================================== */
@media (max-width: 768px) {
  :root {
    --space-xl: 4rem;
    --space-lg: 3rem;
  }
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
  .hero-glass-panel {
    padding: 2rem;
    border-radius: 20px;
  }
}

/* ==================================================
   LIGHTBOX MODAL GALLERY
================================================== */
.project-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--transition-smooth);
}
.project-modal.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(8, 8, 9, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.modal-close {
  position: absolute;
  top: var(--space-md); right: 5vw;
  background: none; border: none; color: var(--text-primary);
  font-family: inherit; font-size: 0.85rem; letter-spacing: 0.1em;
  cursor: pointer; z-index: 10;
  transition: opacity 0.3s;
}
.modal-close:hover { opacity: 0.5; }

.modal-carousel {
  position: relative;
  width: 90vw; height: 80vh;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.modal-media {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  display: none;
  animation: fadeIn 0.4s ease forwards;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-media.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.modal-controls {
  position: absolute;
  bottom: var(--space-md);
  left: 5vw; right: 5vw;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 10;
}
.modal-arrow {
  background: none; border: none; color: var(--text-primary);
  font-family: inherit; font-size: 0.85rem; letter-spacing: 0.1em;
  cursor: pointer; transition: opacity 0.3s;
}
.modal-arrow:hover { opacity: 0.5; }
.modal-arrow.disabled { opacity: 0.2; pointer-events: none; }
.modal-counter {
  font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
