/*
 * Next event — the upcoming race weekend, pulled from the Schedule post type.
 *
 * One grid, five areas: logo, ribbon, countdown, details, actions. The layout
 * is entirely grid-template-areas, so each breakpoint just re-places them.
 *
 *   base rules       1025px and up   Logo down the left, ribbon row beside it.
 *   768–1024px                       Tablet: ribbon row lifts above the logo.
 *   767px and down                   Mobile: everything stacks.
 */

.next-event,
.next-event *,
.next-event *::before,
.next-event *::after {
	box-sizing: border-box;
}

/* Doubled class throughout: core's layout rules tie a single class on
   specificity and are printed later — see the margin below. */
.next-event.next-event {
	--event-logo-width: 21%;
	--event-ribbon-height: 56px;
	--event-pad: clamp(20px, 2.3vw, 44px);
	--event-title-size: clamp(24px, calc(1.25vw + 8px), 32px);
	--event-ribbon-size: 20px;
	--event-dates-size: 24px;
	--event-venue-size: 20px;
	--event-count-size: 32px;
	--event-count-label-size: 14px;
	--event-count-cell: clamp(60px, 4vw, 76px);
	--event-inset: clamp(16px, 3.5vw, 72px);
	--event-line-inset: var(--event-logo-width);

	position: relative;

	/* Margin, not padding — the comp insets the grey panel itself, so the gap
	   sits outside it, not within. Both directions need !important: core zeroes
	   margin-block-end on a last child and forces margin-inline: auto, each from
	   a selector that ties this one on specificity and is printed later. */
	margin-block: var(--event-inset) !important;
	margin-inline: var(--event-inset) !important;
	display: grid;
	/* minmax(0,…) rather than 1fr: a grid item's auto minimum is its
	   min-content, and between the ribbon's nowrap text and the countdown's
	   fixed cells that floor is wider than the page. */
	grid-template-columns: var(--event-logo-width) minmax(0, 1fr) auto;
	grid-template-areas:
		"logo ribbon  countdown"
		"logo details actions";
	background: var(--gray-2);
	font-family: forma-djr-micro, sans-serif;
}

/* The hairline the ribbon sits on, carried across to the countdown. Starts
   clear of the logo panel, which is black and would otherwise be crossed. */
.next-event::before {
	content: '';
	position: absolute;
	inset-inline: var(--event-line-inset) 0;
	inset-block-start: calc(var(--event-ribbon-height) - 1px);
	height: 1px;
	background: var(--red-1);
}

.next-event__logo {
	grid-area: logo;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--event-pad);
	background: var(--gray-8);
}

.next-event__logo-image {
	max-width: 100%;
	height: auto;
}

/* Two classes deep on purpose: the component declares these same properties on
   .section-ribbon, so a single class would only tie and lose to whichever
   stylesheet loads last. */
.next-event .next-event__ribbon {
	--section-ribbon-height: var(--event-ribbon-height);
	--section-ribbon-width: 44%;
	--section-ribbon-padding-left: var(--event-pad);

	grid-area: ribbon;
	min-width: max-content;
}

/* The component declares these on the text itself, so they're set here, not on
   the ribbon. Two classes outrank its one. */
.next-event__ribbon .section-ribbon-text {
	--section-ribbon-font-family: guildhall-wide, sans-serif;
	--section-ribbon-font-weight: 500;
	--section-ribbon-font-size: var(--event-ribbon-size);
}

/* Same height as the ribbon beside it, so the hairline below lands on the
   bottom edge of both rather than partway up the taller one. */
.next-event__countdown {
	grid-area: countdown;
	display: flex;
	height: var(--event-ribbon-height);
	margin: 0;
	padding: 0;
	list-style: none;
	background: var(--gray-8);
	color: var(--white);
	text-align: center;
}

/* Hairline between cells, drawn by the one on its left. They grow to share the
   row: its column is sized by the wider buttons below, so fixed-width cells
   would leave dead black space at the right edge. */
.next-event__unit {
	display: flex;
	flex-direction: column;
	justify-content: center;
	flex-grow: 1;
	width: var(--event-count-cell);
	padding-inline: .4em;
	border-inline-start: 1px solid var(--red-1);
}

.next-event__unit:first-child {
	border-inline-start: 0;
}

/* Doto is the dot-matrix face the comps use for the clock; it comes in with
   the theme's Google Fonts import. */
