/**
 * AKT Products Plugin - Stylesheet
 * * Haldab toodete ruudustiku (grid) paigutust ja toote kaartide disaini.
 * Grid on responsiivne:
 * - Desktop: Kasutab PHP poolt määratud veergude arvu (.cpee-cols-X).
 * - Tablet (< 1024px): Max 3 veergu.
 * - Mobile (< 768px): Max 2 veergu.
 * - Small Mobile (< 480px): 1 veerg.
 */

.cpee-product-grid {
	display: grid;
	gap: 20px;
	margin-top: 20px;
	width: 100%;
	/* Rakendame border-box ainult gridile ja selle otsestele lastele */
	box-sizing: border-box;
}

.cpee-product-grid * {
	box-sizing: border-box;
}

/* * Desktop vaade (vaikimisi)
 * Kasutame minmax(0, 1fr), et vältida sisu (nt pika teksti või pildi)
 * poolt veeru laiuse "laiali lükkamist". See tagab võrdsed veerud.
 */
.cpee-product-grid.cpee-cols-1 {
	grid-template-columns: repeat(1, minmax(0, 1fr));
}

.cpee-product-grid.cpee-cols-2 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cpee-product-grid.cpee-cols-3 {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cpee-product-grid.cpee-cols-4 {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cpee-product-grid.cpee-cols-5 {
	grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* * Toote kaardi stiilid 
 */
.cpee-product-item {
	display: block;
	/* Position relative on vajalik, et sisemine link saaks laieneda üle terve kasti */
	position: relative; 
	border: 1px solid #e1e1e1;
	padding: 15px;
	text-align: center;
	background: #fff;
	transition: box-shadow 0.2s ease;
	height: 100%;
}

.cpee-product-item:hover {
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
	/* Valikuline: muudab kursori lingi omaks, kui hiir on kasti kohal */
	cursor: pointer;
}

/* STRETCHED LINK MAGIC
 * See klass venitatakse üle terve .cpee-product-item kasti.
 * Tulemus: kasutaja saab klikkida ükskõik kuhu kastile.
 */
.cpee-card-link::after {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1; /* Tõstab lingi kihi kõige peale */
}

.cpee-product-image {
	width: 100%;
	aspect-ratio: 2/1;
	overflow: hidden;
	display: block;
	background-color: #f7f7f7;
	position: relative;
	margin-bottom: 15px;
}

.cpee-product-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	position: absolute;
	top: 0;
	left: 0;
    pointer-events: none !important;
}

.cpee-product-title {
	font-size: 16px;
	line-height: 1.4;
	margin: 10px 0;
	word-wrap: break-word;
    overflow-wrap: break-word;
}

.cpee-product-title a {
	text-decoration: none;
	color: #333;
}

.cpee-product-price {
	display: block;
	font-weight: bold;
	margin-bottom: 10px;
	color: #222;
	font-size: 1.1em;
	/* Et hind oleks nähtav lingi all, aga klikk läheb lingile */
	position: relative; 
}

.cpee-event-starts {
	font-size: 14px;
	color: #666;
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid #eee;
}

/* * RESPONSIVE LOGIC
 */

@media (max-width: 1024px) {
	.cpee-product-grid.cpee-cols-5,
	.cpee-product-grid.cpee-cols-4 {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}
}

@media (max-width: 768px) {
	.cpee-product-grid.cpee-cols-5,
	.cpee-product-grid.cpee-cols-4,
	.cpee-product-grid.cpee-cols-3 {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}

@media (max-width: 480px) {
	.cpee-product-grid[class*="cpee-cols-"] {
		grid-template-columns: 1fr !important;
	}
	
	.cpee-product-grid {
		gap: 15px;
	}
}