/*
 * Section: upcoming sessions (the "jl-upcoming" group).
 *
 * A heading, intro and button on the left; on the right the next sessions
 * from the schedule, one row each. The rows come from the [jlaude_upcoming]
 * shortcode (inc/upcoming.php). The split layout is meant to hold up whether
 * there are six sessions, one, or none: with none, the "jl-upcoming__empty"
 * note takes the place of the list.
 *
 * Colours, fonts and edge spacing come from the theme. The reveal only starts
 * once the script is running (html.jl-js), and each row waits until it is on
 * screen.
 */

.jl-upcoming.jl-upcoming {
	--up-pad: 48px;
	--up-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	column-gap: clamp(48px, 7vw, 120px);
	align-items: start;
	margin-block: 0;
	padding: clamp(96px, 14vh, 150px) var(--up-pad);
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

/*
 * Straight after the services section, start on the sage tint that section
 * ends on (--svc-bg in services.css) and ease back to the page colour, so
 * the two meet without a seam.
 */
.jl-services + .jl-upcoming {
	--up-from: color-mix(in srgb, var(--wp--preset--color--accent-1) 26%, var(--wp--preset--color--base));
	background-image: linear-gradient(
		to bottom,
		var(--up-from) 0,
		color-mix(in srgb, var(--up-from) 88%, var(--wp--preset--color--base)) 70px,
		color-mix(in srgb, var(--up-from) 55%, var(--wp--preset--color--base)) 150px,
		color-mix(in srgb, var(--up-from) 18%, var(--wp--preset--color--base)) 230px,
		var(--wp--preset--color--base) 300px
	);
}

/* WordPress spaces out a Group's children; every part here sets its own spacing. */
.jl-upcoming.jl-upcoming > *,
.jl-upcoming .jl-upcoming__head > *,
.jl-upcoming .jl-upcoming__empty > * {
	margin-block: 0;
}

/* ---------- Heading and intro ---------- */

.jl-upcoming .jl-upcoming__head {
	position: sticky;
	top: 120px;
	grid-row: 1 / span 2;
	grid-column: 1;
}

.jl-upcoming.jl-upcoming > :not(.jl-upcoming__head) {
	grid-column: 2;
}

/* Small labels: the tag above the heading, and the labels inside each row */
.jl-upcoming .jl-upcoming__tag,
.jl-upcoming .jl-session__dow,
.jl-upcoming .jl-session__month,
.jl-upcoming .jl-session__kind {
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	line-height: 1.4;
	text-transform: uppercase;
}

.jl-upcoming .jl-upcoming__head h2 {
	margin-top: 28px;
	font-size: clamp(2.5rem, 4.6vw, 4.25rem);
	letter-spacing: -0.03em;
	line-height: 1;
}

.jl-upcoming .jl-upcoming__head > p:not(.jl-upcoming__tag) {
	max-width: 400px;
	margin-top: 28px;
	font-size: 1.1875rem;
	letter-spacing: -0.01em;
	line-height: 1.35;
}

.jl-upcoming .jl-upcoming__head .wp-block-buttons {
	margin-top: 44px;
}

/* With nothing coming up there is no schedule to send people to; the note has its own link. */
.jl-upcoming--empty .jl-upcoming__head .wp-block-buttons {
	display: none;
}

/* ---------- Sessions ---------- */

.jl-upcoming .jl-upcoming__list {
	margin: 0;
	padding: 0;
	border-bottom: 1px solid var(--jl-line);
	list-style: none;
}

.jl-upcoming .jl-session {
	border-top: 1px solid var(--jl-line);
}

/* The row reaches a little past its text on both sides, so the hover tint has room. */
.jl-upcoming .jl-session__link {
	display: grid;
	grid-template-columns: 88px minmax(0, 1fr) auto 44px;
	column-gap: 28px;
	align-items: center;
	margin: 0 -16px;
	padding: 26px 16px;
	color: inherit;
	text-decoration: none;
	transition: background-color 0.4s;
}

.jl-upcoming a.jl-session__link:hover,
.jl-upcoming a.jl-session__link:focus-visible {
	background-color: var(--jl-tint);
}

.jl-upcoming .jl-session__date {
	display: grid;
	justify-items: start;
	row-gap: 2px;
}

.jl-upcoming .jl-session__day {
	font-family: var(--wp--preset--font-family--fraunces);
	font-size: 2.75rem;
	letter-spacing: -0.03em;
	line-height: 1;
}

.jl-upcoming .jl-session__main {
	display: grid;
	justify-items: start;
	min-width: 0;
}

.jl-upcoming .jl-session__kind,
.jl-upcoming .jl-session__meta,
.jl-upcoming .jl-session__places small,
.jl-upcoming .jl-session--full .jl-session__places {
	color: var(--wp--preset--color--accent-4);
}

/* Special editions and rows with few places left carry a dot in the accent colour. */
.jl-upcoming .jl-session--special .jl-session__kind::before,
.jl-upcoming .jl-session--low .jl-session__places::before {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	margin-right: 8px;
	border-radius: 50%;
	background: var(--wp--preset--color--accent-2);
	vertical-align: 0.08em;
}

.jl-upcoming .jl-session__name {
	margin: 6px 0 0;
	font-size: clamp(1.5rem, 2.2vw, 2rem);
	letter-spacing: -0.02em;
	line-height: 1.1;
	transition: transform 0.5s var(--up-ease);
}

.jl-upcoming a.jl-session__link:hover .jl-session__name {
	transform: translateX(6px);
}

.jl-upcoming .jl-session__meta {
	margin-top: 8px;
	font-size: 0.9375rem;
	line-height: 1.4;
}

.jl-upcoming .jl-session__places {
	font-size: 0.875rem;
	line-height: 1.4;
	text-align: right;
	white-space: nowrap;
}

.jl-upcoming .jl-session__places small {
	display: block;
	font-size: 0.8125rem;
}

/* Round arrow badge; it fills in on hover. */
.jl-upcoming .jl-session__go {
	position: relative;
	width: 44px;
	height: 44px;
	border: 1px solid var(--jl-line);
	border-radius: 50%;
	transition: background-color 0.3s, border-color 0.3s;
}

.jl-upcoming .jl-session__go::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	background: var(--wp--preset--color--contrast);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 9H16M10.5 3.5L16 9L10.5 14.5'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 9H16M10.5 3.5L16 9L10.5 14.5'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: background-color 0.3s;
}

