/**
 * Viora Schedule widget.
 *
 * A week on one rule. The days are markers along a single horizontal line and
 * their work hangs alternately above and below it, so the eye zig-zags along
 * the week instead of reading down a list.
 *
 * The line is drawn per column rather than once across the rail: butted
 * together the segments read as one continuous rule, and each column keeps its
 * own marker centred without anything having to know the others' widths.
 */

.viora-schedule {
	--viora-schedule-title: clamp(1.125rem, 1.53vw, 1.375rem);
	--viora-schedule-accent: var(--viora-color-accent);
	--viora-schedule-days: 5;
	/* Shared by the day's text and its marker, so the dot sits under the word
	   it belongs to instead of at the raw column edge. */
	--viora-schedule-pad: clamp(0.75rem, 1.6vw, 1.5rem);

	position: relative;
	padding-block: clamp(3.5rem, 7.64vw, 6.875rem);
	overflow: hidden;
}

.viora-schedule--boxed .viora-schedule__inner {
	width: min(1082px, 100% - 2 * var(--viora-layout-container-pad));
	margin-inline: auto;
}

.viora-schedule--bleed .viora-schedule__inner {
	width: calc(100% - 2 * var(--viora-layout-edge));
	margin-inline: auto;
}

.viora-schedule__head {
	margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

/* -------------------------------------------------- *
 * The rail
 * -------------------------------------------------- */

.viora-schedule__rail {
	display: grid;
	grid-template-columns: repeat(var(--viora-schedule-days), minmax(0, 1fr));
	align-items: stretch;
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * Every day is the same three-row frame — work, rule, work — so the middle row
 * lands at the same height in every column and the segments line up.
 *
 * No fixed height: the two 1fr rows take their size from the tallest block on
 * each side of the rule, which is exactly where the line should sit. Forcing a
 * height instead left a field of empty space above and below the week.
 */
.viora-schedule__day {
	display: grid;
	grid-template-rows: 1fr auto 1fr;
}

.viora-schedule__slot {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.4rem;
	padding-inline: var(--viora-schedule-pad);
}

/* Above the line the block sits on the line; below it, it hangs from it. */
.viora-schedule__day--above .viora-schedule__slot {
	grid-row: 1;
	justify-content: flex-end;
	padding-bottom: clamp(1rem, 1.8vw, 1.5rem);
}

.viora-schedule__day--below .viora-schedule__slot {
	grid-row: 3;
	justify-content: flex-start;
	padding-top: clamp(1rem, 1.8vw, 1.5rem);
}

.viora-schedule__day:first-child .viora-schedule__slot {
	padding-inline-start: 0;
}

.viora-schedule__day:first-child .viora-schedule__dot {
	left: 0;
}

.viora-schedule__day:last-child .viora-schedule__slot {
	padding-inline-end: 0;
}

/* -------------------------------------------------- *
 * The rule and its markers
 * -------------------------------------------------- */

.viora-schedule__mark {
	position: relative;
	grid-row: 2;
	height: 1px;
	background-color: var(--viora-hairline, rgba(17, 17, 17, 0.14));
}

.viora-schedule__dot {
	position: absolute;
	top: 50%;
	left: var(--viora-schedule-pad);
	width: 0.5rem;
	height: 0.5rem;
	margin-top: -0.25rem;
	border-radius: 50%;
	background-color: var(--viora-schedule-accent);
}

/* The last column carries a closing marker so the week ends on a stop. */
.viora-schedule__day:last-child .viora-schedule__mark::after {
	content: '';
	position: absolute;
	top: 50%;
	right: 0;
	width: 0.5rem;
	height: 0.5rem;
	margin-top: -0.25rem;
	border-radius: 50%;
	border: 1px solid var(--viora-schedule-accent);
}

/* -------------------------------------------------- *
 * Day copy
 * -------------------------------------------------- */

.viora-schedule__label {
	color: var(--viora-schedule-accent);
	font-family: var(--viora-font-ui);
	font-size: 0.625rem;
	font-weight: var(--viora-weight-medium);
	letter-spacing: 0.28em;
	text-transform: uppercase;
}

.viora-schedule__title {
	margin: 0;
	color: var(--viora-ink, var(--viora-color-heading));
	font-family: var(--viora-font-display);
	font-size: var(--viora-schedule-title);
	font-weight: 400;
	line-height: 1.15;
	letter-spacing: -0.02em;
}

.viora-schedule__text {
	margin: 0.15rem 0 0;
	color: var(--viora-ink-soft, var(--viora-color-heading-soft));
	font-family: var(--viora-font-ui);
	font-size: 0.8125rem;
	line-height: 1.6;
}

.viora-schedule__meta {
	margin-top: 0.35rem;
	color: var(--viora-ink-soft, var(--viora-color-heading-soft));
	font-family: var(--viora-font-ui);
	font-size: 0.5625rem;
	font-weight: var(--viora-weight-medium);
	letter-spacing: 0.22em;
	text-transform: uppercase;
}

/* -------------------------------------------------- *
 * Reveal — along the week, not all at once
 * -------------------------------------------------- */

.viora-schedule.is-animated .viora-schedule__item {
	opacity: 0;
	transform: translateY(20px);
}

.viora-schedule.is-animated.is-in .viora-schedule__item {
	opacity: 1;
	transform: none;
	transition:
		opacity 0.8s var(--viora-motion-easing),
		transform 0.8s var(--viora-motion-easing);
	transition-delay: var(--viora-schedule-delay, 0ms);
}

/* -------------------------------------------------- *
 * Tablet — a week no longer fits across
 * -------------------------------------------------- */

@media (max-width: 1024px) {
	.viora-schedule__rail {
		grid-template-columns: minmax(0, 1fr);
	}

	/*
	 * Unwound: the rule turns on its side and runs down the left, every day
	 * hangs from it in reading order, and the above/below alternation stops
	 * meaning anything.
	 */
	.viora-schedule__day {
		grid-template-rows: auto;
		grid-template-columns: auto minmax(0, 1fr);
		min-height: 0;
		column-gap: clamp(1rem, 3vw, 1.5rem);
	}

	.viora-schedule__day--above .viora-schedule__slot,
	.viora-schedule__day--below .viora-schedule__slot {
		grid-row: 1;
		grid-column: 2;
		padding: 0 0 clamp(1.75rem, 5vw, 2.5rem);
	}

	.viora-schedule__mark {
		grid-row: 1;
		grid-column: 1;
		width: 1px;
		height: auto;
		align-self: stretch;
	}

	/*
	 * The first-child rule above is more specific than a bare class, so the
	 * override has to match it or day one's marker stays pinned to the left
	 * instead of sitting on the vertical rule.
	 */
	.viora-schedule__dot,
	.viora-schedule__day:first-child .viora-schedule__dot {
		top: 0.4rem;
		left: 50%;
		margin-top: 0;
		margin-left: -0.25rem;
	}

	/* The rule should stop at the last marker, not run past it. */
	.viora-schedule__day:last-child .viora-schedule__mark {
		background: linear-gradient(
			var(--viora-hairline, rgba(17, 17, 17, 0.14)) 0.65rem,
			transparent 0.65rem
		);
	}

	.viora-schedule__day:last-child .viora-schedule__mark::after {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.viora-schedule.is-animated .viora-schedule__item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}
