/* Home hero ambient — opt-in (.home-hero--ambient), preset allineato al lab */

.home-hero--ambient {
  isolation: isolate;
  overflow: hidden !important;
  position: relative;
  z-index: 2;
}

.home-shell {
  overflow-x: clip;
  max-width: 100%;
}

.home-hero--ambient .home-hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.home-hero--ambient .home-hero-media .home-hero-bg,
.home-hero--ambient .home-hero-media .home-hero-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0 !important;
  clip-path: none !important;
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

.home-hero--ambient .home-hero-inner {
  position: relative;
  z-index: 3;
}

/* Secondo strato dissolvenza copy (lab enhanced) */
.home-hero--ambient .home-hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 1) 14%,
    rgba(255, 255, 255, 0.97) 24%,
    rgba(255, 255, 255, 0.9) 34%,
    rgba(255, 255, 255, 0.76) 44%,
    rgba(255, 255, 255, 0.56) 54%,
    rgba(255, 255, 255, 0.36) 64%,
    rgba(255, 255, 255, 0.18) 72%,
    rgba(255, 255, 255, 0.06) 80%,
    rgba(255, 255, 255, 0) 88%
  );
}

.home-hero--ambient .home-hero-overlay {
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.98) 12%,
    rgba(255, 255, 255, 0.92) 24%,
    rgba(255, 255, 255, 0.8) 38%,
    rgba(255, 255, 255, 0.6) 52%,
    rgba(255, 255, 255, 0.38) 66%,
    rgba(255, 255, 255, 0.18) 80%,
    rgba(255, 255, 255, 0.06) 100%
  ) !important;
}

.home-hero--ambient.is-ken-burns-on .home-hero-media .home-hero-bg {
  animation: portal-home-ken-burns 11s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes portal-home-ken-burns {
  from {
    transform: scale(1) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.17) translate3d(-1.4%, -1%, 0);
  }
}

.home-hero--ambient .portal-ambient-canvas,
.home-hero--ambient .portal-ambient-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.home-hero--ambient .portal-ambient-canvas {
  z-index: 2;
  opacity: 0;
  mix-blend-mode: soft-light;
  transition: opacity 0.45s ease;
}

.home-hero--ambient .portal-ambient-canvas.is-active {
  opacity: 1;
}

.home-hero--ambient .portal-ambient-grain {
  z-index: 4;
  opacity: 0;
  mix-blend-mode: overlay;
  transition: opacity 0.35s ease;
}

.home-hero--ambient .portal-ambient-grain.is-active {
  opacity: 0.18;
}

.home-hero--ambient .home-hero-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 85% at 50% 38%, transparent 42%, rgba(var(--brand-rgb), 0.16) 100%),
    linear-gradient(to top, rgba(var(--brand-rgb), 0.12), transparent 45%);
}

.home-hero--ambient .home-hero-edge-glow {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 1;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.55),
    inset 0 0 40px rgba(var(--brand-rgb), 0.08);
  animation: portal-home-edge-pulse 5s ease-in-out infinite;
}

@keyframes portal-home-edge-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.45),
      inset 0 0 28px rgba(var(--brand-rgb), 0.06);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.72),
      inset 0 0 52px rgba(var(--brand-rgb), 0.18);
  }
}

.home-hero--ambient.is-glass-on .home-search-panel {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: rgba(255, 255, 255, 0.30) !important;
  backdrop-filter: blur(28px) saturate(1.38);
  -webkit-backdrop-filter: blur(28px) saturate(1.38);
  border: 1px solid rgba(255, 255, 255, 0.82) !important;
  box-shadow:
    0 24px 56px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 0 0 1px rgba(var(--brand-rgb), 0.1);
}

.home-hero--ambient.is-glass-on .home-field input,
.home-hero--ambient.is-glass-on .home-field select {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(var(--brand-rgb), 0.14) !important;
}

.home-hero--ambient.is-glass-on .home-submit {
  background: var(--brand-strong) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff;
  border: 0 !important;
  box-shadow: 0 12px 28px rgba(var(--brand-rgb), 0.32);
}

.home-hero--ambient.is-glass-on .home-search-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.42) 0%,
    transparent 38%,
    rgba(var(--brand-rgb), 0.08) 100%
  );
}

.home-hero--ambient.is-glass-on .home-search-panel > *:not(.portal-panel-cursor-light) {
  position: relative;
  z-index: 1;
}

.home-hero--ambient.is-shine-on .home-search-panel::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  clip-path: inset(0 round var(--radius-lg, 28px));
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.5) 48%,
    transparent 100%
  );
  animation: portal-home-shine-sweep 3.8s ease-in-out infinite;
}

@keyframes portal-home-shine-sweep {
  0% {
    transform: translateX(-120%);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  48% {
    transform: translateX(320%);
    opacity: 0;
  }
  100% {
    transform: translateX(320%);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-hero--ambient.is-ken-burns-on .home-hero-media .home-hero-bg,
  .home-hero--ambient.is-shine-on .home-search-panel::after,
  .home-hero--ambient .home-hero-edge-glow {
    animation: none !important;
  }

  .home-hero--ambient .portal-ambient-canvas.is-active {
    opacity: 0.55;
  }
}

/* Autocomplete: il pannello glass resta overflow hidden per shine; il menu usa position fixed (JS) */
.home-hero--ambient.is-glass-on .home-search-panel.is-suggest-open,
.home-hero--ambient.is-glass-on .home-search-panel:has(.home-field--search.is-suggest-open) {
  overflow: visible !important;
  isolation: auto !important;
}
