/* ==========================================================================
   BSA events — the Events module's shortcodes
     [bsa_events_upcoming]          home page list, and cards (layout="cards")
     [bsa_events_list]              /events/ and the past list
     [bsa_event]                    a single event
   Needs tokens.css, typography.css and buttons.css first.
   Markup reference: docs/shortcodes.md section 11.

   TEC's own stylesheets don't load on the calendar pages any more, so
   nothing here fights them.

   Links: typography.css underlines links inside Divi Text and Post
   Content modules. Links that shouldn't be underlined here (titles, tabs,
   paging) carry ":not(#bsa)", the same trick as buttons.css: no element
   has that ID, but it counts as one, so these rules win.

   Headings: the calendar pages are custom post type pages, where Divi
   prints its Customizer heading sizes as ".et-db #et-boc .et-l h2"
   (et-divi-customizer-cpt-global.css): one ID, two classes, one element.
   So every heading rule here also carries ":not(#bsa)" plus at least
   three classes, which outranks it.

   Breakpoints follow Divi: 980px (tablet) and 767px (phone).
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Shared pieces (rows, cards and the single event)
   -------------------------------------------------------------------------- */

/* Eyebrow line: status, categories, then the Ongoing badge. */
.bsa-event-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2) var(--space-3);
	margin: 0;
	padding: 0;
	font-family: var(--font-sans);
	font-size: 0.8125rem;                  /* 13px eyebrow */
	line-height: 1.23;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ink-muted);               /* the " · " between categories */
}

.bsa-event-category {
	color: var(--Blue);
}

/* Canceled / Postponed */
.bsa-event-status {
	color: var(--danger);
}

/* Ongoing: the design system's orange "spark", as a small tag. */
.bsa-event-badge {
	display: inline-flex;
	align-items: center;
	min-height: 24px;
	padding: 0 var(--space-2);
	border-radius: var(--radius-sm);
	background: var(--orange-50);
	color: var(--orange-700);
}

/* Dates: "Nov 9 – Nov 28", "Nov 17, 6–9 pm". Each date stays on one line,
   so a long range breaks only at the dash. */
.bsa-event-date {
	margin: 0;
	padding: 0;
	font-family: var(--font-sans);
	font-size: 1.0625rem;
	line-height: 1.5;
	font-weight: 600;
	color: var(--Blue);
}

.bsa-event-date time,
.bsa-event-lede time {
	white-space: nowrap;
}

/* Venue line: name in ink, address muted. */
.bsa-event-venue {
	margin: 0;
	padding: 0;
	font-size: 0.9375rem;                  /* small */
	line-height: 1.6;
	color: var(--ink-muted);
}

.bsa-event-venue strong {
	font-weight: 600;
	color: var(--ink);
}

.bsa-event-summary {
	margin: 0;
	padding: 0;
	color: var(--ink-muted);
}

/* Image mat: a fixed 4:3 paper box, the whole image inside it (flyers carry
   text, so never cropped). An event with no image keeps an empty mat so
   text lines up. Change the mat's padding with --bsa-event-mat. */
.bsa-event-rows .bsa-event-media,
.bsa-event-cards .bsa-event-media {
	--bsa-event-mat: var(--space-6);
	position: relative;
	aspect-ratio: 4 / 3;
	background: var(--paper);
}

.bsa-event-rows .bsa-event-media img,
.bsa-event-cards .bsa-event-media img {
	position: absolute;
	top: var(--bsa-event-mat);
	left: var(--bsa-event-mat);
	width: calc(100% - 2 * var(--bsa-event-mat));
	height: calc(100% - 2 * var(--bsa-event-mat));
	object-fit: contain;
	border-radius: var(--radius-none);
}

/* Notices: staff sample, "This event has ended.", a cancellation reason. */
.bsa-events-sample,
.bsa-event-past,
.bsa-event-status-note {
	margin: 0;
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius-md);
	background: var(--blue-50);
	color: var(--ink);
	font-size: 0.9375rem;
	line-height: 1.6;
}

.bsa-event-status-note {
	background: var(--orange-50);
}