.next-event__value {
	display: block;
	font-family: "Doto", sans-serif;
	font-optical-sizing: auto;
	font-weight: 600;
	font-variation-settings: "ROND" 0;
	font-size: var(--event-count-size);
	line-height: 1;
}

.next-event__unit-label {
	display: block;
	font-size: var(--event-count-label-size);
	font-weight: 500;
	color: var(--gray-3);
	line-height: 1.2;
	letter-spacing: .08em;
	text-transform: uppercase;
}

.next-event__details {
	grid-area: details;
	min-width: 0;
	padding: var(--event-pad);
	color: var(--gray-8);
}

.next-event__title {
	margin: 0 0 .7em;
	font-size: var(--event-title-size);
	font-weight: 700;
	line-height: 1.2;
}

.next-event__dates {
	margin: 0 0 .8em;
	font-size: var(--event-dates-size);
	font-weight: 500;
}

.next-event__venue {
	margin: 0;
	font-size: var(--event-venue-size);
	font-weight: 500;
}

.next-event__actions {
	grid-area: actions;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 12px;
	padding: var(--event-pad);
	padding-inline-start: 0;
}

/* The comp's buttons are wider than their labels. */
.next-event__actions .kalitta-button {
	min-width: 360px;
}

/* Keeps "See Full Schedule" on one line when its column is narrow. */
.next-event__actions .button-text {
	white-space: nowrap;
}

/* LAPTOP and TABLET share the same type sizes. */
@media (max-width: 1400px) {
	.next-event.next-event {
		--event-ribbon-size: 18px;
		--event-dates-size: 20px;
		--event-venue-size: 18px;
	}
}

/* TABLET — the ribbon row lifts above the logo rather than sitting beside it.
   These rules also apply at mobile widths; mobile only overrides what differs. */
@media (max-width: 1024px) {
	.next-event.next-event {
		--event-logo-width: 37%;
		--event-title-size: 22px;
		/* The hairline spans everything now; no logo panel in its row. */
		--event-line-inset: 0;

		grid-template-columns: var(--event-logo-width) minmax(0, 1fr);
		grid-template-areas:
			"ribbon countdown"
			"logo   details"
			"logo   actions";
	}
	/* Fills its column, which the logo below now sets the width of, and squares
	   off — the angled end only reads against open space beside it. */
	.next-event .next-event__ribbon {
		--section-ribbon-width: 100%;
		--section-ribbon-cut: 0px;
	}
	.next-event__countdown {
		justify-self: end;
	}
	/* Buttons share the details column here, so they take its inset rather than
	   filling it. fit-content sizes the stack to the longer label and the
	   inherited stretch matches the shorter button to it. */
	.next-event__actions {
		width: fit-content;
		padding-block-start: 0;
		padding-inline-start: var(--event-pad);
	}
	.next-event__actions .kalitta-button {
		min-width: 0;
	}
}

/* MOBILE — the ribbon row keeps its two columns; everything under it goes full
   width, logo included. */
@media (max-width: 767px) {
	.next-event.next-event {
		--event-inset: 16px;
		--event-pad: 24px;
		--event-logo-width: 36%;
		--event-ribbon-height: 48px;
		--event-title-size: 20px;
		--event-ribbon-size: 16px;
		--event-dates-size: 16px;
		--event-venue-size: 16px;
		/* The 48px row can't fit the desktop 32px + 14px stack. */
		--event-count-size: 20px;
		--event-count-label-size: 11px;

		grid-template-columns: var(--event-logo-width) minmax(0, 1fr);
		grid-template-areas:
			"ribbon  countdown"
			"logo    logo"
			"details details"
			"actions actions";
	}
	/* Too narrow for one line; the component holds it to nowrap by default. */
	.next-event__ribbon .section-ribbon-text {
		line-height: 1.05;
		white-space: normal;
	}
	.next-event .next-event__ribbon { min-width: 0; }
	.next-event__countdown { justify-self: stretch; }
	.next-event__unit { width: auto; }
	/* Undoes the tablet rule above, which still applies at this width. */
	.next-event__actions { width: auto; }
}

/* The canvas shows a placeholder, not the event — its data comes from the
   Schedule at render time. Two classes to outrank the grid rule above. */
.next-event.next-event--editor {
	display: block;
	padding: var(--event-pad);
	background: var(--gray-2);
	color: var(--gray-8);
}

.next-event__editor-note {
	margin: 0;
	font-weight: 700;
}
