/*
 * OutdoorCabins comparison: «Sammenlign» on products, the compare bar and the comparison table.
 * Structural defaults with the theme's colour tokens (and fallbacks), so it works in any theme.
 */

/* -- «Sammenlign» on a product ---------------------------------------------------------------- */

.oc-compare-toggle {
	margin: 0;
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

.oc-compare-toggle[hidden] {
	display: none;
}

.oc-compare-toggle__label {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	min-height: 2.75rem; /* touch target */
	cursor: pointer;
}

.oc-compare-toggle__input {
	width: 1.15em;
	height: 1.15em;
	margin: 0;
	accent-color: var(--wp--preset--color--brand, #f26122);
}

/* -- The compare bar --------------------------------------------------------------------------- */

.oc-compare-bar {
	position: fixed;
	inset-inline: 0;
	inset-block-end: 0;
	z-index: 100;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem 1rem;
	padding: 0.75rem max(1rem, calc((100vw - 1280px) / 2));
	background: var(--wp--preset--color--base, #fff);
	border-top: 1px solid var(--wp--preset--color--border, #e4e2dc);
	box-shadow: 0 -4px 16px rgb(23 22 20 / 10%);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

.oc-compare-bar[hidden] {
	display: none;
}

body.oc-has-compare-bar {
	padding-block-end: 6rem;
}

.oc-compare-bar__message {
	flex-basis: 100%;
	margin: 0;
	padding: 0.4rem 0.75rem;
	border-radius: 4px;
	background: var(--wp--preset--color--warning-soft, #fdf3e2);
	color: var(--wp--preset--color--warning, #7a4a06);
}

.oc-compare-bar__message[hidden] {
	display: none;
}

.oc-compare-bar__items {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.oc-compare-bar__item {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	max-width: 16rem;
	padding: 0.25rem 0.25rem 0.25rem 0.25rem;
	border: 1px solid var(--wp--preset--color--border, #e4e2dc);
	border-radius: 4px;
	background: var(--wp--preset--color--surface, #f6f5f2);
}

.oc-compare-bar__item img {
	flex: none;
	width: 2.25rem;
	height: 2.25rem;
	object-fit: cover;
	border-radius: 2px;
}

.oc-compare-bar__item a {
	overflow: hidden;
	color: inherit;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.oc-compare-bar__remove,
.oc-compare-bar__clear {
	min-width: 2.75rem;
	min-height: 2.75rem;
	padding: 0 0.5rem;
	border: 0;
	background: none;
	color: var(--wp--preset--color--contrast-muted, #5b5a54);
	font: inherit;
	cursor: pointer;
}

.oc-compare-bar__remove {
	font-size: 1.25rem;
	line-height: 1;
}

.oc-compare-bar__clear {
	text-decoration: underline;
}

.oc-compare-bar__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	margin-inline-start: auto;
}

.oc-compare-bar__hint {
	margin: 0;
	color: var(--wp--preset--color--contrast-muted, #5b5a54);
}

.oc-compare-bar__hint[hidden],
.oc-compare-bar__go[hidden] {
	display: none;
}

/* Phones: names only on wide screens; the thumbnails and the button carry the bar. */
@media (max-width: 599px) {
	.oc-compare-bar__item a {
		display: none;
	}

	.oc-compare-bar__actions {
		margin-inline-start: 0;
		width: 100%;
		justify-content: space-between;
	}
}

/* -- The comparison table ---------------------------------------------------------------------- */

.oc-comparison__tools[hidden] {
	display: none;
}

.oc-comparison__scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.oc-comparison__scroll:focus-visible {
	outline: 2px solid var(--wp--preset--color--brand, #f26122);
	outline-offset: 2px;
}

.oc-comparison__table {
	width: 100%;
	min-width: calc(9rem + var(--oc-compare-columns, 2) * 12rem);
	border-collapse: collapse;
	table-layout: fixed;
}

.oc-comparison__table th,
.oc-comparison__table td {
	padding: 0.6rem 0.75rem;
	border-bottom: 1px solid var(--wp--preset--color--border, #e4e2dc);
	text-align: start;
	vertical-align: top;
}

/* The labels stay in view while the products scroll sideways. */
.oc-comparison__table tbody th[scope="row"],
.oc-comparison__corner {
	position: sticky;
	inset-inline-start: 0;
	z-index: 1;
	width: 9rem;
	background: var(--wp--preset--color--base, #fff);
	font-weight: 600;
}

.oc-comparison__group th {
	padding-top: 1.25rem;
	background: var(--wp--preset--color--surface, #f6f5f2);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.oc-comparison__product {
	font-weight: 400;
}

.oc-comparison__product > * {
	display: block;
	margin-block-end: 0.5rem;
}

.oc-comparison__image img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 4px;
}

.oc-comparison__name {
	color: inherit;
	font-weight: 700;
	font-size: var(--wp--preset--font-size--large, 1.125rem);
	line-height: 1.3;
	text-decoration: none;
}

.oc-comparison__name:hover,
.oc-comparison__name:focus-visible {
	text-decoration: underline;
}

.oc-comparison__view {
	text-align: center;
}

.oc-comparison__remove {
	color: var(--wp--preset--color--contrast-muted, #5b5a54);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

.oc-comparison--differences tr[data-oc-same] {
	display: none;
}

/* Phones: a narrow label column and narrower products, so two products fit side by side. */
@media (max-width: 599px) {
	.oc-comparison__table {
		min-width: calc(5.5rem + var(--oc-compare-columns, 2) * 8.75rem);
		font-size: var(--wp--preset--font-size--small, 0.875rem);
	}

	.oc-comparison__table th,
	.oc-comparison__table td {
		padding: 0.5rem;
	}

	.oc-comparison__table tbody th[scope="row"],
	.oc-comparison__corner {
		width: 5.5rem;
		overflow-wrap: anywhere;
	}

	.oc-comparison__name {
		font-size: var(--wp--preset--font-size--medium, 1rem);
	}

	.oc-comparison__view {
		padding: 0.5em 0.75em;
		font-size: var(--wp--preset--font-size--small, 0.875rem);
	}
}