.bsa-events-sample {
	margin-bottom: var(--space-6);
}


/* --------------------------------------------------------------------------
   2. [bsa_events_upcoming] — the home page list
   Date column on the left, serif title and summary on the right.
   -------------------------------------------------------------------------- */

/* Beats Divi's ".et-l--body ul" bullets and padding. */
.bsa-events-upcoming .bsa-event-list {
	list-style: none;
	margin: 0;
	padding: 0;
	border-top: 1px solid var(--border);
}

.bsa-events-upcoming .bsa-event {
	position: relative;                    /* for the stretched link */
	display: grid;
	grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr);
	column-gap: var(--space-8);
	margin: 0;
	padding: var(--space-6) 0;
	border-bottom: 1px solid var(--border);
	line-height: inherit;
}

/* The title comes first in the markup (for screen readers); the grid
   shows the date first. */
.bsa-events-upcoming .bsa-event .bsa-event-date {
	grid-column: 1;
	grid-row: 1 / span 2;
	padding-top: 0.3em;                    /* lines up with the serif title */
}

.bsa-events-upcoming .bsa-event .bsa-event-title {
	grid-column: 2;
	grid-row: 1;
	margin: 0 0 var(--space-2);
}

.bsa-events-upcoming .bsa-event .bsa-event-summary {
	grid-column: 2;
	grid-row: 2;
}

@media (max-width: 767px) {
	.bsa-events-upcoming .bsa-event {
		grid-template-columns: minmax(0, 1fr);
	}

	.bsa-events-upcoming .bsa-event .bsa-event-date {
		grid-column: 1;
		grid-row: 1;
		padding-top: 0;
		margin-bottom: var(--space-1);
	}

	.bsa-events-upcoming .bsa-event .bsa-event-title {
		grid-column: 1;
		grid-row: 2;
	}

	.bsa-events-upcoming .bsa-event .bsa-event-summary {
		grid-column: 1;
		grid-row: 3;
	}
}

/* Empty state (also used by [bsa_events_list] and the cards). */
.bsa-events-empty {
	padding: var(--space-6) 0;
	border-top: 1px solid var(--border);
	border-bottom: 1px solid var(--border);
}

.bsa-events-empty p {
	margin: 0;
	padding: 0;
}

.bsa-events-empty p:first-child {
	font-family: var(--font-serif);
	font-size: clamp(1.375rem, 1.29rem + 0.364vw, 1.5625rem);   /* h3 */
	line-height: 1.28;
	margin-bottom: var(--space-2);
}

.bsa-events-empty p:last-child {
	margin-top: var(--space-4);
}


/* --------------------------------------------------------------------------
   3. Whole row or card clickable
   The title's link is the only link in a row or card; its ::after covers
   the whole item. The focus ring goes round the item, not just the title.
   -------------------------------------------------------------------------- */

.bsa-events-upcoming .bsa-event,
.bsa-event-rows .bsa-event,
.bsa-event-cards .bsa-event-card {
	position: relative;
}

:is(.bsa-events-upcoming, .bsa-event-rows, .bsa-event-cards) .bsa-event-title a:not(#bsa) {
	color: var(--ink);
	text-decoration: none;
}

:is(.bsa-events-upcoming, .bsa-event-rows, .bsa-event-cards) .bsa-event-title a:not(#bsa)::after {
	content: "";
	position: absolute;
	inset: 0;
}

:is(.bsa-events-upcoming .bsa-event, .bsa-event-rows .bsa-event, .bsa-event-cards .bsa-event-card):hover .bsa-event-title a:not(#bsa) {
	color: var(--Blue);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.15em;
}

:is(.bsa-events-upcoming, .bsa-event-rows, .bsa-event-cards) .bsa-event-title a:not(#bsa):focus-visible {
	outline: none;
}

