/**
 * Image Choice field — frontend styles.
 *
 * Visual tile grid where users pick between images.
 * Each tile = image (or placeholder) + optional label + check overlay on select.
 */

/* ==========================================================================
   Grid
   ========================================================================== */

.bf-image-choice {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat( 3, 1fr );
}

.bf-image-choice--2col { grid-template-columns: repeat( 2, 1fr ); }
.bf-image-choice--3col { grid-template-columns: repeat( 3, 1fr ); }
.bf-image-choice--4col { grid-template-columns: repeat( 4, 1fr ); }
.bf-image-choice--5col { grid-template-columns: repeat( 5, 1fr ); }
.bf-image-choice--6col { grid-template-columns: repeat( 6, 1fr ); }

/* ==========================================================================
   Tile  (<label>)
   ========================================================================== */

.bf-image-choice__item {
	cursor: pointer;
	display: flex;
	flex-direction: column;
	border: 2px solid var( --bf-field-border, #e2e8f0 );
	border-radius: 10px;
	overflow: hidden;
	background: var( --bf-field-bg, #ffffff );
	transition: border-color 0.15s, box-shadow 0.15s;
	user-select: none;
	-webkit-user-select: none;
}

.bf-image-choice__item:hover {
	border-color: var( --bf-button-bg, var( --bf-focus-color, #0f766e ) );
}

.bf-image-choice__item.is-checked {
	border-color: var( --bf-button-bg, var( --bf-focus-color, #0f766e ) );
	box-shadow: 0 0 0 3px color-mix( in srgb, var( --bf-button-bg, var( --bf-focus-color, #0f766e ) ) 15%, transparent );
}

/* ==========================================================================
   Hidden native input
   ========================================================================== */

.bf-image-choice__item input[type="radio"],
.bf-image-choice__item input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	width: 0;
	height: 0;
	margin: 0;
}

/* ==========================================================================
   Image wrapper — 1:1 aspect ratio, image fills it
   ========================================================================== */

.bf-image-choice__img-wrap {
	position: relative;
	height: var( --bf-ic-img-height, 160px );
	overflow: hidden;
	/* The "no image" well is anchored on the SAME base as the label strip (field-bg),
	   just deepened ~10% toward a neutral, so the two read as a harmonious light→deeper
	   pair of one hue rather than two different tints. (Deriving the well from the accent
	   put it in a different hue family than the field-bg label → a visible two-tone seam.) */
	background: color-mix( in srgb, var( --bf-field-bg, #f1f5f9 ) 90%, #94a3b8 );
	flex-shrink: 0;
}

.bf-image-choice__img-wrap img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.2s ease;
}

.bf-image-choice__item:hover .bf-image-choice__img-wrap img {
	transform: scale( 1.04 );
}

/* Placeholder when no image is set.
   The icon is a CSS background SVG (not the dashicons font, which is not loaded on
   the front end) so it always renders, paired with a short "No image" caption. */
.bf-image-choice__img-placeholder {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	gap: 8px;
	align-items: center;
	justify-content: center;
	color: #94a3b8;
}

.bf-image-choice__img-placeholder-icon {
	width: 36px;
	height: 36px;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E");
}

.bf-image-choice__img-placeholder-text {
	font-size: 12px;
	line-height: 1;
	color: #94a3b8;
}

/* ==========================================================================
   Check badge — top-right overlay, appears on selection
   ========================================================================== */

.bf-image-choice__check {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var( --bf-button-bg, var( --bf-focus-color, #0f766e ) );
	color: var( --bf-button-text, #fff );
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
	opacity: 0;
	transform: scale( 0.6 );
	transition: opacity 0.15s ease, transform 0.15s ease;
	pointer-events: none;
	box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.bf-image-choice__item.is-checked .bf-image-choice__check {
	opacity: 1;
	transform: scale( 1 );
}

/* ==========================================================================
   Label strip
   ========================================================================== */

.bf-image-choice__label {
	padding: 8px 10px;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.4;
	text-align: center;
	color: var( --bf-field-text, #374151 );
	word-break: break-word;
	transition: color 0.15s;
}

.bf-image-choice__item.is-checked .bf-image-choice__label {
	color: var( --bf-button-bg, var( --bf-focus-color, #0f766e ) );
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media ( max-width: 480px ) {
	.bf-image-choice--4col {
		grid-template-columns: repeat( 2, 1fr );
	}
}
