/* TOSA Drive Gallery */
.tosa-dg {
	--dg-cols: 4;
	--dg-gap: 8px;
	--dg-radius: 6px;
	--dg-placeholder: rgba(127, 127, 127, .18);
	--dg-btn-bg: transparent;
	--dg-btn-fg: inherit;
	width: 100%;
}

.tosa-dg__grid {
	display: grid;
	grid-template-columns: repeat(var(--dg-cols), minmax(0, 1fr));
	gap: var(--dg-gap);
}

.tosa-dg__item {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--dg-radius);
	background: var(--dg-placeholder);
	aspect-ratio: 1 / 1;
	cursor: zoom-in;
	outline-offset: 2px;
}

.tosa-dg__item img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity .35s ease, transform .5s ease;
}

.tosa-dg__item.is-loaded img { opacity: 1; }
.tosa-dg__item:hover img,
.tosa-dg__item:focus-visible img { transform: scale(1.04); }
.tosa-dg__item.is-error { display: none; }

/* Masonry */
.tosa-dg--masonry .tosa-dg__grid {
	display: block;
	column-count: var(--dg-cols);
	column-gap: var(--dg-gap);
}
.tosa-dg--masonry .tosa-dg__item {
	aspect-ratio: auto;
	margin-bottom: var(--dg-gap);
	break-inside: avoid;
	min-height: 120px;
}
.tosa-dg--masonry .tosa-dg__item.is-loaded { min-height: 0; }
.tosa-dg--masonry .tosa-dg__item img { height: auto; }

@media (max-width: 1024px) {
	.tosa-dg { --dg-cols: 3 !important; }
}
@media (max-width: 640px) {
	.tosa-dg { --dg-cols: 2 !important; --dg-gap: 4px !important; }
}

.tosa-dg__footer {
	text-align: center;
	margin-top: 24px;
}

.tosa-dg__more {
	appearance: none;
	border: 2px solid currentColor;
	border-radius: 999px;
	padding: 12px 32px;
	background: var(--dg-btn-bg);
	color: var(--dg-btn-fg);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: opacity .2s ease;
}
.tosa-dg__more:hover,
.tosa-dg__more:focus-visible { opacity: .75; }
.tosa-dg__more[hidden] { display: none; }

.tosa-dg__count {
	margin: 10px 0 0;
	font-size: 14px;
	opacity: .7;
}

/* Lightbox */
html.tosa-dg-lock { overflow: hidden; }

.tosa-dg-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: rgba(10, 10, 10, .94);
	display: flex;
	align-items: center;
	justify-content: center;
}
.tosa-dg-lb[hidden] { display: none; }

.tosa-dg-lb__stage {
	position: absolute;
	inset: 56px 64px 64px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.tosa-dg-lb__img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
	transition: opacity .2s ease;
}
.tosa-dg-lb.is-loading .tosa-dg-lb__img { opacity: .35; }

.tosa-dg-lb__spinner {
	position: absolute;
	width: 40px;
	height: 40px;
	border: 3px solid rgba(255, 255, 255, .25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: tosa-dg-spin .8s linear infinite;
	display: none;
}
.tosa-dg-lb.is-loading .tosa-dg-lb__spinner { display: block; }
@keyframes tosa-dg-spin { to { transform: rotate(360deg); } }

.tosa-dg-lb__btn {
	position: absolute;
	appearance: none;
	border: 0;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	font-size: 30px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background .2s ease;
}
.tosa-dg-lb__btn:hover,
.tosa-dg-lb__btn:focus-visible { background: rgba(255, 255, 255, .25); }
.tosa-dg-lb__close { top: 12px; right: 12px; }
.tosa-dg-lb__prev { left: 10px; top: 50%; transform: translateY(-50%); }
.tosa-dg-lb__next { right: 10px; top: 50%; transform: translateY(-50%); }

.tosa-dg-lb__bar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 16px;
	display: flex;
	gap: 20px;
	align-items: center;
	justify-content: center;
	color: rgba(255, 255, 255, .8);
	font-size: 14px;
}
.tosa-dg-lb__dl {
	color: #fff !important;
	text-decoration: underline;
}
.tosa-dg-lb__dl[hidden] { display: none; }

@media (max-width: 640px) {
	.tosa-dg-lb__stage { inset: 56px 8px 56px; }
	.tosa-dg-lb__prev, .tosa-dg-lb__next { top: auto; bottom: 6px; transform: none; width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
	.tosa-dg__item img, .tosa-dg-lb__img { transition: none; }
}