:is(.bsa-events-upcoming, .bsa-event-rows, .bsa-event-cards) .bsa-event-title a:not(#bsa):focus-visible::after {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}


/* --------------------------------------------------------------------------
   4. [bsa_events_upcoming layout="cards"] — "More Events & Exhibitions"
   White cards on Anthony's paper band, three across.
   -------------------------------------------------------------------------- */

.bsa-events-upcoming-cards .bsa-event-cards {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--space-6);
	list-style: none;
	margin: 0;
	padding: 0;
}

.bsa-event-cards .bsa-event-card {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	line-height: inherit;
}

.bsa-event-cards .bsa-event-media {
	--bsa-event-mat: var(--space-4);
}

.bsa-event-cards .bsa-event-body {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding: var(--space-5, 20px) var(--space-6) var(--space-6);
}

.bsa-event-cards .bsa-event-date {
	font-size: 0.9375rem;
}

.bsa-events-upcoming-cards .bsa-event-cards .bsa-event-title:not(#bsa) {
	margin: 0;
	padding: 0;
	font-family: var(--font-serif);
	font-weight: 400;
	font-size: 1.375rem;                   /* 22px */
	line-height: 1.28;
}

/* Tablets: two across, so only the first two cards (three would leave one
   alone on a second row). Phones keep two, stacked, to keep the page short.
   A hidden card's image is lazy-loaded, so it isn't downloaded either. */
@media (max-width: 980px) {
	.bsa-events-upcoming-cards .bsa-event-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.bsa-events-upcoming-cards .bsa-event-card:nth-child(n + 3) {
		display: none;
	}
}

@media (max-width: 767px) {
	.bsa-events-upcoming-cards .bsa-event-cards {
		grid-template-columns: minmax(0, 1fr);
	}
}


/* --------------------------------------------------------------------------
   5. [bsa_events_list] — /events/ and the past list
   -------------------------------------------------------------------------- */

/* Upcoming / Past Events tabs, like the directory's tier tabs. */
.bsa-events-tabs {
	border-bottom: 1px solid var(--border);
}

/* ":not(#bsa)" so Divi's list rules (bullets, 1em indent, 23px bottom
   padding, 26px line height) can't win the tie. */
.bsa-events .bsa-events-tabs ul:not(#bsa) {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0 var(--space-8);
	list-style: none;
	margin: 0;
	padding: 0;
	line-height: normal;
}

.bsa-events .bsa-events-tabs li:not(#bsa) {
	display: block;
	margin: 0;
	padding: 0;
	line-height: normal;
}

.et-l .bsa-events .bsa-events-tabs a:not(#bsa) {
	display: block;
	margin: 0;
	padding: 14px 0 12px;
	border-bottom: 4px solid transparent;
	color: var(--ink);
	font-size: 1rem;
	line-height: 1.25;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-decoration: none;
}

.et-l .bsa-events .bsa-events-tabs a:not(#bsa):hover {
	color: var(--Blue);
	border-bottom-color: var(--border);
}

.et-l .bsa-events .bsa-events-tabs a:not(#bsa)[aria-current] {
	color: var(--ink);
	border-bottom-color: var(--Blue);
}

/* Rows: image mat on the left, details on the right, hairlines between. */
.bsa-events .bsa-event-rows {
	list-style: none;
	margin: 0;
	padding: 0;
}

.bsa-event-rows .bsa-event {
	display: grid;
	grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
	column-gap: var(--space-12);
	align-items: start;
	margin: 0;
	padding: var(--space-10, 40px) 0;
	border-bottom: 1px solid var(--border);
	line-height: inherit;
}

.bsa-event-rows .bsa-event-body {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	padding-top: var(--space-1);
}

.bsa-events .bsa-event-rows .bsa-event-title:not(#bsa) {
	margin: 0;
	padding: 0;
	font-family: var(--font-serif);
	font-weight: 400;
	font-size: clamp(1.375rem, 1.29rem + 0.364vw, 1.5625rem);   /* h3 look */
	line-height: 1.28;
}

.bsa-event-rows .bsa-event-summary {
	max-width: 68ch;
	margin-top: var(--space-1);
	color: var(--ink);
}

/* Tablets: a narrower image column. Phones: image on top. */
@media (max-width: 980px) {
	.bsa-event-rows .bsa-event {
		grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
		column-gap: var(--space-8);
	}
}

