/* Colouring Page Picker — front end styles.
   Everything is scoped to .cpp-* so themes and Elementor stay out of the way. */

.cpp-app {
	/* Supplied inline by the plugin, derived from the configured background and
	   contrast-checked. These are only fallbacks. */
	--cpp-bg: transparent;
	--cpp-ink: #171614;
	--cpp-muted: #56534c;
	--cpp-border: #c9c7c1;
	--cpp-surface: #e6e5e1;
	--cpp-card: #ffffff;
	--cpp-track: #d7d5d0;
	--cpp-accent: #1f6feb;
	--cpp-accent-ink: #1a5fc8;
	--cpp-on-accent: #ffffff;
	--cpp-error: #96231f;
	--cpp-radius: 12px;
	--cpp-cols: 1;
	--cpp-gap: 20px;
	background: var(--cpp-bg);
	color: var(--cpp-ink);
	box-sizing: border-box;
	/* Survive being dropped into a flex or grid parent (Elementor containers,
	   most block themes) instead of collapsing to its intrinsic width. */
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	flex: 1 1 100%;
	align-self: stretch;
	justify-self: stretch;
	grid-column: 1 / -1;
}

/* The dropzone, file bar, grid and action bar are all toggled with the [hidden]
   attribute, and each sets its own display — which would otherwise beat the
   browser's default display:none for [hidden] and leave them stuck on screen. */
.cpp-app [hidden] {
	display: none !important;
}

/* Breathing room when the block paints its own background. */
.cpp-app.has-bg {
	padding: clamp(18px, 3vw, 32px);
	border-radius: var(--cpp-radius);
}

.cpp-app h2,
.cpp-app h3,
.cpp-app p,
.cpp-app label {
	color: var(--cpp-ink);
}

.cpp-app *,
.cpp-app *::before,
.cpp-app *::after {
	box-sizing: border-box;
}

.cpp-heading {
	margin: 0 0 .4em;
}

.cpp-intro {
	margin: 0 0 1.2em;
	max-width: 65ch;
}

.cpp-intro p:last-child {
	margin-bottom: 0;
}

/* ---------- status ---------- */

.cpp-status {
	margin: 0 0 1em;
	padding: .75em 1em;
	border: 1px solid var(--cpp-border);
	border-radius: var(--cpp-radius);
	font-size: .95em;
	color: var(--cpp-muted);
	background: var(--cpp-surface);
}

.cpp-status--error {
	border-color: color-mix(in srgb, var(--cpp-error) 40%, var(--cpp-border));
	background: color-mix(in srgb, var(--cpp-error) 8%, var(--cpp-bg, transparent));
	color: var(--cpp-error);
}

.cpp-notice {
	padding: 1em 1.2em;
	border: 1px dashed rgba(0, 0, 0, .25);
	border-radius: 12px;
	background: rgba(0, 0, 0, .03);
}

/* ---------- upload dropzone ([colouring_upload]) ---------- */

.cpp-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .4em;
	padding: 2.6em 1.5em;
	margin-bottom: 1.2em;
	text-align: center;
	border: 2px dashed var(--cpp-border);
	border-radius: var(--cpp-radius);
	background: var(--cpp-surface);
	cursor: pointer;
	transition: border-color .15s ease, background .15s ease;
}

.cpp-drop:hover,
.cpp-drop:focus-visible,
.cpp-drop.is-over {
	border-color: var(--cpp-accent);
	background: color-mix(in srgb, var(--cpp-accent) 7%, transparent);
	outline: none;
}

.cpp-drop-icon {
	width: 34px;
	height: 34px;
	color: var(--cpp-accent-ink);
}

.cpp-drop-title {
	margin: 0;
	font-weight: 600;
}

.cpp-drop-note {
	margin: 0;
	font-size: .88em;
	color: var(--cpp-muted);
	max-width: 46ch;
}

.cpp-file {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: .6em .9em;
	margin-bottom: 1.2em;
	border: 1px solid var(--cpp-border);
	border-radius: 10px;
	background: var(--cpp-surface);
}

.cpp-file-name {
	font-size: .92em;
	font-weight: 600;
	min-width: 0;
	overflow-wrap: anywhere;
}

.cpp-btn-small {
	padding: .35em .9em;
	font-size: .85em;
}

/* ---------- grid ---------- */

/* Column count is worked out in JS from the measured width, so the widget is
   immune to whatever intrinsic-sizing games the surrounding theme plays. */
