/* =============================================================
   Ingenium — motore animazioni (anime.js + Lenis)
   Reveal on-scroll + tipografia cinetica (word-rise) — stile energico.
   GPU-only (transform/opacity). Failsafe + prefers-reduced-motion.
   ============================================================= */

/* --- Lenis (smooth scroll) --- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

/* --- Reveal generico: fade + slide up --- */
.anim-ready :where(
  .section-tag, .section-subtitle,
  .about-content, .about-stats, .about-actions,
  .why-card, .feature-item, .feature-card,
  .timeline-item, .team-member-card,
  .event-card, .eventi-cta, .stat-item,
  .footer-brand, .footer-links, .footer-contact
) {
  opacity: 0;
  transform: translateY(44px);
  will-change: transform, opacity;
}

/* --- Visual/immagini: fade + zoom --- */
.anim-ready :where(.about-visual, .hero-visual, .main-image, .small-image, .photo-gallery-item) {
  opacity: 0;
  transform: scale(0.93);
  will-change: transform, opacity;
}

/* --- Heading a split di parole (tipografia cinetica) --- */
.anim-ready .hero-title,
.anim-ready .section-title { opacity: 0; }

.a-word {
  display: inline-block;
  overflow: visible;        /* niente clip: le parole non vengono mai tagliate a metà */
  vertical-align: top;
  padding-bottom: 0.14em;   /* spazio per i discendenti (g, p, y) */
  margin-bottom: -0.14em;
}
.a-word-in { display: inline-block; will-change: transform, opacity; }
/* Stato iniziale: parole leggermente più in basso e trasparenti -> fade+rise
   pulito. Anche se l'animazione si blocca, restano quasi del tutto leggibili. */
.anim-ready .a-word-in { transform: translateY(14px); opacity: 0; }

/* --- Hero: sottotitolo e bottoni --- */
.anim-ready .hero-content .hero-subtitle { opacity: 0; will-change: transform, opacity; }
.anim-ready .hero-content .hero-buttons > * { opacity: 0; will-change: transform, opacity; }

/* Liberazione will-change a reveal completato */
.is-revealed { will-change: auto !important; }
.is-revealed .a-word-in { will-change: auto; }

/* --- Fallback: se anim.js non parte, mostra tutto --- */
.anim-fallback :where(
  .section-tag, .section-subtitle, .about-content, .about-stats, .about-actions,
  .why-card, .feature-item, .feature-card, .timeline-item, .team-member-card,
  .event-card, .eventi-cta, .stat-item, .footer-brand, .footer-links, .footer-contact,
  .about-visual, .hero-visual, .main-image, .small-image, .photo-gallery-item
),
.anim-fallback .hero-title, .anim-fallback .section-title,
.anim-fallback .hero-content .hero-subtitle,
.anim-fallback .hero-content .hero-buttons > * {
  opacity: 1 !important;
  transform: none !important;
}
.anim-fallback .a-word-in { transform: none !important; opacity: 1 !important; }

/* --- Accessibilità / risparmio batteria: nessun movimento --- */
@media (prefers-reduced-motion: reduce) {
  .anim-ready :where(
    .section-tag, .section-subtitle, .about-content, .about-stats, .about-actions,
    .why-card, .feature-item, .feature-card, .timeline-item, .team-member-card,
    .event-card, .eventi-cta, .stat-item, .footer-brand, .footer-links, .footer-contact,
    .about-visual, .hero-visual, .main-image, .small-image, .photo-gallery-item
  ),
  .anim-ready .hero-title, .anim-ready .section-title,
  .anim-ready .hero-content .hero-subtitle,
  .anim-ready .hero-content .hero-buttons > * {
    opacity: 1 !important;
    transform: none !important;
  }
  .anim-ready .a-word-in { transform: none !important; opacity: 1 !important; }
}

/* --- Parallax hero (perf) --- */
.anim-ready .hero-content { will-change: transform, opacity; }

/* --- Gallery: scroll orizzontale (energico, mobile-safe) --- */
.gallery-horizontal {
  column-count: initial !important;
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1rem;
  scrollbar-width: thin;
  cursor: grab;
}
.gallery-horizontal.dragging { cursor: grabbing; }
.gallery-horizontal .photo-gallery-item {
  flex: 0 0 auto;
  width: 300px;
  margin-bottom: 0 !important;
  scroll-snap-align: center;
}
.gallery-horizontal .photo-gallery-item img {
  width: 100%;
  height: 380px;
  object-fit: cover;
  display: block;
}
@media (max-width: 768px) {
  .gallery-horizontal .photo-gallery-item { width: 78vw; }
  .gallery-horizontal .photo-gallery-item img { height: 300px; }
}

/* --- Hero grid: firma anime.js (stagger + ripple) --- */
.hero-section { position: relative; }
.hero-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-auto-rows: 1fr;
  pointer-events: none;
}
.hg-dot {
  align-self: center;
  justify-self: center;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--secondary-color);
  transform: scale(0);
  opacity: 0;
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: reduce) { .hero-grid { display: none; } }