@media (max-width: 767px) {
	.bsa-event-rows .bsa-event {
		grid-template-columns: minmax(0, 1fr);
		row-gap: var(--space-4);
		padding: var(--space-8) 0;
	}
}

/* Previous / Next */
.bsa-events-paging {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: var(--space-4);
	padding-top: var(--space-6);
}

.bsa-events-paging :is(a, span) {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	min-height: 44px;
	font-size: 1rem;
	line-height: 1.25;
	font-weight: 600;
}

.bsa-events-paging a:not(#bsa) {
	color: var(--Blue);
	text-decoration: none;
}

.bsa-events-paging a:not(#bsa):hover {
	color: var(--blue-700);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.bsa-events-paging span[aria-disabled="true"] {
	color: var(--border-strong);
}

.bsa-events-paging svg {
	flex: none;
	width: 20px;
	height: 20px;
}

/* Next stays on the right when there's no Previous to push it. */
.bsa-events-next {
	margin-left: auto;
}

/* Empty lists */
.bsa-events .bsa-events-empty {
	margin-top: var(--space-8);
}

.bsa-events .bsa-events-empty + p {
	margin: var(--space-4) 0 0;
	padding: 0;
}

.bsa-events-none {
	margin: var(--space-8) 0 0;
	padding: 0;
	color: var(--ink-muted);
}


/* --------------------------------------------------------------------------
   6. [bsa_event] — a single event
   Wide screens: header, image and description on the left (two thirds),
   the details sidebar on the right, beside the image and description.
   Phones and tablets: one column — header, image, description, details.
   -------------------------------------------------------------------------- */

/* Rows: header, image, description. The sidebar spans the image and
   description rows; the last row is 1fr so a sidebar taller than the image
   pushes the description's row down, not the gap under the image. */
.bsa-event-single {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
	grid-template-rows: auto auto 1fr;
	column-gap: var(--space-12);
	align-items: start;
}

.bsa-event-single > .bsa-event-header {
	grid-column: 1;
	grid-row: 1;
}

.bsa-event-single > .bsa-event-media {
	grid-column: 1;
	grid-row: 2;
}

.bsa-event-single > .bsa-event-content {
	grid-column: 1;
	grid-row: 3;
}

.bsa-event-single > .bsa-event-details {
	grid-column: 2;
	grid-row: 2 / span 2;
}

/* Header: eyebrow, h1, lede ("dates · venue"), any notice. */
.bsa-event-single .bsa-event-header {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	margin-bottom: var(--space-8);
}

.bsa-event-single .bsa-event-header .bsa-event-title:not(#bsa) {
	margin: 0;
	padding: 0;
	font-family: var(--font-serif);
	font-weight: 400;
	font-size: clamp(2rem, 1.716rem + 1.212vw, 2.625rem);       /* h1 */
	line-height: 1.19;
	color: var(--ink);
}

.bsa-event-lede {
	margin: 0;
	padding: 0;
	font-size: 1.1875rem;                  /* body-lg */
	line-height: 1.58;
	color: var(--ink);
}

.bsa-event-lede strong {
	font-weight: 600;
	color: var(--Blue);
}

/* The flyer, on a paper mat like the news article's figure. */
.bsa-event-single .bsa-event-media {
	display: flex;
	justify-content: center;
	margin: 0 0 var(--space-8);
	padding: var(--space-8);
	background: var(--paper);
}

.bsa-event-single .bsa-event-media img {
	display: block;
	max-width: 100%;
	height: auto;
	max-height: 80vh;
	width: auto;
	object-fit: contain;
	border-radius: var(--radius-none);
}

/* Description */
.bsa-event-content {
	max-width: 720px;
}

.bsa-event-content > :last-child {
	margin-bottom: 0;
	padding-bottom: 0;
}

/* Details sidebar: blocks with a hairline on top, like the profile's
   Education / Awards column. Stays in view while the description scrolls,
   on screens tall enough to show it whole. */
.bsa-event-details {
	display: flex;
	flex-direction: column;
	gap: var(--space-6);
}

@media (min-width: 981px) and (min-height: 900px) {
	.bsa-event-details {
		position: sticky;
		top: var(--space-6);
	}
}

.bsa-event-detail {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding-top: var(--space-5, 20px);
	border-top: 1px solid var(--border);
	font-size: 0.9375rem;
	line-height: 1.6;
}

.bsa-event-single .bsa-event-details .bsa-event-detail h2:not(#bsa) {
	margin: 0;
	padding: 0;
	font-family: var(--font-sans);
	font-weight: 600;
	font-size: 1.25rem;                    /* h4 look */
	line-height: 1.4;
	color: var(--ink);
}

.bsa-event-detail :is(p, address) {
	margin: 0;
	padding: 0;
	font-style: normal;
}

.bsa-event-detail strong {
	font-weight: 600;
}

.bsa-event-ongoing-note {
	color: var(--ink-muted);
}

.bsa-event-detail a {
	font-weight: 600;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.15em;
}

/* The map, full sidebar width. */
.bsa-event-map {
	margin-top: var(--space-2);
}

.bsa-event-map iframe {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	border: 1px solid var(--border);
}

/* Add to Calendar: a Secondary button that opens a short list. */
.bsa-event-calendar {
	margin: 0;
}

.bsa-event-calendar summary {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-3);
	min-height: 48px;
	padding: var(--space-3) var(--space-6);
	border: 2px solid var(--Blue);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--Blue);
	font-family: var(--font-sans);
	font-size: 1rem;
	line-height: 20px;
	font-weight: 600;
	letter-spacing: 0.02em;
	cursor: pointer;
	list-style: none;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bsa-event-calendar summary::-webkit-details-marker {
	display: none;
}

