/* Certificate gallery (Projects page) — premium logo-focused cards:
   blurred certificate background, centered transparent logo, minimal
   full-bleed lightbox. Native scroll track; the script adds slow RTL autoplay (pauses on hover/drag/touch/focus),
   mouse drag and a seamless loop. Without JS (or with too few cards) it is a plain scroll-snap strip. */

.pejvak-cg {
	--pejvak-cg-blue: #233A7A;
	--pejvak-cg-cyan: #29AAE1;
	position: relative;
	display: flex;
	align-items: center;
	direction: rtl;
}

/* PASS 18: gap 24px -> 18px (within the requested 16-20px card-gap
   target); the matching .pejvak-cg__slide column formula below was
   updated to 5 columns instead of 4, which is what actually brings
   the card width down to the ~190-220px target (at 24px/4 columns
   the cards measured ~267px wide - "oversized certificate cards"). */
.pejvak-cg__track {
	display: flex;
	gap: 18px;
	list-style: none;
	margin: 0;
	padding: 20px 4px 28px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	flex: 1 1 auto;
	scrollbar-width: thin;
	scrollbar-color: var(--pejvak-cg-blue) transparent;
}

.pejvak-cg__track::-webkit-scrollbar {
	height: 6px;
}

.pejvak-cg__track::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 10px;
}

/* The parent theme's `ul > li { list-style: outside none square }` is set on the <li> itself and beats the
   list-style:none inherited from the track, which drew a square marker beside every card (clones included,
   they carry the same class). Fixed on our own slides only. */
.pejvak-cg__slide {
	list-style: none;
}
.pejvak-cg__slide::marker {
	content: none;
}

.pejvak-cg__slide {
	flex: 0 0 calc((100% - 4 * 18px) / 5);
	scroll-snap-align: start;
}

.pejvak-cg__card {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 11px;
}

/* --- Autoplay / drag (classes are set by pejvak-cert-gallery.js) --- */
.pejvak-cg__slide.is-clone { display: none; }
.pejvak-cg.is-loop .pejvak-cg__slide.is-clone,
.pejvak-cg.is-measuring .pejvak-cg__slide.is-clone { display: block; }
.pejvak-cg.is-draggable .pejvak-cg__track {
	scroll-snap-type: none;   /* snapping would fight the programmatic and dragged scrolling */
	scroll-behavior: auto;
	scrollbar-width: none;
	cursor: grab;
	overscroll-behavior-x: contain;
}
.pejvak-cg.is-draggable .pejvak-cg__track::-webkit-scrollbar { display: none; }
.pejvak-cg.is-dragging .pejvak-cg__track,
.pejvak-cg.is-dragging .pejvak-cg__track * { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.pejvak-cg.is-dragging .pejvak-cg__frame { transform: none; pointer-events: none; }
.pejvak-cg__track:focus-visible { outline: 2px solid var(--pejvak-cg-cyan); outline-offset: 2px; border-radius: 12px; }
.pejvak-cg__logo, .pejvak-cg__bg { -webkit-user-drag: none; user-select: none; }

/* --- Card: blurred certificate background + centered logo --- */

.pejvak-cg__frame {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 4 / 5;
	padding: 0;
	border: none;
	border-radius: 16px;
	background: #EEF2F8;
	cursor: zoom-in;
	overflow: hidden;
	box-shadow: 0 4px 16px rgba(35, 58, 122, 0.1);
	transition: transform 350ms cubic-bezier(.22,.9,.32,1), box-shadow 350ms ease;
}

.pejvak-cg__bg {
	position: absolute;
	inset: -14px;
	background-size: cover;
	background-position: center;
	filter: blur(10px);
	transform: scale(1.06);
	transition: filter 350ms ease;
}

.pejvak-cg__scrim {
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.62);
	transition: background 350ms ease;
}

