/**
 * Frontend Styles for Santa's Joke of the Day (v3.4)
 *
 * Strictly scoped with .sjotd-* and .santa-joke-trigger to prevent conflicts
 * with Elementor, WoodMart, or any WordPress theme.
 * Uses transparent PNG popup cutout so the website remains visible behind the popup.
 * Fully responsive across Desktop, Laptop, Tablet, Mobile Portrait & Mobile Landscape.
 *
 * @package Santas_Joke_Of_The_Day
 */

/* ==========================================================================
   1. Scroll Lock & Trigger Cursor
   ========================================================================== */
html.sjotd-scroll-locked,
html.sjotd-scroll-locked body {
	overflow: hidden !important;
}

.santa-joke-trigger {
	cursor: pointer;
}

/* ==========================================================================
   2. Shortcode Button ([santa_joke_button])
   ========================================================================== */
.sjotd-shortcode-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	max-width: 100%;
	padding: 13px 26px;
	font-family: 'Fredoka', 'Nunito', 'Segoe UI', Roboto, sans-serif;
	font-size: clamp(14px, 2.2vw, 17px);
	font-weight: 700;
	line-height: 1.25;
	color: #ffffff !important;
	background: linear-gradient(180deg, #e52521 0%, #b81414 100%);
	border: 2px solid #fff3c4;
	border-radius: 999px;
	box-shadow:
		0 6px 18px rgba(184, 20, 20, 0.38),
		inset 0 2px 2px rgba(255, 255, 255, 0.35);
	text-decoration: none !important;
	text-align: center;
	cursor: pointer;
	transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, filter 0.22s ease;
	user-select: none;
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
}

.sjotd-shortcode-btn:hover,
.sjotd-shortcode-btn:focus-visible {
	color: #ffffff !important;
	transform: translateY(-2px) scale(1.02);
	box-shadow:
		0 10px 24px rgba(184, 20, 20, 0.48),
		0 0 0 3px rgba(255, 215, 100, 0.45),
		inset 0 2px 2px rgba(255, 255, 255, 0.45);
	filter: brightness(1.05);
	outline: none;
}

.sjotd-shortcode-btn:active {
	transform: translateY(0) scale(0.98);
}

.sjotd-shortcode-btn__icon {
	font-size: 1.2em;
	line-height: 1;
	display: inline-block;
	flex-shrink: 0;
}

.sjotd-shortcode-btn__label {
	display: inline-block;
	word-break: break-word;
}

/* ==========================================================================
   3. Screen Reader Utility
   ========================================================================== */
.sjotd-sr-only {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* ==========================================================================
   4. Popup Overlay & Semi-Transparent Backdrop (Website Visible Behind Popup)
   ========================================================================== */
.sjotd-overlay {
	position: fixed;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	z-index: 2147483640;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: clamp(6px, 2vw, 20px);
	padding-top: max(clamp(6px, 2vw, 20px), env(safe-area-inset-top, 0px));
	padding-right: max(clamp(6px, 2vw, 20px), env(safe-area-inset-right, 0px));
	padding-bottom: max(clamp(6px, 2vw, 20px), env(safe-area-inset-bottom, 0px));
	padding-left: max(clamp(6px, 2vw, 20px), env(safe-area-inset-left, 0px));
	box-sizing: border-box;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition:
		opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
		visibility 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.sjotd-overlay[hidden] {
	display: none !important;
}

.sjotd-overlay.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.sjotd-backdrop {
	position: absolute;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba(6, 16, 34, 0.46);
	backdrop-filter: blur(2.5px);
	-webkit-backdrop-filter: blur(2.5px);
}

/* ==========================================================================
   5. Modal Wrapper & Transparent Aspect-Ratio Stage (1024 x 682)
   ========================================================================== */
.sjotd-modal-wrapper {
	position: relative;
	z-index: 2;
	width: 100%;
	/* Fits both width-constrained (portrait) and height-constrained (landscape) screens */
	max-width: min(940px, 100%, calc((100vh - 24px) * 1.501466));
	max-width: min(940px, 100%, calc((100dvh - 24px) * 1.501466));
	margin: auto;
	background: transparent !important;
	transform: scale(0.86) translateY(20px);
	opacity: 0;
	transition:
		transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
		opacity 0.3s ease;
	will-change: transform, opacity;
	pointer-events: none;
}

.sjotd-overlay.is-open .sjotd-modal-wrapper {
	transform: scale(1) translateY(0);
	opacity: 1;
}

.sjotd-overlay.is-closing .sjotd-modal-wrapper {
	transform: scale(0.9) translateY(14px);
	opacity: 0;
}

.sjotd-stage {
	position: relative;
	width: 100%;
	aspect-ratio: 1024 / 682;
	container-type: inline-size;
	background: transparent !important;
	box-shadow: none !important;
	border: none !important;
	overflow: visible;
	user-select: none;
	pointer-events: auto;
}

/* Fallback for older browsers without aspect-ratio support */
@supports not (aspect-ratio: 1024 / 682) {
	.sjotd-stage::before {
		content: "";
		display: block;
		padding-top: 66.6015625%;
	}
	.sjotd-stage__bg {
		position: absolute;
		top: 0;
		left: 0;
	}
}

#sjotd-popup-overlay,
#sjotd-popup-overlay *,
#sjotd-popup-overlay *::before,
#sjotd-popup-overlay *::after {
	box-sizing: border-box !important;
}

#sjotd-popup-overlay img.sjotd-stage__bg {
	display: block !important;
	width: 100% !important;
	max-width: 100% !important;
	height: 100% !important;
	max-height: none !important;
	object-fit: contain !important;
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	background: transparent !important;
	filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55));
	pointer-events: none;
}

