/* Southern Smiles — home page scroll reveal (CSS only, no JavaScript).
 *
 * Sections fade up, and photos/text columns slide in, as they scroll into view.
 * Uses CSS scroll-driven animations (animation-timeline: view()).
 *  - Browsers without support (e.g. Firefox today) simply show the page as normal.
 *  - Visitors who ask their device for reduced motion see no movement.
 *  - Content is never hidden from print or from browsers that can't animate it.
 *
 * TIMING (v2): each effect waits until the element is ~12% of the screen up
 * from the bottom edge, then plays over ~340px of scrolling, so it finishes
 * around the middle of the screen — where the eye actually is.
 *  - To make effects start sooner/later, change the 12% in --ss-timeline.
 *  - To make them play faster/slower, change --ss-run (scroll distance).
 *  - To make movement bigger/smaller, change the distances in the @keyframes.
 *
 * TO UNDO: delete the southern_smiles_scroll_reveal() block in functions.php
 * (or delete this file). Nothing else depends on it.
 *
 * Loaded on the home page only (see functions.php).
 */

@media screen and (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: view()) {

		@keyframes ss-rise {
			from { opacity: 0; translate: 0 90px; }
			to   { opacity: 1; translate: 0 0; }
		}
		@keyframes ss-from-left {
			from { opacity: 0; translate: -140px 0; }
			to   { opacity: 1; translate: 0 0; }
		}
		@keyframes ss-from-right {
			from { opacity: 0; translate: 140px 0; }
			to   { opacity: 1; translate: 0 0; }
		}
		@keyframes ss-pop {
			from { opacity: 0; scale: 0.8; }
			70%  { opacity: 1; scale: 1.03; }
			to   { opacity: 1; scale: 1; }
		}

		/* Sideways slides must never cause a sideways scrollbar. */
		.site-main { overflow-x: clip; }

		/* ---------- fade up ---------- */
		.site-main .section-head,
		.site-main .offer,
		.site-main .offer-note,
		.site-main .book-panel,
		.site-main .service-card,
		.site-main .steps > li,
		.site-main .finance,
		.site-main .review,
		.site-main .reviews-more,
		.site-main .faq-grid > .wp-block-group:first-child,
		.site-main .faq-list > .wp-block-details,
		.site-main .final .shell,
		/* on phones, the side-sliders below rise instead */
		.site-main .doctor .shell > .wp-block-group:not(.doctor-card),
		.site-main .doctor-card,
		.site-main .framed-side,
		.site-main #insurance .split > .wp-block-group:first-child,
		.site-main #insurance .frame,
		.site-main .visit-split > .map,
		.site-main .visit-split > .wp-block-group,
		.site-main .doctor .stamp,
		.site-main .emergency__in {
			animation: ss-rise both;
			animation-timing-function: cubic-bezier(0.22, 0.8, 0.3, 1);
			/* the "viewport" for the effect stops 12% above the real bottom edge,
			   so nothing starts moving until it is properly on screen */
			animation-timeline: view(block 0% 12%);
			animation-range: entry 0px entry 340px;
		}

		/* ---------- stagger across a row of cards ---------- */
		.site-main .offer:nth-child(3n+2),
		.site-main .service-card:nth-child(3n+2),
		.site-main .steps > li:nth-child(2),
		.site-main .review:nth-child(even),
		.site-main .faq-list > .wp-block-details:nth-child(2) {
			animation-range: entry 70px entry 410px;
		}
		.site-main .offer:nth-child(3n+3),
		.site-main .service-card:nth-child(3n+3),
		.site-main .steps > li:nth-child(3),
		.site-main .faq-list > .wp-block-details:nth-child(3) {
			animation-range: entry 140px entry 480px;
		}
		.site-main .faq-list > .wp-block-details:nth-child(4) {
			animation-range: entry 210px entry 550px;
		}

		/* ---------- "Practicing since 1983" stamp and the emergency panel ---------- */
		.site-main .doctor .stamp,
		.site-main .emergency__in {
			animation-name: ss-pop;
		}

		/* ---------- wider screens: two-column sections slide in from their sides ---------- */
		@media (min-width: 782px) {
			.site-main .doctor .shell > .wp-block-group:not(.doctor-card),
			.site-main #insurance .split > .wp-block-group:first-child,
			.site-main .framed-side,
			.site-main .visit-split > .map {
				animation-name: ss-from-left;
			}
			.site-main .doctor-card,
			.site-main #insurance .frame,
			.site-main .visit-split > .wp-block-group {
				animation-name: ss-from-right;
			}
			/* the right-hand column follows a beat after the left */
			.site-main .doctor-card,
			.site-main #insurance .frame,
			.site-main .visit-split > .wp-block-group {
				animation-range: entry 60px entry 400px;
			}
		}
	}
}