.pejvak-cg__logo-wrap {
	position: absolute;
	inset: 14%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pejvak-cg__logo {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
	filter: drop-shadow(0 6px 18px rgba(15, 23, 42, 0.16));
	transition: transform 350ms cubic-bezier(.22,.9,.32,1), filter 350ms ease;
}

/* Opaque-background logo source: blend its white backdrop into the card
   instead of showing it as a visible box (see no_alpha flag in PHP). */
.pejvak-cg__logo--blend {
	mix-blend-mode: multiply;
	filter: none;
}

.pejvak-cg__sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.pejvak-cg__frame:hover,
.pejvak-cg__frame:focus-visible {
	transform: translateY(-6px);
	box-shadow: 0 22px 48px rgba(35, 58, 122, 0.22);
	outline: none;
	z-index: 5;
}

.pejvak-cg__frame:hover .pejvak-cg__bg,
.pejvak-cg__frame:focus-visible .pejvak-cg__bg {
	filter: blur(6px);
}

.pejvak-cg__frame:hover .pejvak-cg__scrim,
.pejvak-cg__frame:focus-visible .pejvak-cg__scrim {
	background: rgba(255, 255, 255, 0.5);
}

.pejvak-cg__frame:hover .pejvak-cg__logo,
.pejvak-cg__frame:focus-visible .pejvak-cg__logo {
	transform: scale(1.1);
	filter: drop-shadow(0 10px 26px rgba(35, 58, 122, 0.32));
}

.pejvak-cg__frame:hover .pejvak-cg__logo--blend,
.pejvak-cg__frame:focus-visible .pejvak-cg__logo--blend {
	filter: none;
}

.pejvak-cg__caption {
	margin: 0;
	text-align: center;
	font-size: 14px;
	font-weight: 600;
	color: var(--pejvak-cg-blue);
	line-height: 1.6;
}

@media (max-width: 1024px) {
	.pejvak-cg__slide {
		flex-basis: calc((100% - 2 * 20px) / 3);
	}
	.pejvak-cg__track {
		gap: 20px;
	}
}

@media (max-width: 768px) {
	.pejvak-cg__slide {
		flex-basis: calc((100% - 16px) / 2);
	}
	.pejvak-cg__track {
		gap: 16px;
	}
		/* No hover on touch: hold the "active" look only while actually pressed */
	.pejvak-cg__frame:hover {
		transform: none;
		box-shadow: 0 4px 16px rgba(35, 58, 122, 0.1);
	}
	.pejvak-cg__frame:hover .pejvak-cg__bg {
		filter: blur(10px);
	}
	.pejvak-cg__frame:hover .pejvak-cg__logo {
		transform: none;
	}
	.pejvak-cg__frame:active {
		transform: scale(0.98);
	}
}

@media (max-width: 480px) {
	.pejvak-cg__slide {
		flex-basis: 84%;
	}
}

/* --- Lightbox: dark blurred backdrop, real pan & zoom viewer --- */

.pejvak-cg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	/* Delay the visibility flip until the opacity transition finishes so
	   closing (incl. click-outside) actually fades out instead of
	   snapping away instantly. */
	transition: opacity 300ms ease, visibility 0s linear 300ms;
}

.pejvak-cg-lightbox.is-open {
	opacity: 1;
	visibility: visible;
	/* Opening: become visible/interactive immediately, only opacity fades in. */
	transition: opacity 300ms ease, visibility 0s linear 0s;
}

.pejvak-cg-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 14, 28, 0.78);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}

/* Stage: fixed viewport for the viewer, clips panned/zoomed content */
.pejvak-cg-lightbox__stage {
	position: relative;
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	touch-action: none;
}

.pejvak-cg-lightbox__content {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transform-origin: center center;
	will-change: transform;
	opacity: 0;
	transition: opacity 350ms ease, transform 350ms cubic-bezier(.22,.9,.32,1);
}

.pejvak-cg-lightbox.is-open .pejvak-cg-lightbox__content {
	opacity: 1;
}

.pejvak-cg-lightbox__content.is-interacting {
	transition: none;
}

.pejvak-cg-lightbox__stage img {
	display: block;
	border-radius: 8px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
	-webkit-user-drag: none;
	user-select: none;
	pointer-events: none;
}

.pejvak-cg-lightbox__stage.can-pan {
	cursor: grab;
}

.pejvak-cg-lightbox__stage.is-panning {
	cursor: grabbing;
}

.pejvak-cg-lightbox__caption {
	position: fixed;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	direction: rtl;
	font-size: 14px;
	font-weight: 600;
	color: #fff;
	background: rgba(15, 23, 42, 0.55);
	padding: 6px 18px;
	border-radius: 999px;
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	z-index: 2;
	max-width: 70vw;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pejvak-cg-lightbox__close {
	position: fixed;
	top: 20px;
	left: 20px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 200ms ease, transform 200ms ease;
	z-index: 3;
}

.pejvak-cg-lightbox__close:hover {
	background: var(--pejvak-cg-cyan);
	transform: scale(1.06);
}

.pejvak-cg-lightbox__zoom {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px;
	border-radius: 999px;
	background: rgba(15, 23, 42, 0.55);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	z-index: 2;
}

.pejvak-cg-lightbox__zbtn {
	width: 44px;
	height: 44px;
	flex: 0 0 auto;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 200ms ease;
}

.pejvak-cg-lightbox__zbtn:hover {
	background: var(--pejvak-cg-cyan);
}

.pejvak-cg-lightbox__zbtn--reset svg {
	width: 16px;
	height: 16px;
}

.pejvak-cg-lightbox__zpct {
	min-width: 48px;
	text-align: center;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	direction: ltr;
}

@media (max-width: 600px) {
	.pejvak-cg-lightbox__close {
		top: 12px;
		left: 12px;
		width: 44px;
		height: 44px;
	}
	.pejvak-cg-lightbox__caption {
		top: 12px;
		max-width: 56vw;
		font-size: 13px;
	}
	.pejvak-cg-lightbox__zoom {
		bottom: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pejvak-cg-lightbox,
	.pejvak-cg-lightbox__content,
	.pejvak-cg-lightbox__close,
	.pejvak-cg-lightbox__zbtn {
		transition: none !important;
	}
}
