
/**
 * DeukSpine Scroll Animations - Apple-style Text Reveal
 *
 * Desktop: Two-column layout (animation + text side-by-side)
 * Mobile: Stacked layout (animation on top, text below)
 */

/* ==========================================================================
   DESKTOP: SIDE-BY-SIDE LAYOUT
   ========================================================================== */

/* Override sticky wrapper for side-by-side on desktop */
.dsa-section-apple-reveal .dsa-sticky-wrapper {
	flex-direction: row;
	align-items: stretch;
	gap: 3rem;
}

/* Animation Container - takes up space needed */
.dsa-section-apple-reveal .dsa-animation-container {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.dsa-section-apple-reveal .dsa-animation-canvas {
	max-width: 100%;
	max-height: 90vh;
	width: auto;
	height: auto;
	object-fit: contain;
}

/* ==========================================================================
   TEXT REVEAL AREA - Side panel on desktop
   ========================================================================== */
.dsa-text-reveal-area {
	position: relative;
	width: 350px;
	flex-shrink: 0;
	padding: 2rem;
	background: var(--dsa-text-bg, #fff);
	overflow-y: auto;
	overflow-x: hidden;
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 200px;
	max-height: 90vh;
}

/* Hide scrollbar but keep functionality */
.dsa-text-reveal-area {
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.dsa-text-reveal-area::-webkit-scrollbar {
	display: none;
}

/* ==========================================================================
   LEFT/RIGHT POSITION VARIANTS
   ========================================================================== */

/* Text on left (animation on right) */
.dsa-layout-left .dsa-sticky-wrapper {
	flex-direction: row-reverse;
}

/* Text on right (animation on left) - default */
.dsa-layout-right .dsa-sticky-wrapper {
	flex-direction: row;
}

/* ==========================================================================
   TEXT BLOCKS - Only active one visible
   ========================================================================== */
.dsa-text-block {
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	transform: translateY(-50%);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .4s ease, transform .4s ease, visibility 0s .4s;
}

.dsa-text-block.dsa-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition: opacity .4s ease, transform .4s ease, visibility 0s 0s;
}

/* ==========================================================================
   TEXT ANIMATION EFFECTS (Desktop Only)
   ========================================================================== */

/* Fade (default) - just opacity */
.dsa-effect-fade .dsa-text-block {
	transform: none;
}

/* Slide from Left */
.dsa-effect-slide-left .dsa-text-block {
	transform: translate(-40px, -50%);
}

.dsa-effect-slide-left .dsa-text-block.dsa-active {
	transform: translate(0, -50%);
}

.dsa-effect-slide-left .dsa-text-block.dsa-exiting {
	transform: translate(40px, -50%);
}

/* Slide from Right */
.dsa-effect-slide-right .dsa-text-block {
	transform: translate(40px, -50%);
}

.dsa-effect-slide-right .dsa-text-block.dsa-active {
	transform: translate(0, -50%);
}

.dsa-effect-slide-right .dsa-text-block.dsa-exiting {
	transform: translate(-40px, -50%);
}

/* Slide from Below (slide up) */
.dsa-effect-slide-up .dsa-text-block {
	transform: translate(0, calc(-50% + 40px));
}

.dsa-effect-slide-up .dsa-text-block.dsa-active {
	transform: translate(0, -50%);
}

.dsa-effect-slide-up .dsa-text-block.dsa-exiting {
	transform: translate(0, calc(-50% - 40px));
}

/* Slide from Above (slide down) */
.dsa-effect-slide-down .dsa-text-block {
	transform: translate(0, calc(-50% - 40px));
}

.dsa-effect-slide-down .dsa-text-block.dsa-active {
	transform: translate(0, -50%);
}

.dsa-effect-slide-down .dsa-text-block.dsa-exiting {
	transform: translate(0, calc(-50% + 40px));
}

/* Zoom In */
.dsa-effect-zoom .dsa-text-block {
	transform: translateY(-50%) scale(.85);
}

.dsa-effect-zoom .dsa-text-block.dsa-active {
	transform: translateY(-50%) scale(1);
}

.dsa-effect-zoom .dsa-text-block.dsa-exiting {
	transform: translateY(-50%) scale(1.1);
}

/* Flip (3D) */
.dsa-effect-flip .dsa-text-reveal-area {
	perspective: 1000px;
}

.dsa-effect-flip .dsa-text-block {
	transform: translateY(-50%) rotateX(-90deg);
	transform-origin: center center;
	backface-visibility: hidden;
}

.dsa-effect-flip .dsa-text-block.dsa-active {
	transform: translateY(-50%) rotateX(0);
}

.dsa-effect-flip .dsa-text-block.dsa-exiting {
	transform: translateY(-50%) rotateX(90deg);
}

/* ==========================================================================
   PLACEHOLDER TEXT
   ========================================================================== */
.dsa-text-placeholder {
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	transform: translateY(-50%);
	opacity: 0;
	visibility: hidden;
	transition: opacity .4s ease, visibility 0s .4s;
}

.dsa-text-placeholder.active {
	opacity: 1;
	visibility: visible;
	transition: opacity .4s ease, visibility 0s 0s;
}

.dsa-placeholder-image {
	margin-bottom: 16px;
	text-align: center;
}

.dsa-placeholder-image img {
	max-width: 100%;
	max-height: 120px;
	width: auto;
	height: auto;
	border-radius: 8px;
	opacity: .7;
}

.dsa-placeholder-title {
	font-size: 1.5rem;
	font-weight: 600;
	color: #888;
	margin: 0 0 12px;
}

.dsa-placeholder-subtitle {
	font-size: 1rem;
	color: #aaa;
	margin: 0;
	line-height: 1.6;
}

/* ==========================================================================
   TEXT CONTENT STYLES
   ========================================================================== */

/* Stage Badge */
.dsa-stage-badge {
	display: inline-block;
	padding: 6px 14px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .15em;
	text-transform: uppercase;
	color: #2271b1;
	background: rgba(34, 113, 177, .1);
	border-radius: 20px;
	margin: 0 0 16px 0;
}

/* Label Title */
.dsa-label-title {
	font-size: 1.75rem;
	font-weight: 700;
	color: #1a1a2e;
	margin: 0 0 12px 0;
	line-height: 1.2;
}

/* Label Subtitle */
.dsa-label-subtitle {
	font-size: 1.1rem;
	color: #4a4a5a;
	margin: 0 0 16px 0;
	line-height: 1.5;
	font-weight: 500;
}

/* Label Detail (Full Description) */
.dsa-label-detail {
	font-size: 1rem;
	color: #666;
	line-height: 1.7;
	margin: 0;
}

.dsa-label-detail p {
	margin: 0 0 12px 0;
}

.dsa-label-detail p:last-child {
	margin-bottom: 0;
}

.dsa-label-detail p:empty {
	display: none;
}

/* Ensure stage badge is not wrapped in <p> */
.dsa-text-block > p:first-child {
	display: contents;
}

/* Details Link */
.dsa-details-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 20px;
	padding: 12px 24px;
	font-size: 15px;
	font-weight: 600;
	color: #fff !important;
	background: #2271b1;
	border-radius: 8px;
	text-decoration: none;
	transition: background .2s ease, transform .2s ease;
}

.dsa-details-link svg {
	fill: currentColor;
}

.dsa-details-link:hover {
	background: #135e96;
	transform: translateY(-2px);
	color: #fff !important;
}

/* ==========================================================================
   NO TEXT MODE
   ========================================================================== */
.dsa-layout-none .dsa-text-reveal-area {
	display: none;
}

.dsa-layout-none .dsa-animation-container {
	width: 100%;
}

/* ==========================================================================
   MOBILE STAGE INDICATORS (Hidden on Desktop)
   ========================================================================== */

/* Hide mobile stage indicators on desktop - only show on mobile */
.dsa-mobile-stage-indicators, .dsa-mobile-modal {
	display: none;
}

/* ==========================================================================
   MOBILE: STACKED LAYOUT
   ========================================================================== */
@media (max-width: 768px) {
	/* ==========================================================================
       MOBILE STACKED LAYOUT (default)
       ========================================================================== */
	
	/* Switch to stacked layout on mobile by default */
	.dsa-section-apple-reveal .dsa-sticky-wrapper, .dsa-mobile-layout-stacked .dsa-sticky-wrapper {
		flex-direction: column;
		padding: 0;
		gap: 0;
	}
	
	/* Override left/right variants on mobile - stacked */
	.dsa-mobile-layout-stacked.dsa-layout-left .dsa-sticky-wrapper, .dsa-mobile-layout-stacked.dsa-layout-right .dsa-sticky-wrapper {
		flex-direction: column;
	}
	
	/* Animation container - full width in stacked mode */
	.dsa-mobile-layout-stacked .dsa-animation-container {
		flex: none;
		width: 100%;
		min-height: 75vh;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	/* Canvas - responsive sizing */
	.dsa-mobile-layout-stacked .dsa-animation-canvas {
		max-width: 100%;
		max-height: 60vh;
	}
	
	/* Hide text area completely in stacked mode - we'll use floating indicators instead */
	.dsa-mobile-layout-stacked .dsa-text-reveal-area {
		display: none !important;
	}
	
	/* Floating stage indicators - appear below animation */
	.dsa-mobile-stage-indicators {
		position: relative;
		display: flex;
		gap: 8px;
		z-index: 100;
		padding: 0;
		margin-top: -20px;
		flex-wrap: wrap;
		justify-content: center;
		max-width: 100%;
	}
	
	/* Hide all indicators by default */
	.dsa-mobile-stage-indicator {
		display: none;
		flex-direction: column;
		align-items: center;
		gap: 3px;
		padding: 0;
		background: transparent;
		border: none;
		font-size: 11px;
		font-weight: 600;
		color: #1a1a2e;
		cursor: pointer;
		transition: all .3s ease;
	}
	
	.dsa-mobile-stage-indicator .dsa-stage-number {
		font-weight: 700;
		font-size: 10px;
		letter-spacing: .05em;
		text-transform: uppercase;
		color: #666;
	}
	
	/* Title row - horizontal layout for title + icon */
	.dsa-mobile-stage-indicator .dsa-stage-title-row {
		display: flex;
		align-items: center;
		gap: 6px;
	}
	
	.dsa-mobile-stage-indicator .dsa-stage-name {
		font-weight: 600;
		font-size: 12px;
		color: #1a1a2e;
		white-space: nowrap;
	}
	
	/* Only show the active indicator */
	.dsa-mobile-stage-indicator.active {
		display: flex;
	}
	
	.dsa-mobile-stage-indicator:active {
		opacity: .7;
	}
	
	.dsa-mobile-stage-indicator svg {
		width: 16px;
		height: 16px;
		flex-shrink: 0;
		color: #2271b1;
	}
	
	/* Mobile modal/slide-up sheet */
	.dsa-mobile-modal {
		display: block;
		/* Override desktop display: none */
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 999999;
		visibility: hidden;
		opacity: 0;
		transition: visibility 0s .3s, opacity .3s ease;
	}
	
	.dsa-mobile-modal.active {
		visibility: visible;
		opacity: 1;
		transition: visibility 0s 0s, opacity .3s ease;
	}
	
	.dsa-mobile-modal-backdrop {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, .5);
		cursor: pointer;
	}
	
	.dsa-mobile-modal-content {
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		max-height: 85vh;
		background: white;
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -4px 20px rgba(0, 0, 0, .25);
		transform: translateY(100%);
		transition: transform .3s cubic-bezier(.4, 0, .2, 1);
		overflow: hidden;
		display: flex;
		flex-direction: column;
	}
	
	.dsa-mobile-modal.active .dsa-mobile-modal-content {
		transform: translateY(0);
	}
	
	.dsa-mobile-modal-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 12px 20px 10px;
		border-bottom: 1px solid #e5e5e5;
		flex-shrink: 0;
	}
	
	.dsa-mobile-modal-header h3 {
		margin: 0;
		font-size: 16px;
		font-weight: 700;
		color: #1a1a2e;
	}
	
	.dsa-mobile-modal-close {
		background: none;
		border: none;
		padding: 6px;
		cursor: pointer;
		color: #666;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 50%;
		transition: background .2s ease;
	}
	
	.dsa-mobile-modal-close:active {
		background: #f0f0f0;
	}
	
	.dsa-mobile-modal-close svg {
		width: 18px;
		height: 18px;
	}
	
	.dsa-mobile-modal-body {
		padding: 16px 20px;
		overflow-y: auto;
		flex: 1;
		-webkit-overflow-scrolling: touch;
	}
	
	.dsa-mobile-modal-body .dsa-stage-badge {
		margin-bottom: 12px;
	}
	
	.dsa-mobile-modal-body .dsa-label-title {
		font-size: 1.5rem;
		margin-bottom: 12px;
	}
	
	.dsa-mobile-modal-body .dsa-label-subtitle {
		font-size: 1rem;
		margin-bottom: 16px;
	}
	
	.dsa-mobile-modal-body .dsa-label-detail {
		font-size: .95rem;
		line-height: 1.6;
	}
	
	.dsa-mobile-modal-body .dsa-details-link {
		width: 100%;
		justify-content: center;
		margin-top: 20px;
	}
	
	/* ==========================================================================
       MOBILE OVERLAY LAYOUT
       ========================================================================== */
	
	/* Animation wrapper - constrained height, contained scrolling */
	.dsa-section-apple-reveal.dsa-mobile-layout-overlay .dsa-animation-wrapper {
		position: relative !important;
		height: 50vh !important;
		/* Fixed height for medium default */
		min-height: 50vh !important;
		max-height: 50vh !important;
		overflow-y: auto !important;
		/* Allow internal scrolling */
		overflow-x: hidden !important;
	}
	
	/* Sticky wrapper - fills wrapper, allows internal scroll */
	.dsa-section-apple-reveal.dsa-mobile-layout-overlay .dsa-sticky-wrapper {
		display: block !important;
		flex-direction: initial !important;
		position: relative !important;
		/* Not sticky, just relative */
		height: auto !important;
		/* Let it be tall internally */
		min-height: 100% !important;
		/* At least fill parent */
		gap: 0 !important;
	}
	
	/* Animation container - sticky positioned to stay in view */
	.dsa-section-apple-reveal.dsa-mobile-layout-overlay .dsa-animation-container {
		position: sticky !important;
		top: 0 !important;
		width: 100% !important;
		height: 50vh !important;
		/* Match wrapper height */
		min-height: 0 !important;
		flex: none !important;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 1 !important;
	}
	
	/* Text overlay - positioned over sticky animation */
	.dsa-section-apple-reveal.dsa-mobile-layout-overlay .dsa-text-reveal-area {
		position: absolute !important;
		bottom: 0 !important;
		left: 0 !important;
		right: 0 !important;
		width: 100% !important;
		max-height: 50% !important;
		padding: 1rem 1.5rem !important;
		background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, .95) 60%, rgba(255, 255, 255, 0) 100%) !important;
		overflow-y: auto !important;
		z-index: 10 !important;
		flex: none !important;
		pointer-events: auto !important;
	}
	
	/* Text blocks in overlay mode - adjust positioning */
	.dsa-mobile-layout-overlay .dsa-text-block {
		position: static;
		/* Not absolutely positioned in overlay mode */
		transform: none;
		padding: .5rem 0;
	}
	
	.dsa-mobile-layout-overlay .dsa-text-block.dsa-active {
		transform: none;
	}
	
	.dsa-mobile-layout-overlay .dsa-text-placeholder {
		position: static;
		transform: none;
		padding: .5rem 0;
	}
	
	/* Canvas - fill container in overlay mode */
	.dsa-mobile-layout-overlay .dsa-animation-canvas {
		width: 100%;
		height: 100%;
		object-fit: contain;
		max-width: 100%;
		max-height: 100%;
	}
	
	/* ==========================================================================
       MOBILE ANIMATION SIZE VARIANTS
       ========================================================================== */
	
	/* Small - 40vh */
	.dsa-section-apple-reveal.dsa-mobile-small.dsa-mobile-layout-overlay .dsa-animation-wrapper {
		height: 40vh !important;
		min-height: 40vh !important;
		max-height: 40vh !important;
	}
	
	/* Medium - 50vh (default) - already set above */
	
	/* Large - 60vh */
	.dsa-section-apple-reveal.dsa-mobile-large.dsa-mobile-layout-overlay .dsa-animation-wrapper {
		height: 60vh !important;
		min-height: 60vh !important;
		max-height: 60vh !important;
	}
	
	.dsa-stage-badge {
		font-size: 10px;
		padding: 4px 12px;
		margin: 0 0 8px 0;
	}
	
	.dsa-label-title {
		font-size: 1.5rem;
		margin: 0 0 8px 0;
	}
	
	.dsa-label-subtitle {
		font-size: 1rem;
		margin: 0 0 8px 0;
	}
	
	.dsa-label-detail {
		font-size: .95rem;
	}
	
	.dsa-details-link {
		width: 100%;
		justify-content: center;
		margin-top: 12px;
	}
	
	/* Smaller text in overlay mode to fit better */
	.dsa-mobile-layout-overlay .dsa-stage-badge {
		font-size: 9px;
		padding: 3px 10px;
		margin: 0 0 6px 0;
	}
	
	.dsa-mobile-layout-overlay .dsa-label-title {
		font-size: 1.25rem;
		margin: 0 0 6px 0;
	}
	
	.dsa-mobile-layout-overlay .dsa-label-subtitle {
		font-size: .9rem;
		margin: 0 0 6px 0;
	}
	
	.dsa-mobile-layout-overlay .dsa-label-detail {
		font-size: .85rem;
	}
	
	.dsa-mobile-layout-overlay .dsa-details-link {
		margin-top: 8px;
		font-size: 14px;
		padding: 10px 20px;
	}
}

