/**
 * Sobre de Boda
 *
 * Todas las clases van con prefijo .sbw- para no chocar con el tema ni con
 * Elementor. Los colores llegan como variables CSS inyectadas por PHP, una
 * declaración por instancia.
 */

html.sbw-lock,
html.sbw-lock body {
	overflow: hidden !important;
	height: 100% !important;
}

.sbw-overlay {
	--sbw-display: 'Cormorant Garamond', 'Times New Roman', serif; /* la sobrescribe el atributo style si hay tipografia="..." */
	--sbw-texto: 'Jost', system-ui, -apple-system, sans-serif;

	position: fixed;
	inset: 0;
	z-index: 2147483000;
	overflow: hidden;
	perspective: 1400px;
	overscroll-behavior: none;
	touch-action: none;
	transition: opacity .7s ease;
	/* Sin esto, iOS y Android pintan un velo oscuro al tocar. */
	-webkit-tap-highlight-color: transparent;
}

.sbw-overlay.sbw-fuera { opacity: 0; }
.sbw-overlay.sbw-oculto { display: none; }

/* ── Bolsa del sobre ───────────────────────────────────────────── */
.sbw-bolsa {
	position: absolute;
	inset: 0;
	z-index: 1;
	background:
		repeating-linear-gradient(45deg, rgba(0,0,0,.018) 0 1px, transparent 1px 3px),
		linear-gradient(170deg, var(--sbw-papel) 0%, var(--sbw-papel-2) 100%);
	transition: transform 1s cubic-bezier(.4,0,.2,1);
}
.sbw-overlay.sbw-saliendo .sbw-bolsa { transform: translateX(-101%); }

/* ── Sombras del doblez, en dos niveles ────────────────────────────
   Una de contacto (corta y oscura) y una ambiental (larga y difusa).
   La luz entra por arriba-izquierda: ambas caen hacia abajo-derecha. */
.sbw-sombra,
.sbw-sombra-amb {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	width: var(--sbw-punta);
	z-index: 2;
	clip-path: polygon(100% 0, 100% 100%, 0 50%);
	background: #2E2418;
	pointer-events: none;
	transition: opacity .5s ease;
}

/* Contacto: más fuerte junto al sello, donde el papel queda prensado. */
.sbw-sombra {
	filter: blur(3px);
	opacity: .30;
	transform: translate(2px, 3px);
	-webkit-mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,.4) 55%, rgba(0,0,0,.18) 100%);
	mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,.4) 55%, rgba(0,0,0,.18) 100%);
}

/* Ambiental: domina lejos del sello, donde el filo se despega. */
.sbw-sombra-amb {
	filter: blur(18px);
	opacity: .15;
	transform: translate(10px, 13px);
	-webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,.25) 0%, #000 100%);
	mask-image: linear-gradient(90deg, rgba(0,0,0,.25) 0%, #000 100%);
}

/* Oclusión donde se juntan los dos pliegues. */
.sbw-oclusion {
	position: absolute;
	top: 50%;
	left: calc(100% - var(--sbw-punta));
	z-index: 2;
	width: min(48vw, 230px);
	aspect-ratio: 1;
	transform: translate(-50%, -50%);
	background: radial-gradient(circle, rgba(46,36,24,.17) 0%, rgba(46,36,24,.06) 42%, transparent 70%);
	filter: blur(9px);
	pointer-events: none;
	transition: opacity .5s ease;
}

.sbw-overlay.sbw-abriendo .sbw-sombra,
.sbw-overlay.sbw-abriendo .sbw-sombra-amb,
.sbw-overlay.sbw-abriendo .sbw-oclusion { opacity: 0; }

/* ── La solapa: único doblez, anclada al borde derecho ─────────── */
.sbw-solapa {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	width: var(--sbw-punta);
	z-index: 3;
	background:
		repeating-linear-gradient(45deg, rgba(0,0,0,.018) 0 1px, transparent 1px 3px),
		linear-gradient(268deg, var(--sbw-solapa) 0%, var(--sbw-solapa-2) 62%, var(--sbw-solapa) 100%);
	clip-path: polygon(100% 0, 100% 100%, 0 50%);
	transform-origin: center right;
	transform: rotateY(0deg);
	backface-visibility: hidden;
}

