/**
 * Category Grid Template Styles
 * Responsive grid layout for WooCommerce product category subcategories
 * Displays categories as image buttons in a 4-column grid
 */

/* ========================================
   Force Full Width Layout
   ======================================== */

/* Force primary content area to be full width when grid template is active */
body.category-grid-template #primary.pls-content-area {
	width: 100% !important;
	max-width: 100% !important;
	flex: 0 0 100% !important;
}

/* Hide secondary sidebar on grid template pages */
body.category-grid-template #secondary {
	display: none !important;
}

/* Hide mobile sidebar elements on grid template pages */
body.category-grid-template .mobile-element-sidebar {
	display: none !important;
}

/* ========================================
   Category Description
   ======================================== */

.category-description {
	margin-bottom: 40px;
	text-align: right;
	padding: 0 15px;
}

.category-description .term-description {
	font-size: 18px;
	line-height: 1.4;
	color: #666;
	margin: 0;
	max-width: unset !important;
}

.category-description .term-description p:last-child {
	margin-bottom: 0;
}

/* Archive page specific styling */
.archive.tax-product_cat .category-description.archive-description {
	margin-top: 30px;
	margin-bottom: 40px;
	padding: 0;
}

.archive.tax-product_cat .category-description.archive-description .term-description {
	max-width: 100%;
}

/* ========================================
   SEO Text Read More (All Devices)
   ======================================== */

/* Desktop: 2 rows exposed */
.category-description .term-description.seo-text-collapse {
	position: relative;
	max-height: 2.8em; /* 2 lines at line-height 1.4 */
	overflow: hidden;
	transition: max-height 0.4s ease;
	line-height: 1.4;
}

.category-description .term-description.seo-text-collapse::after {
	content: '';
	position: absolute;
	bottom: 0;
	right: 0;
	left: 0;
	height: 1.4em;
	background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.category-description .term-description.seo-text-collapse.is-expanded {
	max-height: 2000px; /* large enough for any content */
}

.category-description .term-description.seo-text-collapse.is-expanded::after {
	opacity: 0;
}

.seo-text-read-more {
	display: inline-block;
	background: none;
	border: none;
	color: #000;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	padding: 8px 0;
	margin-top: 4px;
	font-family: inherit;
	transition: color 0.2s ease;
	text-align: left;
	text-decoration: underline;
}

.seo-text-read-more:hover {
    background: white;
    color: black;
}

.seo-text-read-more .read-less-text {
	display: none;
}

.seo-text-read-more[aria-expanded="true"] .read-more-text {
	display: none;
}

.seo-text-read-more[aria-expanded="true"] .read-less-text {
	display: inline;
}

/* ========================================
   SEO Text Read More (Mobile Adjustments)
   ======================================== */

@media (max-width: 768px) {
	.category-description .term-description.seo-text-collapse {
		max-height: 5.6em; /* 4 lines on mobile */
	}
	
	.category-description .term-description.seo-text-collapse::after {
		height: 2.8em; /* Larger fade on mobile */
	}
}

/* ========================================
   Category Bottom Content
   ======================================== */

.category-bottom-content {
	margin-top: 60px;
	margin-bottom: 40px;
	text-align: right;
	padding: 0 15px;
	width: 100%;
}

.category-bottom-content .term-bottom-description {
	font-size: 18px;
	line-height: 1.4;
	color: #666;
	margin: 0;
	max-width: unset !important;
}

.term-bottom-description h2{
	font-weight: 700;
}

.category-bottom-content .term-bottom-description p:last-child {
	margin-bottom: 0;
}

/* Responsive styling for bottom content */
@media (max-width: 768px) {
	.category-bottom-content {
		margin-top: 40px;
		margin-bottom: 30px;
	}
	
	.category-bottom-content .term-bottom-description {
		font-size: 18px;
	}

	.category-bottom-content .term-bottom-description h2{
		font-size: 28px;
	}
}



@media (max-width: 480px) {
	.category-bottom-content {
		margin-top: 30px;
		margin-bottom: 20px;
		padding: 0 10px;
	}
	
	.category-bottom-content .term-bottom-description {
		font-size: 18px;
	}
}

@media (max-width: 480px) {
	.archive.tax-product_cat .category-description.archive-description {
		margin-top: 0;
		padding: 20px;
	}
	.archive.tax-product_cat .category-description.archive-description p {
		font-size: 18px;
		line-height: 1.6;
	}
}

/* ========================================
   Grid Container
   ======================================== */

.category-grid-container {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 80px;
	width: 100%;
	margin: 0 auto 80px;
}

.category-grid-image img:hover {
    transform: scale(0.9);
}

/* ========================================
   Category Card
   ======================================== */

.category-grid-card {
	background: #ffffff;
	border-radius: var(--pls-border-radius, 8px);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: inherit;
	position: relative;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
}



/* ========================================
   Image Section
   ======================================== */

.category-grid-image {
	width: 100%;
	overflow: hidden;
	position: relative;
	border-radius: var(--pls-border-radius, 8px);
}

.category-grid-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	display: block;
	transition: transform 0.3s ease;
}


