/**
 * Scroll story (inc/story.php): «Scroll-Effekt» on any block, the chapter
 * opener, the «Zahl» group style and the «Bildgeschichte».
 *
 * Motion only under prefers-reduced-motion: no-preference, and hiding only
 * once story.js has set .suaq-motion on <html>: without the script every
 * block shows. Entrances use the individual translate/scale/rotate
 * properties, so a print keeps its own tilt (transform: rotate(--rot)).
 */

/* Scroll effect ----------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
	.suaq-motion :is(.suaq-reveal, .suaq-chapter) {
		--suaq-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
		transition:
			opacity 0.9s var(--suaq-ease) var(--suaq-delay, 0ms),
			translate 0.9s var(--suaq-ease) var(--suaq-delay, 0ms),
			scale 0.9s var(--suaq-ease) var(--suaq-delay, 0ms),
			rotate 0.9s var(--suaq-ease) var(--suaq-delay, 0ms);
	}

	.suaq-motion .suaq-reveal:not(.is-revealed) {
		opacity: 0;
		translate: 0 2.5rem;
	}

	.suaq-motion .suaq-reveal--left:not(.is-revealed) {
		translate: -3rem 0;
	}

	.suaq-motion .suaq-reveal--right:not(.is-revealed) {
		translate: 3rem 0;
	}

	/* «Eingeklebt»: the print comes down from above the page, a little
	   larger and turned, and settles with a small bounce. */
	.suaq-motion .suaq-reveal--pin {
		--suaq-ease: cubic-bezier(0.3, 1.35, 0.5, 1);
	}

	.suaq-motion .suaq-reveal--pin:not(.is-revealed) {
		translate: 0 -1.5rem;
		scale: 1.08;
		rotate: -5deg;
	}

	.suaq-motion .suaq-reveal--pin:nth-of-type(even):not(.is-revealed) {
		rotate: 5deg;
	}
}

/* Chapter opener (pattern «Kapitelanfang») --------------------------------
   A big hollow number beside the chapter's marker, title and lead. */

.suaq-chapter {
	position: relative;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	column-gap: clamp(1.25rem, 4vw, 4rem);
	align-items: start;
	padding-block: clamp(2rem, 1rem + 5vw, 5rem) clamp(1rem, 0.5rem + 2vw, 2rem);
}

.suaq-chapter > * {
	grid-column: 2;
	margin-block: 0;
}

.suaq-chapter > * + * {
	margin-top: var(--wp--preset--spacing--30);
}

.suaq-chapter > p.suaq-chapter__number {
	grid-column: 1;
	grid-row: 1 / span 4;
	margin: 0;
	color: transparent;
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(6rem, 3rem + 12vw, 13rem);
	font-weight: 700;
	line-height: 0.8;
	letter-spacing: -0.02em;
	-webkit-text-stroke: 2px var(--wp--preset--color--accent);
	font-variant-numeric: tabular-nums;
	user-select: none;
}

.suaq-chapter > h2 {
	font-size: var(--wp--preset--font-size--x-large);
}

.suaq-chapter > p:not(.suaq-chapter__number, .is-style-marker) {
	max-width: 38rem;
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.5;
}

@media (max-width: 599px) {
	.suaq-chapter {
		grid-template-columns: minmax(0, 1fr);
	}

	.suaq-chapter > *,
	.suaq-chapter > p.suaq-chapter__number {
		grid-column: 1;
		grid-row: auto;
	}

	.suaq-chapter > p.suaq-chapter__number {
		margin-bottom: var(--wp--preset--spacing--30);
		font-size: 6.5rem;
		line-height: 1;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.suaq-motion .suaq-chapter > * {
		transition: opacity 0.8s ease, translate 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
	}

	.suaq-motion .suaq-chapter > :nth-child(2) { transition-delay: 0.1s; }
	.suaq-motion .suaq-chapter > :nth-child(3) { transition-delay: 0.2s; }
	.suaq-motion .suaq-chapter > :nth-child(n + 4) { transition-delay: 0.3s; }

	.suaq-motion .suaq-chapter:not(.is-revealed) > * {
		opacity: 0;
		translate: 0 1.5rem;
	}

	.suaq-motion .suaq-chapter:not(.is-revealed) > .suaq-chapter__number {
		translate: 0 3rem;
	}

	/* Where the browser can tie it to scrolling, the number drifts up a
	   little slower than the page. */
	@supports (animation-timeline: view()) {
		.suaq-chapter.is-revealed > .suaq-chapter__number {
			animation: suaq-drift linear both;
			animation-timeline: view();
			animation-range: cover 0% cover 100%;
		}

		@keyframes suaq-drift {
			from { translate: 0 2.5rem; }
			to { translate: 0 -2.5rem; }
		}
	}
}

/* «Zahl» (group style) ----------------------------------------------------
   The first line is the number, the rest its label. Pattern «Zahlenreihe»
   sets several side by side. */

.wp-block-group.is-style-stat {
	padding-top: var(--wp--preset--spacing--30);
	border-top: 2px solid var(--wp--preset--color--contrast);
}

.wp-block-group.is-style-stat > * {
	margin-block: 0;
}

.wp-block-group.is-style-stat > p:first-child {
	color: var(--wp--preset--color--accent);
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(3.25rem, 2rem + 4.5vw, 5.5rem);
	font-weight: 700;
	line-height: 0.95;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.wp-block-group.is-style-stat > p:first-child + * {
	margin-top: var(--wp--preset--spacing--20);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
}

.suaq-stats {
	gap: clamp(1.5rem, 3vw, 3rem) clamp(1.25rem, 3vw, 2.5rem);
}

/* Bildgeschichte ------------------------------------------------------------ */

.suaq-story {
	--suaq-story-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--suaq-bar-h, 75px) + 1.5rem);
	position: relative;
}

