/**
 * Care Rating Badge — front-end styles.
 *
 * The rating image itself is the official CQC artwork, rendered untouched.
 * Only the name pill and the layout around it belong to this plugin.
 */

.crb-badge {
	--crb-width: 280px;
	--crb-purple: #5f2865;

	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	width: 100%;
	max-width: var(--crb-width);
	margin-bottom: 1em;
}

.crb-badge--align-center {
	margin-left: auto;
	margin-right: auto;
}

.crb-badge--align-right {
	margin-left: auto;
	margin-right: 0;
}

.crb-badge--align-left {
	margin-left: 0;
	margin-right: auto;
}

.crb-badge__link {
	display: block;
	width: 100%;
	line-height: 0;
	border: 0;
	box-shadow: none;
	text-decoration: none;
}

.crb-badge__link:focus-visible {
	outline: 3px solid var(--crb-purple);
	outline-offset: 3px;
}

.crb-badge__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.crb-badge__name {
	display: inline-block;
	box-sizing: border-box;
	max-width: 100%;
	padding: 0.5em 1.1em;
	border-radius: 999px;
	background: var(--crb-purple);
	color: #fff;
	font-size: clamp(0.95rem, 1.6vw, 1.15rem);
	font-weight: 700;
	line-height: 1.35;
	text-align: center;
	text-wrap: balance;
}

.crb-badge__date {
	font-size: 0.8125rem;
	line-height: 1.4;
	text-align: center;
	opacity: 0.75;
}

/* Size presets ---------------------------------------------------------- */

.crb-badge--size-small {
	gap: 7px;
}

.crb-badge--size-small .crb-badge__name {
	padding: 0.4em 0.9em;
	font-size: 0.8125rem;
}

.crb-badge--size-small .crb-badge__date {
	font-size: 0.75rem;
}

.crb-badge--size-large {
	gap: 14px;
}

.crb-badge--size-large .crb-badge__name {
	font-size: clamp(1.05rem, 1.9vw, 1.35rem);
}

.crb-badges--size-small {
	gap: 20px;
}

/* Grid ------------------------------------------------------------------ */

.crb-badges {
	--crb-cols: 3;

	display: grid;
	grid-template-columns: repeat(var(--crb-cols), minmax(0, 1fr));
	gap: 28px;
	align-items: stretch;
	justify-items: center;
	margin-bottom: 1em;
}

.crb-badges .crb-badge {
	height: 100%;
	margin-bottom: 0;
}

/*
 * Official CQC images are not all the same shape, so in a grid the name pill
 * is pushed to the bottom of the row. That keeps the pills on one line even
 * when the images above them differ in height.
 */

.crb-badges .crb-badge__name {
	margin-top: auto;
}

.crb-badges--align-left {
	justify-items: start;
}

.crb-badges--align-right {
	justify-items: end;
}

@media (max-width: 900px) {
	.crb-badges {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.crb-badges {
		grid-template-columns: 1fr;
		justify-items: center;
	}
}

/* Only added in case the active theme does not define it. */

.crb-badge .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
