/* Galeria Parallax 3D v3 - Estilos frontend aislados */

.gp3d-gallery,
.gp3d-gallery * {
	box-sizing: border-box;
}

.gp3d-gallery {
	--gp3d-bg:       #0d2137;
	--gp3d-bg-deep:  #050d1a;
	--gp3d-card:     #0d1b2a;
	--gp3d-card-deep:#0a1628;
	--gp3d-text:     #e2e8f0;
	--gp3d-accent:   #4fc3f7;
	--gp3d-gold:     #ffd700;

	width: 100%;
	max-width: 1400px;
	margin: 0 auto;
	position: relative;
	isolation: isolate;
	overflow: hidden;
	color: var(--gp3d-text);
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

	/*
	 * AJUSTE 1: el fondo usa la variable CSS del tema si existe,
	 * y cae al degradado oscuro por defecto si no hay variable de tema.
	 * AJUSTE 2: cuando el usuario elige un color, el PHP anade
	 * style="background: #hexcolor" inline que sobreescribe esto.
	 */
	background: var(--wp--style--color--background,
		radial-gradient(ellipse at center, var(--gp3d-bg) 0%, var(--gp3d-bg-deep) 100%)
	);
	border-radius: 20px;
}

/* AJUSTE 3 - alineaciones nativas de WordPress */
.gp3d-gallery.alignwide {
	max-width: var(--wp--style--global--wide-size, 1200px);
}
.gp3d-gallery.alignfull {
	max-width: 100%;
	border-radius: 0;
}

/* Estrellas decorativas de fondo */
.gp3d-gallery::before {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	background-image:
		radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,.4) 0%, transparent 100%),
		radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,.3) 0%, transparent 100%),
		radial-gradient(1px 1px at 55% 10%, rgba(255,255,255,.5) 0%, transparent 100%),
		radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,.3) 0%, transparent 100%),
		radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,.4) 0%, transparent 100%),
		radial-gradient(1px 1px at 20% 90%, rgba(255,255,255,.2) 0%, transparent 100%),
		radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,.35) 0%, transparent 100%);
}

/* ---- Layout principal ---- */

.gp3d-gallery-wrapper {
	position: relative;
	z-index: 1;
	width: 100%;
	min-height: 720px;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 40px;
	padding: 40px;
	align-items: center;
	justify-items: center;
}

.gp3d-preview-section,
.gp3d-carousel-section {
	width: 100%;
}

/* ---- Panel de preview ---- */

.gp3d-preview-section {
	min-height: 600px;
	display: flex;
	align-items: center;
	justify-content: center;
	perspective: 800px;
}

.gp3d-preview-container {
	width: 100%;
	max-width: 500px;
	height: 500px;
	position: relative;
	background: var(--gp3d-card);
	border-radius: 20px;
	overflow: hidden;
	box-shadow:
		0 0 0 1px rgba(100,200,255,.15),
		0 30px 80px rgba(0,0,0,.7),
		0 0 100px rgba(50,150,255,.08);
	transform-style: preserve-3d;
	transition: transform .15s ease-out;
	will-change: transform;
}

.gp3d-preview-image {
	width: 100%;
	height: 85%;
	object-fit: cover;
	display: block;
	animation: gp3d-fade-in .5s ease;
}

