/**
 * RepoStage — Gallery showcase block
 */

.wp-block-repostage-gallery-showcase.rs-gallery,
.rs-gallery {
	width: 100%;
	max-width: 100%;
	margin-left: auto;
	margin-right: auto;
	box-sizing: border-box;
	padding-block: 3.5rem;
}

.rs-gallery__main {
	width: 100%;
	max-width: 100%;
	line-height: 0;
	margin: 0 auto;
}

.rs-gallery__main-trigger {
	display: block;
	width: 100%;
	padding: 0;
	margin: 0;
	border: none;
	cursor: zoom-in;
	line-height: 0;
	background-color: var(--rs-gray-100, #f3f3f3);
	background-size: contain;
	background-position: center;
	background-repeat: no-repeat;
	aspect-ratio: 16 / 9;
	max-height: min(88vh, 1100px);
	touch-action: pan-y;
}

.rs-gallery__strip-outer {
	width: 100%;
	max-width: 100%;
	overflow: hidden;
	margin: 1rem auto 0;
	position: relative;
	touch-action: pan-y;
}

/* ПК: слева столбик миниатюр; справа основное фото — ширина по контейнеру, высота не более 500px (как раньше) */
@media (min-width: 1024px) {
	.wp-block-repostage-gallery-showcase.rs-gallery,
	.rs-gallery {
		display: flex;
		flex-direction: row;
		align-items: flex-start;
		gap: 1rem;
		box-sizing: border-box;
	}

	.rs-gallery__main {
		flex: 1;
		min-width: 0;
		width: auto;
		order: 2;
	}

	.rs-gallery__main-trigger {
		width: 100%;
		height: auto;
		aspect-ratio: 16 / 9;
		max-height: min(500px, 88vh);
		background-size: contain;
		background-position: center;
	}

	.rs-gallery__strip-outer {
		order: 1;
		flex-shrink: 0;
		width: auto;
		min-width: 0;
		margin: 0;
		align-self: flex-start;
		touch-action: pan-x;
		overflow: hidden;
		/* max-height задаётся в view.js = высоте основного кадра — лишние миниатюры скрыты по вертикали */
	}
}

.rs-gallery__strip {
	display: flex;
	flex-wrap: nowrap;
	align-items: stretch;
	gap: 10px;
	width: max-content;
	transition: transform 0.35s ease;
	will-change: transform;
}

/* Мобилка: миниатюры в ряд снизу; десктоп: столбик слева (см. выше — порядок flex на .rs-gallery) */
@media (max-width: 1023px) {
	.rs-gallery__strip {
		flex-direction: row;
	}
}

@media (min-width: 1024px) {
	.rs-gallery__strip {
		flex-direction: column;
		width: max-content;
		height: max-content;
	}
}

.rs-gallery__thumb {
	display: block;
	padding: 0;
	margin: 0;
	border: 2px solid transparent;
	border-radius: 0;
	cursor: pointer;
	overflow: hidden;
	line-height: 0;
	flex-shrink: 0;
	box-sizing: border-box;
	aspect-ratio: 1;
	background-color: var(--rs-gray-100, #f3f3f3);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	transition: border-color 0.15s ease, opacity 0.15s ease;
	opacity: 0.75;
}

.rs-gallery__thumb:hover,
.rs-gallery__thumb.is-active {
	opacity: 1;
	border-color: var(--rs-primary, #8b0000);
}

/* Editor */
.rs-gallery--editor .rs-gallery__placeholder {
	padding: 2rem;
	text-align: center;
	border: 2px dashed var(--rs-gray-300, #d4d4d4);
	border-radius: 4px;
	background: var(--rs-gray-50, #f9f9f9);
}

.rs-gallery__editor-panel {
	width: 100%;
	max-width: 100%;
	margin-left: auto;
	margin-right: auto;
}

.rs-gallery__editor-hint {
	font-size: 12px;
	color: var(--rs-gray-600, #525252);
	margin: 0 0 0.75rem;
	line-height: 1.4;
}

.rs-gallery__editor-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: flex-start;
}

.rs-gallery__editor-cell {
	position: relative;
	width: 120px;
	height: 120px;
	border-radius: 0;
	overflow: hidden;
	border: 1px solid var(--rs-gray-200, #e5e5e5);
	background: var(--rs-gray-100, #f3f3f3);
	flex-shrink: 0;
}

.rs-gallery__editor-thumb {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.rs-gallery__editor-thumb--loading {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	color: var(--rs-gray-400, #a3a3a3);
}

.rs-gallery__editor-remove {
	position: absolute !important;
	top: 2px;
	right: 2px;
	min-width: 24px !important;
	height: 24px !important;
	padding: 0 !important;
	line-height: 1;
	font-size: 18px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.55) !important;
	color: #fff !important;
}

.rs-gallery__editor-remove:hover {
	background: rgba(180, 0, 0, 0.9) !important;
	color: #fff !important;
}

.rs-gallery__editor-add {
	width: 120px;
	height: 120px;
	border: 2px dashed var(--rs-gray-300, #d4d4d4);
	border-radius: 4px;
	background: var(--rs-gray-50, #f9f9f9);
	font-size: 2rem;
	line-height: 1;
	color: var(--rs-gray-500, #737373);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
	flex-shrink: 0;
}

.rs-gallery__editor-add:hover {
	border-color: var(--rs-primary, #8b0000);
	color: var(--rs-primary, #8b0000);
	background: #fff;
}

.rs-gallery__editor-note {
	font-size: 13px;
	color: var(--rs-gray-600, #525252);
	margin: 0;
	padding: 1rem;
	background: var(--rs-gray-50, #f9f9f9);
	border-radius: 4px;
}

/* Lightbox */
body.rs-gallery-lightbox-open {
	overflow: hidden;
}

.rs-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: rgba(0, 0, 0, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	box-sizing: border-box;
}

.rs-gallery-lightbox__img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.rs-gallery-lightbox__close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	width: 3rem;
	height: 3rem;
	font-size: 2rem;
	line-height: 1;
	color: #fff;
	background: transparent;
	border: none;
	cursor: pointer;
	z-index: 2;
}

.rs-gallery-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 3rem;
	height: 4rem;
	font-size: 2rem;
	color: #fff;
	background: rgba(255, 255, 255, 0.1);
	border: none;
	cursor: pointer;
	z-index: 2;
}

.rs-gallery-lightbox__prev {
	left: 1rem;
}

.rs-gallery-lightbox__next {
	right: 1rem;
}
