/*
 * Tatoli Tiled Gallery – CSS
 * Compatible with tatolitheme (Bootstrap 5, dark mode)
 */

/* ───── Gallery Grid ───── */
.ttg-gallery {
	display: grid;
	gap: 4px;
	margin: 1rem 0 1.5rem;
	width: 100%;
}

/* Column variants */
.ttg-columns-1 { grid-template-columns: 1fr; }
.ttg-columns-2 { grid-template-columns: repeat(2, 1fr); }
.ttg-columns-3 { grid-template-columns: repeat(3, 1fr); }
.ttg-columns-4 { grid-template-columns: repeat(4, 1fr); }
.ttg-columns-5 { grid-template-columns: repeat(5, 1fr); }
.ttg-columns-6 { grid-template-columns: repeat(6, 1fr); }
.ttg-columns-7 { grid-template-columns: repeat(7, 1fr); }
.ttg-columns-8 { grid-template-columns: repeat(8, 1fr); }
.ttg-columns-9 { grid-template-columns: repeat(9, 1fr); }

/* ───── Gallery Item ───── */
.ttg-item {
	margin: 0;
	padding: 0;
	position: relative;
	overflow: hidden;
	border-radius: 3px;
	background: var(--bs-gray-100, #f8f9fa);
}

.ttg-item img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	object-fit: cover;
	transition: transform 0.3s ease, filter 0.3s ease;
}

.ttg-item-link {
	display: block;
	width: 100%;
	height: 100%;
	line-height: 0;
}

/* Hover effect */
.ttg-item:hover img {
	transform: scale(1.05);
	filter: brightness(0.85);
}

/* Overlay icon on hover */
.ttg-item-link::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M6.002 5.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z'/%3E%3Cpath d='M2.002 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2h-12zm12 1a1 1 0 0 1 1 1v6.5l-3.777-1.947a.5.5 0 0 0-.577.093l-3.71 3.71-2.66-1.772a.5.5 0 0 0-.63.062L1.002 12V3a1 1 0 0 1 1-1h12z'/%3E%3C/svg%3E") center center no-repeat;
	background-size: 28px 28px;
	opacity: 0;
	transition: opacity 0.3s ease, background-color 0.3s ease;
	pointer-events: none;
	border-radius: 3px;
}

.ttg-item-link:hover::after {
	opacity: 1;
	background-color: rgba(0, 0, 0, 0.25);
}

/* ───── Captions ───── */
.ttg-caption {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 6px 8px;
	margin: 0;
	font-size: 0.7rem;
	line-height: 1.3;
	color: #fff;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.ttg-item:hover .ttg-caption {
	opacity: 1;
}

/* ───── Responsive ───── */
@media (max-width: 767px) {
	.ttg-columns-4,
	.ttg-columns-5,
	.ttg-columns-6,
	.ttg-columns-7,
	.ttg-columns-8,
	.ttg-columns-9 {
		grid-template-columns: repeat(3, 1fr);
	}
	.ttg-columns-3 {
		grid-template-columns: repeat(2, 1fr);
	}
	.ttg-gallery {
		gap: 3px;
	}
}

@media (max-width: 480px) {
	.ttg-columns-3,
	.ttg-columns-4,
	.ttg-columns-5,
	.ttg-columns-6,
	.ttg-columns-7,
	.ttg-columns-8,
	.ttg-columns-9 {
		grid-template-columns: repeat(2, 1fr);
	}
	.ttg-gallery {
		gap: 2px;
	}
	.ttg-item-link::after {
		display: none; /* no hover on mobile */
	}
}

/* ───── Type: Tiled Mosaic ───── */
.ttg-type-tiled-mosaic {
	grid-template-columns: repeat(3, 1fr);
	grid-auto-rows: 180px;
	gap: 4px;
}

.ttg-type-tiled-mosaic .ttg-item:nth-child(5n+1) {
	grid-column: span 2;
	grid-row: span 2;
}

.ttg-type-tiled-mosaic .ttg-item:nth-child(5n+4) {
	grid-column: span 2;
}

@media (max-width: 767px) {
	.ttg-type-tiled-mosaic {
		grid-template-columns: repeat(2, 1fr);
		grid-auto-rows: 140px;
	}
	.ttg-type-tiled-mosaic .ttg-item:nth-child(5n+1) {
		grid-column: span 2;
		grid-row: span 1;
	}
	.ttg-type-tiled-mosaic .ttg-item:nth-child(5n+4) {
		grid-column: span 1;
	}
}

/* ───── Type: Square Tiles ───── */
.ttg-type-square-tiles .ttg-item {
	aspect-ratio: 1 / 1;
}

.ttg-type-square-tiles .ttg-item img {
	aspect-ratio: 1 / 1;
	object-fit: cover;
}

/* ───── Type: Circles ───── */
.ttg-type-circles {
	gap: 12px;
}

.ttg-type-circles .ttg-item {
	border-radius: 50%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

.ttg-type-circles .ttg-item img {
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 50%;
	transition: transform 0.4s ease;
}

.ttg-type-circles .ttg-item:hover img {
	transform: scale(1.1);
}

.ttg-type-circles .ttg-item-link::after {
	border-radius: 50%;
}

.ttg-type-circles .ttg-caption {
	border-radius: 0 0 50% 50%;
	text-align: center;
	padding: 0 8px 20%;
	font-size: 0.65rem;
}

@media (max-width: 767px) {
	.ttg-type-circles {
		gap: 8px;
	}
}

/* ───── Dark Mode (tatolitheme night-mode) ───── */
body.night-mode .ttg-item {
	background: var(--bs-gray-800, #343a40);
}

body.night-mode .ttg-item img {
	opacity: 0.92;
}

body.night-mode .ttg-item:hover img {
	opacity: 1;
}

/* ───── Override default WP gallery styles when plugin active ───── */
.ttg-gallery .gallery-item,
.ttg-gallery .gallery-icon,
.ttg-gallery .gallery-caption {
	all: unset;
}

/* ───── Magnific Popup override for tiled gallery ───── */
.mfp-bg {
	z-index: 100042;
}
.mfp-wrap {
	z-index: 100043;
}
