/**
 * Blue Island Lightbox — front-end and shared styles.
 *
 * Everything themeable is a custom property, so a site can override the
 * look in its own stylesheet without touching the plugin.
 */

.bil-grid {
	--bil-card-bg: #ffffff;
	--bil-card-text: inherit;
	--bil-card-radius: 4px;
	--bil-card-shadow: 0 2px 8px rgba( 0, 0, 0, 0.08 );
	--bil-card-shadow-hover: 0 8px 24px rgba( 0, 0, 0, 0.14 );
	--bil-columns: 3;
	--bil-columns-tablet: 2;
	--bil-gap: 24px;
	--bil-media-ratio: 1/1;
	--bil-media-radius: 0;
	--bil-media-position: center top;
	--bil-accent: #1c285e;
	--bil-lightbox-bg: #ffffff;
	--bil-lightbox-max-width: 680px;
	--bil-lightbox-padding-y: clamp( 20px, 4vw, 32px );
	--bil-lightbox-padding-x: clamp( 16px, 5vw, 40px );
	--bil-overlay: 0.7;

	display: grid;
	grid-template-columns: repeat( var( --bil-columns ), minmax( 0, 1fr ) );
	gap: var( --bil-gap );
}

/* -------------------------------------------------------------------------
 * Cards
 * ---------------------------------------------------------------------- */

.bil-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var( --bil-card-bg );
	color: var( --bil-card-text );
	border-radius: var( --bil-card-radius );
	box-shadow: var( --bil-card-shadow );
	overflow: hidden;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bil-card__trigger {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.bil-card__trigger:focus-visible {
	outline: 2px solid var( --bil-accent );
	outline-offset: -2px;
}

.bil-card__media {
	display: block;
	position: relative;
	overflow: hidden;
	background-color: #e8eef7;
	aspect-ratio: var( --bil-media-ratio );
	border-radius: var( --bil-media-radius );
}

.bil-card__image,
.bil-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: var( --bil-media-position );
	transition: transform 0.4s ease;
}

.bil-card__image-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 120px;
	background-color: #d0daea;
}

.bil-card__body {
	display: block;
	padding: 14px 16px 16px;
}

.bil-card__title {
	display: block;
	font-size: var( --bil-title-size, 1em );
	font-weight: 700;
	line-height: 1.3;
	color: inherit;
}

.bil-card__subtitle {
	display: block;
	margin-top: 4px;
	font-size: var( --bil-subtitle-size, 0.875em );
	line-height: 1.3;
	opacity: 0.75;
}

/* Card Details — arbitrary blocks rendered on the card. Deliberately
   smaller and tighter than body content. */
.bil-card__extra {
	display: block;
	margin-top: auto;
	padding: 10px 16px 14px;
	font-size: 0.85em;
	line-height: 1.45;
}

.bil-card__extra > :first-child {
	margin-top: 0;
}

.bil-card__extra > :last-child {
	margin-bottom: 0;
}

.bil-card__extra :where( p, ul, ol, blockquote, pre, figure ) {
	margin: 0 0 0.5em;
}

.bil-card__extra :where( h1, h2, h3, h4, h5, h6 ) {
	margin: 0.6em 0 0.3em;
	font-size: 1em;
	line-height: 1.3;
}

.bil-card__extra :where( ul, ol ) {
	padding-left: 1.2em;
}

.bil-card__extra a {
	color: var( --bil-accent );
}

/* Hover animations */
.bil-grid.is-hover-lift .bil-card:hover,
.bil-grid.is-hover-lift-zoom .bil-card:hover,
.bil-grid.is-hover-lift .bil-card:focus-within,
.bil-grid.is-hover-lift-zoom .bil-card:focus-within {
	transform: translateY( -4px );
	box-shadow: var( --bil-card-shadow-hover );
}

