/* Kookaburra Grid - front-end styles. Theme-independent. */

.kbg-grid {
	display: grid;
	grid-template-columns: repeat(var(--kbg-columns, 3), 1fr);
	gap: var(--kbg-gap, 16px);
	max-width: var(--kbg-grid-max-width, none);
	padding: var(--kbg-grid-padding, 0);
	background-color: var(--kbg-grid-bg, transparent);
	background-image: var(--kbg-grid-bg-image, none);
	background-size: var(--kbg-grid-bg-size, cover);
	background-position: var(--kbg-grid-bg-position, center center);
	background-repeat: var(--kbg-grid-bg-repeat, no-repeat);
	background-attachment: var(--kbg-grid-bg-attachment, scroll);
	border: var(--kbg-grid-border, none);
	border-radius: var(--kbg-grid-radius, 0);
	box-shadow: var(--kbg-grid-shadow, none);
	box-sizing: border-box;
}

.kbg-grid.kbg-align-left {
	margin-left: 0;
	margin-right: auto;
}

.kbg-grid.kbg-align-center {
	margin-left: auto;
	margin-right: auto;
}

.kbg-grid.kbg-align-right {
	margin-left: auto;
	margin-right: 0;
}

@media (max-width: 1024px) {
	.kbg-grid {
		grid-template-columns: repeat(var(--kbg-columns-tablet, 2), 1fr);
	}
}

@media (max-width: 600px) {
	.kbg-grid {
		grid-template-columns: repeat(var(--kbg-columns-mobile, 1), 1fr);
	}
}

.kbg-grid .kbg-tile {
	position: relative;
	display: block;
	overflow: hidden;
	text-decoration: none;
	border-radius: var(--kbg-tile-radius, 4px);
	background-color: var(--kbg-tile-bg, #111) !important;
	background-image: none !important;
	border: var(--kbg-tile-border, none);
	box-shadow: var(--kbg-tile-shadow, none);
}

.kbg-tile:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
}

