/**
 * Colour picker tool. Loaded only where [em_color_picker] is.
 */

.em-cp {
	margin: 2rem 0;
}

/* ---------- the way in ---------- */

.em-cp-drop {
	padding: 2.5rem 1.5rem;
	border: 2px dashed var(--em-border);
	border-radius: 16px;
	background: var(--em-bg-2);
	text-align: center;
	transition: border-color 0.15s, background 0.15s;
}

.em-cp-drop.is-over {
	border-color: var(--em-primary);
	background: var(--em-bg-card);
}

/* Hidden from sight, not from the keyboard: the label is the button, and a
   display:none input cannot be focused or reached by a click on that label. */
.em-cp-file {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.em-cp-choose {
	cursor: pointer;
}

.em-cp-file:focus-visible + .em-cp-choose {
	outline: 2px solid var(--em-primary);
	outline-offset: 3px;
}

.em-cp-hint {
	margin: 0.9rem 0 0;
	font-size: 0.95rem;
	color: var(--em-muted);
}

.em-cp-privacy {
	margin: 0.35rem 0 0;
	font-size: 0.8rem;
	color: var(--em-muted);
}

/* ---------- the answer ---------- */

.em-cp-preview {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
	margin-bottom: 1.25rem;
}

.em-cp-preview img {
	width: 160px;
	height: 160px;
	object-fit: cover;
	border: 1px solid var(--em-border);
	border-radius: 12px;
	background: var(--em-bg-2);
}

.em-cp-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 0.75rem;
}

.em-cp-swatch {
	display: flex;
	flex-direction: column;
	padding: 0;
	overflow: hidden;
	border: 1px solid var(--em-border);
	border-radius: 12px;
	background: var(--em-bg-card);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.em-cp-swatch:hover,
.em-cp-swatch:focus-visible {
	transform: translateY(-2px);
	border-color: var(--em-primary);
	box-shadow: 0 10px 24px rgba(12, 18, 32, 0.12);
	outline: none;
}

.em-cp-swatch:focus-visible {
	outline: 2px solid var(--em-primary);
	outline-offset: 3px;
}

/* The hex sits on its own colour, so the text has to pick a side. */
.em-cp-chip {
	display: flex;
	align-items: flex-end;
	min-height: 84px;
	padding: 0.6rem 0.75rem;
	font-family: 'JetBrains Mono', ui-monospace, monospace;
	font-size: 0.95rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: #0A101A;
}

.em-cp-chip.is-dark {
	color: #F7F8FA;
}

.em-cp-meta {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	padding: 0.6rem 0.75rem 0.7rem;
	font-family: 'JetBrains Mono', ui-monospace, monospace;
	font-size: 0.74rem;
	line-height: 1.5;
	color: var(--em-muted);
}

.em-cp-meta strong {
	display: inline-block;
	min-width: 3.4em;
	color: var(--em-text);
	font-weight: 700;
}

/* ---------- what the tool has to say ---------- */

.em-cp-error {
	margin: 1rem 0 0;
	padding: 0.7rem 0.9rem;
	border: 1px solid var(--em-warning);
	border-radius: 10px;
	font-size: 0.9rem;
	color: var(--em-text);
}

.em-cp-status {
	margin: 0.75rem 0 0;
	min-height: 1.3em;
	font-size: 0.85rem;
	color: var(--em-muted);
}

@media (max-width: 560px) {
	.em-cp-preview {
		flex-direction: column;
		align-items: stretch;
	}

	.em-cp-preview img {
		width: 100%;
		height: 180px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.em-cp-swatch,
	.em-cp-drop {
		transition: none;
	}

	.em-cp-swatch:hover,
	.em-cp-swatch:focus-visible {
		transform: none;
	}
}
