/* Animate only decorative layers, never hero text or controls. */
[data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero) {
  --hero-float-distance: -10px;
  --hero-zoom-scale: 1.035;
  overflow: hidden;
}

/* Entry fades expose the canvas tint before the hero copy appears. */
[data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero) .reveal {
  opacity: 1;
  transform: none;
  transition: none;
}

[data-public-content] .info-hero { position: relative; isolation: isolate; }
[data-public-content] .info-hero-media {
  position: absolute;
  inset: 0;
  background: inherit;
  pointer-events: none;
}
[data-public-content] .info-hero-inner { position: relative; z-index: 1; }
[data-public-content] .editorial-hero > figure { overflow: hidden; }
.hero-effect-filters { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
html.is-page-scrolling [data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero),
html.is-page-scrolling [data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero) *,
html.is-page-scrolling [data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero)::before,
html.is-page-scrolling [data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero)::after,
html.is-page-scrolling [data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero) *::before,
html.is-page-scrolling [data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero) *::after {
  animation-play-state: paused !important;
}
[data-public-content] .hero-motion-paused,
[data-public-content] .hero-motion-paused *,
[data-public-content] .hero-motion-paused::before,
[data-public-content] .hero-motion-paused::after,
[data-public-content] .hero-motion-paused *::before,
[data-public-content] .hero-motion-paused *::after {
  animation-play-state: paused !important;
  will-change: auto !important;
}
[data-public-content].info-page-trading .editorial-hero > figure { --trading-hero-position: center; }
[data-public-content].info-page-trading .editorial-hero > figure > img { object-position: var(--trading-hero-position); }
[data-public-content] .hytale-hero > .page-hero-media {
  --detail-image-position: center 42%;
  background-position: var(--detail-image-position);
}
[data-public-content] .webfarm-hero > .page-hero-media {
  --detail-image-position: center;
  background-position: var(--detail-image-position);
}
[data-public-content]:is(.info-page-partner, .info-page-affiliazione) .editorial-hero > figure {
  --editorial-detail-position: center;
}
[data-public-content]:is(.info-page-partner, .info-page-affiliazione) .editorial-hero > figure > img {
  object-position: var(--editorial-detail-position);
}

@media (prefers-reduced-motion: no-preference) {
  [data-public-content] :is(.hero > .hero-media, .page-hero > .page-hero-media, .editorial-hero > figure > img, .info-hero > .info-hero-media),
  [data-public-content].info-page-pagamenti .info-hero::before {
    animation: heroBackgroundZoom 18s ease-in-out infinite alternate;
    transform-origin: 65% 45%;
    will-change: scale;
  }

  [data-public-content] .page-hero :is(.product-hero-art:not(.is-photo), .product-hero-logo) {
    animation: heroForegroundFloat 6.8s ease-in-out infinite;
    will-change: transform;
  }

  /* Brighten the original photo pixels; the mask selects lamp housings, not drawn LED lines. */
  [data-public-content] .fivem-hero > .page-hero-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background-position: inherit;
    background-size: inherit;
    background-repeat: no-repeat;
    pointer-events: none;
    background-image: inherit;
    mask-image: url("/images/fivem-lamp-areas.svg");
    mask-position: var(--fivem-hero-position);
    mask-size: cover;
    mask-repeat: no-repeat;
    filter: brightness(4) saturate(1.35);
    animation: fivemTaillightGlow 5.6s ease-in-out infinite;
    will-change: opacity;
  }

  /* Inherit the photo geometry so highlights stay aligned through zoom and mobile crops. */
  [data-public-content] .hero > .hero-media::after,
  [data-public-content] :is(.hytale-hero, .webfarm-hero, .minecraft-hero) > .page-hero-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: inherit;
    background-position: inherit;
    background-size: inherit;
    background-repeat: no-repeat;
    mask-position: inherit;
    mask-size: cover;
    mask-repeat: no-repeat;
    pointer-events: none;
    animation: heroDetailGlow 8s ease-in-out infinite;
    will-change: opacity;
  }
  [data-public-content] .hero > .hero-media::after {
    filter: url("#hero-blue-lights") brightness(2.6);
    --detail-glow-peak: .65;
  }
  [data-public-content] .hytale-hero > .page-hero-media::after {
    mask-image: url("/images/hytale-portal-mask.svg");
    mask-position: var(--detail-image-position);
    filter: url("#hero-portal-light") brightness(2.4);
    --detail-glow-peak: .55;
    animation-duration: 9s;
  }
  [data-public-content] .webfarm-hero > .page-hero-media::after {
    mask-image: url("/images/webfarm-led-mask.svg");
    mask-position: var(--detail-image-position);
    filter: url("#hero-blue-lights") brightness(5);
    --detail-glow-peak: .8;
    animation: rackLedActivity 6.4s ease-in-out infinite;
  }
  [data-public-content] .minecraft-hero > .page-hero-media::after {
    mask-image: url("/images/minecraft-lantern-mask.svg");
    mask-position: center;
    filter: url("#hero-lantern-light") brightness(2.5);
    animation: lanternShimmer 8.2s ease-in-out infinite;
  }

  [data-public-content]:is(.info-page-partner, .info-page-affiliazione) .editorial-hero > figure {
    animation: heroBackgroundZoom 18s ease-in-out infinite alternate;
    transform-origin: 65% 45%;
    will-change: scale;
  }
  [data-public-content]:is(.info-page-partner, .info-page-affiliazione) .editorial-hero > figure > img {
    animation: none;
    will-change: auto;
  }
  /* The affiliation readability overlay remains above its chart highlights. */
  [data-public-content]:is(.info-page-partner, .info-page-affiliazione) .editorial-hero > figure::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--editorial-detail-image) var(--editorial-detail-position) / cover no-repeat;
    mask-position: var(--editorial-detail-position);
    mask-size: cover;
    mask-repeat: no-repeat;
    pointer-events: none;
    animation: heroDetailGlow 9.4s ease-in-out infinite;
    will-change: opacity;
  }
  [data-public-content].info-page-partner .editorial-hero > figure::before {
    mask-image: url("/images/partner-rgb-mask.svg");
    filter: url("#hero-rgb-panels") brightness(2.1);
    --detail-glow-peak: .6;
  }
  [data-public-content].info-page-affiliazione .editorial-hero > figure::before {
    content: none;
    animation: none;
  }

  /* Move the photo and its pixel-matched highlight layers as one surface. */
  [data-public-content].info-page-trading .editorial-hero > figure {
    animation: heroBackgroundZoom 18s ease-in-out infinite alternate;
    transform-origin: 65% 45%;
    will-change: scale;
  }
  [data-public-content].info-page-trading .editorial-hero > figure > img {
    animation: none;
    will-change: auto;
  }
  [data-public-content].info-page-trading .editorial-hero > figure::before,
  [data-public-content].info-page-trading .editorial-hero > figure::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--trading-hero-image) var(--trading-hero-position) / cover no-repeat;
    mask-position: var(--trading-hero-position);
    mask-size: cover;
    mask-repeat: no-repeat;
    filter: url("#trading-bars-only") brightness(3.5) saturate(1.15);
    pointer-events: none;
    animation: tradingChartGlow 7.6s ease-in-out infinite;
    will-change: opacity;
  }
  [data-public-content].info-page-trading .editorial-hero > figure::before {
    mask-image: url("/images/trading-chart-upper-mask.svg?v=2");
  }
  [data-public-content].info-page-trading .editorial-hero > figure::after {
    mask-image: url("/images/trading-chart-lower-mask.svg?v=2");
    animation-delay: -3.8s;
  }

  /* Scaling a filtered photo forces its full-size light layers to rasterize again. */
  [data-public-content] .hero > .hero-media,
  [data-public-content] :is(.minecraft-hero, .hytale-hero, .webfarm-hero, .fivem-hero) > .page-hero-media,
  [data-public-content]:is(.info-page-trading, .info-page-partner, .info-page-affiliazione) .editorial-hero > figure {
    animation: none;
    will-change: auto;
  }
}