.gp3d-preview-info {
	width: 100%;
	height: 15%;
	padding: 20px;
	background: var(--gp3d-card-deep);
	border-top: 1px solid rgba(100,200,255,.15);
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.gp3d-preview-title {
	margin: 0 0 5px;
	font-size: 20px;
	line-height: 1.25;
	font-weight: 700;
	color: var(--gp3d-text);
}

.gp3d-preview-desc {
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	color: var(--gp3d-accent);
}

.gp3d-preview-glare {
	position: absolute;
	inset: 0;
	border-radius: 20px;
	pointer-events: none;
	opacity: 0;
	transition: opacity .3s ease;
	z-index: 5;
}

.gp3d-preview-container:hover .gp3d-preview-glare {
	opacity: 1;
}

@keyframes gp3d-fade-in {
	from { opacity: 0; transform: scale(.95); }
	to   { opacity: 1; transform: scale(1);   }
}

/* ---- Carrusel ---- */

.gp3d-carousel-section {
	min-height: 600px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 30px;
}

.gp3d-carousel-scene {
	width: 100%;
	height: 600px;
	display: flex;
	align-items: center;
	justify-content: center;
	user-select: none;
	perspective: 1000px;
	perspective-origin: 50% 50%;
	touch-action: none;
}

.gp3d-tilt-wrapper {
	position: relative;
	transform-style: preserve-3d;
	will-change: transform;
}

.gp3d-carousel-container {
	position: relative;
	width: 250px;
	height: 400px;
	transform-style: preserve-3d;
}

.gp3d-carousel-item {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 150px;
	height: 150px;
	transform: translate(-50%, -50%);
	transform-style: preserve-3d;
	cursor: pointer;
}

.gp3d-carousel-item-inner {
	position: relative;
	width: 100%;
	height: 100%;
	border-radius: 14px;
	overflow: hidden;
	background: var(--gp3d-card);
	transition: box-shadow .3s ease, filter .3s ease;
	backface-visibility: hidden;
	will-change: transform;
}

.gp3d-carousel-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.gp3d-carousel-item-number {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(0,0,0,.85);
	color: #fff;
	font-weight: 700;
	font-size: 10px;
	opacity: 0;
	transition: opacity .3s ease;
	z-index: 10;
}

.gp3d-carousel-item-shadow {
	position: absolute;
	bottom: -20px;
	left: 10%;
	width: 80%;
	height: 20px;
	background: rgba(0,0,0,.4);
	border-radius: 50%;
	filter: blur(8px);
	pointer-events: none;
	opacity: 0;
	transition: opacity .3s ease, transform .3s ease;
}

.gp3d-carousel-item:hover .gp3d-carousel-item-inner {
	box-shadow:
		0 0 0 2px rgba(79,195,247,.7),
		0 20px 60px rgba(79,195,247,.25);
	filter: brightness(1.15);
}

.gp3d-carousel-item:hover .gp3d-carousel-item-number,
.gp3d-carousel-item.active .gp3d-carousel-item-number {
	opacity: 1;
}

.gp3d-carousel-item:hover .gp3d-carousel-item-shadow,
.gp3d-carousel-item.active .gp3d-carousel-item-shadow {
	opacity: 1;
}

.gp3d-carousel-item.active .gp3d-carousel-item-inner {
	box-shadow:
		0 0 0 2px rgba(255,215,0,.9),
		0 0 50px rgba(255,215,0,.35),
		0 25px 70px rgba(255,215,0,.15);
	filter: brightness(1.25);
}

.gp3d-depth-lines {
	position: absolute;
	inset: 0;
	pointer-events: none;
	border-radius: 14px;
	background: linear-gradient(
		135deg,
		rgba(255,255,255,.06) 0%,
		transparent 50%,
		rgba(0,0,0,.1) 100%
	);
}

/* ---- Info y contador ---- */

.gp3d-carousel-info {
	text-align: center;
	display: flex;
	flex-direction: column;
	gap: 15px;
	align-items: center;
}

.gp3d-drag-hint {
	margin: 0;
	font-size: 14px;
	opacity: .7;
	font-weight: 500;
	color: var(--gp3d-accent);
}

.gp3d-carousel-counter {
	font-size: 16px;
	font-weight: 600;
	opacity: .9;
}

.gp3d-carousel-counter [data-current-index] {
	color: var(--gp3d-gold);
	font-weight: 700;
	font-size: 18px;
}

/* ---- AJUSTE 5 - Boton de enlace en el panel preview ---- */

.gp3d-preview-link {
	display: inline-block;
	margin-top: 10px;
	padding: 6px 16px;
	background: var(--gp3d-accent);
	color: #0d1b2a;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
	border-radius: 20px;
	transition: opacity .2s ease, transform .2s ease;
}

.gp3d-preview-link:hover {
	opacity: .85;
	transform: translateY(-1px);
}

/* ---- AJUSTE 5 - Badge de enlace en tarjetas del carrusel ---- */

.gp3d-link-badge {
	position: absolute;
	bottom: 6px;
	left: 6px;
	font-size: 14px;
	line-height: 1;
	pointer-events: none;
	opacity: 0;
	transition: opacity .3s ease;
	z-index: 10;
}

.gp3d-carousel-item.gp3d-has-link:hover .gp3d-link-badge,
.gp3d-carousel-item.gp3d-has-link.active .gp3d-link-badge {
	opacity: 1;
}

/* Cursor pointer solo en tarjetas activas con URL */
.gp3d-carousel-item.gp3d-has-link.active {
	cursor: pointer;
}

/* ---- Aviso de galeria vacia ---- */

.gp3d-empty {
	padding: 20px;
	border: 1px solid #dcdcde;
	background: #f6f7f7;
	color: #1d2327;
	border-radius: 6px;
}

/* ---- Responsive ---- */

@media (max-width: 1200px) {
	.gp3d-gallery-wrapper {
		gap: 30px;
		padding: 30px;
	}
	.gp3d-preview-container {
		max-width: 400px;
		height: 400px;
	}
	.gp3d-carousel-scene {
		height: 500px;
	}
	.gp3d-carousel-item {
		width: 130px;
		height: 130px;
	}
}

@media (max-width: 1024px) {
	.gp3d-gallery-wrapper {
		grid-template-columns: 1fr;
		gap: 20px;
		padding: 20px;
	}
	.gp3d-preview-section {
		min-height: 0;
	}
	.gp3d-preview-container {
		max-width: 600px;
		height: 400px;
	}
	.gp3d-carousel-section {
		min-height: 0;
	}
	.gp3d-carousel-scene {
		height: 420px;
	}
	.gp3d-carousel-container {
		height: 300px;
	}
	.gp3d-carousel-item {
		width: 110px;
		height: 110px;
	}
}

@media (max-width: 768px) {
	.gp3d-gallery-wrapper {
		gap: 15px;
		padding: 15px;
		min-height: 0;
	}
	.gp3d-preview-container {
		height: 300px;
	}
	.gp3d-carousel-scene {
		height: 350px;
	}
	.gp3d-carousel-container {
		height: 250px;
	}
	.gp3d-carousel-item {
		width: 100px;
		height: 100px;
	}
}

@media (max-width: 480px) {
	.gp3d-gallery-wrapper {
		gap: 10px;
		padding: 10px;
	}
	.gp3d-preview-container {
		height: 250px;
	}
	.gp3d-preview-title {
		font-size: 16px;
	}
	.gp3d-preview-desc {
		font-size: 12px;
	}
	.gp3d-carousel-scene {
		height: 300px;
	}
	.gp3d-carousel-container {
		width: 200px;
		height: 200px;
	}
	.gp3d-carousel-item {
		width: 90px;
		height: 90px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gp3d-gallery *,
	.gp3d-gallery *::before,
	.gp3d-gallery *::after {
		scroll-behavior: auto !important;
	}
	.gp3d-preview-image {
		animation: none;
	}
}