.kbg-grid .kbg-tile-image {
	display: block;
	width: 100%;
	height: 100%;
	background-color: var(--kbg-tile-bg, #111) !important;
}

.kbg-tile-image[style*="aspect-ratio"] {
	overflow: hidden;
}

.kbg-tile-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.kbg-fit-contain .kbg-tile-image img {
	object-fit: contain;
}

.kbg-grid .kbg-tile-no-image {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	background-color: var(--kbg-tile-bg, #111) !important;
	background-image: none !important;
}

.kbg-tile-overlay {
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: var(--kbg-overlay-opacity, 0.6);
	transition: opacity 0.3s ease;
}

.kbg-tile-text {
	position: absolute;
	inset-inline: 0;
	padding: var(--kbg-tile-padding, 0.9em 1em);
	display: flex;
	flex-direction: column;
	gap: 0.25em;
	line-height: 1.3;
	z-index: 1;
}

.kbg-pos-top .kbg-tile-text {
	top: 0;
	justify-content: flex-start;
}

.kbg-pos-center .kbg-tile-text {
	top: 50%;
	transform: translateY(-50%);
}

.kbg-pos-bottom .kbg-tile-text {
	bottom: 0;
	justify-content: flex-end;
}

/* Per-tile position overrides. */
.kbg-tile.kbg-tile-pos-top .kbg-tile-text {
	top: 0;
	bottom: auto;
	transform: none;
	justify-content: flex-start;
}

.kbg-tile.kbg-tile-pos-center .kbg-tile-text {
	top: 50%;
	bottom: auto;
	transform: translateY(-50%);
}

.kbg-tile.kbg-tile-pos-bottom .kbg-tile-text {
	top: auto;
	bottom: 0;
	transform: none;
	justify-content: flex-end;
}

.kbg-tile-title {
	font-weight: 600;
	font-size: var(--kbg-title-size, 1rem);
	text-shadow: var(--kbg-title-shadow, none);
}

.kbg-tile-subtitle {
	font-size: var(--kbg-subtitle-size, 0.85rem);
	text-shadow: var(--kbg-subtitle-shadow, none);
	opacity: 0.9;
}

/* Overlay visibility modes. */
.kbg-overlay-hover .kbg-tile-overlay {
	opacity: 0;
	transition: opacity 0.3s ease;
}

.kbg-overlay-hover .kbg-tile:hover .kbg-tile-overlay,
.kbg-overlay-hover .kbg-tile:focus-visible .kbg-tile-overlay {
	opacity: var(--kbg-overlay-opacity, 0.6);
}

.kbg-overlay-hidden .kbg-tile-overlay,
.kbg-overlay-hidden .kbg-tile-text {
	display: none;
}

/* Hover transition effects. */
.kbg-hover-zoom .kbg-tile .kbg-tile-image img,
.kbg-hover-lift .kbg-tile .kbg-tile-image img {
	transition: transform 0.3s ease;
}

.kbg-hover-zoom .kbg-tile:hover .kbg-tile-image img,
.kbg-hover-zoom .kbg-tile:focus-visible .kbg-tile-image img {
	transform: scale(1.04);
}

.kbg-hover-lift .kbg-tile {
	transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kbg-hover-lift .kbg-tile:hover,
.kbg-hover-lift .kbg-tile:focus-visible {
	transform: translateY(-4px);
}

.kbg-hover-reveal .kbg-tile-overlay {
	opacity: 0;
	transition: opacity 0.3s ease;
}

.kbg-hover-reveal .kbg-tile:hover .kbg-tile-overlay,
.kbg-hover-reveal .kbg-tile:focus-visible .kbg-tile-overlay {
	opacity: var(--kbg-overlay-opacity, 0.6);
}

@media (prefers-reduced-motion: reduce) {
	.kbg-tile,
	.kbg-tile-image img,
	.kbg-tile-overlay,
	.kbg-tile-text {
		transition: none !important;
	}
}

/* Lightbox for media grids. */
.kbg-lb-active {
	overflow: hidden;
}

.kbg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.9);
}

.kbg-lightbox.kbg-lb-open {
	display: flex;
}

.kbg-lb-figure {
	margin: 0;
	max-width: 90vw;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.kbg-lb-img {
	max-width: 90vw;
	max-height: 82vh;
	object-fit: contain;
}

.kbg-lightbox.kbg-lb-fill .kbg-lb-img {
	width: 90vw;
	height: 82vh;
	object-fit: contain;
}

.kbg-lb-caption {
	color: #fff;
	padding-top: 0.75em;
	font-size: 0.95rem;
}

.kbg-lb-counter {
	color: rgba(255, 255, 255, 0.7);
	font-size: 0.85rem;
	padding-top: 0.25em;
}

.kbg-lb-close,
.kbg-lb-prev,
.kbg-lb-next {
	position: absolute;
	background: rgba(255, 255, 255, 0.1);
	border: 0;
	color: #fff;
	font-size: 2rem;
	line-height: 1;
	padding: 0.4em 0.5em;
	cursor: pointer;
	border-radius: 4px;
}

.kbg-lb-close:hover,
.kbg-lb-prev:hover,
.kbg-lb-next:hover,
.kbg-lb-close:focus-visible,
.kbg-lb-prev:focus-visible,
.kbg-lb-next:focus-visible {
	background: rgba(255, 255, 255, 0.25);
	outline: 2px solid #fff;
}

.kbg-lb-close {
	top: 16px;
	right: 16px;
}

.kbg-lb-prev {
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
}

.kbg-lb-next {
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
}

/* Grid-aware post navigation. */
.kbg-post-nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100%;
	gap: 24px;
	margin-top: 2em;
	padding-top: 1em;
	border-top: 1px solid rgba(128, 128, 128, 0.3);
}

.kbg-post-nav {
	font-size: var(--kbg-nav-font-size, 16px);
}

.kbg-nav-prev,
.kbg-nav-next,
.kbg-nav-back {
	text-decoration: none;
	font-weight: 600;
}

.kbg-nav-links .kbg-nav-prev,
.kbg-nav-links .kbg-nav-next {
	color: var(--kbg-nav-color, inherit);
}

.kbg-nav-back {
	font-weight: 400;
	opacity: 0.8;
}

.kbg-back-links .kbg-nav-back {
	color: var(--kbg-back-color, inherit);
}

.kbg-nav-buttons .kbg-nav-prev,
.kbg-nav-buttons .kbg-nav-next {
	display: inline-block;
	padding: 0.6em 1.4em;
	background: var(--kbg-nav-button-bg, #222);
	color: var(--kbg-nav-button-text, #fff);
	border-radius: var(--kbg-nav-button-radius, 4px);
	transition: filter 0.2s ease;
}

.kbg-post-nav.kbg-back-buttons .kbg-nav-back {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.6em 1.4em;
	background-color: var(--kbg-back-button-bg, #555) !important;
	background-image: none !important;
	color: var(--kbg-back-button-text, #fff) !important;
	border: 0;
	border-radius: var(--kbg-back-button-radius, 4px);
	text-decoration: none;
	transition: filter 0.2s ease;
	opacity: 1;
	font-weight: 600;
}

.kbg-nav-buttons .kbg-nav-prev:hover,
.kbg-nav-buttons .kbg-nav-next:hover,
.kbg-back-buttons .kbg-nav-back:hover {
	filter: brightness(1.15);
}

.kbg-nav-spacer {
	flex: 0 0 auto;
}
