/**
 * Ultimate Events — frontend styles.
 *
 * Every selector is scoped under .ultimate-events so the feature cannot affect
 * the rest of the site. Layout uses logical properties so it mirrors correctly
 * when WPML switches the document to Arabic/RTL.
 *
 * @package Astra Child
 */

.ultimate-events {
	--ue-green: #006838;
	--ue-green-light: #37b34a;
	/* Primary call-to-action colour. */
	--ue-cta: #54b435;
	--ue-cta-hover: #479a2c;
	--ue-gray: #58595b;
	--ue-ink: #1d2321;
	--ue-muted: #6b6c6e;
	--ue-surface: #ffffff;
	--ue-tint: #f4f9f2;
	--ue-session-bg: #f6faf5;
	--ue-border: #e5eae7;
	--ue-border-strong: #cfe0c6;
	--ue-radius: 14px;
	--ue-gap: 28px;

	--ue-max: 1440px;

	box-sizing: border-box;
	color: var(--ue-ink);

	/*
	 * Full-bleed: escape the theme's content container. The margins are
	 * symmetrical, so RTL mirrors automatically with no special case.
	 *
	 * 100vw includes the scrollbar width, which would overflow by ~15px on
	 * desktop, so the body is pinned against horizontal scrolling below.
	 */
	position: relative;
	inline-size: auto;
	max-inline-size: none;
	margin-inline: calc(50% - 50vw);
	padding-block: clamp(32px, 5vw, 64px);
	background-color: var(--ue-surface);
}

/*
 * Astra constrains direct children of the block editor's content area with
 * `.entry-content[data-ast-blocks-layout] > *` using PHYSICAL margin-left/right,
 * which outranks the logical `margin-inline` above. These selectors are scoped
 * to this section only and re-assert the full-bleed; the global theme rule is
 * left untouched for every other block on the page.
 */