/* ==========================================================================
   MOBILE: DISABLE COMPLEX ANIMATIONS
   ========================================================================== */
@media (max-width: 768px) {
	/* Reset all effects to simple fade on mobile, but keep vertical centering */
	.dsa-effect-slide-left .dsa-text-block, .dsa-effect-slide-right .dsa-text-block, .dsa-effect-slide-up .dsa-text-block, .dsa-effect-slide-down .dsa-text-block, .dsa-effect-zoom .dsa-text-block, .dsa-effect-flip .dsa-text-block {
		transform: translateY(-50%);
	}
	
	.dsa-effect-slide-left .dsa-text-block.dsa-active, .dsa-effect-slide-right .dsa-text-block.dsa-active, .dsa-effect-slide-up .dsa-text-block.dsa-active, .dsa-effect-slide-down .dsa-text-block.dsa-active, .dsa-effect-zoom .dsa-text-block.dsa-active, .dsa-effect-flip .dsa-text-block.dsa-active {
		transform: translateY(-50%);
	}
	
	.dsa-effect-slide-left .dsa-text-block.dsa-exiting, .dsa-effect-slide-right .dsa-text-block.dsa-exiting, .dsa-effect-slide-up .dsa-text-block.dsa-exiting, .dsa-effect-slide-down .dsa-text-block.dsa-exiting, .dsa-effect-zoom .dsa-text-block.dsa-exiting, .dsa-effect-flip .dsa-text-block.dsa-exiting {
		transform: translateY(-50%);
	}
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.dsa-text-block, .dsa-text-placeholder {
		transition: none;
	}
	
	/* Also disable transforms for reduced motion, but keep vertical centering */
	[class*="dsa-effect-"] .dsa-text-block, [class*="dsa-effect-"] .dsa-text-block.dsa-active, [class*="dsa-effect-"] .dsa-text-block.dsa-exiting {
		transform: translateY(-50%);
	}
}