@keyframes heroDetailGlow {
  0%, 100% { opacity: .04; }
  50% { opacity: var(--detail-glow-peak); }
}

@keyframes lanternShimmer {
  0%, 100% { opacity: .10; }
  24% { opacity: .45; }
  42% { opacity: .22; }
  57% { opacity: .52; }
  76% { opacity: .30; }
}

@keyframes rackLedActivity {
  0%, 40%, 100% { opacity: .08; }
  18%, 68% { opacity: var(--detail-glow-peak); }
  82% { opacity: .25; }
}

@keyframes tradingChartGlow {
  0%, 100% { opacity: .05; }
  50% { opacity: .65; }
}

@keyframes fivemTaillightGlow {
  0%, 100% { opacity: .12; }
  50% { opacity: .9; }
}

@keyframes heroBackgroundZoom {
  from { scale: 1; }
  to { scale: var(--hero-zoom-scale); }
}

@keyframes heroForegroundFloat {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, var(--hero-float-distance), 0); }
}

@media (max-width: 760px) {
  [data-public-content] .page-hero {
    isolation: isolate;
    contain: paint;
  }
  [data-public-content] .page-hero-grid > div:first-child {
    text-align: center;
  }
  [data-public-content] .page-hero-grid > div:first-child > p {
    margin-inline: auto;
  }
  [data-public-content] .page-hero .hero-actions { justify-content: center; }
  [data-public-content] .minecraft-hero .product-hero-art {
    width: min(260px, 76%);
    height: auto;
    max-height: 260px;
    margin: 8px auto 0;
  }
  [data-public-content]:is(.info-page-partner, .info-page-affiliazione) .editorial-hero > figure {
    --editorial-detail-position: 64% center;
  }
  [data-public-content].info-page-trading .editorial-hero > figure { --trading-hero-position: 64% center; }
  [data-public-content] :is(.hero, .page-hero, .editorial-hero, .info-hero) {
    --hero-float-distance: -6px;
    --hero-zoom-scale: 1.02;
  }
}

@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  [data-public-content] .page-hero :is(.product-hero-art:not(.is-photo), .product-hero-logo) {
    animation-duration: 7.5s;
  }
}

@media (max-width: 780px) {
  [data-public-content] .hytale-hero > .page-hero-media {
    --detail-image-position: 58% center;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-public-content] :is(.hero-media, .page-hero-media, .editorial-hero > figure > img, .info-hero-media, .product-hero-art, .product-hero-logo),
  [data-public-content].info-page-pagamenti .info-hero::before {
    animation: none !important;
    will-change: auto;
  }
}
