/**
 * OTA Events Block widget styles.
 *
 * The "Upcoming CPD & events" section from the OTA design file: an eyebrow, a
 * heading, a View all button and a row of event cards. The card is the design's
 * Component/Events, Variant2 of the Events Block frame: a 170px image strip
 * carrying the date and the category, a body with the title and the event's
 * details, and a View Event footer.
 *
 * Every colour is a colour theme role, mapped once in the token block below and
 * referenced by name after that, so the block follows whatever theme is in force
 * above it: its own, else the container's, else the page's, else the site's. The
 * exceptions are the section background, which the widget offers as a control,
 * and the hover ring, which has a note of its own further down. The roles come
 * from the Events Block and Component/Events components, binding for binding:
 *
 *   section surface   bar/background     --ota-background
 *   eyebrow           bar/accent         --ota-accent
 *   heading           bar/White Text     --ota-white-text
 *   View all button   .ota-btn--primary, which reads cta-bg / cta-text itself
 *   card surface      bar/background     --ota-background
 *   date badge        bar/cta-bg         --ota-cta-bg
 *   date badge text   bar/cta-text       --ota-cta-text
 *   category pill     bar/cta-bg         --ota-cta-bg
 *   category text     bar/cta-text       --ota-cta-text
 *   card title        bar/White Text     --ota-white-text
 *   venue and CPD     bar/text-muted     --ota-text-muted
 *   card rule         bar/Divider        --ota-divider
 *   View Event        bar/text           --ota-text
 *   arrow dot, hover  bar/cta-bg         --ota-cta-bg
 *
 * THE CARDS ARE A SECOND THEME, ON PURPOSE
 *
 * As with the News Block, the design frame is two variable modes rather than
 * one: the section resolves bar/background to navy and the cards resolve the
 * same variable to white, a Navy section holding Ash cards. So the widget offers
 * a "Card theme" of its own and the token block below is declared on
 * `.ota-events` and `.ota-events__card` both.
 *
 * The duplication is load bearing rather than untidy. A custom property whose
 * value contains `var()` resolves on the element that declares it, so tokens
 * declared once on `.ota-events` would inherit into the cards already resolved
 * against the section's theme and the card's own class would do nothing. Naming
 * the card in the same rule makes it resolve them again, against its own theme.
 *
 * THE HOVER RING IS THE ONE BINDING THE DESIGN CANNOT SETTLE
 *
 * Component/Events draws its hover ring in `brand/white`, which is a fixed brand
 * colour rather than a theme role, and it is fixed for a reason: the ring has to
 * separate an Ash card from the Navy section behind it, so it cannot be the
 * card's own text colour (navy on navy reads as the card shrinking) and it
 * cannot be the card's background either. No role in the palette does that job
 * on every theme. `--ota-cta-text` is the closest: in the mode the frame draws
 * it resolves white, which is the design's own value, and on other themes it at
 * least stays legible against the card's CTA colour. It is exposed as
 * `--oeb-ring` so it is one line to change, and it is worth a designer's ruling
 * before sign-off.
 *
 * Typography comes from the Elementor global fonts, each as a `var()` with the
 * Figma number as its fallback, so the block still renders to spec on a site
 * whose kit has not had the type scale imported. Label/Eyebrow for the eyebrow,
 * Heading/H2 for the heading, Body/Lead for the card titles, Body/Small for the
 * venue and CPD lines and Body/Caption for the category pill.
 *
 * Weights are stated locally where the scale has no cut for them: the category
 * pill, the date badge and View Event are Bold at sizes the scale publishes
 * Light or Regular. The sizes still come from the globals.
 */

/*
 * The roles. Navy section values as fallbacks, so the block is never unstyled on
 * a site with no colour theme configured. Declared for the cards as well as the
 * section: see the note on the two modes above.
 */