/* ==========================================================================
   DEBUG MODE (Enable via Settings > Debug Mode)
   ========================================================================== */
body.dsa-debug-mode .dsa-mobile-layout-overlay .dsa-animation-wrapper {
	outline: 3px solid red !important;
}

body.dsa-debug-mode .dsa-mobile-layout-overlay .dsa-sticky-wrapper {
	outline: 3px solid blue !important;
}

body.dsa-debug-mode .dsa-mobile-layout-overlay .dsa-animation-container {
	outline: 3px solid green !important;
}

body.dsa-debug-mode .dsa-mobile-layout-overlay .dsa-text-reveal-area {
	outline: 3px solid orange !important;
	background: rgba(255, 165, 0, .3) !important;
}

body.dsa-debug-mode .dsa-mobile-layout-overlay .dsa-animation-wrapper::before {
	content: "Animation Wrapper (RED)";
	position: absolute;
	top: 0;
	left: 0;
	background: red;
	color: white;
	padding: 2px 5px;
	font-size: 10px;
	z-index: 9999;
}

body.dsa-debug-mode .dsa-mobile-layout-overlay .dsa-sticky-wrapper::before {
	content: "Sticky Wrapper (BLUE) - Height: " attr(style);
	position: absolute;
	top: 20px;
	left: 0;
	background: blue;
	color: white;
	padding: 2px 5px;
	font-size: 10px;
	z-index: 9999;
}

/* Size-specific sticky wrapper heights */
.dsa-section-apple-reveal.dsa-mobile-small.dsa-mobile-layout-overlay .dsa-sticky-wrapper {
	height: 40vh !important;
	max-height: 40vh !important;
}

.dsa-section-apple-reveal.dsa-mobile-medium.dsa-mobile-layout-overlay .dsa-sticky-wrapper {
	height: 50vh !important;
	max-height: 50vh !important;
}

.dsa-section-apple-reveal.dsa-mobile-large.dsa-mobile-layout-overlay .dsa-sticky-wrapper {
	height: 60vh !important;
	max-height: 60vh !important;
}
