/* ZIP Photo Gallery - front */

.zpg-gallery {
	--zpg-cols: 4;
	--zpg-cols-t: 3;
	--zpg-cols-m: 2;
	--zpg-gap: 8px;
	--zpg-radius: 4px;
	--zpg-ratio: 1/1;
	margin: 1.5em 0;
	clear: both;
}

.zpg-gallery .zpg-grid,
.zpg-gallery .zpg-item,
.zpg-gallery .zpg-figure {
	list-style: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}

.zpg-gallery .zpg-item::before,
.zpg-gallery .zpg-item::marker {
	content: none;
	display: none;
}

.zpg-gallery .zpg-grid {
	display: grid;
	grid-template-columns: repeat(var(--zpg-cols), minmax(0, 1fr));
	gap: var(--zpg-gap);
	align-items: start;
}

.zpg-gallery .zpg-item[hidden] {
	display: none !important;
}

.zpg-gallery .zpg-figure {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.zpg-gallery .zpg-link {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--zpg-radius);
	background: rgba(127, 127, 127, 0.12);
	aspect-ratio: var(--zpg-ratio);
	line-height: 0;
	text-decoration: none;
	box-shadow: none;
	outline-offset: 2px;
}

.zpg-gallery a.zpg-link {
	cursor: zoom-in;
}

.zpg-gallery[data-zpg-click="file"] a.zpg-link {
	cursor: pointer;
}

.zpg-gallery .zpg-link .zpg-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: cover;
	transition: transform 0.35s ease, opacity 0.35s ease;
}

.zpg-gallery a.zpg-link:hover .zpg-img,
.zpg-gallery a.zpg-link:focus-visible .zpg-img {
	transform: scale(1.04);
}

/* 元の比率 / メイソンリー */
.zpg-gallery.zpg-ratio-auto .zpg-link {
	aspect-ratio: auto;
}

.zpg-gallery.zpg-ratio-auto .zpg-link .zpg-img {
	height: auto;
}

.zpg-gallery.zpg-layout-masonry .zpg-grid {
	display: block;
	column-count: var(--zpg-cols);
	column-gap: var(--zpg-gap);
}

.zpg-gallery.zpg-layout-masonry .zpg-item {
	break-inside: avoid;
	page-break-inside: avoid;
	margin-bottom: var(--zpg-gap);
}

/* キャプション */
.zpg-gallery .zpg-caption {
	margin: 0.4em 0 0;
	padding: 0;
	font-size: 0.85em;
	line-height: 1.4;
	text-align: center;
	opacity: 0.8;
	overflow-wrap: anywhere;
}

.zpg-gallery .zpg-overlay {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 1.6em 0.75em 0.6em;
	color: #fff;
	font-size: 0.85em;
	line-height: 1.4;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.25s ease, transform 0.25s ease;
	pointer-events: none;
	overflow-wrap: anywhere;
}

.zpg-gallery .zpg-link:hover .zpg-overlay,
.zpg-gallery .zpg-link:focus-visible .zpg-overlay {
	opacity: 1;
	transform: none;
}

@media (hover: none) {
	.zpg-gallery .zpg-overlay {
		opacity: 1;
		transform: none;
	}
}

/* ページ送り */
.zpg-gallery .zpg-pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 6px;
	margin: 1.2em 0 0;
}