.cpp-grid {
	display: grid;
	grid-template-columns: repeat(var(--cpp-cols, 1), minmax(0, 1fr));
	gap: var(--cpp-gap, 20px);
	width: 100%;
	margin: 0 0 1.25em;
	padding: 0;
	list-style: none;
}

.cpp-card {
	position: relative;
}

.cpp-card-label {
	display: block;
	margin: 0;
	cursor: pointer;
	font-weight: inherit;
}

.cpp-check {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.cpp-frame {
	position: relative;
	display: block;
	border: 2px solid var(--cpp-border);
	border-radius: var(--cpp-radius);
	overflow: hidden;
	background: var(--cpp-card);
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.cpp-frame canvas {
	display: block;
	width: 100%;
	height: auto;
}

.cpp-card:hover .cpp-frame {
	border-color: color-mix(in srgb, var(--cpp-accent) 45%, transparent);
}

.cpp-check:focus-visible + .cpp-frame {
	outline: 3px solid var(--cpp-accent);
	outline-offset: 3px;
}

.cpp-card.is-selected .cpp-frame {
	border-color: var(--cpp-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--cpp-accent) 22%, transparent);
}

.cpp-tick {
	position: absolute;
	top: 8px;
	left: 8px;
	width: 26px;
	height: 26px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	border: 2px solid var(--cpp-border);
	background: var(--cpp-card);
	color: transparent;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.cpp-tick svg {
	width: 15px;
	height: 15px;
}

.cpp-card.is-selected .cpp-tick {
	background: var(--cpp-accent);
	border-color: var(--cpp-accent);
	color: var(--cpp-on-accent);
}

.cpp-caption {
	display: block;
	margin-top: .5em;
	font-size: .9em;
	color: var(--cpp-muted);
	text-align: center;
}

.cpp-zoom {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 28px;
	height: 28px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 1px solid var(--cpp-border);
	border-radius: 50%;
	background: var(--cpp-card);
	color: var(--cpp-ink);
	cursor: pointer;
	opacity: 0;
	transition: opacity .15s ease;
}

.cpp-card:hover .cpp-zoom,
.cpp-zoom:focus-visible {
	opacity: 1;
}

.cpp-zoom svg {
	width: 16px;
	height: 16px;
}

@media (hover: none) {
	.cpp-zoom {
		opacity: 1;
	}
}

/* ---------- action bar ---------- */

.cpp-bar {
	position: sticky;
	bottom: 0;
	z-index: 5;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	border: 1px solid var(--cpp-border);
	border-radius: var(--cpp-radius);
	background: var(--cpp-card);
	box-shadow: 0 6px 20px rgba(0, 0, 0, .10);
}

.cpp-bar-left {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.cpp-count {
	font-weight: 600;
}

.cpp-hint {
	font-size: .85em;
	color: var(--cpp-muted);
}

.cpp-hint--warn {
	color: var(--cpp-error);
	font-weight: 600;
}

.cpp-bar-right {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

.cpp-btn {
	font: inherit;
	line-height: 1.2;
	padding: .6em 1.1em;
	border-radius: 999px;
	border: 1px solid var(--cpp-border);
	background: var(--cpp-card);
	color: var(--cpp-ink);
	cursor: pointer;
	transition: background .15s ease, opacity .15s ease;
}

.cpp-btn-ghost:hover {
	background: var(--cpp-surface);
}

.cpp-btn-primary {
	background: var(--cpp-accent);
	border-color: var(--cpp-accent);
	color: var(--cpp-on-accent);
	font-weight: 600;
	padding: .7em 1.5em;
}

.cpp-btn-primary:hover:not(:disabled) {
	filter: brightness(1.07);
}

.cpp-btn:disabled {
	opacity: .45;
	cursor: not-allowed;
}

.cpp-app.is-building .cpp-btn-primary {
	opacity: .7;
}

/* ---------- preview overlay ---------- */

.cpp-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: grid;
	place-items: center;
	padding: 20px;
	background: rgba(0, 0, 0, .72);
}

.cpp-overlay-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	max-height: 92vh;
}

.cpp-overlay-inner canvas {
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
	max-width: 100%;
	height: auto;
}

.cpp-overlay-close {
	font: inherit;
	padding: .5em 1.3em;
	border-radius: 999px;
	border: 0;
	background: #fff;
	color: #111;
	cursor: pointer;
}

body.cpp-noscroll {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.cpp-app * {
		transition: none !important;
	}
}