.sbw-overlay.sbw-abriendo .sbw-solapa {
	animation: sbw-abrir 1.15s cubic-bezier(.5,.02,.2,1) forwards;
}

/* El z-index salta a mitad del giro para que la solapa pase por detrás. */
@keyframes sbw-abrir {
	0%    { transform: rotateY(0deg);   z-index: 3; }
	49.9% {                             z-index: 3; }
	50%   {                             z-index: 0; }
	100%  { transform: rotateY(172deg); z-index: 0; }
}

/* ── Líneas del doblez ─────────────────────────────────────────── */
.sbw-doblez {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 4;
	pointer-events: none;
	transition: opacity .35s ease;
}
.sbw-doblez line { fill: none; vector-effect: non-scaling-stroke; }
.sbw-db-brillo line { stroke: rgba(255,255,255,.30); stroke-width: 7; }
.sbw-db-luz line    { stroke: rgba(255,255,255,.90); stroke-width: 1.5; }
.sbw-db-filo line   { stroke: var(--sbw-linea); stroke-width: 1; opacity: .75; }
.sbw-overlay.sbw-abriendo .sbw-doblez { opacity: 0; }

/* ── Grano y viñeta ────────────────────────────────────────────── */
.sbw-grano {
	position: absolute;
	inset: 0;
	z-index: 5;
	pointer-events: none;
	opacity: .055;
	mix-blend-mode: multiply;
	background-size: 170px 170px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='170' height='170' filter='url(%23n)'/%3E%3C/svg%3E");
	transition: opacity .4s ease;
}
.sbw-vineta {
	position: absolute;
	inset: 0;
	z-index: 5;
	pointer-events: none;
	background: radial-gradient(125% 85% at 45% 42%, transparent 55%, rgba(60,48,32,.10) 100%);
	transition: opacity .4s ease;
}
.sbw-overlay.sbw-abriendo .sbw-grano,
.sbw-overlay.sbw-abriendo .sbw-vineta { opacity: 0; }

/* ── Sello y etiqueta ──────────────────────────────────────────── */
.sbw-centro {
	position: absolute;
	top: 50%;
	left: calc(100% - var(--sbw-punta));
	z-index: 6;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0;
	pointer-events: none;
}

.sbw-toca {
	position: relative;
	margin: 0;
	background: #1A1A1A;
	color: #fff;
	border-radius: 4px;
	padding: .34em .7em;
	font-family: var(--sbw-texto);
	font-weight: 400;
	font-size: clamp(.66rem, 2.9vw, .78rem);
	line-height: 1.3;
	box-shadow: 0 2px 8px rgba(0,0,0,.22);
	animation: sbw-flota 2.2s ease-in-out infinite;
	transition: opacity .3s ease;
	/* Compensa la franja transparente del lienzo del SVG sobre la cera,
	   para que la flecha quede pegada al lacre y no al borde del botón. */
	margin-bottom: -6px;
	z-index: 1;
}
.sbw-toca::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -5px;
	border: 5px solid transparent;
	border-top-color: #1A1A1A;
}
@keyframes sbw-flota {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-4px); }
}

/* El aspecto del sello lo pone el SVG; el <button> no debe aportar nada.
   Los estilos globales de Elementor (.elementor-kit-N button) y muchos
   temas pintan TODOS los botones con fondo propio y ganan por
   especificidad a una clase sola — de ahí el cuadro oscuro detrás del
   lacre, que "se quitaba" al hover porque el kit trae su propio :hover.
   Selector reforzado + !important para ganar esa pelea siempre. */