.zpg-gallery .zpg-pagination button {
	min-width: 2.4em;
	height: 2.4em;
	margin: 0;
	padding: 0 0.8em;
	border: 1px solid rgba(127, 127, 127, 0.35);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.zpg-gallery .zpg-pagination button:hover:not(:disabled) {
	border-color: currentColor;
}

.zpg-gallery .zpg-pagination button[aria-current="page"] {
	background: #222;
	border-color: #222;
	color: #fff;
	cursor: default;
}

.zpg-gallery .zpg-pagination button:disabled:not([aria-current]) {
	opacity: 0.35;
	cursor: default;
}

.zpg-gallery .zpg-pagination .zpg-ellipsis {
	padding: 0 0.2em;
	opacity: 0.6;
}

.zpg-notice {
	padding: 0.8em 1em;
	border-left: 4px solid #d63638;
	background: #fcf0f1;
	color: #1d2327;
	font-size: 0.9em;
}

/* レスポンシブ */
@media (max-width: 1024px) {
	.zpg-gallery .zpg-grid {
		grid-template-columns: repeat(var(--zpg-cols-t), minmax(0, 1fr));
	}
	.zpg-gallery.zpg-layout-masonry .zpg-grid {
		column-count: var(--zpg-cols-t);
	}
}

@media (max-width: 600px) {
	.zpg-gallery .zpg-grid {
		grid-template-columns: repeat(var(--zpg-cols-m), minmax(0, 1fr));
	}
	.zpg-gallery.zpg-layout-masonry .zpg-grid {
		column-count: var(--zpg-cols-m);
	}
}

/* ---------- ライトボックス ---------- */
html.zpg-lb-open,
html.zpg-lb-open body {
	overflow: hidden !important;
}

.zpg-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	-webkit-tap-highlight-color: transparent;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.zpg-lb[hidden] {
	display: none;
}

.zpg-lb.is-open {
	opacity: 1;
}

.zpg-lb-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 10, 12, 0.96);
}

.zpg-lb-stage {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	max-width: 100%;
	max-height: 100%;
	pointer-events: none;
}

.zpg-lb-img {
	display: block;
	max-width: calc(100vw - 140px);
	max-height: calc(100vh - 120px);
	max-height: calc(100dvh - 120px);
	width: auto;
	height: auto;
	margin: 0;
	border-radius: 2px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	pointer-events: auto;
	user-select: none;
	-webkit-user-drag: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.zpg-lb.is-loading .zpg-lb-img {
	opacity: 0.25;
}

.zpg-lb-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: zpg-spin 0.8s linear infinite;
	opacity: 0;
	transition: opacity 0.2s;
}

.zpg-lb.is-loading .zpg-lb-spinner {
	opacity: 1;
}

@keyframes zpg-spin {
	to {
		transform: rotate(360deg);
	}
}

.zpg-lb-caption {
	max-width: min(800px, 90vw);
	margin-top: 12px;
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
	color: rgba(255, 255, 255, 0.9);
	pointer-events: auto;
}

.zpg-lb-caption:empty {
	display: none;
}

.zpg-lb-counter {
	position: absolute;
	top: 18px;
	left: 20px;
	z-index: 2;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	color: rgba(255, 255, 255, 0.8);
}

.zpg-lb-btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font: inherit;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s;
}

.zpg-lb-btn:hover,
.zpg-lb-btn:focus-visible {
	background: rgba(255, 255, 255, 0.22);
	outline: none;
}

.zpg-lb-btn:focus-visible {
	box-shadow: 0 0 0 2px #fff;
}

.zpg-lb-btn svg {
	width: 24px;
	height: 24px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.zpg-lb-close {
	top: 10px;
	right: 12px;
}

.zpg-lb-prev,
.zpg-lb-next {
	top: 50%;
	margin-top: -24px;
}

.zpg-lb-prev {
	left: 14px;
}

.zpg-lb-next {
	right: 14px;
}

.zpg-lb.is-single .zpg-lb-prev,
.zpg-lb.is-single .zpg-lb-next,
.zpg-lb.is-single .zpg-lb-counter {
	display: none;
}

@media (max-width: 600px) {
	.zpg-lb-img {
		max-width: 100vw;
		max-height: calc(100vh - 140px);
		max-height: calc(100dvh - 140px);
		border-radius: 0;
	}
	.zpg-lb-prev,
	.zpg-lb-next {
		top: auto;
		bottom: 14px;
		margin-top: 0;
	}
	.zpg-lb-prev {
		left: calc(50% - 60px);
	}
	.zpg-lb-next {
		right: calc(50% - 60px);
	}
	.zpg-lb-caption {
		padding: 0 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.zpg-gallery .zpg-link .zpg-img,
	.zpg-lb,
	.zpg-lb-img {
		transition: none;
	}
	.zpg-gallery a.zpg-link:hover .zpg-img {
		transform: none;
	}
}
