/**
 * TRANSIZIONI FLUIDE PER NAVIGAZIONE
 * Elimina "scatti" visivi durante il cambio pagina
 */

/* Animazione fade per cambio pagina */
body {
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

body.page-transitioning {
  opacity: 0;
}

/* Ottimizzazioni rendering */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hardware acceleration solo per elementi attivamente animati */
/* Rimosso will-change da elementi statici per ridurre consumo memoria */
a, button, .nav-link, .dropdown-menu {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Rimosso will-change permanente - applicato solo con JS quando necessario */

/* Transizioni fluide per link */
a {
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

a:hover {
  transform: translateY(-1px);
}

/* Dropdown menu smooth */
.dropdown-menu {
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.dropdown:hover .dropdown-menu,
.dropdown-menu.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Immagini lazy con placeholder */
img[loading="lazy"] {
  background: linear-gradient(
    135deg,
    rgba(0, 212, 255, 0.05) 0%,
    rgba(0, 136, 204, 0.05) 100%
  );
  min-height: 100px;
}

img {
  transition: opacity 0.3s ease;
}

img:not([src]), img[src=""] {
  opacity: 0;
}

/* Prevenzione layout shift */
.container, .section {
  contain: layout style paint;
}

/* Ottimizzazione scroll smooth nativo */
html {
  scroll-behavior: smooth;
}
/* Riduci motion per utenti con preferenze accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  body {
    transition: none !important;
  }
}

/* Prevenzione FOUC (Flash of Unstyled Content) */
.wf-loading {
  visibility: hidden;
}

.wf-active, .wf-inactive {
  visibility: visible;
}

/* Skeleton screen per contenuti in caricamento */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Ottimizzazione video background - NO will-change permanente */
.video-bg video {
  transform: translateZ(0);
}

/* Navbar fixed smooth - NO will-change */
header {
  transform: translateZ(0);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Contenuto principale con transizione */
main {
  transition: opacity 0.2s ease;
}

main.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Button ripple effect */
button, .btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

button::after, .btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

button:active::after, .btn:active::after {
  width: 300px;
  height: 300px;
}

/* Card hover effects */
.card, .portfolio-item {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover, .portfolio-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Form inputs smooth focus */
input, textarea, select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-color, #00d4ff);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

/* Mobile touch feedback */
@media (max-width: 768px) {
  a:active, button:active, .btn:active {
    opacity: 0.8;
    transform: scale(0.98);
  }
}

/* Prevenzione flash content */
[x-cloak] {
  display: none !important;
}

/* Lazy load fade-in */
.lazy-load {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.lazy-load.loaded {
  opacity: 1;
}

/* Performance: GPU acceleration solo quando necessario - NO will-change */
@media (min-width: 769px) {
  .accelerated {
    transform: translate3d(0, 0, 0);
  }
}

/* Contenitore principale con content-visibility per performance */
@supports (content-visibility: auto) {
  section {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
  }
}
