/**
 * Bewiched People's Choice Award — ballot styles.
 *
 * Deliberately low specificity and variable driven so an Elementor theme can
 * override colours without fighting !important.
 *
 * @since 1.0.0
 */

/*
 * Defaults live here; the Appearance settings emit an inline rule with the same
 * selector afterwards, so anything set in the admin wins on source order, and
 * an Elementor widget overrides both by scoping to its own wrapper.
 *
 * Unset variables intentionally fall back to `inherit`, which is what makes the
 * ballot pick up the theme's typography when nothing has been customised.
 */
.bpc-ballot {
	--bpc-accent: #6f4e37;
	--bpc-accent-contrast: #ffffff;
	--bpc-border: #dcd6cf;
	--bpc-radius: 10px;
	--bpc-gap: 1rem;

	max-width: 60rem;
	margin: 0 auto;
	color: var(--bpc-text, inherit);
	font-family: var(--bpc-font, inherit);
	font-size: var(--bpc-font-size, inherit);
}

/*
 * Themes routinely set `input, button, select, legend { font-family: ... }`,
 * which beats plain inheritance from the wrapper. Naming those elements
 * explicitly is what makes the Appearance font setting apply to the whole form.
 */
.bpc-ballot label,
.bpc-ballot legend,
.bpc-ballot p,
.bpc-ballot span,
.bpc-ballot a,
.bpc-ballot input,
.bpc-ballot button,
.bpc-ballot .bpc-notice {
	font-family: var(--bpc-font, inherit);
}

/* Core does not ship .screen-reader-text on the front end, and the ballot uses
   it to hide the legend when the prompt is left empty. */

.bpc-ballot .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/*
 * The heading deliberately declares no font or colour. `var( --unset, inherit )`
 * would drag an h2 down to body size, because this class selector outranks the
 * theme's own h2 rule and `inherit` is not the same as "leave it alone". The
 * Appearance settings emit a .bpc-ballot__heading rule only for the properties
 * that were actually filled in.
 */
.bpc-ballot__heading {
	margin: 0 0 0.5em;
}

.bpc-ballot__intro {
	margin-bottom: 1.5rem;
}

/*
 * A display rule beats the `hidden` attribute, which silently leaves supposedly
 * hidden parts of the form on screen. This puts that right for good.
 */
.bpc-ballot [hidden] {
	display: none !important;
}

/* Thank-you panel — what a voter sees in place of the form */

.bpc-thanks {
	border: 2px solid var(--bpc-accent);
	border-radius: var(--bpc-radius);
	background: var(--bpc-card-bg, transparent);
	padding: 2.25rem 1.5rem;
	text-align: center;
	max-width: 34rem;
	margin: 0 auto;
}

.bpc-thanks__tick {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3.25rem;
	height: 3.25rem;
	border-radius: 50%;
	background: var(--bpc-accent);
	color: var(--bpc-accent-contrast);
	margin-bottom: 1rem;
}

/* No font-family here: the Appearance settings emit one for this selector when
   a heading font is chosen, and `inherit` would override the theme otherwise. */

.bpc-thanks__heading {
	margin: 0 0 0.5rem;
	font-size: 1.5em;
	line-height: 1.2;
}

.bpc-thanks__message {
	margin: 0;
}

.bpc-thanks__message > :first-child {
	margin-top: 0;
}

.bpc-thanks__message > :last-child {
	margin-bottom: 0;
}

/* Notices */

.bpc-notice {
	border: 1px solid var(--bpc-border);
	border-left-width: 4px;
	border-radius: var(--bpc-radius);
	padding: 0.9rem 1.1rem;
	margin: 0 0 1.5rem;
}

.bpc-notice > :first-child {
	margin-top: 0;
}

.bpc-notice > :last-child {
	margin-bottom: 0;
}

.bpc-notice--success {
	border-left-color: #2e7d32;
	background: #f1f8f2;
}

.bpc-notice--error {
	border-left-color: #c62828;
	background: #fdf3f3;
}

.bpc-notice--info,
.bpc-notice--closed {
	border-left-color: var(--bpc-accent);
	background: #faf7f4;
}

/* Venue grid */

.bpc-venues {
	border: 0;
	padding: 0;
	margin: 0 0 1.75rem;
}

.bpc-venues__legend {
	font-weight: 700;
	padding: 0;
	margin-bottom: 0.75rem;
}

.bpc-venues__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(var(--bpc-venue-min, 11rem), 1fr));
	gap: var(--bpc-gap);
}

.bpc-venue {
	position: relative;
}

