/* ─── Product Gallery Widget (npg-*) ───
 * Page bg (--nsimco-bg) shows between the model cards; each model is a
 * white card (--nsimco-card-bg) and tiles sit on --nsimco-table-bg,
 * matching the product detail widget.
 */

.npg-wrap {
	direction: rtl;
	text-align: right;
}

/* Header — on page background */
.npg-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 24px;
}

.npg-title {
	margin: 0;
	font-size: var(--nsimco-text-lg);
	font-weight: 800;
	color: var(--nsimco-primary);
}

.npg-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: var(--nsimco-radius-md);
	background: var(--nsimco-card-bg);
	color: var(--nsimco-secondary);
	font-size: var(--nsimco-text-sm);
	font-weight: 600;
	text-decoration: none;
	transition: color 0.2s ease, transform 0.15s ease;
}

.npg-back::before {
	content: "\2192";
}

.npg-back:hover {
	color: var(--nsimco-primary);
	transform: translateY(-1px);
}

/* Model cards */
.npg-sections {
	display: flex;
	flex-direction: column;
	gap: 32px;
}

.npg-section {
	background: var(--nsimco-card-bg);
	border-radius: var(--nsimco-radius-lg);
	padding: 24px;
	scroll-margin-top: 24px;
	overflow: hidden;
}

.npg-section:target {
	box-shadow: 0 0 0 2px var(--nsimco-button-bg);
}

.npg-model-title {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 16px;
	font-size: var(--nsimco-text-base);
	font-weight: 700;
}

.npg-model-name {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--nsimco-primary);
	text-decoration: none;
}

.npg-model-name:hover {
	color: var(--nsimco-primary);
}

.npg-name-icon {
	display: inline-flex;
	align-items: center;
}

.npg-name-icon img {
	width: 28px;
	height: 28px;
	object-fit: contain;
}

.npg-model-count {
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--nsimco-table-bg);
	color: var(--nsimco-muted);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.6;
}

/* ── Grid ── */
.npg-grid {
	display: grid;
	gap: 6px;
}

.npg-grid--uniform {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

/*
 * Explore: 4 columns, repeating every 18 tiles —
 * big tile on the right + 4 small, a row of 4,
 * 2 small + big tile on the left + 2 small, a row of 4.
 * Order on screen stays the same as the order in the editor.
 */
.npg-wrap .npg-grid.npg-grid--explore {
	grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.npg-grid--explore .npg-item:nth-child(18n + 1) {
	grid-column: span 2;
	grid-row: span 2;
}

.npg-grid--explore .npg-item:nth-child(18n + 12) {
	grid-column: 3 / span 2;
	grid-row: span 2;
}

.npg-item {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: var(--nsimco-radius-sm);
	background: var(--nsimco-table-bg);
	cursor: zoom-in;
}

.npg-item--video {
	cursor: pointer;
}

.npg-item img,
.npg-item video {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	border-radius: 0 !important;
	object-fit: cover;
	transition: transform 0.35s ease;
	pointer-events: none;
}

.npg-item::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0);
	transition: background 0.2s ease;
}

.npg-item:hover::after,
.npg-item:focus-visible::after {
	background: rgba(0, 0, 0, 0.18);
}

.npg-item:hover img,
.npg-item:hover video {
	transform: scale(1.05);
}

.npg-play {
	position: absolute;
	z-index: 2;
	top: 50%;
	left: 50%;
	width: clamp(40px, 34%, 84px);
	aspect-ratio: 1 / 1;
	border: 2px solid rgba(255, 255, 255, 0.9);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.5);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
	transform: translate(-50%, -50%);
	transition: transform 0.2s ease, background-color 0.2s ease;
	pointer-events: none;
}

.npg-play::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36%;
	height: 42%;
	background: #fff;
	clip-path: polygon(0 0, 100% 50%, 0 100%);
	transform: translate(-38%, -50%);
}

.npg-item:hover .npg-play {
	transform: translate(-50%, -50%) scale(1.08);
	background-color: rgba(0, 0, 0, 0.65);
}

.npg-empty {
	margin: 0;
	padding: 24px 16px;
	border-radius: var(--nsimco-radius-sm);
	background: var(--nsimco-table-bg);
	color: var(--nsimco-muted);
	font-size: var(--nsimco-text-sm);
	text-align: center;
}

/* ── Zoom viewer (slider) ── */
.npg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	flex-direction: column;
	background: rgba(12, 10, 12, 0.94);
	direction: rtl;
}

.npg-lightbox.is-open {
	display: flex;
}

.npg-lb-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	color: #fff;
	font-size: 14px;
	flex: 0 0 auto;
}

.npg-lb-counter {
	padding: 2px 10px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
	font-weight: 600;
	direction: ltr;
}

.npg-lb-caption {
	flex: 1 1 auto;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.npg-lb-track {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior: contain;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.npg-lb-track::-webkit-scrollbar {
	display: none;
}

.npg-lb-track.is-dragging {
	scroll-snap-type: none;
	cursor: grabbing;
}

.npg-lb-slide {
	flex: 0 0 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 64px 24px;
	box-sizing: border-box;
	scroll-snap-align: center;
	scroll-snap-stop: always;
}

.npg-lb-slide img,
.npg-lb-slide video {
	display: block;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: var(--nsimco-radius-md);
	user-select: none;
	-webkit-user-select: none;
	-webkit-user-drag: none;
}

.npg-lb-slide img {
	cursor: grab;
}

.npg-lb-slide video {
	width: auto;
	background: #000;
}

.npg-lb-btn {
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font-size: 26px;
	line-height: 44px;
	text-align: center;
	cursor: pointer;
	transition: background 0.2s ease;
}

.npg-lb-btn:hover,
.npg-lb-btn:focus-visible {
	background: rgba(255, 255, 255, 0.3);
	color: #fff;
}

.npg-lb-close {
	flex: 0 0 auto;
	margin-inline-start: auto;
}

.npg-lb-prev,
.npg-lb-next {
	position: absolute;
	top: 50%;
	margin-top: -22px;
}

.npg-lb-prev {
	right: 12px;
}

.npg-lb-next {
	left: 12px;
}

.npg-lb-prev svg,
.npg-lb-next svg {
	display: block;
	width: 22px;
	height: 22px;
	margin: auto;
}

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

@media (max-width: 767px) {
	.npg-sections {
		gap: 20px;
	}

	.npg-section {
		padding: 16px;
	}

	.npg-grid {
		gap: 3px;
	}

	.npg-grid--uniform {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.npg-item {
		border-radius: 4px;
	}

	/* Swipe replaces the arrows on touch screens. */
	.npg-lb-prev,
	.npg-lb-next {
		display: none;
	}

	.npg-lb-slide {
		padding: 0 0 16px;
	}

	.npg-lb-slide img,
	.npg-lb-slide video {
		border-radius: 0;
	}
}