.suaq-story__stage {
	display: none;
}

.suaq-story-step + .suaq-story-step {
	margin-top: clamp(3rem, 2rem + 4vw, 5rem);
}

.suaq-story-step__media > .wp-block-image {
	margin: 0 0 var(--wp--preset--spacing--40);
}

.suaq-story-step__text > * {
	margin-block: 0;
}

.suaq-story-step__text > * + * {
	margin-top: var(--wp--preset--spacing--30);
}

.suaq-story-step__text > h3 {
	font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
}

@media (min-width: 960px) {
	.suaq-story.is-staged {
		display: grid;
		grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
		column-gap: clamp(2rem, 5vw, 5rem);
	}

	.suaq-story.is-staged .suaq-story__stage {
		position: sticky;
		top: var(--suaq-story-top);
		display: grid;
		height: calc(100vh - var(--suaq-story-top) - 1.5rem);
		height: calc(100svh - var(--suaq-story-top) - 1.5rem);
		place-items: center;
	}

	/* Every photo sits in the same cell; the active one is on top. */
	.suaq-story__stage > .suaq-story__frame {
		grid-area: 1 / 1;
		max-width: 100%;
		margin: 0;
		opacity: 0;
		visibility: hidden;
	}

	.suaq-story__stage > .suaq-story__frame.is-active {
		opacity: 1;
		visibility: visible;
	}

	.suaq-story__stage > .suaq-story__frame:nth-of-type(3n + 1) { --rot: -1.2deg; }
	.suaq-story__stage > .suaq-story__frame:nth-of-type(3n + 2) { --rot: 1.4deg; }
	.suaq-story__stage > .suaq-story__frame:nth-of-type(3n + 3) { --rot: -0.4deg; }

	.suaq-story__stage > .suaq-story__frame img {
		width: auto;
		max-width: 100%;
		height: auto;
		max-height: calc(100vh - var(--suaq-story-top) - 9rem);
		max-height: calc(100svh - var(--suaq-story-top) - 9rem);
		object-fit: contain;
	}

	.suaq-story__count {
		position: absolute;
		right: 0;
		bottom: 0;
		margin: 0;
		color: var(--wp--preset--color--muted);
		font-variant-numeric: tabular-nums;
	}

	/* The step keeps its photo for screen readers only. */
	.suaq-story.is-staged .suaq-story-step__media {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.suaq-story.is-staged .suaq-story__steps {
		padding-block: 20vh 30vh;
	}

	.suaq-story.is-staged .suaq-story-step {
		display: flex;
		min-height: 70vh;
		align-items: center;
		margin: 0;
	}

	.suaq-story.is-staged .suaq-story-step__text {
		padding-left: clamp(1rem, 2vw, 1.75rem);
		border-left: 3px solid var(--wp--preset--color--border);
		transition: border-color 0.4s ease;
	}

	.suaq-story.is-staged .suaq-story-step.is-active .suaq-story-step__text {
		border-left-color: var(--wp--preset--color--accent);
	}
}

@media (min-width: 960px) and (prefers-reduced-motion: no-preference) {
	/* One print is laid over the other. */
	.suaq-story__stage > .suaq-story__frame {
		translate: 0 1.25rem;
		scale: 0.97;
		transition: opacity 0.6s ease, translate 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), scale 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s linear 0.7s;
	}

	.suaq-story__stage > .suaq-story__frame.is-active {
		translate: 0 0;
		scale: 1;
		transition-delay: 0s;
	}
}

/* Editor: the story and its steps as labelled boxes. */
.suaq-story.is-preview {
	padding: var(--wp--preset--spacing--30);
	border: 1px dashed var(--wp--preset--color--border);
}

.suaq-story-step.is-preview {
	padding: var(--wp--preset--spacing--30);
	border-left: 3px solid var(--wp--preset--color--accent);
	background: var(--wp--preset--color--paper);
}

.suaq-story-step.is-preview + .suaq-story-step.is-preview {
	margin-top: var(--wp--preset--spacing--30);
}