.bil-grid.is-hover-zoom .bil-card:hover .bil-card__image,
.bil-grid.is-hover-lift-zoom .bil-card:hover .bil-card__image,
.bil-grid.is-hover-zoom .bil-card:focus-within .bil-card__image,
.bil-grid.is-hover-lift-zoom .bil-card:focus-within .bil-card__image {
	transform: scale( 1.06 );
}

.bil-grid.is-hover-zoom .bil-card:hover,
.bil-grid.is-hover-zoom .bil-card:focus-within {
	box-shadow: var( --bil-card-shadow-hover );
}

/* The panel is markup for the lightbox only; never shown in the grid. */
.bil-card__panel {
	display: none;
}

/* -------------------------------------------------------------------------
 * Lightbox
 * ---------------------------------------------------------------------- */

.bil-lightbox {
	--bil-accent: #1c285e;
	--bil-lightbox-bg: #ffffff;
	--bil-lightbox-max-width: 680px;
	--bil-lightbox-padding-y: clamp( 20px, 4vw, 32px );
	--bil-lightbox-padding-x: clamp( 16px, 5vw, 40px );
	--bil-media-ratio: 1/1;
	--bil-media-radius: 0;
	--bil-media-position: center top;
	--bil-overlay: 0.7;

	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
}

.bil-lightbox.is-open {
	display: flex;
}

.bil-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background-color: rgba( 0, 0, 0, var( --bil-overlay ) );
	animation: bil-fade 0.25s ease;
}

.bil-lightbox__dialog {
	position: relative;
	width: 100%;
	max-width: var( --bil-lightbox-max-width );
	max-height: 90vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var( --bil-lightbox-bg );
	border-radius: 4px;
	box-shadow: 0 20px 60px rgba( 0, 0, 0, 0.3 );
	animation: bil-zoom 0.25s ease;
}

/* Padding lives on the inner content, not the container, so a card header
   (or any other block the script prepends) can span the full dialog width. */
.bil-panel__content {
	margin: 0;
	padding: var( --bil-lightbox-padding-y ) var( --bil-lightbox-padding-x );
}

.bil-lightbox__content > .bil-panel__content > *:first-child {
	margin-top: 0;
}

.bil-lightbox__content > .bil-panel__content > *:last-child {
	margin-bottom: 0;
}

/* A full-width child bleeds to the edges of the dialog, so the first block
   can be a coloured header strip. */
.bil-lightbox__content .bil-panel__content > .alignfull,
.bil-lightbox__content .bil-panel__content > .bil-bleed {
	margin-left: calc( -1 * var( --bil-lightbox-padding-x ) );
	margin-right: calc( -1 * var( --bil-lightbox-padding-x ) );
	max-width: none;
	width: auto;
}

.bil-lightbox__content .bil-panel__content > .alignfull:first-child,
.bil-lightbox__content .bil-panel__content > .bil-bleed:first-child {
	margin-top: calc( -1 * var( --bil-lightbox-padding-y ) );
}

.bil-lightbox__content .bil-panel__content > .alignfull:last-child,
.bil-lightbox__content .bil-panel__content > .bil-bleed:last-child {
	margin-bottom: calc( -1 * var( --bil-lightbox-padding-y ) );
}

.bil-lightbox__close {
	position: absolute;
	top: 10px;
	right: 12px;
	z-index: 3;
	padding: 4px 8px;
	border: 0;
	background: none;
	font-size: 28px;
	line-height: 1;
	color: #999;
	cursor: pointer;
	transition: color 0.2s ease;
}

.bil-lightbox__close:hover,
.bil-lightbox__close:focus-visible {
	color: var( --bil-accent );
}