.entry-content > .ultimate-events,
.entry-content[data-ast-blocks-layout] > .ultimate-events,
.page-content > .ultimate-events,
.entry-summary > .ultimate-events {
	max-inline-size: none;
	max-width: none;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

/* Centered, readable content area inside the full-width section. */
.ultimate-events .ultimate-events__inner {
	inline-size: 100%;
	max-inline-size: var(--ue-max);
	margin-inline: auto;
	padding-inline: clamp(16px, 4vw, 48px);
}

.ultimate-events *,
.ultimate-events *::before,
.ultimate-events *::after {
	box-sizing: border-box;
}

/*
 * No underlines anywhere in the feature, in every link state. Scoped to
 * .ultimate-events so the rest of the site keeps its own link styling.
 */
.ultimate-events a,
.ultimate-events a:link,
.ultimate-events a:visited,
.ultimate-events a:hover,
.ultimate-events a:focus,
.ultimate-events a:active {
	text-decoration: none;
	box-shadow: none;
}

/* ---------------------------------------------------------------------------
 * Grid
 * ------------------------------------------------------------------------ */

.ultimate-events .ultimate-events__grid {
	display: grid;
	gap: var(--ue-gap);
	grid-template-columns: 1fr;
}

/* 2 events: two equal columns. */
@media (min-width: 768px) {
	.ultimate-events--2 .ultimate-events__grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* 3+ events: two columns on tablet, three on desktop. */
@media (min-width: 768px) {
	.ultimate-events--3 .ultimate-events__grid,
	.ultimate-events--many .ultimate-events__grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 1024px) {
	.ultimate-events--3 .ultimate-events__grid,
	.ultimate-events--many .ultimate-events__grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* ---------------------------------------------------------------------------
 * Card
 * ------------------------------------------------------------------------ */

.ultimate-events .ultimate-events__card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background-color: var(--ue-surface);
	border: 1px solid var(--ue-border);
	border-radius: var(--ue-radius);
	transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.ultimate-events .ultimate-events__card:hover,
.ultimate-events .ultimate-events__card:focus-within {
	transform: translateY(-4px);
	border-color: var(--ue-border-strong);
	box-shadow: 0 14px 34px rgba(31, 61, 20, 0.10);
}

/* Media ------------------------------------------------------------------ */

/*
 * Fixed 16:9 media box, so the image stays compact and the event information
 * leads the card. The uploaded image keeps its own proportions and is cropped
 * by object-fit — never stretched — so landscape, portrait, square and banner
 * uploads all present identically and card heights stay predictable.
 */
.ultimate-events .ultimate-events__media {
	position: relative;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background-color: var(--ue-tint);
}

.ultimate-events .ultimate-events__image {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	object-position: center center;
	transition: transform 0.35s ease;
}

.ultimate-events .ultimate-events__card:hover .ultimate-events__image {
	transform: scale(1.03);
}

/* Graceful fallback when no featured image is set: a quiet branded panel. */
.ultimate-events .ultimate-events__media--empty {
	background-image: linear-gradient(135deg, var(--ue-tint) 0%, #eaf1ed 100%);
	border-block-end: 1px solid var(--ue-border);
}

.ultimate-events .ultimate-events__media--empty::after {
	content: "";
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	transform: translate(-50%, -50%);
	inline-size: 40px;
	block-size: 3px;
	background-color: var(--ue-green-light);
	opacity: 0.55;
}

/* Session-count pill overlaid on the image -------------------------------- */

.ultimate-events .ultimate-events__image-badge {
	position: absolute;
	inset-block-end: 16px;
	inset-inline-start: 16px;
	z-index: 1;
	max-inline-size: calc(100% - 32px);
	padding-block: 7px;
	padding-inline: 14px;
	background-color: rgba(0, 104, 56, 0.92);
	border-radius: 6px;
	color: #ffffff;
	font-size: 0.78125rem;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0.01em;
	overflow-wrap: break-word;
}

/* Inline icons ------------------------------------------------------------ */

.ultimate-events .ultimate-events__icon {
	flex: 0 0 auto;
	inline-size: 1em;
	block-size: 1em;
	/* Optical alignment with the adjacent text baseline. */
	margin-block-start: 0.12em;
	font-size: 1.0625rem;
	color: var(--ue-green);
}

/* Body ------------------------------------------------------------------- */

.ultimate-events .ultimate-events__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 12px;
	padding: 24px;
	text-align: start;
}

.ultimate-events .ultimate-events__badge {
	align-self: start;
	margin: 0;
	padding-block: 6px;
	padding-inline: 14px;
	background-color: #eaf7e4;
	border-radius: 100px;
	color: #3d8526;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.01em;
	overflow-wrap: break-word;
	max-inline-size: 100%;
}

.ultimate-events .ultimate-events__date {
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.02em;
	color: var(--ue-green);
	text-transform: none;
}

.ultimate-events .ultimate-events__title {
	margin: 0;
	font-size: 1.1875rem;
	font-weight: 700;
	line-height: 1.35;
	color: var(--ue-ink);
	overflow-wrap: break-word;
}

.ultimate-events .ultimate-events__description {
	margin: 0;
	font-size: 0.9375rem;
	line-height: 1.65;
	color: var(--ue-gray);
	overflow-wrap: break-word;
}

.ultimate-events .ultimate-events__location {
	display: flex;
	align-items: flex-start;
	gap: 9px;
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.55;
	color: var(--ue-muted);
	overflow-wrap: anywhere;
}

/* Session tiles ---------------------------------------------------------- */

.ultimate-events .ultimate-events__sessions-heading {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	margin-block-start: 2px;
	font-size: 0.8125rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--ue-green);
}

.ultimate-events .ultimate-events__sessions-heading .ultimate-events__icon {
	margin-block-start: 0;
}

.ultimate-events .ultimate-events__sessions {
	display: grid;
	gap: 12px;
	grid-template-columns: 1fr;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ultimate-events .ultimate-events__session {
	margin: 0;
	padding-block: 13px;
	padding-inline: 16px;
	background-color: var(--ue-session-bg);
	border: 1px solid var(--ue-border);
	border-radius: 12px;
	text-align: start;
	transition: border-color 0.2s ease;
}

.ultimate-events .ultimate-events__card:hover .ultimate-events__session {
	border-color: var(--ue-border-strong);
}

/* One icon + text line inside a session card. */
.ultimate-events .ultimate-events__session-row {
	display: flex;
	align-items: flex-start;
	gap: 9px;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--ue-muted);
	overflow-wrap: anywhere;
}

.ultimate-events .ultimate-events__session-row + .ultimate-events__session-row {
	margin-block-start: 7px;
}

/* The date is the strongest metadata in the card. */
.ultimate-events .ultimate-events__session-row.is-primary {
	font-size: 0.9375rem;
	font-weight: 600;
	color: var(--ue-ink);
}

/* Session Information sits visually below date/time/location. */
.ultimate-events .ultimate-events__session-row.is-muted {
	color: var(--ue-gray);
}

.ultimate-events .ultimate-events__session-row.is-muted .ultimate-events__icon {
	color: var(--ue-muted);
}

/*
 * Fixed icon column so every row's text starts at the same offset, in both
 * LTR and RTL. The icon box is sized independently of the row's font-size.
 */
.ultimate-events .ultimate-events__session-row .ultimate-events__icon {
	inline-size: 17px;
	block-size: 17px;
	font-size: 17px;
	margin-block-start: 0.1em;
}

/* Two tiles sit side by side once there is room for them. */
@media (min-width: 560px) {
	/*
	 * Exactly two sessions sit side by side; three or more stack, so a row of
	 * uneven cards never appears. Counted with :has() on the list — the second
	 * child exists and is also the last one — so no PHP or JS is involved.
	 */
	.ultimate-events .ultimate-events__sessions:has(> :nth-child(2):last-child) {
		/*
		 * auto-fit + a 165px floor: the pair sits side by side when the column
		 * is wide enough, and falls back to stacking in narrow cards (such as
		 * the 3-up grid on tablet) instead of squeezing the text.
		 */
		grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
	}
}

/* CTA — pushed to the bottom so buttons align across uneven cards. */
.ultimate-events .ultimate-events__cta {
	margin: 0;
	margin-block-start: auto;
	padding-block-start: 8px;
}

.ultimate-events .ultimate-events__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	min-block-size: 51px;
	padding-block: 13px;
	padding-inline: 26px;
	background-color: var(--ue-cta);
	border: 1px solid var(--ue-cta);
	/* Pill shape, identical in every layout (1, 2, 3 or more cards). */
	border-radius: 100px;
	color: #ffffff;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.ultimate-events .ultimate-events__button:hover,
.ultimate-events .ultimate-events__button:focus,
.ultimate-events .ultimate-events__button:active,
.ultimate-events .ultimate-events__button:visited {
	color: #ffffff;
	text-decoration: none;
}

.ultimate-events .ultimate-events__button:hover,
.ultimate-events .ultimate-events__button:focus {
	background-color: var(--ue-cta-hover);
	border-color: var(--ue-cta-hover);
	box-shadow: 0 6px 16px rgba(84, 180, 53, 0.25);
}

.ultimate-events .ultimate-events__button:focus-visible {
	outline: 2px solid var(--ue-cta);
	outline-offset: 3px;
}

/*
 * The arrow inherits the button colour and mirrors in RTL so it always points
 * "forward" in the reading direction. --ue-arrow-flip drives both the mirror
 * and the hover nudge, so the two transforms never fight.
 */
.ultimate-events .ultimate-events__button-arrow {
	--ue-arrow-flip: 1;
	--ue-arrow-shift: 0px;
	margin-block-start: 0;
	color: inherit;
	transform: scaleX(var(--ue-arrow-flip)) translateX(var(--ue-arrow-shift));
	transition: transform 0.2s ease;
}

[dir="rtl"] .ultimate-events .ultimate-events__button-arrow {
	--ue-arrow-flip: -1;
}

.ultimate-events .ultimate-events__button:hover .ultimate-events__button-arrow,
.ultimate-events .ultimate-events__button:focus-visible .ultimate-events__button-arrow {
	--ue-arrow-shift: 3px;
}

/*
 * Mobile: the CTA fills the card's content width with a comfortable touch
 * target. Direction-agnostic — it stretches rather than being pinned to a side,
 * so LTR and RTL behave identically.
 */
@media (max-width: 575px) {
	.ultimate-events .ultimate-events__cta {
		padding-block-start: 12px;
	}

	.ultimate-events .ultimate-events__button {
		display: flex;
		inline-size: 100%;
		min-block-size: 52px;
		padding-inline: 20px;
		text-align: center;
	}
}

/* Screen-reader-only text (Astra ships its own, this is a safe local fallback). */
.ultimate-events .screen-reader-text {
	position: absolute !important;
	inline-size: 1px;
	block-size: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* ---------------------------------------------------------------------------
 * Single event — editorial horizontal card
 * ------------------------------------------------------------------------ */

@media (min-width: 860px) {
	.ultimate-events--1 .ultimate-events__card {
		display: grid;
		/* ~42% image / ~58% content, so the information area leads the card. */
		grid-template-columns: minmax(0, 42fr) minmax(0, 58fr);
		align-items: stretch;
	}

	/*
	 * The image fills the column and matches the content height instead of
	 * imposing its own ratio, so the card cannot be driven tall by the image.
	 * min-block-size keeps it from collapsing when the content is very short.
	 */
	.ultimate-events--1 .ultimate-events__media {
		aspect-ratio: auto;
		block-size: 100%;
		min-block-size: 300px;
	}

	.ultimate-events--1 .ultimate-events__media--empty {
		border-block-end: 0;
		border-inline-end: 1px solid var(--ue-border);
	}

	.ultimate-events--1 .ultimate-events__body {
		justify-content: center;
		gap: 16px;
		padding: 44px;
	}

	.ultimate-events--1 .ultimate-events__title {
		font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.5rem);
		font-weight: 600;
		line-height: 1.22;
		letter-spacing: -0.015em;
	}

	.ultimate-events--1 .ultimate-events__description {
		font-size: 1rem;
	}

	.ultimate-events--1 .ultimate-events__cta {
		margin-block-start: 8px;
	}

	/* Pill CTA on the editorial single-event card, matching the brand style. */
	/* Slightly larger on the featured single-event card; shape is shared. */
	.ultimate-events--1 .ultimate-events__button {
		padding-block: 14px;
		padding-inline: 30px;
		font-size: 1rem;
	}
}

/* ---------------------------------------------------------------------------
 * Motion preferences
 * ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.ultimate-events .ultimate-events__card,
	.ultimate-events .ultimate-events__image,
	.ultimate-events .ultimate-events__button,
	.ultimate-events .ultimate-events__button-arrow,
	.ultimate-events .ultimate-events__session {
		transition: none;
	}

	.ultimate-events .ultimate-events__card:hover,
	.ultimate-events .ultimate-events__card:focus-within {
		transform: none;
	}

	.ultimate-events .ultimate-events__card:hover .ultimate-events__image {
		transform: none;
	}

	/* Keep the RTL mirror (it is orientation, not motion); drop the nudge. */
	.ultimate-events .ultimate-events__button:hover .ultimate-events__button-arrow,
	.ultimate-events .ultimate-events__button:focus-visible .ultimate-events__button-arrow {
		--ue-arrow-shift: 0px;
	}
}
