/* ============================================================
   COLOR EXTRACTOR (module/tools/color-extractor.php)
   Restyles the rgber plugin's .cpe-* markup to match the other tools:
   drop zone, sample photos, photo with colored pins beside the palette.
   Loaded after the plugin's color-palette-extractor.css, so .swx-ex wins.
   ============================================================ */

.swx-ex {
	--ex-rim: rgba(255, 255, 255, 0.09);
	--ex-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
	position: relative;
	z-index: 3; /* the Download menu opens over the tips below */
	display: grid;
	gap: 14px;
	margin-top: 8px;
}

/* ---------- Drop zone ---------- */

.swx-ex-drop { margin: 0; }

.swx-ex-file {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.swx-ex-droplabel {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 0;
	padding: 18px 20px;
	border-radius: 18px;
	background: var(--card);
	border: 1.5px dashed rgba(255, 255, 255, 0.2);
	color: #fff;
	cursor: pointer;
	transition: border-color 160ms ease, background-color 160ms ease, transform 200ms var(--ex-spring);
}

.swx-ex-droplabel:hover,
.swx-ex-file:focus-visible + .swx-ex-droplabel { border-color: rgba(255, 255, 255, 0.45); }
.swx-ex-file:focus-visible + .swx-ex-droplabel { outline: 2px solid #fff; outline-offset: 3px; }

.swx-ex-dropicon {
	flex: none;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	border-radius: 14px;
	background: conic-gradient(from 200deg, #f78154, #f2c14e, #5fad56, #4d9078, #2387ff, #b4436c, #f78154);
	color: #fff;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.swx-ex-dropicon svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }

.swx-ex-droptext { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.swx-ex-droptext b { font-size: 1.08rem; font-weight: 800; letter-spacing: -0.01em; }
.swx-ex-droptext span { color: var(--text-2); font-size: 0.88rem; }

.swx-ex-dropbtn {
	flex: none;
	padding: 10px 18px;
	border-radius: 999px;
	background: #fff;
	color: #000;
	font-size: 0.92rem;
	font-weight: 800;
	transition: transform 200ms var(--ex-spring);
}
.swx-ex-droplabel:hover .swx-ex-dropbtn { transform: translateY(-1px); }

/* Dragging a file anywhere over the tool */
.swx-ex.is-over .swx-ex-droplabel {
	border-color: #fff;
	background-color: var(--card-2);
	transform: scale(1.01);
}
.swx-ex.is-over .swx-ex-stage { opacity: 0.5; }

/* ---------- Sample photos ---------- */

.swx-ex-samples {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.swx-ex-samples-label {
	margin-right: 4px;
	color: var(--text-3);
	font-size: 0.78rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.swx-ex-sample {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 4px 12px 4px 4px;
	border-radius: 999px;
	background: var(--card);
	color: var(--text-2);
	font-size: 0.88rem;
	font-weight: 700;
	text-decoration: none;
	box-shadow: inset 0 0 0 1px var(--ex-rim);
	transition: color 150ms ease, box-shadow 150ms ease;
}
.swx-ex-sample img { width: 34px; height: 26px; border-radius: 999px; object-fit: cover; }
.swx-ex-sample:hover { color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.swx-ex-sample[aria-current] { color: #fff; background: var(--card-2); box-shadow: inset 0 0 0 2px #fff; }

/* ---------- Stage: the plugin's output ---------- */

.swx-ex-stage { position: relative; transition: opacity 200ms ease; }

.swx-ex .cpe-wrapper {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: #fff;
	font-family: var(--sans);
}

/* The page header and our drop zone replace these */
.swx-ex .cpe-title,
.swx-ex .cpe-description,
.swx-ex .cpe-form { display: none; }

.swx-ex .cpe-error {
	margin: 0;
	padding: 14px 16px;
	border: 0;
	border-radius: 14px;
	background: rgba(239, 68, 68, 0.12);
	box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.4);
	color: #fca5a5;
	font-size: 0.95rem;
	font-weight: 600;
}
/* A missing sample is our problem, not the visitor's */
.swx-ex.is-sample .cpe-error { display: none; }

/* Photo with pins. The box hugs the image so the pins land on the right pixels. */
.swx-ex .cpe-uploaded-image {
	position: relative;
	align-self: start;
	margin: 0;
	padding: 10px;
	border-radius: 22px;
	background: var(--card);
	box-shadow: inset 0 0 0 1px var(--ex-rim);
	text-align: left;
	line-height: 0;
}

.swx-ex .cpe-uploaded-image img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	max-height: none;
	border-radius: 14px;
	box-shadow: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-user-drag: none;
}

.swx-ex .cpe-color-nodes { position: absolute; inset: 10px; pointer-events: none; }

.swx-ex .cpe-color-node {
	position: absolute;
	width: 28px;
	height: 28px;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: var(--pin, #fff);
	box-shadow: 0 0 0 3px #fff, 0 6px 16px rgba(0, 0, 0, 0.55);
	transform: translate(-50%, -50%);
	cursor: grab;
	pointer-events: auto;
	touch-action: none;
	transition: transform 200ms var(--ex-spring), box-shadow 160ms ease;
	animation: swx-ex-pin 420ms var(--ex-spring) both;
}
.swx-ex .cpe-color-node:nth-child(2) { animation-delay: 60ms; }
.swx-ex .cpe-color-node:nth-child(3) { animation-delay: 120ms; }
.swx-ex .cpe-color-node:nth-child(4) { animation-delay: 180ms; }
.swx-ex .cpe-color-node:nth-child(5) { animation-delay: 240ms; }
.swx-ex .cpe-color-node:nth-child(n+6) { animation-delay: 300ms; }

@keyframes swx-ex-pin { from { transform: translate(-50%, -50%) scale(0); } }

.swx-ex .cpe-color-node:hover,
.swx-ex .cpe-color-node--highlight { transform: translate(-50%, -50%) scale(1.25); z-index: 2; }
.swx-ex .cpe-color-node--dragging {
	z-index: 3;
	cursor: grabbing;
	transform: translate(-50%, -50%) scale(1.45);
	box-shadow: 0 0 0 3px #fff, 0 0 0 7px rgba(255, 255, 255, 0.25), 0 10px 24px rgba(0, 0, 0, 0.6);
	transition: box-shadow 160ms ease;
}

/* ---------- Palette panel ---------- */

.swx-ex .cpe-results {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

.swx-ex .cpe-mood-container { order: 0; }
.swx-ex .cpe-swatch-bar { order: 1; }
.swx-ex .cpe-color-controls { order: 2; }
.swx-ex .cpe-swatches { order: 3; }
.swx-ex .cpe-download-row { order: 4; }
.swx-ex .cpe-wcag-checker { order: 5; }
.swx-ex .cpe-harmony-section { order: 6; }

.swx-ex .cpe-mood-badge {
	margin: 0;
	padding: 5px 12px;
	border: 0;
	background: var(--card-2);
	color: var(--text-2);
	font-size: 0.82rem;
	font-weight: 700;
	box-shadow: inset 0 0 0 1px var(--ex-rim);
}

/* The palette as one bar */
.swx-ex .cpe-swatch-bar {
	display: flex;
	width: 100%;
	max-width: none;
	height: 84px;
	margin: 0;
	border: 0;
	border-radius: 18px;
	overflow: hidden;
	background: var(--card-2) !important;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 12px 28px rgba(0, 0, 0, 0.4);
}
.swx-ex .cpe-swatch-bar-segment { flex: 1; height: 100%; transition: flex 260ms var(--ex-spring); }
.swx-ex .cpe-swatch-bar-segment:hover,
.swx-ex .cpe-swatch-bar-segment--highlight { flex: 1.6; transform: none; }

/* − 5 colors + */
.swx-ex .cpe-color-controls {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	gap: 0;
	margin: 0;
	padding: 4px;
	border-radius: 999px;
	background: var(--card);
	box-shadow: inset 0 0 0 1px var(--ex-rim);
}
.swx-ex .cpe-color-btn {
	width: 36px;
	min-width: 0;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--card-2);
	color: #fff;
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1;
}
.swx-ex .cpe-color-btn:not([disabled]):hover { background: #fff; color: #000; transform: none; }
.swx-ex .cpe-color-btn[disabled] { opacity: 0.3; }
.swx-ex .cpe-color-count-label {
	min-width: 84px;
	color: #fff;
	font-size: 0.92rem;
	font-weight: 800;
	text-align: center;
}

/* Color cards */
.swx-ex .cpe-swatches { display: grid; gap: 8px; }

.swx-ex .cpe-swatch {
	position: relative;
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr);
	align-items: stretch;
	gap: 12px;
	padding: 8px 40px 8px 8px;
	border: 0;
	border-radius: 16px;
	background: var(--card);
	color: #fff;
	box-shadow: inset 0 0 0 1px var(--ex-rim);
	transition: box-shadow 160ms ease, background-color 160ms ease;
}
.swx-ex .cpe-swatch:hover { transform: none; background: var(--card); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); }
.swx-ex .cpe-swatch--highlight { background: var(--card-2); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); }

.swx-ex .cpe-swatch-color {
	width: 64px;
	height: auto;
	min-height: 64px;
	border: 0;
	border-radius: 11px;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.swx-ex .cpe-swatch-body {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	align-content: center;
	gap: 0;
	padding: 0;
	color: #fff;
	font-size: 0.85rem;
	line-height: 1.3;
}

.swx-ex .cpe-code-row {
	display: grid;
	grid-template-columns: 68px minmax(0, 1fr) 16px;
	align-items: center;
	gap: 6px;
	padding: 3px 6px;
	border-radius: 8px;
	color: #fff;
}
.swx-ex .cpe-code-row:hover { background: rgba(255, 255, 255, 0.07); }
.swx-ex .cpe-code-row.cpe-copied { background: rgba(34, 197, 94, 0.18); }

/* HEX first and bigger */
.swx-ex .cpe-code-row:first-child .cpe-swatch-value { font-size: 1.05rem; font-weight: 800; letter-spacing: 0.02em; }

.swx-ex .cpe-swatch-label { color: var(--text-3); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.swx-ex .cpe-code-row:hover .cpe-swatch-label { color: var(--text-2); }
.swx-ex .cpe-swatch-value { font-family: var(--mono); font-size: 0.82rem; color: #fff; }

/* Copy glyph drawn in CSS (no icon font needed) */
.swx-ex .cpe-copy-icon { width: 16px; height: 16px; color: var(--text-3); opacity: 0.5; }
.swx-ex .cpe-copy-icon i { display: none; }
.swx-ex .cpe-copy-icon::before {
	content: '';
	width: 14px;
	height: 14px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15V5a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15V5a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E") center / contain no-repeat;
}
.swx-ex .cpe-code-row:hover .cpe-copy-icon { color: #fff; opacity: 1; }

.swx-ex .cpe-remove-swatch {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: transparent;
	color: var(--text-3);
	font-size: 1.1rem;
	line-height: 1;
}
.swx-ex .cpe-remove-swatch:hover { background: rgba(239, 68, 68, 0.9); color: #fff; transform: none; }

/* Download */
.swx-ex .cpe-download-row { margin: 0; padding: 0; border: 0; background: none; }
.swx-ex .cpe-download-row form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 8px;
	border-radius: 16px;
	background: var(--card);
	box-shadow: inset 0 0 0 1px var(--ex-rim);
}
.swx-ex .cpe-download-label { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; }
.swx-ex .cpe-download-label span { flex: none; padding-left: 6px; color: var(--text-2); font-size: 0.88rem; font-weight: 700; }
.swx-ex .cpe-download-select {
	flex: 1;
	min-width: 0;
	height: 42px;
	padding: 0 34px 0 12px;
	border: 0;
	border-radius: 10px;
	background: var(--card-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9acb8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 10px center / 16px no-repeat;
	color: #fff;
	font-family: var(--sans);
	font-size: 16px; /* no iOS zoom */
	-webkit-appearance: none;
	appearance: none;
	box-shadow: inset 0 0 0 1px var(--ex-rim);
}
.swx-ex .cpe-download-btn {
	height: 42px;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	background: #fff;
	color: #000;
	font-size: 0.95rem;
	font-weight: 800;
	box-shadow: none;
	cursor: pointer;
	transition: transform 200ms var(--ex-spring);
}
.swx-ex .cpe-download-btn:hover { transform: translateY(-1px); background: #fff; }

/* Contrast + harmonies */
.swx-ex .cpe-wcag-checker,
.swx-ex .cpe-harmony-section {
	margin: 0;
	padding: 14px;
	border: 0;
	border-radius: 16px;
	background: var(--card);
	box-shadow: inset 0 0 0 1px var(--ex-rim);
}
.swx-ex .cpe-wcag-title { margin: 0 0 10px; color: #fff; font-size: 0.95rem; font-weight: 800; }
.swx-ex .cpe-wcag-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.swx-ex .cpe-wcag-item { padding: 10px 6px; border-radius: 10px; background: var(--card-2); }
.swx-ex .cpe-wcag-label { color: var(--text-3); font-size: 0.68rem; font-weight: 800; }
.swx-ex .cpe-wcag-status { color: #fff; font-family: var(--mono); }
.swx-ex .cpe-wcag-status.pass { color: #4ade80; }
.swx-ex .cpe-wcag-status.fail { color: #f87171; }
.swx-ex .cpe-harmony-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.swx-ex .cpe-harmony-card { padding: 8px; border: 0; border-radius: 12px; background: var(--card-2); }
.swx-ex .cpe-harmony-swatches { height: 36px; margin-top: 6px; border-radius: 8px; }

/* Plugin toast, matched to the site's */
.cpe-copy-toast {
	padding: 12px 20px;
	border-radius: 8px;
	background: #fff;
	color: #000;
	font-family: var(--sans, 'Figtree', sans-serif);
	font-size: 0.95rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- Under the tool ---------- */

.swx-ex-next { display: flex; flex-wrap: wrap; gap: 10px; }
.swx-ex-next[hidden] { display: none; }

/* ---------- Uploading ---------- */

.swx-ex-busy {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	border-radius: 22px;
	background: rgba(10, 10, 14, 0.72);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	color: #fff;
	font-weight: 800;
}
.swx-ex-busy span {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: conic-gradient(#f78154, #f2c14e, #5fad56, #2387ff, #b4436c, #f78154);
	-webkit-mask: radial-gradient(circle, transparent 13px, #000 14px);
	mask: radial-gradient(circle, transparent 13px, #000 14px);
	animation: swx-ex-spin 900ms linear infinite;
}
@keyframes swx-ex-spin { to { transform: rotate(1turn); } }
.swx-ex.is-busy .swx-ex-busy { display: flex; }
.swx-ex.is-busy .swx-ex-stage { min-height: 200px; }
.swx-ex.is-busy .swx-ex-dropbtn { opacity: 0.4; }

/* ---------- Wide screens: photo beside the palette ---------- */

@media (min-width: 900px) {
	.swx-ex .cpe-wrapper {
		grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
		align-items: start;
		gap: 20px;
	}
	.swx-ex .cpe-error { grid-column: 1 / -1; }
	.swx-ex .cpe-uploaded-image { position: sticky; top: 90px; }
}

/* ---------- Phones ---------- */

@media (max-width: 760px) {
	.swx-ex-droplabel { gap: 12px; padding: 14px; border-radius: 16px; }
	.swx-ex-dropicon { width: 42px; height: 42px; border-radius: 12px; }
	.swx-ex-droptext b { font-size: 1rem; }
	.swx-ex-droptext span { font-size: 0.8rem; }
	.swx-ex { gap: 10px; margin-top: 0; }
	.swx-ex-droplabel { padding: 10px 12px; }
	.swx-ex-dropicon { width: 38px; height: 38px; }
	.swx-ex-dropbtn { display: none; } /* the whole card is the button; the dock has New image too */

	.swx-ex-samples { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
	.swx-ex-samples::-webkit-scrollbar { display: none; }
	.swx-ex-sample, .swx-ex-samples-label { flex: none; }

	.swx-ex .cpe-uploaded-image { padding: 6px; border-radius: 18px; }
	.swx-ex .cpe-uploaded-image img { border-radius: 13px; }
	.swx-ex .cpe-color-nodes { inset: 6px; }
	.swx-ex .cpe-color-node { width: 30px; height: 30px; } /* a bigger thumb target */

	.swx-ex .cpe-swatch-bar { height: 64px; border-radius: 14px; }
	.swx-ex .cpe-color-controls { align-self: stretch; justify-content: space-between; }

	.swx-ex-next { display: none; } /* the dock has these */
}

@media (max-width: 520px) {
	.swx-ex .cpe-swatch { grid-template-columns: 52px minmax(0, 1fr); gap: 10px; }
	.swx-ex .cpe-swatch-color { width: 52px; }
	.swx-ex .cpe-code-row { grid-template-columns: 62px minmax(0, 1fr) 16px; padding: 3px 4px; }
	.swx-ex .cpe-wcag-grid,
	.swx-ex .cpe-harmony-grid { gap: 5px; }
	.swx-ex .cpe-download-label span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.swx-ex .cpe-color-node,
	.swx-ex-busy span { animation: none; }
}

/* ---------- Downloads: the theme's menu replaces the plugin's dropdown ---------- */

.swx-ex .cpe-download-row { display: none; }
.swx-ex .swx-ex-export { order: 4; }
.swx-ex .swx-ex-export[hidden] { display: none; }
.swx-ex .swx-ex-export .sw-export,
.swx-ex .swx-ex-export summary { width: 100%; justify-content: center; }
.swx-ex .swx-ex-export summary { background: #fff; color: #000; }
/* At the bottom of the column, open upwards */
.swx-ex .sw-export--up .sw-export-menu { top: auto; bottom: calc(100% + 8px); }
