/* Front-end grid */
.houyukai-gallery {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 32px 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.houyukai-gallery--cols-4 {
	grid-template-columns: repeat(4, 1fr);
}

@media screen and (max-width: 1024px) {
	.houyukai-gallery--cols-4 {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media screen and (max-width: 767px) {
	.houyukai-gallery,
	.houyukai-gallery--cols-4 {
		grid-template-columns: repeat(2, 1fr);
		gap: 20px 16px;
	}
}

@media screen and (max-width: 480px) {
	.houyukai-gallery,
	.houyukai-gallery--cols-4 {
		grid-template-columns: 1fr;
	}
}

.houyukai-gallery-item {
	margin: 0;
}

.houyukai-gallery-item-link,
.houyukai-gallery-item-link--static {
	display: block;
	position: relative;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	/* border: 1px solid #c9c9c9; */
	background: #f5f5f5;
	border-radius: 16px;
}

.houyukai-gallery-item-link {
	cursor: zoom-in;
}

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

.houyukai-gallery-item-link:hover .houyukai-gallery-item-img {
	transform: scale(1.05);
}

.houyukai-gallery-item-caption {
	margin-top: 8px;
	font-size: 0.875rem;
	line-height: 1.6;
	text-align: center;
	color: #3c3d42;
}

/* Lightbox overlay */
.houyukai-lightbox {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 100000;
	align-items: center;
	justify-content: center;
	padding: 40px;
	background: rgba(0, 0, 0, 0.85);
}

.houyukai-lightbox.is-active {
	display: flex;
}

.houyukai-lightbox-stage {
	position: relative;
	z-index: 1;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.houyukai-lightbox-slide {
	position: absolute;
	inset: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	transition: transform 0.4s ease;
}

.houyukai-lightbox-slide.is-no-transition {
	transition: none;
}

.houyukai-lightbox-img {
	max-width: 100%;
	max-height: calc(100% - 48px);
	display: block;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.houyukai-lightbox-caption {
	margin-top: 16px;
	max-width: 80%;
	color: #fff;
	font-size: 0.95rem;
	line-height: 1.6;
	text-align: center;
}

.houyukai-lightbox-close {
	position: absolute;
	z-index: 2;
	top: 16px;
	right: 24px;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

.houyukai-lightbox-close:hover {
	background: rgba(255, 255, 255, 0.3);
}

.houyukai-lightbox-prev,
.houyukai-lightbox-next {
	position: absolute;
	z-index: 2;
	top: 50%;
	transform: translateY(-50%);
	width: 52px;
	height: 52px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	font-size: 36px;
	line-height: 1;
	cursor: pointer;
}

.houyukai-lightbox-prev {
	left: 16px;
}

.houyukai-lightbox-next {
	right: 16px;
}

.houyukai-lightbox-prev:hover,
.houyukai-lightbox-next:hover {
	background: rgba(255, 255, 255, 0.3);
}

@media screen and (max-width: 640px) {
	.houyukai-lightbox-prev,
	.houyukai-lightbox-next {
		width: 40px;
		height: 40px;
		font-size: 28px;
	}

	.houyukai-lightbox-prev {
		left: 4px;
	}

	.houyukai-lightbox-next {
		right: 4px;
	}
}

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

/* Editor */
.houyukai-gallery-editor-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 16px;
	margin-bottom: 16px;
}

.houyukai-gallery-editor-item {
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 12px;
	background: #fff;
	transition: opacity 0.15s ease;
}

.houyukai-gallery-editor-item.is-dragging {
	opacity: 0.4;
}

.houyukai-gallery-editor-item.is-drop-target {
	outline: 2px dashed #4c9a5d;
	outline-offset: 2px;
}

.houyukai-gallery-editor-item-handle {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	margin-bottom: 8px;
	padding: 4px 0;
	font-size: 12px;
	color: #555;
	background: #f0f0f0;
	border-radius: 3px;
	cursor: grab;
	-webkit-user-select: none;
	user-select: none;
	touch-action: none;
}

.houyukai-gallery-editor-item-handle:active {
	cursor: grabbing;
}

.houyukai-gallery-editor-item-thumb {
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	margin-bottom: 8px;
	padding: 0;
	border: 1px dashed #999;
	background: #f0f0f0;
	cursor: pointer;
	overflow: hidden;
}

.houyukai-gallery-editor-item-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.houyukai-gallery-editor-add {
	justify-content: center;
}
