/* Device comparison table (template-parts/device-comparison.php)

   Desktop: a label column plus one column per device. Each column is a
   subgrid of the parent's rows, so a long "Best for" value in one device
   grows that row for all of them. The MOST POPULAR column is shaded from
   its image down to the last row.

   Phones (< 768px): the label column goes and each device stacks as a card
   with the labels inline, as in the finalised mobile frame. */

.dc-wrap {
	--dc-line: 1px solid var(--color-grey-darker);
	--dc-pad-x: var(--default-gutter-x);
}

.device-comparison {
	display: grid;
	grid-template-columns: max-content repeat(var(--dc-products), minmax(0, 1fr));
	grid-template-rows: auto repeat(var(--dc-rows), auto) auto;
	font-size: var(--text-size-sm);
	font-weight: 400;
	line-height: 1.4;

	p {
		margin: 0;
	}
}

.dc-labels,
.dc-device {
	display: grid;
	grid-row: 1 / -1;
	grid-template-rows: subgrid;
	min-width: 0;
}

.dc-specs {
	display: grid;
	grid-row: span var(--dc-rows);
	grid-template-rows: subgrid;
	margin: 0;

	dd {
		margin: 0;
	}
}

.dc-head {
	position: relative;
	padding: var(--dc-pad-x) var(--dc-pad-x) calc(var(--default-gutter-y) * 1.5);
}

.dc-cell {
	display: flex;
	align-items: center;
	padding: var(--default-gutter-y) var(--dc-pad-x);
	border-top: var(--dc-line);

	&:last-child {
		border-bottom: var(--dc-line);
	}
}

/* The label column ends with the empty actions cell, so its last row is
   second from last. */
.dc-labels .dc-cell:nth-last-child(2) {
	border-bottom: var(--dc-line);
}

.dc-labels .dc-cell {
	padding-right: calc(var(--default-gutter-x) * 8);
	color: var(--color-secondary);
	font-weight: 300;
}

/* The label column says what each row is on desktop; the in-cell label is
   for screen readers there and becomes visible on phones. */
.dc-cell-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.dc-media {
	display: block;
	aspect-ratio: 1 / 1;
	margin-bottom: var(--default-gutter-y);
	overflow: hidden;
	background-color: var(--color-grey);
	border-radius: 8px;

	img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

.dc-badge {
	position: absolute;
	top: calc(var(--dc-pad-x) + 10px);
	left: calc(var(--dc-pad-x) + 10px);
	padding: 3px 10px;
	background-color: var(--color-primary);
	border-radius: 50vh;
	font-size: var(--text-size-xs);
	color: var(--color-white);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.dc-title {
	margin: 0 0 4px;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
}

.dc-price {
	font-weight: 600;

	.dc-vat {
		font-weight: 400;
	}
}

.dc-finance {
	margin-top: 2px;
	font-size: var(--text-size-xs);
	color: #6b6b6b;
}

/* Every second device column is shaded, so with three the middle one is. */
.dc-device:nth-of-type(even) {
	/* Between the section's --color-grey and the --color-grey-darker lines. */
	background-color: #ececec;

	.dc-media {
		background-color: var(--color-white);
	}
}

.dc-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: calc(var(--default-gutter-x) / 2);
	padding: calc(var(--default-gutter-y) * 1.5) var(--dc-pad-x) 0;
}

/* "Still not sure?" banner */
.dc-banner {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: var(--default-gutter-y) calc(var(--default-gutter-x) * 2);
	margin-top: calc(var(--default-gutter-y) * 3);
	padding: calc(var(--default-gutter-y) * 1.5) calc(var(--default-gutter-x) * 2);
	background-color: var(--color-primary);
	border-radius: 12px;
	color: var(--color-white);

	p {
		margin: 0;
		font-size: var(--text-size-sm);
	}

	.dc-banner-title {
		font-size: var(--text-size);
		font-weight: 600;
	}

	/* White pill on the black band; the arrow chip inverts to match. */
	.button,
	.button:not(.label, .outline, :disabled):hover {
		background-color: var(--color-white);
		color: var(--color-primary);
	}

	.button:not(.iconless):after {
		background-color: var(--color-primary);
		color: var(--color-white);
	}
}

@media (max-width: 991.98px) {
	.dc-wrap {
		--dc-pad-x: 10px;
	}

	.dc-labels .dc-cell {
		padding-right: var(--default-gutter-x);
	}

	.dc-actions .button {
		flex: 1 1 100%;
	}
}

@media (max-width: 767.98px) {
	.device-comparison {
		display: flex;
		flex-direction: column;
		gap: var(--default-gutter-y);
	}

	.dc-labels {
		display: none;
	}

	.dc-device {
		display: block;
		overflow: hidden;
		background-color: var(--color-white);
		border: var(--dc-line);
		border-radius: 12px;

		&.is-popular {
			border: 2px solid var(--color-primary);
		}

		&:nth-of-type(even) {
			background-color: var(--color-white);

			.dc-media {
				background-color: var(--color-grey);
			}
		}
	}

	.dc-head {
		padding: 0 0 var(--default-gutter-y);
	}

	.dc-media {
		aspect-ratio: 16 / 10;
		margin-bottom: var(--default-gutter-y);
		border-radius: 0;
	}

	.dc-badge {
		top: 10px;
		left: 10px;
	}

	.dc-title,
	.dc-price,
	.dc-finance {
		padding: 0 var(--default-gutter-x);
	}

	.dc-specs {
		display: block;
		padding: 0 var(--default-gutter-x);
	}

	.dc-cell {
		display: grid;
		grid-template-columns: 38% 1fr;
		gap: var(--default-gutter-x);
		padding: 10px 0;
		border-top: 0;
		border-bottom: var(--dc-line);

		&:last-child {
			border-bottom: 0;
		}
	}

	.dc-cell-label {
		position: static;
		width: auto;
		height: auto;
		overflow: visible;
		clip: auto;
		white-space: normal;
		font-size: var(--text-size-xs);
		font-weight: 300;
		align-self: center;
	}

	.dc-actions {
		flex-direction: column;
		align-items: stretch;
		padding: var(--default-gutter-y) var(--default-gutter-x);
	}

	.dc-banner {
		padding: var(--default-gutter-y) calc(var(--default-gutter-x) * 1.5);

		.button {
			width: 100%;
		}
	}
}
