/**
 * CPH Stats Grid Styles
 *
 * Grid layout with dividers for displaying statistics.
 *
 * @package Salient_Child
 * @since   1.0.0
 */

/* ==========================================================================
   GRID CONTAINER
   ========================================================================== */

.cph-stats-grid {
	--columns: 3;
	--divider-color: #000;
	--label-font-size: 28px;
	--value-font-size: 43px;
	--label-color: #000;
	--value-color: #000;
	--cell-padding: 40px;
	--label-value-gap: 10px;

	display: grid;
	grid-template-columns: repeat(var(--columns), 1fr);
	width: 100%;
}

/* ==========================================================================
   GRID ITEM
   ========================================================================== */

.cph-stats-grid__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: var(--cell-padding);
	gap: var(--label-value-gap);
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

.cph-stats-grid__label {
	font-family: "area-normal", sans-serif;
	font-size: var(--label-font-size);
	font-weight: 400;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--label-color);
	line-height: 1.2;
}

.cph-stats-grid__value {
	font-family: "area-normal", sans-serif;
	font-size: var(--value-font-size);
	font-weight: 700;
	letter-spacing: 0.8px;
	color: var(--value-color);
	line-height: 1.1;
}

/* ==========================================================================
   DIVIDERS
   --------------------------------------------------------------------------
   "internal" = inner dividers only (no outer border)
   "full"     = inner dividers + outer border

   The inner-divider logic (a right border between columns, a bottom border
   between rows, with the outer edges trimmed) is identical for both styles.
   "full" only adds the outer container border on top.

   Which cells sit in the last column / last row depends on the column count,
   so that trimming lives in the column-aware media blocks below. The column
   count comes from the .cph-stats-grid--cols-{N} class set in the render
   (NOT a [style] attribute — the --columns custom property is delivered via
   a per-instance <style> block and can't be matched with [style*=...]).
   ========================================================================== */

/* Inner dividers: every cell draws a right + bottom border. */
.cph-stats-grid--dividers .cph-stats-grid__item {
	border-right: 1px solid var(--divider-color);
	border-bottom: 1px solid var(--divider-color);
}

/* The final cell never needs a trailing right border (covers a partially
   filled last row, e.g. an orphan cell). */
.cph-stats-grid--dividers .cph-stats-grid__item:last-child {
	border-right: none;
}

/* "Full" style adds the outer border around the whole grid. */
.cph-stats-grid--dividers-full {
	border: 1px solid var(--divider-color);
}

/* ==========================================================================
   DESKTOP COLUMN LOGIC (min-width: 1000px)
   Trim the right border off the last column and the bottom border off the
   last row, per chosen column count. Gated to desktop so the tablet/mobile
   ranges below stand on their own without specificity battles.
   ========================================================================== */

@media only screen and (min-width: 1000px) {
	/* 2 columns */
	.cph-stats-grid--cols-2 .cph-stats-grid__item:nth-child(2n) {
		border-right: none;
	}
	.cph-stats-grid--cols-2 .cph-stats-grid__item:nth-last-child(-n+2):nth-child(2n+1),
	.cph-stats-grid--cols-2 .cph-stats-grid__item:nth-last-child(-n+2):nth-child(2n+1) ~ .cph-stats-grid__item {
		border-bottom: none;
	}

	/* 3 columns */
	.cph-stats-grid--cols-3 .cph-stats-grid__item:nth-child(3n) {
		border-right: none;
	}
	.cph-stats-grid--cols-3 .cph-stats-grid__item:nth-last-child(-n+3):nth-child(3n+1),
	.cph-stats-grid--cols-3 .cph-stats-grid__item:nth-last-child(-n+3):nth-child(3n+1) ~ .cph-stats-grid__item {
		border-bottom: none;
	}

	/* 4 columns */
	.cph-stats-grid--cols-4 .cph-stats-grid__item:nth-child(4n) {
		border-right: none;
	}
	.cph-stats-grid--cols-4 .cph-stats-grid__item:nth-last-child(-n+4):nth-child(4n+1),
	.cph-stats-grid--cols-4 .cph-stats-grid__item:nth-last-child(-n+4):nth-child(4n+1) ~ .cph-stats-grid__item {
		border-bottom: none;
	}
}

/* ==========================================================================
   RESPONSIVE - TABLET (691px - 999px) — grid collapses to 2 columns.
   Bounded range so these rules don't leak into the mobile block below.
   ========================================================================== */

@media only screen and (min-width: 691px) and (max-width: 999px) {
	.cph-stats-grid {
		--label-font-size: 22px;
		--value-font-size: 36px;
		--cell-padding: 30px;
	}

	/* 2-column trims (base right + bottom borders come from the rules above). */
	.cph-stats-grid--dividers .cph-stats-grid__item:nth-child(2n) {
		border-right: none;
	}
	.cph-stats-grid--dividers .cph-stats-grid__item:nth-last-child(-n+2):nth-child(2n+1),
	.cph-stats-grid--dividers .cph-stats-grid__item:nth-last-child(-n+2):nth-child(2n+1) ~ .cph-stats-grid__item {
		border-bottom: none;
	}
}

/* ==========================================================================
   RESPONSIVE - MOBILE (max-width: 690px) — single column.
   ========================================================================== */

@media only screen and (max-width: 690px) {
	.cph-stats-grid {
		--label-font-size: 18px;
		--value-font-size: 30px;
		--cell-padding: 25px 20px;
	}

	/* One column: bottom dividers only. */
	.cph-stats-grid--dividers .cph-stats-grid__item {
		border-right: none;
		border-bottom: 1px solid var(--divider-color);
	}
	.cph-stats-grid--dividers .cph-stats-grid__item:last-child {
		border-bottom: none;
	}
}
