/* External URL Gallery — estils
   Els colors de fons/text s'adapten automàticament amb prefers-color-scheme,
   i també amb classes/atributs habituals que fan servir plugins de mode fosc
   (html.dark-mode, body.dark-mode, [data-theme="dark"], etc). */

.eug-gallery {
	--eug-accent: #F86900;

	--eug-bg: #f4f4f6;
	--eug-bg-elevated: #ffffff;
	--eug-text: #1b1b1f;
	--eug-border: rgba(0, 0, 0, 0.1);
	--eug-dot-inactive: rgba(0, 0, 0, 0.25);
	--eug-overlay-btn-bg: rgba(0, 0, 0, 0.45);
	--eug-overlay-btn-color: #ffffff;
	--eug-scrollbar-track: rgba(0, 0, 0, 0.06);
	--eug-scrollbar-thumb: rgba(0, 0, 0, 0.25);

	max-width: 100%;
	box-sizing: border-box;
	font-family: inherit;
	color: var(--eug-text);
	background: var(--eug-bg);
	border: 1px solid var(--eug-border);
	border-radius: 12px;
	padding: 12px;
}

.eug-gallery *,
.eug-gallery *::before,
.eug-gallery *::after {
	box-sizing: border-box;
}

/* Tema fosc automàtic segons preferències del sistema */
@media (prefers-color-scheme: dark) {
	.eug-gallery {
		--eug-bg: #1b1b1f;
		--eug-bg-elevated: #26262c;
		--eug-text: #f5f5f5;
		--eug-border: rgba(255, 255, 255, 0.12);
		--eug-dot-inactive: rgba(255, 255, 255, 0.35);
		--eug-scrollbar-track: rgba(255, 255, 255, 0.06);
		--eug-scrollbar-thumb: rgba(255, 255, 255, 0.28);
	}
}

/* Tema fosc forçat pel tema/plugin de WordPress (classes habituals) */
html.dark-mode .eug-gallery,
body.dark-mode .eug-gallery,
html.dark .eug-gallery,
body.dark .eug-gallery,
[data-theme="dark"] .eug-gallery {
	--eug-bg: #1b1b1f;
	--eug-bg-elevated: #26262c;
	--eug-text: #f5f5f5;
	--eug-border: rgba(255, 255, 255, 0.12);
	--eug-dot-inactive: rgba(255, 255, 255, 0.35);
	--eug-scrollbar-track: rgba(255, 255, 255, 0.06);
	--eug-scrollbar-thumb: rgba(255, 255, 255, 0.28);
}

/* Tema clar forçat (per si el fosc és el per defecte del tema) */
html.light-mode .eug-gallery,
body.light-mode .eug-gallery,
html.light .eug-gallery,
body.light .eug-gallery,
[data-theme="light"] .eug-gallery {
	--eug-bg: #f4f4f6;
	--eug-bg-elevated: #ffffff;
	--eug-text: #1b1b1f;
	--eug-border: rgba(0, 0, 0, 0.1);
	--eug-dot-inactive: rgba(0, 0, 0, 0.25);
	--eug-scrollbar-track: rgba(0, 0, 0, 0.06);
	--eug-scrollbar-thumb: rgba(0, 0, 0, 0.25);
}

/* ---------- Imatge principal ---------- */

.eug-main {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: var(--eug-bg-elevated);
	border-radius: 8px;
	overflow: hidden;
}

.eug-stage {
	position: relative;
	width: 100%;
	height: 100%;
}

.eug-slide {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.35s ease;
}

.eug-slide.is-active {
	opacity: 1;
	pointer-events: auto;
}

.eug-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: var(--eug-overlay-btn-bg);
	color: var(--eug-overlay-btn-color);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease;
	z-index: 2;
}

.eug-nav:hover,
.eug-nav:focus-visible {
	background: var(--eug-accent);
}

.eug-prev { left: 14px; }
.eug-next { right: 14px; }

.eug-fullscreen {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 34px;
	height: 34px;
	border: none;
	border-radius: 6px;
	background: var(--eug-overlay-btn-bg);
	color: var(--eug-overlay-btn-color);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background-color 0.2s ease;
	z-index: 2;
}

.eug-fullscreen:hover,
.eug-fullscreen:focus-visible {
	background: var(--eug-accent);
}

/* ---------- Miniatures ---------- */

.eug-thumbs {
	display: flex;
	gap: 8px;
	margin-top: 10px;
	overflow-x: auto;
	padding-bottom: 4px;
	scrollbar-width: thin;
	scrollbar-color: var(--eug-scrollbar-thumb) var(--eug-scrollbar-track);
}

.eug-thumbs::-webkit-scrollbar {
	height: 6px;
}

