/**
 * StPageFlip Integration CSS
 * Simple styles for StPageFlip library integration with GenerateBlocks Query Loop
 *
 * @package CCWS_Container_Effects
 */

.ccws-page-flick-container {
	position: relative;
	width: 100%;
	margin: 0 auto;
}

/* Multi-container wrapper */
.ccws-multi-container-wrapper {
	position: relative;
	width: 100%;
	margin: 0 auto;
}

/* StPageFlip book container */
.ccws-stpageflip {
	width: 1400px;  /* Fixed width for double-page spread (700px x 2) */
	max-width: 100%;
	min-height: 600px;
	height: auto;
	margin: 0 auto;
	overflow: visible;
	position: relative;
}

/* Book layout styles */
.ccws-stpageflip .stf__block {
	margin: 0 auto;
}

/* Ensure proper height for stf items */
.ccws-stpageflip .stf__item {
	height: 100%;
	min-height: 600px;
	overflow: visible;
}

/* StPageFlip wrapper structure */
.ccws-stpageflip .stf__wrapper {
	min-height: 600px;
	overflow: visible;
	position: relative;
}

.ccws-stpageflip .stf__block {
	min-height: 600px;
	overflow: visible;
	position: relative;
}

/* Individual page styling */
.ccws-page {
	background: #fff;
	color: #333;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
	overflow-y: auto;
	overflow-x: hidden;
	padding: 30px;
	box-sizing: border-box;
	min-height: 600px;
	height: 100%;
}

/* Each page displays its container content as-is */
.ccws-page {
	/* Container already has its own layout from page editor */
	/* Simply display the content without modification */
}

/* Preserve GenerateBlocks grid structure within pages */
.ccws-page .gb-grid-wrapper,
.ccws-page [class*="gb-grid"] {
	height: 100%;
	width: 100%;
}

/* Ensure GenerateBlocks containers work properly within pages */
.ccws-page .gb-container {
	height: auto;
	width: 100%;
}

/* Make sure images scale properly within the page */
.ccws-page img {
	max-width: 100%;
	height: auto;
}

/* Ensure text content is readable */
.ccws-page p,
.ccws-page li {
	line-height: 1.6;
}

/* Preserve any custom field styling */
.ccws-page .acf-field,
.ccws-page [class*="field-"] {
	margin-bottom: 15px;
}

/* Blank page for odd number of items */
.ccws-page-blank {
	background: #fff;
	position: relative;
}

.ccws-page-blank .ccws-blank-page-content {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #e0e0e0;
	font-style: italic;
}

.ccws-page-blank .ccws-blank-page-content::after {
	content: "End of content";
	font-size: 14px;
}