.jl-upcoming a.jl-session__link:hover .jl-session__go,
.jl-upcoming a.jl-session__link:focus-visible .jl-session__go {
	border-color: var(--wp--preset--color--contrast);
	background-color: var(--wp--preset--color--contrast);
}

.jl-upcoming a.jl-session__link:hover .jl-session__go::before,
.jl-upcoming a.jl-session__link:focus-visible .jl-session__go::before {
	background-color: var(--wp--preset--color--base);
}

/* Without a schedule page to link to, a row is plain text. */
.jl-upcoming div.jl-session__link .jl-session__go {
	visibility: hidden;
}

/* ---------- Note shown when nothing is scheduled ---------- */

.jl-upcoming .jl-upcoming__empty {
	padding: 36px 0 44px;
	border-top: 1px solid var(--jl-line);
	border-bottom: 1px solid var(--jl-line);
}

.jl-upcoming .jl-upcoming__empty h3 {
	font-size: clamp(1.75rem, 2.6vw, 2.25rem);
	letter-spacing: -0.02em;
	line-height: 1.1;
}

.jl-upcoming .jl-upcoming__empty > p:not(.jl-upcoming__link) {
	max-width: 460px;
	margin-top: 16px;
	color: var(--wp--preset--color--accent-4);
	font-size: 1.0625rem;
	line-height: 1.5;
}

.jl-upcoming .jl-upcoming__empty .jl-upcoming__link {
	margin-top: 28px;
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1;
}

.jl-upcoming .jl-upcoming__empty .jl-upcoming__link a {
	display: inline-flex;
	align-items: center;
	gap: 0.6em;
	color: inherit;
	text-decoration: none;
}

.jl-upcoming .jl-upcoming__empty .jl-upcoming__link a::after {
	content: "";
	flex: none;
	width: 1.15em;
	height: 0.8em;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 14' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 7h17M12 1l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 14' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 7h17M12 1l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 0.5s var(--up-ease);
}

.jl-upcoming .jl-upcoming__empty .jl-upcoming__link a:hover::after {
	transform: translateX(6px);
}

/* ---------- In the editor ---------- */

/*
 * The editor shows the Shortcode block and the note together, each under a
 * label, because it cannot know what the schedule holds. These rules only
 * match the editor's own block wrappers.
 */
.jl-upcoming .wp-block-shortcode.block-editor-block-list__block::before,
.jl-upcoming .jl-upcoming__empty.block-editor-block-list__block::before {
	display: block;
	margin-bottom: 12px;
	color: var(--wp--preset--color--accent-4);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
}

