/*
 * عابرين — specs.css (SPEC §22)
 * «مواصفات الباقة» block of the product page (template-parts/product/specs.php):
 * a speed tile (wifi icon, required internet speed, 4-bar meter, «مقترحة»
 * mark) and a quality tile (tv icon, quality chip in its tone). Handle
 * stv-specs, printed after stv-page-product on product pages that have
 * specs. Below 360px the tiles stack (icon · text · meter on one row); from
 * 360px they sit side by side; a lone tile always takes the whole row.
 * Tokens only: the light mode (theme-light.css) and palette B follow on their
 * own. Nothing here is interactive, so there are no hover or focus states.
 */

.stv-specs-wrap { min-width: 0; }

.stv-specs {
	display: flex;
	flex-direction: column;
	gap: var(--stv-space-2);
	min-width: 0;
}

.stv-specs__title {
	margin: 0;
	font-size: var(--stv-font-size-sm);
	font-weight: var(--stv-weight-ui);
	line-height: 1.5;
	color: var(--stv-color-text-muted);
}

.stv-specs__list {
	display: flex;
	flex-wrap: wrap;
	gap: var(--stv-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* specs.js hides the block, a tile or the «مقترحة» mark with the hidden attribute; their own display rules would override it. */
.stv-specs[hidden],
.stv-specs__tile[hidden],
.stv-specs__note[hidden] { display: none; }

/* ===== Tile (phones below 360px: one row per tile) ===== */
.stv-specs__tile {
	--stv-specs-accent: var(--stv-color-primary);
	--stv-specs-accent-soft: var(--stv-color-primary-soft);
	--stv-specs-ink: var(--stv-specs-accent);

	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	grid-template-areas: "icon body meter";
	align-items: center;
	gap: var(--stv-space-3);
	flex: 1 1 100%;
	min-width: 0;
	margin: 0;
	padding: var(--stv-space-3) var(--stv-space-4);
	border: 1px solid var(--stv-color-border);
	border-radius: var(--stv-radius-lg);
	background: var(--stv-color-surface);
}

.stv-specs__icon {
	grid-area: icon;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 40px;
	block-size: 40px;
	border-radius: var(--stv-radius-md);
	background: var(--stv-specs-accent-soft);
	color: var(--stv-specs-ink);
}

.stv-specs__icon .stv-icon { font-size: 22px; }

.stv-specs__body {
	grid-area: body;
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.stv-specs__label {
	font-size: var(--stv-font-size-xs);
	font-weight: var(--stv-weight-ui);
	line-height: 1.5;
	color: var(--stv-color-text-muted);
}

.stv-specs__value {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--stv-space-1) var(--stv-space-2);
	min-width: 0;
	font-size: var(--stv-font-size-lg);
	font-weight: var(--stv-weight-heading);
	line-height: 1.4;
	color: var(--stv-color-text);
}

.stv-specs__speed { white-space: nowrap; }

/* «مقترحة»: the speed is the quality's recommendation, not a value set for this package. */
.stv-specs__note {
	display: inline-flex;
	align-items: center;
	min-height: 22px;
	padding: 0 var(--stv-space-2);
	border: 1px dashed var(--stv-color-border-strong);
	border-radius: var(--stv-radius-pill);
	font-size: var(--stv-font-size-xs);
	font-weight: var(--stv-weight-ui);
	line-height: 1.2;
	color: var(--stv-color-text-muted);
	white-space: nowrap;
}

/* Quality chip */
.stv-specs__chip {
	display: inline-flex;
	align-items: center;
	max-width: 100%;
	min-height: 30px;
	padding: 0 var(--stv-space-3);
	overflow: hidden;
	border: 1px solid var(--stv-specs-accent);
	border-radius: var(--stv-radius-pill);
	background: var(--stv-specs-accent-soft);
	color: var(--stv-specs-ink);
	font-size: var(--stv-font-size-sm);
	font-weight: var(--stv-weight-heading);
	line-height: 1.2;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Tones of the quality tile (عابرين › مواصفات الباقات › الجودات) */
.stv-specs__tile--quality[data-tone="secondary"] { --stv-specs-accent: var(--stv-color-secondary); --stv-specs-accent-soft: var(--stv-color-secondary-soft); }
.stv-specs__tile--quality[data-tone="success"] { --stv-specs-accent: var(--stv-color-success); --stv-specs-accent-soft: var(--stv-color-success-soft); }
.stv-specs__tile--quality[data-tone="info"] { --stv-specs-accent: var(--stv-color-info); --stv-specs-accent-soft: var(--stv-color-info-soft); }

.stv-specs__tile--quality[data-tone="muted"] {
	--stv-specs-accent: var(--stv-color-text-muted);
	--stv-specs-accent-soft: var(--stv-color-surface-3);
}

.stv-specs__tile--quality[data-tone="muted"] .stv-specs__chip {
	border-color: var(--stv-color-border-strong);
	color: var(--stv-color-text);
}

/*
 * ===== Signal meter: four rising bars, filled up to the level (is-0 … is-4) =====
 * Drawn left to right in every language, like the familiar signal glyph
 * (it is a picture, hidden from screen readers; the value says the speed).
 */
.stv-specs__meter {
	grid-area: meter;
	display: inline-flex;
	align-items: flex-end;
	gap: 3px;
	block-size: 20px;
	direction: ltr;
}

.stv-specs__bar {
	display: block;
	inline-size: 5px;
	border-radius: 2px;
	background: var(--stv-color-border-strong);
	transition: background-color var(--stv-transition);
}

.stv-specs__bar:nth-child(1) { block-size: 8px; }
.stv-specs__bar:nth-child(2) { block-size: 12px; }
.stv-specs__bar:nth-child(3) { block-size: 16px; }
.stv-specs__bar:nth-child(4) { block-size: 20px; }

.stv-specs__meter.is-1 .stv-specs__bar:nth-child(-n+1),
.stv-specs__meter.is-2 .stv-specs__bar:nth-child(-n+2),
.stv-specs__meter.is-3 .stv-specs__bar:nth-child(-n+3),
.stv-specs__meter.is-4 .stv-specs__bar:nth-child(-n+4) {
	background: var(--stv-specs-ink);
}

.stv-specs__meter.is-0 { visibility: hidden; }

/*
 * Dark mode: the tone ink is lifted towards the text colour so every tone of
 * both palettes keeps at least 4.5:1 on its tint (palette B's red alone
 * gives 2.8:1 on the dark surface). The light mode keeps the plain accent
 * (5.2:1 or more).
 */
@supports (color: color-mix(in srgb, red 50%, black)) {
	:root:not([data-theme="light"]) .stv-specs__tile { --stv-specs-ink: color-mix(in srgb, var(--stv-specs-accent) 65%, var(--stv-color-text)); }
}

/* ===== Two tiles side by side from 360px ===== */
@media (min-width: 360px) {
	.stv-specs__tile {
		flex-basis: calc(50% - var(--stv-space-3) / 2);
		grid-template-columns: auto minmax(0, 1fr);
		grid-template-areas:
			"icon meter"
			"body body";
		align-items: start;
		row-gap: var(--stv-space-2);
		padding: var(--stv-space-3);
	}

	.stv-specs__meter { align-self: center; justify-self: end; }

	/* A lone tile takes the whole row and keeps the one-row layout. */
	.stv-specs--single .stv-specs__tile {
		grid-template-columns: auto minmax(0, 1fr) auto;
		grid-template-areas: "icon body meter";
		align-items: center;
		padding: var(--stv-space-3) var(--stv-space-4);
	}
}

@media (min-width: 600px) {
	.stv-specs__tile { padding: var(--stv-space-4); }
	.stv-specs--single .stv-specs__tile { padding: var(--stv-space-3) var(--stv-space-4); }
}

/* ===== Windows high contrast ===== */
@media (forced-colors: active) {
	.stv-specs__tile { border-color: CanvasText; }

	.stv-specs__bar {
		forced-color-adjust: none;
		background: GrayText;
	}

	.stv-specs__meter.is-1 .stv-specs__bar:nth-child(-n+1),
	.stv-specs__meter.is-2 .stv-specs__bar:nth-child(-n+2),
	.stv-specs__meter.is-3 .stv-specs__bar:nth-child(-n+3),
	.stv-specs__meter.is-4 .stv-specs__bar:nth-child(-n+4) {
		background: CanvasText;
	}

	.stv-specs__chip,
	.stv-specs__note { border-color: CanvasText; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
	.stv-specs__bar { transition: none; }
}

/* ===== Print ===== */
@media print {
	.stv-specs__tile { break-inside: avoid; }
}
