/* Comparison table. Needs review-box.css (shared resets, dots, pros/cons). */

/* ---------- Comparison table [wp-review-comparison-table] ---------- */

.ansr-cmp.ansr-cmp {
	container-type: inline-size;
	padding: 14px;
	border-radius: 18px;
	background: var(--rb-tint);
	font-size: 13px;
	line-height: 1.5;
}

.ansr-cmp.ansr-cmp .ansr-cmp__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 16px;
	padding: 0 4px 10px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__head:empty {
	display: none;
}

.ansr-cmp.ansr-cmp .ansr-cmp__title {
	font-size: 16px;
	font-weight: 900;
}

.ansr-cmp.ansr-cmp .ansr-cmp__legend {
	color: var(--rb-muted);
	font-size: 12px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__legend-best {
	color: var(--rb-ink);
	font-weight: 700;
}

.ansr-cmp.ansr-cmp .ansr-cmp__box {
	/* One set of columns for the header and every row; the name column is as wide as the
	   longest name (at least 110px, at most 220px, then it wraps), and the links take what is left. */
	display: grid;
	grid-template-columns: minmax(110px, max-content) repeat(var(--cmp-cols), minmax(44px, 62px)) 92px minmax(140px, auto);
	column-gap: 6px;
	overflow: hidden;
	border-radius: 12px;
	background: #fff;
}

.ansr-cmp.ansr-cmp .ansr-cmp__list {
	display: grid;
	grid-template-columns: subgrid;
	grid-column: 1 / -1;
}

.ansr-cmp.ansr-cmp .ansr-cmp__labels,
.ansr-cmp.ansr-cmp .ansr-cmp__row {
	display: grid;
	grid-template-columns: subgrid;
	grid-column: 1 / -1;
	align-items: center;
	padding: 10px 14px;
}

/* Gap between the name and the first score column; long names wrap at 220px. */
.ansr-cmp.ansr-cmp .ansr-cmp__product,
.ansr-cmp.ansr-cmp .ansr-cmp__label-product {
	max-width: 220px;
	padding-right: 12px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__labels {
	border-bottom: 2px solid var(--rb-off);
	color: var(--rb-ink);
	font-size: 12px;
	font-weight: 700;
}

.ansr-cmp.ansr-cmp .ansr-cmp__label-cat,
.ansr-cmp.ansr-cmp .ansr-cmp__label-total {
	text-align: center;
}

.ansr-cmp.ansr-cmp .ansr-cmp__row {
	border-bottom: 1px solid var(--rb-off);
}

.ansr-cmp.ansr-cmp .ansr-cmp__row:last-child {
	border-bottom: 0;
}

.ansr-cmp.ansr-cmp .ansr-cmp__product {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.ansr-cmp.ansr-cmp .ansr-cmp__name {
	font-size: 15px;
	font-weight: 900;
	line-height: 1.35;
}

.ansr-cmp.ansr-cmp .ansr-cmp__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0 12px;
	font-size: 12px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__actions a,
.ansr-cmp.ansr-cmp .ansr-cmp__more a {
	color: var(--rb-ink);
}

.ansr-cmp.ansr-cmp .ansr-cmp__actions a:hover,
.ansr-cmp.ansr-cmp .ansr-cmp__more a:hover {
	text-decoration: underline;
}

.ansr-cmp.ansr-cmp .ansr-cmp__toggle {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--rb-ink);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.ansr-cmp.ansr-cmp .ansr-cmp__toggle::after {
	content: " ▾";
}

.ansr-cmp.ansr-cmp .ansr-cmp__toggle[aria-expanded="true"]::after {
	content: " ▴";
}

/* Scores: on desktop each cell sits in its own table column. */
.ansr-cmp.ansr-cmp .ansr-cmp__scores {
	display: contents;
}

.ansr-cmp.ansr-cmp .ansr-cmp__cell {
	justify-self: center;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 32px;
	border: 1.5px solid transparent;
	border-radius: 8px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h1 { background: #faf0f3; }
.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h2 { background: #f6e2e9; }
.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h3 { background: #f2d3de; }
.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h4 { background: #ecc3d2; }

.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-best {
	border-color: var(--rb-ink);
}

.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-na {
	border: 1px dashed #d9c9cf;
}

.ansr-cmp.ansr-cmp .ansr-cmp__cat,
.ansr-cmp.ansr-cmp .ansr-cmp__cell .ansr-rb__dots,
.ansr-cmp.ansr-cmp .ansr-cmp__sum {
	display: none;
}

.ansr-cmp.ansr-cmp .ansr-cmp__num {
	font-weight: 900;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
}

.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-na .ansr-cmp__num {
	color: #76626b;
	font-weight: 500;
	font-size: 11px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__total {
	justify-self: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__badge {
	padding: 4px 10px;
	border-radius: 8px;
	background: var(--rb-ink);
	color: #fff;
	font-weight: 900;
	font-size: 19px;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
}

.ansr-cmp.ansr-cmp .ansr-cmp__grade {
	color: var(--rb-ink);
	font-size: 11.5px;
	font-weight: 700;
}

.ansr-cmp.ansr-cmp .ansr-cmp__links {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.ansr-cmp.ansr-cmp .ansr-cmp__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 4px 12px;
	border-radius: 10px;
	background: var(--rb-ink);
	color: #fff;
	font-weight: 700;
	font-size: 12.5px;
	line-height: 1.35;
	text-align: center;
}

.ansr-cmp.ansr-cmp .ansr-cmp__btn:hover,
.ansr-cmp.ansr-cmp .ansr-cmp__btn:focus-visible {
	color: #fff;
	filter: brightness(1.12);
}

.ansr-cmp.ansr-cmp .ansr-cmp__more {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0 12px;
	font-size: 12px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__pc {
	grid-column: 1 / -1;
	margin-top: 10px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__pc[hidden] {
	display: none;
}

.ansr-cmp.ansr-cmp .ansr-cmp__pc .ansr-rb__pros,
.ansr-cmp.ansr-cmp .ansr-cmp__pc .ansr-rb__cons {
	padding: 8px 12px;
	border-radius: 12px;
	background: var(--rb-tint);
}

.ansr-cmp.ansr-cmp .ansr-cmp__pc .ansr-rb__cons {
	background: #e6f0f4;
}

.ansr-cmp.ansr-cmp .ansr-cmp__plus {
	color: var(--rb-ink);
	font-weight: 900;
}

.ansr-cmp.ansr-cmp .ansr-cmp__minus {
	color: var(--rb-neg-ink);
	font-weight: 900;
}

.ansr-cmp.ansr-cmp a:focus-visible,
.ansr-cmp.ansr-cmp button:focus-visible {
	outline: 2px solid var(--rb-ink);
	outline-offset: 2px;
}

/* Narrow column or phone: one card per product. */
@container (max-width: 700px) {
	/* Cards have no colour steps or frames, so the legend goes too. */
	.ansr-cmp.ansr-cmp .ansr-cmp__labels,
	.ansr-cmp.ansr-cmp .ansr-cmp__legend {
		display: none;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__actions {
		align-items: center;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__box {
		display: contents;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__list {
		display: flex;
		flex-direction: column;
		gap: 8px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__row,
	.ansr-cmp.ansr-cmp .ansr-cmp__row:last-child {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"product total"
			"scores scores"
			"sum sum"
			"links links"
			"pc pc";
		row-gap: 8px;
		padding: 10px 12px;
		border: 0;
		border-radius: 12px;
		background: #fff;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__product { grid-area: product; }
	.ansr-cmp.ansr-cmp .ansr-cmp__total { grid-area: total; }
	.ansr-cmp.ansr-cmp .ansr-cmp__links { grid-area: links; }

	.ansr-cmp.ansr-cmp .ansr-cmp__scores {
		grid-area: scores;
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 4px 12px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__scores:not(:has(.ansr-cmp__cell:not(.is-na))) {
		display: none;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__cell,
	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h1,
	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h2,
	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h3,
	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h4 {
		justify-self: stretch;
		justify-content: flex-start;
		gap: 6px;
		width: auto;
		height: auto;
		border: 0;
		background: none;
		font-size: 12.5px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-na {
		display: none;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__cat {
		display: block;
		flex: 0 0 3.2em;
		color: var(--rb-muted);
		font-weight: 700;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__cell .ansr-rb__dots {
		display: inline-flex;
		gap: 2px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__cell .ansr-rb__dot {
		width: 9px;
		height: 9px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__num,
	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h2 .ansr-cmp__num,
	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h3 .ansr-cmp__num,
	.ansr-cmp.ansr-cmp .ansr-cmp__cell.is-h4 .ansr-cmp__num {
		color: var(--rb-text);
		font-size: 12.5px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__sum {
		grid-area: sum;
		display: flex;
		flex-direction: column;
		gap: 2px;
		padding-top: 6px;
		border-top: 1px dashed var(--rb-off);
		font-size: 12.5px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__btn {
		min-height: 44px;
		font-size: 13px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__toggle {
		min-height: 32px;
	}

	.ansr-cmp.ansr-cmp .ansr-cmp__pc {
		grid-area: pc;
		margin-top: 0;
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Places (order="score") and 編輯推薦. */
.ansr-cmp.ansr-cmp .ansr-cmp__rank {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	margin-right: 4px;
	border-radius: 11px;
	background: var(--rb-tint);
	color: var(--rb-ink);
	font-size: 12px;
	font-weight: 900;
	vertical-align: 2px;
}

.ansr-cmp.ansr-cmp .ansr-cmp__rank.is-first {
	background: var(--rb-ink);
	color: #fff;
}

.ansr-cmp.ansr-cmp .ansr-cmp__pick {
	display: inline-block;
	margin-left: 4px;
	padding: 0 6px;
	border-radius: 4px;
	background: var(--rb-ink);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.6;
	vertical-align: 2px;
	white-space: nowrap;
}

/* Wider name column when a place or badge sits next to the name. */
.ansr-cmp.ansr-cmp .ansr-cmp__product:has(.ansr-cmp__pick) {
	max-width: 260px;
}