.jl-upcoming .wp-block-shortcode.block-editor-block-list__block::before {
	content: "Sessions list — filled in from Schedule. “show” is how many";
}

.jl-upcoming .jl-upcoming__empty.block-editor-block-list__block::before {
	content: "Shown instead of the list when nothing is scheduled";
}

.jl-upcoming .jl-upcoming__empty.block-editor-block-list__block {
	margin-top: 32px;
}

/* ---------- Motion (front only, once the script is running) ---------- */

.jl-js .jl-upcoming .jl-upcoming__head > *,
.jl-js .jl-upcoming .jl-session,
.jl-js .jl-upcoming .jl-upcoming__empty {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.9s var(--up-ease), transform 0.9s var(--up-ease);
	transition-delay: var(--d, 0s);
}

.jl-js .jl-upcoming .jl-upcoming__head > :nth-child(2) {
	--d: 0.08s;
}

.jl-js .jl-upcoming .jl-upcoming__head > :nth-child(3) {
	--d: 0.16s;
}

.jl-js .jl-upcoming .jl-upcoming__head > :nth-child(n + 4) {
	--d: 0.24s;
}

.jl-js .jl-upcoming .jl-upcoming__head.is-in > *,
.jl-js .jl-upcoming .jl-session.is-in,
.jl-js .jl-upcoming .jl-upcoming__empty.is-in {
	opacity: 1;
	transform: none;
}

/* ---------- Tablet: heading above the list ---------- */
@media (max-width: 1099px) {
	.jl-upcoming.jl-upcoming {
		--up-pad: 40px;
		grid-template-columns: minmax(0, 1fr);
		row-gap: 56px;
		padding-bottom: 96px;
	}

	.jl-upcoming .jl-upcoming__head {
		position: static;
		grid-row: auto;
	}

	.jl-upcoming.jl-upcoming > :not(.jl-upcoming__head) {
		grid-column: 1;
	}

	.jl-upcoming .jl-upcoming__head h2 {
		margin-top: 20px;
	}

	.jl-upcoming .jl-upcoming__head .wp-block-buttons {
		margin-top: 32px;
	}

	.jl-upcoming .jl-upcoming__empty.block-editor-block-list__block {
		margin-top: 0;
	}
}

/* ---------- Mobile: date beside the text, places underneath ---------- */
@media (max-width: 699px) {
	.jl-upcoming.jl-upcoming {
		--up-pad: 24px;
		row-gap: 40px;
		padding-bottom: 72px;
	}

	.jl-upcoming .jl-upcoming__head > p:not(.jl-upcoming__tag) {
		margin-top: 20px;
		font-size: 1.0625rem;
	}

	.jl-upcoming .jl-upcoming__head .wp-block-buttons {
		margin-top: 28px;
	}

	.jl-upcoming .jl-session__link {
		grid-template-areas: "date main" "date places";
		grid-template-columns: 60px minmax(0, 1fr);
		column-gap: 16px;
		align-items: start;
		margin: 0 -12px;
		padding: 22px 12px;
	}

	.jl-upcoming .jl-session__date {
		grid-area: date;
	}

	.jl-upcoming .jl-session__day {
		font-size: 2.125rem;
	}

	.jl-upcoming .jl-session__main {
		grid-area: main;
	}

	.jl-upcoming .jl-session__name {
		font-size: 1.375rem;
	}

	.jl-upcoming .jl-session__places {
		grid-area: places;
		margin-top: 10px;
		text-align: left;
		white-space: normal;
	}

	.jl-upcoming .jl-session__places small {
		display: inline;
	}

	.jl-upcoming .jl-session__places small::before {
		content: "· ";
	}

	.jl-upcoming .jl-session__go {
		display: none;
	}

	.jl-upcoming .jl-upcoming__empty {
		padding: 28px 0 36px;
	}
}

@media (hover: none) {
	.jl-upcoming a.jl-session__link:hover {
		background-color: transparent;
	}

	.jl-upcoming a.jl-session__link:hover .jl-session__name {
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jl-js .jl-upcoming .jl-upcoming__head > *,
	.jl-js .jl-upcoming .jl-session,
	.jl-js .jl-upcoming .jl-upcoming__empty {
		opacity: 1;
		transform: none;
	}

	.jl-upcoming.jl-upcoming * {
		transition: none !important;
	}
}
