/* ============================================================
   Gallery Editor - Frontend Styles
   ============================================================ */

/* ---- Back-to-collection link ---- */
.ge-back-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 20px;
	font-size: 14px;
	text-decoration: none;
	opacity: 0.65;
	transition: opacity 0.2s;
}

.ge-back-link:hover {
	opacity: 1;
	text-decoration: underline;
}

/* ---- Justified grid ---- */
.ge-gallery-grid {
	width: 100%;
	min-width: 0; /* prevent flex-child overflow */
}

.ge-gallery-row {
	display: flex;
	gap: 10px;
	margin-bottom: 10px;
}

.ge-gallery-row:last-child {
	margin-bottom: 0;
}

.ge-grid-item {
	position: relative;
	overflow: hidden;
	background: #e8e8e8;
	cursor: pointer;
	flex-shrink: 0;
}

.ge-grid-item:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 2px;
}

.ge-thumb {
	/* Absolutely fill the container — defeats any intrinsic-size interference
	   from the width/height attributes browsers use for aspect-ratio hints. */
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: opacity 0.35s ease;
	opacity: 0;
}

.ge-thumb.ge-loaded {
	opacity: 1;
}

/* ---- Play icon overlay (video items) ---- */
.ge-play-icon {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.ge-play-icon svg {
	width: 52px;
	height: 52px;
	filter: drop-shadow(0 2px 8px rgba(0,0,0,.5));
	transition: transform 0.2s;
}

.ge-grid-item:hover .ge-play-icon svg {
	transform: scale(1.12);
}

/* ---- Caption overlay ---- */
.ge-caption {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 28px 12px 10px;
	background: linear-gradient(transparent, rgba(0,0,0,.6));
	color: #fff;
	font-size: 13px;
	line-height: 1.4;
	opacity: 0;
	transition: opacity 0.25s;
}

.ge-grid-item:hover .ge-caption {
	opacity: 1;
}

/* ============================================================
   Lightbox
   ============================================================ */
.ge-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: rgba(0,0,0,.93);
	display: flex;
	align-items: center;
	justify-content: center;
}

.ge-lb-inner {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	cursor: default;
}

/* ---- Hover zone cursors ---- */
/* Left zone: circle with left-pointing chevron */
.ge-lb-inner.ge-lb-hover-left {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='18' fill='rgba(0,0,0,.5)'/%3E%3Cpolyline points='23,12 15,20 23,28' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 20 20, w-resize;
}
/* Right zone: circle with right-pointing chevron */
.ge-lb-inner.ge-lb-hover-right {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='18' fill='rgba(0,0,0,.5)'/%3E%3Cpolyline points='17,12 25,20 17,28' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 20 20, e-resize;
}
/* Center zone: 2-row × 3-col thumbnail grid — click closes the lightbox */
.ge-lb-inner.ge-lb-hover-center {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='28' viewBox='0 0 40 28'%3E%3Crect x='1' y='1' width='10' height='10' rx='1.5' fill='white' opacity='.9'/%3E%3Crect x='15' y='1' width='10' height='10' rx='1.5' fill='white' opacity='.9'/%3E%3Crect x='29' y='1' width='10' height='10' rx='1.5' fill='white' opacity='.9'/%3E%3Crect x='1' y='17' width='10' height='10' rx='1.5' fill='white' opacity='.9'/%3E%3Crect x='15' y='17' width='10' height='10' rx='1.5' fill='white' opacity='.9'/%3E%3Crect x='29' y='17' width='10' height='10' rx='1.5' fill='white' opacity='.9'/%3E%3C/svg%3E") 20 14, zoom-out;
}

/* Navigation is handled entirely via custom cursors on desktop and swipe on mobile */

/* ---- Close button ---- */
.ge-lb-close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 10;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: rgba(255,255,255,.15);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	backdrop-filter: blur(4px);
}

.ge-lb-close:hover { background: rgba(255,255,255,.28); }

/* ---- Media area ---- */
.ge-lb-media {
	max-width: 90vw;
	max-height: 90vh;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.ge-lb-img {
	max-width: 90vw;
	max-height: 90vh;
	object-fit: contain;
	border-radius: 2px;
	display: block;
	opacity: 0;
	transition: opacity 0.25s, transform 0.42s cubic-bezier(0.2, 0, 0, 1);
	transform-origin: center center;
	will-change: transform, opacity;
}

.ge-lb-media.ge-lb-loaded .ge-lb-img { opacity: 1; }

.ge-lb-iframe {
	width: min(900px, 90vw);
	height: min(506px, calc(90vh - 60px));
	border: none;
	border-radius: 2px;
	display: block;
	opacity: 0;
	transition: opacity 0.3s;
}

.ge-lb-media.ge-lb-loaded .ge-lb-iframe { opacity: 1; }

/* ---- Caption ---- */
.ge-lb-caption {
	position: absolute;
	bottom: 16px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255,255,255,.85);
	font-size: 14px;
	text-align: center;
	padding: 0 24px;
	max-width: 600px;
	pointer-events: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---- Loading spinner ---- */
.ge-lb-media::after {
	content: '';
	position: absolute;
	width: 36px;
	height: 36px;
	border: 3px solid rgba(255,255,255,.2);
	border-top-color: rgba(255,255,255,.8);
	border-radius: 50%;
	animation: ge-spin 0.7s linear infinite;
	pointer-events: none;
}

.ge-lb-media.ge-lb-loaded::after { display: none; }

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

/* ---- Touch devices: no arrows, swipe only ---- */
@media ( hover: none ) {
	.ge-lb-inner::before,
	.ge-lb-inner::after { display: none !important; }
	/* Restore default cursor — no hover zones needed on touch */
	.ge-lb-inner,
	.ge-lb-inner.ge-lb-hover-left,
	.ge-lb-inner.ge-lb-hover-right,
	.ge-lb-inner.ge-lb-hover-center { cursor: default; }
}

/* ---- Small screens ---- */
@media ( max-width: 600px ) {
	.ge-gallery-row { gap: 5px; margin-bottom: 5px; }
	.ge-lb-media { max-width: 100vw; max-height: calc(100vh - 80px); }
	.ge-lb-img   { max-height: calc(100vh - 80px); }
}

/* ============================================================
   Masonry layout
   ============================================================ */
.ge-masonry-cols {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	width: 100%;
}

.ge-masonry-col {
	display: flex;
	flex-direction: column;
	gap: 10px;
	flex-shrink: 0;
}

/* Masonry items have fixed height set by JS (except text) */
.ge-masonry-col .ge-grid-item {
	width: 100%;
	flex-shrink: 0;
}

/* Text blocks in masonry expand to content height */
.ge-masonry-col .ge-grid-item[data-type="text"] {
	height: auto !important;
}

@media ( max-width: 768px ) {
	.ge-masonry-cols { gap: 6px; }
	.ge-masonry-col  { gap: 6px; }
}

/* ============================================================
   Text blocks (frontend)
   ============================================================ */
.ge-grid-item[data-type="text"] {
	background: #fff;
	cursor: default;
}

.ge-text-block {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	padding: 20px 24px;
	box-sizing: border-box;
}

/* Masonry text blocks don't stretch height */
.ge-masonry-col .ge-text-block {
	align-items: flex-start;
	height: auto;
}

.ge-text-block p {
	margin: 0;
	/* Inherit the page's body font — no override */
	font-size: inherit;
	line-height: inherit;
	color: inherit;
	word-break: break-word;
	overflow-wrap: break-word;
}