/* ==========================================================================
   6. Top-Right 3D Glossy Red Circular Close Button
   ========================================================================== */
.sjotd-close-btn {
	position: absolute;
	left: 88.6%;
	top: 14.8%;
	width: 5.5%;
	aspect-ratio: 1 / 1;
	min-width: 26px;
	min-height: 26px;
	padding: 0 !important;
	margin: 0 !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	background: radial-gradient(circle at 35% 28%, #ff5252 0%, #e31b1b 58%, #9e0b0b 100%) !important;
	border: 2.5px solid #ffffff !important;
	border-radius: 50% !important;
	box-shadow:
		0 5px 12px rgba(90, 6, 6, 0.55),
		inset 0 2px 3px rgba(255, 255, 255, 0.55),
		inset 0 -3px 5px rgba(105, 5, 5, 0.6) !important;
	cursor: pointer;
	z-index: 10;
	transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, filter 0.2s ease;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	appearance: none;
}

.sjotd-close-btn__icon {
	width: 56%;
	height: 56%;
	display: block;
	filter: drop-shadow(0 1px 2px rgba(110, 6, 6, 0.65));
	pointer-events: none;
}

/* Expanded invisible touch target so mobile users can tap the X button effortlessly */
.sjotd-close-btn::before {
	content: '';
	position: absolute;
	top: -12px;
	right: -12px;
	bottom: -12px;
	left: -12px;
	border-radius: 50%;
}

.sjotd-close-btn:hover,
.sjotd-close-btn:focus-visible {
	transform: scale(1.1);
	filter: brightness(1.08);
	box-shadow:
		0 0 0 3px rgba(255, 255, 255, 0.9),
		0 6px 16px rgba(214, 24, 24, 0.75),
		inset 0 2px 3px rgba(255, 255, 255, 0.65) !important;
	outline: none;
}

.sjotd-close-btn:active {
	transform: scale(0.94);
}

/* ==========================================================================
   7. Custom Wooden Sign Title Overlay (only if admin changes default title)
   ========================================================================== */
.sjotd-sign-custom-title {
	position: absolute;
	left: 31.5%;
	top: 10.2%;
	width: 38.5%;
	height: 17.5%;
	margin: 0 !important;
	padding: 2% 3% !important;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	font-family: 'Fredoka', 'Nunito', 'Segoe UI', sans-serif !important;
	font-weight: 700 !important;
	font-size: clamp(10px, 3.5cqw, 34px) !important;
	line-height: 1.08 !important;
	color: #fffdf9 !important;
	text-shadow:
		0 2px 0 #532206,
		0 4px 8px rgba(0, 0, 0, 0.55) !important;
	background: linear-gradient(180deg, #9b4514 0%, #7d330a 52%, #632606 100%);
	border-radius: clamp(6px, 1.4cqw, 14px);
	box-shadow: inset 0 2px 4px rgba(255, 200, 140, 0.25), 0 2px 6px rgba(0, 0, 0, 0.35);
	transform: rotate(-1.2deg);
	box-sizing: border-box;
	z-index: 4;
	pointer-events: none;
}

/* ==========================================================================
   8. Dynamic Question (Q:) & Answer (A:) Text Regions
   ========================================================================== */
.sjotd-question-area {
	position: absolute;
	left: 50.8%;
	top: 35.0%;
	width: 33.4%;
	height: 16.6%;
	z-index: 5;
	display: flex;
	align-items: center;
	box-sizing: border-box;
	pointer-events: auto;
	user-select: text;
	overflow: hidden;
}

.sjotd-question-inner {
	width: 100%;
	max-height: 100%;
	font-family: 'Fredoka', 'Baloo 2', 'Nunito', 'Trebuchet MS', sans-serif;
	font-weight: 700;
	font-size: clamp(8.5px, 2.55cqw, 25px);
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: #2b1408;
	text-align: left;
	transform: rotate(-0.35deg);
	transform-origin: left center;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.sjotd-question-text {
	display: inline-block;
	color: #2b1408 !important;
}

.sjotd-answer-area {
	position: absolute;
	left: 53.0%;
	top: 54.2%;
	width: 26.5%;
	height: 17.3%;
	z-index: 5;
	display: flex;
	align-items: center;
	box-sizing: border-box;
	pointer-events: auto;
	user-select: text;
	overflow: hidden;
}

.sjotd-answer-inner {
	position: relative;
	z-index: 2;
	width: 100%;
	max-height: 100%;
	padding-right: 12%;
	box-sizing: border-box;
	font-family: 'Fredoka', 'Baloo 2', 'Nunito', 'Trebuchet MS', sans-serif;
	font-weight: 700;
	font-size: clamp(8.5px, 2.5cqw, 24px);
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: #2b1408;
	text-align: left;
	transform: rotate(-0.35deg);
	transform-origin: left center;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.sjotd-answer-text {
	display: inline-block;
	color: #2b1408 !important;
}

/* Subtle text transition when cycling jokes */
.sjotd-question-text,
.sjotd-answer-text {
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.sjotd-stage.is-switching-joke .sjotd-question-text,
.sjotd-stage.is-switching-joke .sjotd-answer-text {
	opacity: 0;
	transform: translateY(4px);
}

/* Decorative Mini Gift Box with Burst Rays */
.sjotd-gift-deco {
	position: absolute;
	right: -5%;
	bottom: -5%;
	width: 22%;
	aspect-ratio: 1 / 1;
	z-index: 1;
	pointer-events: none;
}

.sjotd-gift-deco__svg {
	width: 100%;
	height: 100%;
	display: block;
	filter: drop-shadow(0 3px 4px rgba(83, 34, 6, 0.22));
}

/* ==========================================================================
   9. Optional Multi-Joke Switcher Bar (when jokes_count > 1)
   ========================================================================== */
.sjotd-multi-pager {
	position: absolute;
	left: 52%;
	bottom: 24.5%;
	z-index: 8;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: rgba(255, 250, 235, 0.94);
	border: 2px solid #d62020;
	border-radius: 999px;
	padding: 2px 5px 2px 10px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
	font-family: 'Fredoka', 'Nunito', sans-serif;
}

.sjotd-multi-pager[hidden] {
	display: none !important;
}

.sjotd-multi-pager__counter {
	font-size: clamp(9px, 1.4cqw, 13px);
	font-weight: 700;
	color: #5b2c12;
}

.sjotd-multi-pager__btn {
	background: linear-gradient(180deg, #e52521 0%, #b81414 100%) !important;
	color: #ffffff !important;
	border: none !important;
	border-radius: 999px !important;
	padding: 3px 9px !important;
	font-family: 'Fredoka', 'Nunito', sans-serif !important;
	font-size: clamp(9px, 1.4cqw, 13px) !important;
	font-weight: 700 !important;
	line-height: 1.2 !important;
	cursor: pointer;
	transition: transform 0.15s ease, filter 0.15s ease;
}

.sjotd-multi-pager__btn:hover {
	filter: brightness(1.08);
	transform: scale(1.04);
}

/* ==========================================================================
   10. Device-Specific Responsive Breakpoints
   ========================================================================== */

/* Tablets & Small Laptops (<= 1024px) */
@media screen and (max-width: 1024px) {
	.sjotd-modal-wrapper {
		max-width: min(860px, 100%, calc((100dvh - 20px) * 1.501466));
	}
}

/* Portrait Tablets & Large Phones (<= 768px) */
@media screen and (max-width: 768px) {
	.sjotd-overlay {
		padding: 6px;
	}

	.sjotd-close-btn {
		border-width: 2px !important;
	}

	.sjotd-question-inner,
	.sjotd-answer-inner {
		line-height: 1.15;
	}
}

/* Mobile Portrait (<= 480px) */
@media screen and (max-width: 480px) {
	.sjotd-overlay {
		padding: 3px;
	}

	.sjotd-close-btn {
		min-width: 22px;
		min-height: 22px;
		border-width: 1.5px !important;
	}

	.sjotd-question-area {
		left: 50.6%;
		top: 34.8%;
		width: 33.8%;
		height: 17.0%;
	}

	.sjotd-answer-area {
		left: 52.8%;
		top: 54.0%;
		width: 27.0%;
		height: 17.6%;
	}

	.sjotd-question-inner,
	.sjotd-answer-inner {
		line-height: 1.12;
	}

	.sjotd-shortcode-btn {
		padding: 11px 20px;
		font-size: 15px;
	}
}

/* Mobile Landscape / Short Viewport Height (<= 540px height) */
@media screen and (max-height: 540px) {
	.sjotd-overlay {
		padding: 4px;
	}

	.sjotd-modal-wrapper {
		max-width: min(820px, 100%, calc((100vh - 10px) * 1.501466));
		max-width: min(820px, 100%, calc((100dvh - 10px) * 1.501466));
	}
}

@media (prefers-reduced-motion: reduce) {
	.sjotd-overlay,
	.sjotd-modal-wrapper,
	.sjotd-close-btn,
	.sjotd-shortcode-btn {
		transition-duration: 0.01ms !important;
	}
}