/* Chevron, pointing down; up when open. */
.bsa-event-calendar summary::after {
	content: "";
	width: 7px;
	height: 7px;
	margin-top: -4px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.15s ease;
}

.bsa-event-calendar[open] summary::after {
	margin-top: 4px;
	transform: rotate(-135deg);
}

.bsa-event-calendar summary:hover {
	background: var(--blue-50);
	border-color: var(--blue-700);
	color: var(--blue-700);
}

.bsa-event-calendar summary:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

.bsa-event-single .bsa-event-calendar ul:not(#bsa) {
	list-style: none;
	margin: var(--space-2) 0 0;
	padding: 0;
	line-height: normal;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
}

.bsa-event-single .bsa-event-calendar li:not(#bsa) {
	margin: 0;
	padding: 0;
}

.bsa-event-calendar li + li {
	border-top: 1px solid var(--border);
}

.bsa-event-calendar a:not(#bsa) {
	display: flex;
	align-items: center;
	min-height: 44px;
	padding: 0 var(--space-4);
	color: var(--ink);
	font-size: 0.9375rem;
	font-weight: 600;
	text-decoration: none;
}

.bsa-event-calendar a:not(#bsa):hover {
	background: var(--blue-50);
	color: var(--blue-700);
}

@media (prefers-reduced-motion: reduce) {
	.bsa-event-calendar summary,
	.bsa-event-calendar summary::after {
		transition: none;
	}
}

/* Tablets and phones: one column — header, image, description, then the
   details, the same order as the markup. The map becomes a short
   landscape strip. */
@media (max-width: 980px) {
	.bsa-event-single {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: none;
	}

	.bsa-event-single > .bsa-event-header {
		grid-row: 1;
	}

	.bsa-event-single > .bsa-event-media {
		grid-row: 2;
	}

	.bsa-event-single > .bsa-event-content {
		grid-row: 3;
	}

	.bsa-event-single > .bsa-event-details {
		grid-column: 1;
		grid-row: 4;
		margin-top: var(--space-8);
	}

	.bsa-event-map iframe {
		aspect-ratio: 2 / 1;
	}
}

@media (max-width: 767px) {
	.bsa-event-single .bsa-event-media {
		padding: var(--space-4);
	}

	.bsa-event-map iframe {
		aspect-ratio: 16 / 10;
	}
}