.sbw-overlay button.sbw-sello,
.sbw-overlay button.sbw-sello:hover,
.sbw-overlay button.sbw-sello:focus,
.sbw-overlay button.sbw-sello:active,
.sbw-overlay button.sbw-sello:visited {
	background: transparent !important;
	background-color: transparent !important;
	background-image: none !important;
	border: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	border-radius: 0 !important;
	outline: none;
	color: inherit !important;
	text-shadow: none !important;
	min-width: 0 !important;
	min-height: 0 !important;
}
.sbw-sello {
	position: relative;
	pointer-events: auto;
	cursor: pointer;
	line-height: 0;
	width: clamp(88px, 27vw, 126px);
	aspect-ratio: 1;
	animation: sbw-latido 2.6s ease-in-out infinite;
	transition: transform .45s cubic-bezier(.4,0,.2,1), opacity .35s ease;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	appearance: none;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;
}
.sbw-sello::before,
.sbw-sello::after { content: none !important; }
.sbw-sello::-moz-focus-inner { border: 0; padding: 0; }
/* El anillo de foco solo para teclado, no al tocar con el dedo. */
.sbw-sello:focus-visible { outline: 2px solid #1A1A1A; outline-offset: 6px; }

@keyframes sbw-latido {
	0%, 100% { transform: scale(1); }
	50%      { transform: scale(1.05); }
}

.sbw-sello-svg {
	width: 100%;
	height: 100%;
	display: block;
	overflow: visible;
	/* La sombra vive DENTRO del SVG. drop-shadow en CSS sobre un SVG con
	   filtros internos se pinta como un bloque oscuro en Safari hasta que
	   algo fuerza un repintado (por eso desaparecía con el cursor encima). */
}

.sbw-sello-svg .sbw-cera-a { stop-color: var(--sbw-cera-a); }
.sbw-sello-svg .sbw-cera-b { stop-color: var(--sbw-cera-b); }
.sbw-sello-svg .sbw-cera-c { stop-color: var(--sbw-cera-c); }
.sbw-sello-svg .sbw-cera-d { stop-color: var(--sbw-cera-d); }

.sbw-mono text { font-family: var(--sbw-display); font-weight: 400; }
.sbw-mono .sbw-amp { font-style: italic; opacity: .8; }
.sbw-mono-sombra { fill: #000; opacity: .34; }   /* pared en sombra del hueco */
.sbw-mono-luz    { fill: #fff; opacity: .22; }   /* pared iluminada del hueco */
.sbw-mono-base   { fill: var(--sbw-cera-tx); }

.sbw-overlay.sbw-cargando-on .sbw-sello,
.sbw-overlay.sbw-abriendo .sbw-sello,
.sbw-overlay.sbw-saliendo .sbw-sello {
	animation: none;
	opacity: 0;
	transform: scale(.55);
	pointer-events: none;
}
.sbw-overlay.sbw-cargando-on .sbw-toca,
.sbw-overlay.sbw-abriendo .sbw-toca,
.sbw-overlay.sbw-saliendo .sbw-toca { opacity: 0; animation: none; }

/* Y el contenedor entero deja de recibir eventos durante la apertura. */
.sbw-overlay.sbw-abriendo .sbw-centro,
.sbw-overlay.sbw-saliendo .sbw-centro { pointer-events: none; }

/* ── Indicador de carga ────────────────────────────────────────── */
.sbw-cargando {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: 34px;
	height: 34px;
	opacity: 0;
	pointer-events: none;
	transition: opacity .3s ease;
}
.sbw-cargando span {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	border: 1.5px solid rgba(0,0,0,.12);
	border-top-color: var(--sbw-cera-b);
	animation: sbw-girar .85s linear infinite;
}
@keyframes sbw-girar { to { transform: rotate(360deg); } }
.sbw-overlay.sbw-cargando-on .sbw-cargando { opacity: 1; }
.sbw-overlay.sbw-abriendo .sbw-cargando { opacity: 0; }

/* ── Accesibilidad ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.sbw-sello, .sbw-toca { animation: none !important; }
	.sbw-overlay.sbw-abriendo .sbw-solapa { animation-duration: .01ms; }
	.sbw-bolsa, .sbw-sombra, .sbw-sombra-amb { transition-duration: .01ms; }
}