.ota-events,
.ota-events__card {
	--oeb-surface: var(--ota-background, #003038);
	--oeb-text: var(--ota-text, #003038);
	--oeb-muted: var(--ota-text-muted, #005361);
	--oeb-title: var(--ota-white-text, #ffffff);
	--oeb-accent: var(--ota-accent, #49c7da);
	--oeb-badge: var(--ota-cta-bg, #003038);
	--oeb-badge-text: var(--ota-cta-text, #ffffff);
	--oeb-divider: var(--ota-divider, rgba(240, 231, 216, 0.2));
	/* See the note on the hover ring above before changing this. */
	--oeb-ring: var(--ota-cta-text, #ffffff);
}

.ota-events {
	/*
	 * The design's own container: 1280px of content inside a 1440px artboard,
	 * the same measure the News Block uses.
	 */
	--oeb-max: 1280px;
	--oeb-pad: 2rem;
	--oeb-gap: 39px;
	--oeb-radius: 14px;
	--oeb-media-h: 170px;
	--oeb-columns: 3;
	--oeb-ring-w: 2px;

	padding-block: 96px;
	/*
	 * The section band only, and the widget's Background control writes
	 * `--oeb-section-bg` here. A token of its own rather than an override of the
	 * surface role, because the cards read the surface too and overriding it
	 * would repaint them to match the band. Same split as the News Block.
	 */
	background-color: var(--oeb-section-bg, var(--oeb-surface));
	color: var(--oeb-title);
}

.ota-events__inner {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: 48px;
	width: 100%;
	max-width: var(--oeb-max);
	margin-inline: auto;
	padding-inline: var(--oeb-pad);
}

/* --- Header -------------------------------------------------------------- */

.ota-events__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
}

.ota-events__intro {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ota-events__eyebrow {
	margin: 0;
	color: var(--oeb-accent);
	font-size: var(--e-global-typography-eyebrow-font-size, 1.0625rem);
	font-weight: var(--e-global-typography-eyebrow-font-weight, 700);
	line-height: var(--e-global-typography-eyebrow-line-height, 1.46em);
	letter-spacing: var(--e-global-typography-eyebrow-letter-spacing, 1px);
}

.ota-events__title {
	margin: 0;
	color: var(--oeb-title);
	font-size: var(--e-global-typography-h2-font-size, 2.75rem);
	font-weight: var(--e-global-typography-h2-font-weight, 400);
	line-height: var(--e-global-typography-h2-line-height, 1.08em);
	letter-spacing: var(--e-global-typography-h2-letter-spacing, -0.44px);
}

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

/*
 * Three equal columns, from the design's three cards across a 1280 container.
 *
 * A stated count rather than `auto-fit`, because the Columns control is the
 * editor saying how many they want: `--oeb-columns` carries their number, and
 * the two breakpoints at the bottom of this file step it down to 2 and then 1.
 * `auto-fit` would derive the count from the available width instead and leave
 * that control with nothing to do.
 *
 * The consequence is worth knowing: a block set to three columns and holding
 * two events draws two cards and an empty third of the row, rather than two
 * half-width cards. Fewer events than columns is the editor's to resolve, by
 * moving the control, and that is the less surprising of the two behaviours
 * anyway: cards keep the same width as the blocks above and below them.
 *
 * `minmax(0, 1fr)` rather than `1fr` so a long unbroken word in a card cannot
 * push its column past its share. A grid item's automatic minimum size is its
 * content, not zero.
 */
.ota-events__grid {
	display: grid;
	grid-template-columns: repeat(var(--oeb-columns), minmax(0, 1fr));
	gap: var(--oeb-gap);
	align-items: stretch;
}

.ota-events__empty {
	margin: 0;
	color: var(--oeb-title);
	font-size: var(--e-global-typography-body-font-size, 1.0625rem);
	font-weight: var(--e-global-typography-body-font-weight, 300);
}

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

/*
 * The whole card is one anchor, so the image, the date, the title and the View
 * Event affordance are a single target and a single announcement. That is why
 * View Event is a span rather than a second link inside it.
 */
.ota-events__card {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: var(--oeb-radius);
	background-color: var(--oeb-surface);
	color: var(--oeb-text);
	text-decoration: none;
}

.ota-events__card:hover,
.ota-events__card:focus {
	text-decoration: none;
}

/*
 * The hover ring, as a transparent pseudo-element rather than a real border.
 * Same three reasons as the News Block's featured card: a real border resizes
 * the card and shifts the row, an inset shadow paints under the image, and a
 * negative outline offset squares the corners on Safari below 16.4.
 */
.ota-events__card::after {
	content: "";
	position: absolute;
	z-index: 2;
	inset: 0;
	border: var(--oeb-ring-w) solid transparent;
	border-radius: inherit;
	pointer-events: none;
	transition: border-color 150ms ease;
}

.ota-events__card:hover::after {
	border-color: var(--oeb-ring);
}

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

/*
 * A fixed height rather than an aspect ratio, because the design pins 170px and
 * a row of cards wants one shared line under the images. The Image Aspect Ratio
 * control swaps it for a ratio when an editor asks for one. The divider tint
 * stands in when an event has no featured image, so the date badge and the
 * category always have something to sit on.
 */
.ota-events__media {
	position: relative;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	height: var(--oeb-media-h);
	padding: 24px;
	background-color: var(--oeb-divider);
}

.ota-events__media--ratio {
	height: auto;
	aspect-ratio: var(--oeb-media-ratio, 1.7);
}

/*
 * Two classes, not for style but for specificity. Elementor ships
 * `.elementor img { height: auto; max-width: 100% }` at (0,1,1), which beats a
 * lone class and would collapse the box to the image's intrinsic size. Same
 * trap as the one fixed on the News Block, the category feature and the hero.
 */
.ota-events .ota-events__image {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	object-fit: cover;
}

/* The badges sit above the photograph. */
.ota-events__date,
.ota-events__category {
	position: relative;
	z-index: 1;
}

.ota-events__date {
	display: flex;
	flex-direction: column;
	gap: 3px;
	width: 50px;
	padding: 12px;
	border-radius: 12px;
	background-color: var(--oeb-badge);
	color: var(--oeb-badge-text);
	text-align: center;
	font-weight: 700;
}

.ota-events__day {
	display: block;
	font-size: 1.625rem;
	line-height: 1;
}

.ota-events__month {
	display: block;
	font-size: 0.75rem;
	line-height: 1;
	letter-spacing: 0.1em;
}

/*
 * The on-demand label replaces the date entirely, because an event that runs for
 * more than a year has no meaningful day to put in the badge. Wider than the
 * 50px square and set on one line, so it reads as a label rather than a broken
 * date.
 */
.ota-events__date--on-demand {
	width: auto;
	padding-inline: 16px;
	font-size: var(--e-global-typography-caption-font-size, 0.75rem);
	line-height: 1.65em;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.ota-events__category {
	display: inline-flex;
	align-items: center;
	padding: 6px 16px;
	border-radius: 999px;
	background-color: var(--oeb-badge);
	color: var(--oeb-badge-text);
	font-size: var(--e-global-typography-caption-font-size, 0.75rem);
	font-weight: 700;
	line-height: 1.65em;
	letter-spacing: 0.06em;
	text-transform: capitalize;
}

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

/*
 * No padding at the end: the footer's own vertical padding is what the design
 * draws under the rule, and a card padding here would double it.
 */
.ota-events__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	justify-content: space-between;
	gap: 24px;
	padding: 24px 24px 0;
}

.ota-events__group {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.ota-events__card-title {
	margin: 0;
	color: var(--oeb-title);
	font-size: var(--e-global-typography-lead-font-size, 1.375rem);
	font-weight: 400;
	line-height: 1.4;
}

.ota-events__card:hover .ota-events__card-title {
	text-decoration: underline;
}

.ota-events__meta {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ota-events__meta-item {
	display: flex;
	align-items: flex-start;
	gap: 7px;
	color: var(--oeb-muted);
	font-size: var(--e-global-typography-small-font-size, 0.875rem);
	font-weight: var(--e-global-typography-small-font-weight, 300);
	line-height: 1.2;
}

.ota-events__meta-item svg {
	flex: none;
	display: block;
	width: 15px;
	height: 15px;
	/* The glyphs sit on the text's first line rather than its box. */
	margin-block-start: 0.1em;
}

/*
 * The ticket status. No slot is drawn for it in the Events Block frame, so this
 * borrows the filled pill the earlier Component/Events hover frame used for CPD:
 * the Active role, which is the palette's "this one is live" pair.
 */
.ota-events__status {
	align-self: flex-start;
	padding: 6px 14px;
	border-radius: 999px;
	background-color: var(--ota-active-bg, #003038);
	color: var(--ota-active-text, #ffffff);
	font-size: var(--e-global-typography-caption-font-size, 0.75rem);
	font-weight: 700;
	line-height: 1.65em;
}

.ota-events__status--sold-out {
	background-color: var(--oeb-divider);
	color: var(--oeb-muted);
}

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

.ota-events__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding-block: 8px;
	border-block-start: 1px solid var(--oeb-divider);
	/* The design's 48px button row, which is what holds the footer open. */
	min-height: 48px;
}

/*
 * Not a link. The whole card is the anchor, so a second one here would be a
 * nested link and a screen reader would offer two destinations for one card. It
 * is an affordance, which is why it underlines on the card's hover.
 */
.ota-events__more {
	color: var(--oeb-text);
	font-size: var(--e-global-typography-body-font-size, 1.0625rem);
	font-weight: 700;
	line-height: 1;
}

.ota-events__card:hover .ota-events__more {
	text-decoration: underline;
}

/*
 * The arrow's dot. Card-coloured at rest, which is the design's way of saying
 * invisible, and it fills with the CTA colour on hover. Sized and centred at
 * rest as well as on hover so the fill does not move the arrow.
 */
.ota-events__dot {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 999px;
	background-color: var(--oeb-surface);
	color: var(--oeb-text);
	transition:
		background-color 150ms ease,
		color 150ms ease;
}

.ota-events__card:hover .ota-events__dot {
	background-color: var(--oeb-badge);
	color: var(--oeb-badge-text);
}

.ota-events__dot svg {
	flex: none;
	display: block;
	width: 13px;
	height: 13px;
}

/* --- Focus --------------------------------------------------------------- */

/*
 * On the card, not on anything inside it. The whole card is the anchor, so the
 * ring has to describe the whole card or it points at the wrong target.
 */
.ota-events__card:focus-visible {
	outline: 2px solid var(--oeb-ring);
	outline-offset: 3px;
}

/* --- Narrow -------------------------------------------------------------- */

/*
 * No mobile frame was drawn for this block, so everything below is an
 * extrapolation from the desktop one and from the breakpoints the News Block,
 * the hero and the mega menu already use. Worth designing properly before client
 * sign-off.
 */
@media (max-width: 1024px) {
	.ota-events {
		--oeb-pad: 1.1875rem;
		--oeb-columns: 2;
		--oeb-gap: 24px;

		padding-block: 64px;
	}

	.ota-events__inner {
		gap: 32px;
	}
}

@media (max-width: 600px) {
	.ota-events {
		--oeb-columns: 1;
		--oeb-media-h: 200px;
	}

	/* The button goes under the heading rather than beside it: at this width the
	   two share a line only by squeezing the heading to a word a line. */
	.ota-events__head {
		flex-direction: column;
		align-items: flex-start;
	}

	.ota-events__body {
		padding: 20px 20px 0;
	}

	.ota-events__media {
		padding: 16px;
	}
}

/*
 * The rule that hides an empty block's section is in ota-block-empty.css, one
 * copy shared with the news block. This widget declares that handle in
 * `get_style_depends()` alongside this file.
 */