.bpc-venue__input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.bpc-venue__label {
	display: block;
	height: 100%;
	background: var(--bpc-card-bg, transparent);
	border: 2px solid var(--bpc-border);
	border-radius: var(--bpc-radius);
	padding: 0.75rem;
	cursor: pointer;
	text-align: center;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bpc-venue__label:hover {
	border-color: var(--bpc-accent);
}

.bpc-venue__input:checked + .bpc-venue__label {
	border-color: var(--bpc-accent);
	box-shadow: inset 0 0 0 2px var(--bpc-accent);
}

.bpc-venue__input:focus-visible + .bpc-venue__label {
	outline: 3px solid var(--bpc-accent);
	outline-offset: 2px;
}

/*
 * Shape comes from the Appearance setting. A circle needs a square crop, so the
 * ratio travels with the radius rather than being hard-coded here.
 */
.bpc-venue__image {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	margin: 0 auto 0.6rem;
	border-radius: var(--bpc-image-radius, 50%);
	object-fit: cover;
	aspect-ratio: var(--bpc-image-ratio, 1);
}

.bpc-venue__name {
	display: block;
	font-weight: 700;
}

.bpc-venue__town {
	display: block;
	font-size: 0.9em;
	opacity: 0.75;
}

/* Fields */

.bpc-fields {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: var(--bpc-gap);
}

.bpc-field {
	margin: 0;
}

.bpc-field label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.3rem;
}

.bpc-field input[type="text"],
.bpc-field input[type="email"],
.bpc-field input[type="tel"] {
	width: 100%;
	padding: 0.65rem 0.75rem;
	border: 1px solid var(--bpc-border);
	border-radius: var(--bpc-radius);
	font: inherit;
}

.bpc-field input[aria-invalid="true"] {
	border-color: #c62828;
}

.bpc-field--checkbox {
	grid-column: 1 / -1;
}

.bpc-field--checkbox label {
	font-weight: 400;
	display: flex;
	gap: 0.5rem;
	align-items: flex-start;
}

.bpc-required {
	color: #c62828;
}

/* Honeypot — hidden from people, visible to bots. */

.bpc-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Actions */

.bpc-actions {
	margin: 1.5rem 0 0;
}

.bpc-submit {
	background: var(--bpc-accent);
	color: var(--bpc-accent-contrast);
	border: 0;
	border-radius: var(--bpc-button-radius, var(--bpc-radius));
	padding: 0.85rem 1.75rem;
	font: inherit;
	font-family: var(--bpc-font, inherit);
	font-size: var(--bpc-button-size, inherit);
	font-weight: 700;
	cursor: pointer;
}

.bpc-submit:disabled {
	opacity: 0.6;
	cursor: progress;
}

.bpc-privacy {
	font-size: 0.85em;
	opacity: 0.8;
	margin-top: 1rem;
}

/* Compact list layout
   ---------------------------------------------------------------------------
   The photo moves beside the name instead of above it, which turns a ~200px
   card into a ~56px row. With twenty-odd shops that is the difference between
   a page of scrolling and a glance. */

.bpc-layout-list .bpc-venues__grid {
	gap: 0.5rem;
}

.bpc-layout-list .bpc-venue__label {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	text-align: left;
	padding: 0.45rem 0.7rem;
}

.bpc-layout-list .bpc-venue__image {
	flex: 0 0 auto;
	width: 2.75rem;
	margin: 0;
}

.bpc-layout-list .bpc-venue__name {
	font-size: 0.95em;
	line-height: 1.2;
}

.bpc-layout-list .bpc-venue__town {
	font-size: 0.8em;
}

/* Smaller cards need less padding, or the padding dominates the card. */

.bpc-layout-small .bpc-venue__label {
	padding: 0.5rem;
}

.bpc-layout-small .bpc-venue__name {
	font-size: 0.95em;
}

/* Mobile
   ---------------------------------------------------------------------------
   The auto-fill grid drops to a single very tall card on a phone, so below
   600px the column count is fixed (two by default, one if the setting says so)
   and the padding and type come down to match. */

@media (max-width: 600px) {
	.bpc-venues__grid {
		grid-template-columns: var(--bpc-mobile-grid, repeat(2, minmax(0, 1fr)));
		gap: 0.65rem;
	}

	.bpc-venue__label {
		padding: 0.5rem 0.4rem;
		border-width: 2px;
	}

	.bpc-venue__image {
		margin-bottom: 0.45rem;
	}

	.bpc-venue__name {
		font-size: 0.92em;
		line-height: 1.25;
	}

	.bpc-venue__town {
		font-size: 0.8em;
	}

	.bpc-fields {
		grid-template-columns: 1fr;
	}

	.bpc-submit {
		width: 100%;
	}

	/* The list layout is already dense, so it stays one row per venue and
	   keeps its own photo sizing. */

	.bpc-layout-list .bpc-venues__grid {
		grid-template-columns: 1fr;
		gap: 0.4rem;
	}

	.bpc-layout-list .bpc-venue__image {
		width: 2.5rem;
		margin: 0;
	}

	.bpc-layout-list .bpc-venue__label {
		padding: 0.4rem 0.6rem;
	}
}

/* On the narrowest phones a two-up grid leaves very little room, so keep the
   circle from dominating the card. */

@media (max-width: 380px) {
	.bpc-venue__image {
		max-width: 5.5rem;
	}

	.bpc-layout-list .bpc-venue__image {
		max-width: 2.5rem;
	}
}
