/* Scroll reveals inspired by affinity.studio, kept quiet for the winery.
   Fully visible by default: unsupported browsers, print and reduced motion
   need no fallback script. Individual translate/scale leave hover transforms free. */
@media screen and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) and (animation-range: entry 0% entry 55%) {
    :where(
      .hero-art,
      .section-copy,
      .wine-feature,
      .detail-photo,
      .wine-detail-copy,
      .gallery-heading > div,
      .event-photo,
      .off-season-section > div,
      .gathering-section > div,
      .visit-heading,
      .visit-details > div,
      .group-heading,
      .related-wines > div:first-child,
      .private-event-section > div,
      .visit-bridge,
      .visit-information > section,
      .good-to-know > div:first-child,
      .visitor-grid > article,
      .contact-option,
      .contact-visit > div
    ) {
      animation: scroll-settle 1ms cubic-bezier(.2, .75, .25, 1) both;
      /* Must follow animation shorthand, which resets the timeline. */
      animation-timeline: view(block);
      animation-range: entry 0% entry 55%;
    }

    .hero-art, .wine-feature, .detail-photo, .visit-bridge, .event-photo {
      animation-name: scroll-picture-settle;
      transform-origin: center bottom;
    }

    /* Full Gallery frames stay painted from the first load. Hover motion remains. */
    .event-gallery-full .event-photo { animation: none; opacity: 1; translate: none; scale: none; }

    /* A small stagger across desktop rows, without delaying a whole section. */
    @media (min-width: 701px) {
      .catalog-grid > :nth-child(3n + 2),
      .wine-section > .wine-feature:nth-child(2),
      .visitor-grid > :nth-child(2),
      .contact-options > :nth-child(2) {
        animation-range: entry 7% entry 62%;
      }
      .catalog-grid > :nth-child(3n),
      .wine-section > .wine-feature:nth-child(3),
      .visitor-grid > :nth-child(3),
      .contact-options > :nth-child(3) {
        animation-range: entry 14% entry 69%;
      }
    }

    @media (max-width: 700px) and (min-width: 371px) {
      .catalog-grid > :nth-child(even) {
        animation-range: entry 7% entry 62%;
      }
    }

    /* Keyboard navigation and direct section links never wait on a reveal. */
    main :focus-within, main :target, main :target * {
      animation: none !important;
      opacity: 1;
      translate: none;
      scale: none;
    }

    @keyframes scroll-settle {
      from { opacity: .15; translate: 0 30px; }
      to { opacity: 1; translate: 0 0; }
    }

    @keyframes scroll-picture-settle {
      from { opacity: .15; translate: 0 36px; scale: .965; }
      to { opacity: 1; translate: 0 0; scale: 1; }
    }
  }
}