/* Grid-based page structure */
.ccws-page .gb-grid-wrapper,
.ccws-page [class*="gb-grid"],
.ccws-page .ccws-grid-wrapper {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.ccws-page .gb-grid-column,
.ccws-page [class*="gb-grid-column"],
.ccws-page .ccws-grid-column {
	width: 100%;
}

/* Style image column */
.ccws-page .ccws-image-column {
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Style content column */
.ccws-page .ccws-content-column {
	padding: 20px;
}

.ccws-page .gb-container {
	width: 100%;
	height: auto;
}

/* Ensure grid is visible */
.ccws-page > div {
	width: 100%;
}

/* Ensure images scale properly in grid */
.ccws-page .gb-container img {
	max-width: 100%;
	height: auto;
	object-fit: cover;
}

/* Text content styling in grid */
.ccws-page .gb-container h1,
.ccws-page .gb-container h2,
.ccws-page .gb-container h3 {
	margin-top: 0;
	margin-bottom: 1rem;
}

.ccws-page .gb-container p {
	margin-bottom: 1rem;
	line-height: 1.6;
}

/* Legacy case study structure (fallback) */
.ccws-case-study-page {
	display: flex;
	flex-direction: column;
	height: 100%;
	gap: 15px;
}

.ccws-case-study-title {
	flex-shrink: 0;
	font-size: 1.5em;
	font-weight: bold;
	color: #333;
	line-height: 1.3;
	margin-bottom: 10px;
	border-bottom: 2px solid #eee;
	padding-bottom: 10px;
}

.ccws-case-study-image {
	flex-shrink: 0;
	text-align: center;
	margin-bottom: 15px;
}

.ccws-case-study-image img {
	max-width: 100%;
	height: auto;
	border-radius: 4px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ccws-case-study-fields {
	flex: 1;
	overflow-y: auto;
	font-size: 0.95em;
	line-height: 1.6;
}

.ccws-case-study-fields p {
	margin-bottom: 12px;
}

.ccws-case-study-fields p:last-child {
	margin-bottom: 0;
}

/* Navigation controls */
.ccws-flick-nav {
	position: relative;
	margin-top: 20px;
	display: flex;
	justify-content: center;
	gap: 15px;
	z-index: 10;
}

.ccws-flick-btn {
	background: #D6001C;
	color: white;
	border: none;
	padding: 10px 20px;
	border-radius: 5px;
	cursor: pointer;
	font-size: 15px;
	font-weight: 500;
	transition: all 0.3s ease;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.ccws-flick-btn:hover {
	background: #b00018;
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.ccws-flick-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* Indicators */
.ccws-flick-indicators {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 8px;
	z-index: 10;
}

.ccws-flick-indicator {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.5);
	cursor: pointer;
	transition: background-color 0.3s ease;
}

.ccws-flick-indicator.ccws-active {
	background: rgba(255, 255, 255, 1);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
	.ccws-page-flick-container {
		width: 100%;
		min-height: auto;
	}
	
	.ccws-stpageflip {
		width: 100% !important;
		min-width: 100%;
		height: auto !important;
		min-height: 400px;
	}
	
	.ccws-page {
		width: 100%;
		height: auto;
		min-height: 400px;
		padding: 15px;
	}
	
	/* Mobile fallback display */
	.ccws-page-flick-container.ccws-mobile-fallback {
		display: block;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-stpageflip {
		display: none;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-mobile-content {
		display: block;
		width: 100%;
		padding: 20px;
		background: #fff;
		border: 1px solid #ccc;
		margin-bottom: 20px;
		border-radius: 4px;
		opacity: 1;
		transform: translateX(0);
		transition: all 0.3s ease-in-out;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-mobile-content img {
		width: 100%;
		height: auto;
		margin-bottom: 15px;
		border-radius: 4px;
	}
	
	/* Mobile grid structure */
	.ccws-page-flick-container.ccws-mobile-fallback .gb-grid-wrapper {
		display: block; /* Stack columns on mobile */
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .gb-grid-column {
		width: 100%;
		margin-bottom: 15px;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .gb-container {
		width: 100%;
		padding: 10px;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .gb-container img {
		width: 100%;
		height: auto;
		margin-bottom: 15px;
	}

	/* Mobile legacy case study structure (fallback) */
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-case-study-page {
		gap: 12px;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-case-study-title {
		font-size: 1.3em;
		margin-bottom: 8px;
		padding-bottom: 8px;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-case-study-image {
		margin-bottom: 12px;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-case-study-fields {
		font-size: 0.9em;
		overflow-y: visible; /* Allow natural scroll on mobile */
	}
	
	/* Mobile navigation positioning */
	.ccws-flick-nav.ccws-mobile-nav {
		position: relative;
		bottom: auto;
		right: auto;
		justify-content: center;
		margin-top: 20px;
	}
	
	.ccws-flick-nav.ccws-mobile-nav .ccws-flick-btn {
		padding: 12px 20px;
		font-size: 16px;
		min-width: 100px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ccws-page-flick-container .ccws-loop-item {
		transition: opacity 0.3s ease;
		transform: none !important;
	}
	
	.ccws-page-flick-container .ccws-loop-item.ccws-flicking-out,
	.ccws-page-flick-container .ccws-loop-item.ccws-flicking-in {
		transform: none !important;
	}
	
	.ccws-page-flick-container.ccws-mobile-fallback .ccws-mobile-content {
		transition: opacity 0.3s ease !important;
		transform: none !important;
	}
}