/* ========================================
   Content Section
   ======================================== */

.category-grid-content {
	padding: 20px;
	text-align: center;
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: center;
}

.category-grid-title {
	font-size: 22px;
	font-weight: 700;
	color: #1a1a1a;
	margin: 0;
	line-height: 1.3;
	font-family: inherit;
}

/* ========================================
   RTL Support
   ======================================== */

[dir="rtl"] .category-grid-content {
	text-align: center;
}

[dir="ltr"] .category-grid-content {
	text-align: center;
}

/* ========================================
   Accessibility
   ======================================== */

.category-grid-card:focus {
	outline: 2px solid #0066cc;
	outline-offset: 2px;
}

.category-grid-card:focus:not(:focus-visible) {
	outline: none;
}

/* ========================================
   Responsive Design - Large Tablets & Small Desktops
   ======================================== */

@media (max-width: 1024px) {
	.category-grid-container {
		grid-template-columns: repeat(3, 1fr);
		gap: 20px;
	}
	

	
	.category-grid-title {
		font-size: 20px;
	}
	
	.category-description {
		margin-bottom: 35px;
	}
}

/* ========================================
   Responsive Design - Tablets
   ======================================== */

@media (max-width: 768px) {
	.category-grid-container {
		grid-template-columns: repeat(3, 1fr);
		gap: 20px;
		margin-bottom: 50px;
		margin-top: 80px;

	}
	
	
	.category-grid-content {
		padding: 18px 15px;
	}
	
	.category-grid-title {
		font-size: 18px;
	}
	
	.category-description {
		margin-bottom: 30px;
	}
	

}

/* ========================================
   Responsive Design - Mobile Devices
   ======================================== */

@media (max-width: 480px) {
	.category-grid-container {
		grid-template-columns: repeat(3, 1fr);
		gap: 20px;
		margin-bottom: 40px;
		margin-top: 80px;

	}
	
	
	.category-grid-content {
		padding: 15px 12px;
	}
	
	.category-grid-title {
		font-size: 16px;
	}
	
	.category-description {
		margin-bottom: 25px;
		padding: 0 10px;
	}
	

}

/* ========================================
   Loading State
   ======================================== */

.category-grid-card.is-loading {
	pointer-events: none;
	opacity: 0.6;
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
	.category-grid-card {
		break-inside: avoid;
		box-shadow: none;
		border: 1px solid #ddd;
		page-break-inside: avoid;
	}
	
	.category-grid-card:hover {
		transform: none;
		box-shadow: none;
	}
	
	.category-grid-container {
		gap: 40px;
	}
}

/* ========================================
   High Contrast Mode Support
   ======================================== */

@media (prefers-contrast: high) {
	.category-grid-card {
		border: 2px solid currentColor;
	}
	
	.category-description .term-description {
		color: #333;
	}
}

/* ========================================
   Reduced Motion Support
   ======================================== */

@media (prefers-reduced-motion: reduce) {
	.category-grid-card,
	.category-grid-image img {
		transition: none;
	}
	
	.category-grid-card:hover {
		transform: none;
	}
	
	.category-grid-card:hover .category-grid-image img {
		transform: none;
	}
}

/* ========================================
   Empty State
   ======================================== */

.woocommerce-info {
	padding: 20px;
	background: #f7f7f7;
	border: 1px solid #ddd;
	border-radius: var(--pls-border-radius, 8px);
	text-align: center;
	margin: 20px 0;
}
