/*
 * "Scroll story" blog post template (template-scroll-story.php, includes/scroll-story.php).
 * Scoped to article.vb-story. Text inside sections keeps the regular post styles (.single__blog), so
 * these posts read like the rest of the blog; only the photo frame and sliders are new.
 */
.vb-story {
	--st-ink: var(--vb-color-primary, #231F20);
	--st-red: var(--vb-color-accent, #EF4343);
	--st-cream: var(--vb-color-cream, #F4F2EB);
	--st-lilac: var(--vb-color-lilac, #E8D1E3);
	--st-mono: var(--vb-font-mono, "Courier Prime", monospace);
	--st-top: calc(var(--vb-header-height, 90px) + 24px);
	--st-frame: min(40vw, 400px);
	padding: 3em 0 0;
}

/* The theme gives .container overflow: hidden, which makes it a scroll box and stops the sticky frame.
   clip still crops overflow but isn't a scroll box. */
.vb-story-container { overflow: clip; }

/* Text */
.vb-story .single__blog__title h1 { text-wrap: pretty; }
.vb-story p { text-wrap: pretty; }
.vb-story .vb-story__intro > p:first-child { font-size: 1.2em; line-height: 1.45; }
.vb-story .single__blog.vb-story__text { padding: 0; }
.vb-story .single__blog.vb-story__group-head { padding-left: 0; padding-right: 0; } /* flush with the photo column (the theme zeroes column padding here) */
.vb-story .vb-story__intro,
.vb-story .vb-story__outro { margin-bottom: 1em; }
/* Group headings line up with the photo column and span the full content width; the intro keeps a
   readable line length. More space above than between sections, so each group reads as a new part. */
.vb-story .single__blog.vb-story__group-head { padding-top: clamp(48px, 6vw, 88px); padding-bottom: clamp(40px, 4.5vw, 64px); }
.vb-story .vb-story__group-head h2 { font-size: clamp(2rem, 3.4vw, 2.6rem); margin: 0 0 .35em; text-wrap: balance; }
.vb-story .vb-story__group-head p { max-width: 46em; margin-bottom: 0; }
.vb-story .vb-story__h { font-size: clamp(1.7rem, 2.6vw, 2.1rem); line-height: 1.1; margin: 0 0 .3em; text-wrap: balance; }
.vb-story .vb-story__when { font-weight: 600; opacity: .7; margin-bottom: 1em; }
.vb-story .vb-story__details { font-size: .92em; font-weight: 600; padding-top: .8em; border-top: 1px solid rgba(35, 31, 32, .15); }
.vb-story .vb-story__cta a { font-weight: 700; text-transform: uppercase; letter-spacing: .02em; text-decoration: none; }
.vb-story .vb-story__cta a:hover { text-decoration: underline; }
.vb-story .vb-story__outro { padding-top: 2.5em; }

/* Scroll layout */
.vb-story__scroll {
	--st-controls: 52px; /* height of the slider controls row under each photo */
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
	gap: clamp(32px, 4vw, 64px);
	padding-bottom: 2em;
}
.vb-story__media { position: relative; }
/* Frame items share one grid cell and cross-fade; the frame is as tall as the photo plus its controls. */
.vb-story__frame {
	position: sticky;
	top: max(var(--st-top), calc(50vh - (var(--st-frame) + var(--st-controls)) / 2));
	display: grid;
}
.vb-story__frame-item { grid-area: 1 / 1; min-width: 0; opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility 0s .45s; }
.vb-story__frame-item.is-active { opacity: 1; visibility: visible; transition: opacity .45s ease, visibility 0s; }
/* Selector outranks custom.css `.single .type-post ol { padding-left: 12px }`. */
.vb-story-container .vb-story ol.vb-story__sections { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: clamp(56px, 10vh, 104px); }
.vb-story__section { scroll-margin-top: var(--st-top); min-height: var(--st-frame); display: flex; flex-direction: column; justify-content: center; }
.vb-story .vb-slider--inline { display: none; }

/* Slider: a scroll-snap track (swipe, trackpad and arrow keys work natively) with its controls in a
   row underneath: one segment per photo, the count, and the arrows. */
.vb-slider { position: relative; width: 100%; }
.vb-slider__track {
	display: flex;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
	background: var(--st-cream);
}
.vb-slider__track::-webkit-scrollbar { display: none; }
.vb-slider__track:focus-visible { outline: 3px solid var(--st-red); outline-offset: 3px; }
.vb-slider__slide { position: relative; flex: 0 0 100%; margin: 0; scroll-snap-align: start; }
.vb-slider__slide img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
.vb-slider__credit {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	padding: 28px 12px 10px;
	font-size: 11px;
	line-height: 1.3;
	color: #fff;
	background: linear-gradient(to top, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
}

.vb-slider__controls {
	display: flex;
	align-items: center;
	gap: 14px;
	height: var(--st-controls, 52px);
	padding-top: 12px;
	color: var(--st-ink);
}
.vb-slider__dots { flex: 1; display: flex; gap: 6px; min-width: 0; }
/* The .vb-story prefix on the buttons outranks site-kit's `.vb-kit button` (red fill, 11px 28px
   padding), which otherwise styles every <button>. */
.vb-story .vb-slider__dot {
	flex: 1;
	height: 24px; /* tap target; the bar itself is the ::before */
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	cursor: pointer;
	position: relative;
}
.vb-story .vb-slider__dot::before {
	content: "";
	position: absolute;
	left: 0; right: 0; top: 50%;
	height: 3px;
	margin-top: -1.5px;
	background: rgba(35, 31, 32, .16);
	transition: background-color .25s;
}
.vb-story .vb-slider__dot:hover::before { background: rgba(35, 31, 32, .4); }
.vb-story .vb-slider__dot[aria-current="true"]::before { background: var(--st-red); }
.vb-story .vb-slider__dot:focus-visible { outline: 2px solid var(--st-red); outline-offset: 2px; }
.vb-slider__count { font-family: var(--st-mono); font-weight: 700; font-size: 13px; line-height: 1; letter-spacing: .04em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vb-slider__arrows { display: flex; gap: 6px; }
.vb-story .vb-slider__btn {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: 1.5px solid rgba(35, 31, 32, .25);
	border-radius: 50%;
	background: transparent;
	color: var(--st-ink);
	font-size: 0;
	line-height: 1;
	box-shadow: none;
	cursor: pointer;
	transition: background-color .15s, border-color .15s, color .15s;
}
.vb-story .vb-slider__btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.vb-story .vb-slider__btn:hover:not(:disabled) { background: var(--st-ink); border-color: var(--st-ink); color: #fff; }
.vb-story .vb-slider__btn:focus-visible { outline: 2px solid var(--st-red); outline-offset: 2px; }
.vb-story .vb-slider__btn:disabled { opacity: .3; cursor: default; }

/* A section without photos: an info card in the frame, the same size as a photo. The card sits on
   a lilac box offset down and to the right. On desktop the details line moves from the text into the
   card; on phones there's no card and the details line stays. */
.vb-story__info { position: relative; aspect-ratio: 1 / 1; padding: 0 14px 14px 0; }
.vb-story__info::before { content: ""; position: absolute; inset: 14px 0 0 14px; background: var(--st-lilac); }
.vb-story__info-card {
	position: relative;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: clamp(24px, 3vw, 36px);
	background: var(--st-cream);
	color: var(--st-ink);
}
.vb-story .vb-story__info-when {
	font-family: "Instrument Serif", serif;
	font-size: clamp(2.6rem, 4.2vw, 3.6rem);
	line-height: .95;
	text-wrap: balance;
	margin: 0 0 .45em;
}
.vb-story__info-facts { list-style: none; margin: 0; padding: 0; font-size: 15px; line-height: 1.35; }
.vb-story__info-facts li { padding: 10px 0; border-top: 1px solid rgba(35, 31, 32, .15); }
@media (min-width: 992px) {
	/* The card shows the date and the facts, so the text column drops both. */
	.vb-story .vb-story__section--no-photos .vb-story__when,
	.vb-story .vb-story__section--no-photos .vb-story__details { display: none; }
}

/* Tablet and phone: one column, each gallery above its text */
@media (max-width: 991px) {
	.vb-story__scroll { grid-template-columns: 1fr; gap: 0; }
	.vb-story__media { display: none; }
	.vb-story__section { min-height: 0; display: block; }
	.vb-story .vb-slider--inline { display: block; margin-bottom: 20px; }
	.vb-story .vb-slider--inline .vb-slider__track { aspect-ratio: 4 / 3; }
	.vb-story-container .vb-story ol.vb-story__sections { gap: 56px; }
	/* The theme's columns have no padding here and the rows' negative margins cancel the container's,
	   so without this everything in the post runs to the screen edge. */
	.vb-story { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 575px) {
	/* Photos run edge to edge; the controls keep the page gutter. */
	.vb-story .vb-slider--inline { margin-left: -20px; margin-right: -20px; width: auto; }
	.vb-story .vb-slider--inline .vb-slider__controls { padding-left: 20px; padding-right: 20px; }
}
@media (prefers-reduced-motion: reduce) {
	.vb-story__frame-item, .vb-story__frame-item.is-active { transition: none; }
	.vb-slider__track { scroll-behavior: auto; }
	.vb-story .vb-slider__dot::before { transition: none; }
}