.bil-lightbox__nav {
	position: absolute;
	top: 50%;
	z-index: 4;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0 0 4px;
	transform: translateY( -50% );
	border: 0;
	border-radius: 50%;
	background-color: rgba( 255, 255, 255, 0.85 );
	box-shadow: 0 2px 10px rgba( 0, 0, 0, 0.2 );
	font-size: 34px;
	font-weight: 300;
	line-height: 1;
	color: var( --bil-accent );
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.bil-lightbox__nav:hover,
.bil-lightbox__nav:focus-visible {
	background-color: #ffffff;
	color: var( --bil-accent );
}

.bil-lightbox__nav--prev {
	left: 12px;
}

.bil-lightbox__nav--next {
	right: 12px;
}

.bil-lightbox__nav[ hidden ] {
	display: none;
}

/* -------------------------------------------------------------------------
 * Optional card header inside the lightbox (showCardHeader)
 * ---------------------------------------------------------------------- */

.bil-panel__header {
	display: flex;
	margin: 0;
	align-items: center;
	gap: clamp( 16px, 3vw, 28px );
	padding: clamp( 16px, 3vw, 24px ) clamp( 20px, 5vw, 50px );
	background-color: #f0eef2;
	background-color: color-mix( in srgb, var( --bil-accent ) 10%, #ffffff );
	border-bottom: 3px solid var( --bil-accent );
}

.bil-panel__header-media {
	flex: 0 0 auto;
	width: clamp( 80px, 18vw, 150px );
	overflow: hidden;
	background-color: #d0daea;
}

.bil-panel__header-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: var( --bil-media-position );
	display: block;
}

.bil-panel__header-media .bil-card__image-placeholder {
	width: 100%;
	height: 100%;
	min-height: 0;
}

.bil-panel__header .bil-card__body {
	padding: 0;
	min-width: 0;
}

.bil-panel__header .bil-card__title {
	font-size: clamp( 20px, 4vw, 30px );
	line-height: 1.2;
}

.bil-panel__header .bil-card__subtitle {
	font-size: clamp( 15px, 2.4vw, 18px );
	opacity: 0.8;
}

/* Card Details inside the banner: same content, but the card's bottom
   padding and auto-margin don't apply here. */
.bil-panel__header .bil-card__extra {
	margin-top: 10px;
	padding: 10px 0 0;
	font-size: 0.9em;
}

/* Optional link button at the foot of the lightbox. */
.bil-panel__link-wrap {
	margin: 0;
	padding: 0 var( --bil-lightbox-padding-x ) var( --bil-lightbox-padding-y );
}

.bil-panel__link {
	display: inline-block;
	padding: 10px 20px;
	border-radius: 4px;
	background-color: var( --bil-accent );
	color: #ffffff;
	font-weight: 600;
	text-decoration: none;
}

.bil-panel__link:hover,
.bil-panel__link:focus-visible {
	opacity: 0.9;
	color: #ffffff;
}

body.bil-lightbox-open {
	overflow: hidden;
}

@keyframes bil-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes bil-zoom {
	from { opacity: 0; transform: scale( 0.97 ); }
	to   { opacity: 1; transform: scale( 1 ); }
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */

@media ( max-width: 900px ) {
	.bil-grid {
		grid-template-columns: repeat( var( --bil-columns-tablet ), minmax( 0, 1fr ) );
	}
}

@media ( max-width: 600px ) {
	.bil-grid {
		grid-template-columns: 1fr;
	}

	.bil-lightbox {
		padding: 12px 8px;
	}

	.bil-lightbox__dialog {
		max-height: 94vh;
	}

	.bil-lightbox__nav {
		width: 40px;
		height: 40px;
		font-size: 28px;
	}

	.bil-lightbox__nav--prev {
		left: 4px;
	}

	.bil-lightbox__nav--next {
		right: 4px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.bil-card,
	.bil-card__image,
	.bil-lightbox__backdrop,
	.bil-lightbox__dialog {
		transition: none;
		animation: none;
	}

	.bil-grid .bil-card:hover,
	.bil-grid .bil-card:focus-within {
		transform: none;
	}

	.bil-grid .bil-card:hover .bil-card__image,
	.bil-grid .bil-card:focus-within .bil-card__image {
		transform: none;
	}
}