.eug-thumbs::-webkit-scrollbar-track {
	background: var(--eug-scrollbar-track);
	border-radius: 3px;
}

.eug-thumbs::-webkit-scrollbar-thumb {
	background: var(--eug-scrollbar-thumb);
	border-radius: 3px;
}

.eug-thumbs::-webkit-scrollbar-thumb:hover {
	background: var(--eug-accent);
}

.eug-thumb {
	flex: 0 0 auto;
	width: 96px;
	aspect-ratio: 16 / 9;
	padding: 0;
	border-radius: 6px;
	border: 2px solid transparent;
	overflow: hidden;
	cursor: pointer;
	background: none;
	opacity: 0.6;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

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

.eug-thumb:hover {
	opacity: 0.9;
}

.eug-thumb.is-active {
	opacity: 1;
	border-color: var(--eug-accent);
}

/* ---------- Punts de paginació ---------- */

.eug-dots {
	display: flex;
	justify-content: center;
	gap: 6px;
	margin-top: 10px;
}

.eug-dot {
	width: 22px;
	height: 4px;
	border-radius: 2px;
	background: var(--eug-dot-inactive);
	cursor: pointer;
	transition: background-color 0.2s ease, width 0.2s ease;
}

.eug-dot.is-active {
	background: var(--eug-accent);
	width: 32px;
}

/* ---------- Lightbox (pantalla completa amb zoom) ---------- */
/* Element independent, afegit una sola vegada a <body>, reutilitzat
   per totes les galeries de la pàgina. */

.eug-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.92);
}

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

.eug-lightbox-stage {
	position: relative;
	width: 92vw;
	height: 88vh;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none;
}

.eug-lightbox-img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	transform-origin: center center;
	cursor: zoom-in;
	will-change: transform;
}

.eug-lightbox-img.is-zoomed {
	cursor: grab;
}

.eug-lightbox-img.is-dragging {
	cursor: grabbing;
}

.eug-lightbox-close,
.eug-lightbox-nav {
	position: absolute;
	border: none;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease;
	z-index: 2;
}

.eug-lightbox-close:hover,
.eug-lightbox-nav:hover {
	background: var( --eug-lightbox-accent, #F86900 );
}

.eug-lightbox-close {
	top: 16px;
	right: 16px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	font-size: 22px;
	line-height: 1;
}

.eug-lightbox-nav {
	top: 50%;
	transform: translateY(-50%);
	width: 46px;
	height: 46px;
	border-radius: 50%;
	font-size: 20px;
}

.eug-lightbox-prev { left: 16px; }
.eug-lightbox-next { right: 16px; }

.eug-lightbox-counter {
	position: absolute;
	bottom: 16px;
	left: 50%;
	transform: translateX(-50%);
	color: #fff;
	font-size: 13px;
	opacity: 0.75;
	background: rgba(255, 255, 255, 0.12);
	padding: 4px 10px;
	border-radius: 12px;
}

.eug-lightbox-hint {
	position: absolute;
	bottom: 16px;
	right: 16px;
	color: #fff;
	font-size: 12px;
	opacity: 0.5;
}

@media (max-width: 782px) {
	.eug-lightbox-nav { width: 38px; height: 38px; }
	.eug-lightbox-hint { display: none; }
}

@media (max-width: 600px) {
	.eug-thumb {
		width: 72px;
	}
}

/* ---------- Editor del bloc (només admin) ---------- */

.eug-editor-panel {
	border: 1px dashed var(--eug-border, rgba(0, 0, 0, 0.15));
	border-radius: 8px;
	padding: 14px;
}

.eug-editor-panel > *:not(:last-child) {
	margin-bottom: 10px;
}

.eug-editor-empty {
	opacity: 0.6;
	font-style: italic;
}

.eug-editor-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.eug-editor-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 6px;
	border-radius: 4px;
	background: rgba(120, 120, 120, 0.08);
}

.eug-editor-thumb-preview {
	width: 40px;
	height: 28px;
	object-fit: cover;
	border-radius: 3px;
	flex-shrink: 0;
}

.eug-editor-url {
	flex: 1;
	font-size: 12px;
	opacity: 0.8;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.eug-editor-color-label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	margin-bottom: 6px;
}

.eug-editor-color-input {
	width: 100%;
	height: 32px;
	border: 1px solid var(--eug-border, rgba(0, 0, 0, 0.15));
	border-radius: 4px;
	padding: 2px;
	cursor: pointer;
}

.eug-editor-divider {
	border: none;
	border-top: 1px solid var(--eug-border, rgba(0, 0, 0, 0.15));
	margin: 12px 0;
}

.eug-editor-bulk-label {
	font-size: 12px;
	opacity: 0.75;
	margin: 0 0 4px;
}
