/*
 * Guild emblem creator.
 *
 * The control panel ships several themes (default, th1, muhro) with very
 * different palettes, so everything here is built out of translucent greys and
 * inherited text colors.  That way the tool looks at home on a light theme and
 * on the dark muhro theme without a second stylesheet.
 */

.emc {
	/* Corner style follows the host theme. muhro drives everything from these
	   tokens (currently 0, a square panel), the stock FluxCP themes have no
	   tokens and get the fallbacks. The drop zone glyph asks for a circle and
	   gets squared along with everything else under muhro, which is correct
	   here: it is a decorative tile, not an avatar. */
	--emc-radius:      var(--radius-md, 8px);
	--emc-radius-sm:   var(--radius-sm, 6px);
	--emc-radius-xs:   var(--radius-sm, 3px);
	--emc-radius-pill: var(--radius-pill, 10px);
	--emc-line: rgba(127, 127, 127, 0.35);
	--emc-line-soft: rgba(127, 127, 127, 0.18);
	--emc-surface: rgba(127, 127, 127, 0.08);
	--emc-surface-2: rgba(127, 127, 127, 0.14);
	--emc-accent: #7c5cff;
	--emc-ok: #2f9e5f;
	--emc-warn: #c88a00;
	--emc-bad: #d24545;
	font-size: 14px;
	line-height: 1.45;
}

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

.emc-head h2 {
	margin: 0 0 6px;
}

.emc-sub {
	margin: 0 0 18px;
	max-width: 70ch;
	opacity: 0.85;
}

.emc code {
	padding: 1px 4px;
	border-radius: var(--emc-radius-xs);
	background: var(--emc-surface-2);
	font-family: ui-monospace, Consolas, "Courier New", monospace;
	font-size: 0.92em;
}

.emc-grid {
	display: grid;
	grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr);
	gap: 16px;
	align-items: start;
}

@media (max-width: 900px) {
	.emc-grid {
		grid-template-columns: 1fr;
	}
}

.emc-col {
	display: flex;
	flex-direction: column;
	gap: 16px;
	min-width: 0;
}

.emc-panel {
	border: 1px solid var(--emc-line);
	border-radius: var(--emc-radius);
	background: var(--emc-surface);
	padding: 14px;
}

.emc-panel__title {
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 12px;
	opacity: 0.8;
	margin-bottom: 10px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.emc-badge {
	display: inline-block;
	min-width: 20px;
	padding: 0 6px;
	border-radius: var(--emc-radius-pill);
	background: var(--emc-surface-2);
	text-align: center;
	font-weight: 700;
}

/* ------------------------------------------------------------ form controls */

.emc-field {
	display: block;
	margin-bottom: 10px;
}

.emc-field > span {
	display: block;
	margin-bottom: 3px;
	font-size: 12px;
	opacity: 0.85;
}

.emc-field > span b {
	opacity: 1;
	font-variant-numeric: tabular-nums;
}

.emc-field--inline {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 0;
}

.emc-field--inline > span {
	margin: 0;
	white-space: nowrap;
}

.emc select,
.emc input[type="text"],
.emc input[type="number"] {
	width: 100%;
	padding: 6px 8px;
	border: 1px solid var(--emc-line);
	border-radius: var(--emc-radius-sm);
	background: var(--emc-surface-2);
	color: inherit;
	font: inherit;
}

.emc input[type="number"] {
	width: 90px;
}

.emc input[type="range"] {
	width: 100%;
	accent-color: var(--emc-accent);
}

.emc input[type="color"] {
	width: 40px;
	height: 32px;
	padding: 2px;
	border: 1px solid var(--emc-line);
	border-radius: var(--emc-radius-sm);
	background: var(--emc-surface-2);
	cursor: pointer;
}

.emc-check {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	cursor: pointer;
	user-select: none;
}

.emc-check input {
	accent-color: var(--emc-accent);
	margin: 0;
}

.emc-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 10px 0 0;
}

.emc-note {
	margin: 8px 0 0;
	font-size: 12px;
	opacity: 0.7;
}

.emc-warn {
	margin: 8px 0 0;
	padding: 8px 10px;
	border-left: 3px solid var(--emc-warn);
	background: var(--emc-surface-2);
	font-size: 13px;
}

.emc-btn {
	padding: 6px 12px;
	border: 1px solid var(--emc-line);
	border-radius: var(--emc-radius-sm);
	background: var(--emc-surface-2);
	color: inherit;
	font: inherit;
	cursor: pointer;
	white-space: nowrap;
}

.emc-btn:hover:not(:disabled) {
	border-color: var(--emc-accent);
}

.emc-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.emc-btn--sm {
	padding: 4px 9px;
	font-size: 12px;
}

.emc-btn--primary {
	border-color: var(--emc-accent);
	background: var(--emc-accent);
	color: #fff;
	font-weight: 600;
}

.emc-btn--primary b {
	font-weight: 400;
	opacity: 0.85;
	font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- drop target */

.emc-drop {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px;
	border: 2px dashed var(--emc-line);
	border-radius: var(--emc-radius);
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
}

.emc-drop:hover,
.emc-drop:focus,
.emc-drop.is-over {
	border-color: var(--emc-accent);
	background: var(--emc-surface-2);
	outline: none;
}

.emc-drop__icon {
	flex: none;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--emc-surface-2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	line-height: 1;
}

.emc-drop__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 12px;
	opacity: 0.85;
}

.emc-drop__text strong {
	font-size: 14px;
	opacity: 1;
}

/* ------------------------------------------------------------------- canvas */

.emc-canvas {
	display: block;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	background-color: #202024;
	background-image:
		linear-gradient(45deg, rgba(255, 255, 255, 0.07) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.07) 75%),
		linear-gradient(45deg, rgba(255, 255, 255, 0.07) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.07) 75%);
	background-size: 12px 12px;
	background-position: 0 0, 6px 6px;
}

.emc-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-bottom: 10px;
}

.emc-tool {
	padding: 5px 10px;
	border: 1px solid var(--emc-line);
	border-radius: var(--emc-radius-sm);
	background: var(--emc-surface-2);
	color: inherit;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
}

.emc-tool.is-active {
	border-color: var(--emc-accent);
	box-shadow: inset 0 0 0 1px var(--emc-accent);
}

.emc-stage {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	flex-wrap: wrap;
}

.emc-stage__main {
	position: relative;
	width: 288px;
	height: 288px;
	flex: none;
	border: 1px solid var(--emc-line);
	border-radius: var(--emc-radius-sm);
	overflow: hidden;
	touch-action: none;
}

.emc-stage__main .emc-canvas {
	width: 288px;
	height: 288px;
}

.emc-canvas--grid {
	position: absolute;
	inset: 0;
	background: none;
	pointer-events: none;
	opacity: 0;
}

.emc-canvas--grid.is-on {
	opacity: 1;
}

.emc-stage__main.tool-pencil,
.emc-stage__main.tool-eraser,
.emc-stage__main.tool-fill {
	cursor: crosshair;
}

.emc-stage__main.tool-pick {
	cursor: copy;
}

.emc-stage__main.tool-move {
	cursor: grab;
}

.emc-stage__main.tool-move.is-dragging {
	cursor: grabbing;
}

.emc-stage__side {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.emc-mini {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 11px;
	opacity: 0.85;
}

.emc-mini .emc-canvas {
	border: 1px solid var(--emc-line);
}

.emc-canvas--x4 {
	width: 96px;
	height: 96px;
}

.emc-canvas--x2 {
	width: 48px;
	height: 48px;
}

.emc-canvas--x1 {
	width: 24px;
	height: 24px;
}

/* ------------------------------------------------------------- frame strip */

.emc-strip {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 4px 2px 8px;
	min-height: 62px;
}

.emc-frame {
	position: relative;
	flex: none;
	padding: 3px;
	border: 1px solid var(--emc-line);
	border-radius: var(--emc-radius-sm);
	background: var(--emc-surface-2);
	cursor: pointer;
	line-height: 0;
}

.emc-frame.is-active {
	border-color: var(--emc-accent);
	box-shadow: 0 0 0 1px var(--emc-accent);
}

.emc-frame canvas {
	width: 40px;
	height: 40px;
	image-rendering: pixelated;
	display: block;
}

.emc-frame__no {
	position: absolute;
	right: 2px;
	bottom: 2px;
	padding: 0 3px;
	border-radius: var(--emc-radius-xs);
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 9px;
	line-height: 13px;
}

.emc-strip__empty {
	font-size: 12px;
	opacity: 0.6;
	padding: 18px 4px;
}

/* ------------------------------------------------------------ size budget */

.emc-budget {
	margin: 10px 0;
}

.emc-budget__bar {
	height: 8px;
	border-radius: var(--emc-radius-xs);
	background: var(--emc-surface-2);
	overflow: hidden;
}

.emc-budget__bar span {
	display: block;
	height: 100%;
	width: 0;
	background: var(--emc-ok);
	transition: width 0.2s;
}

.emc-budget__bar span.is-warn {
	background: var(--emc-warn);
}

.emc-budget__bar span.is-bad {
	background: var(--emc-bad);
}

.emc-budget__text {
	margin-top: 4px;
	font-size: 12px;
	opacity: 0.8;
	font-variant-numeric: tabular-nums;
}

.emc-checks {
	list-style: none;
	margin: 0 0 10px;
	padding: 0;
	font-size: 12.5px;
}

.emc-checks li {
	display: flex;
	align-items: baseline;
	gap: 7px;
	padding: 2px 0;
}

.emc-checks li::before {
	content: "OK";
	flex: none;
	min-width: 34px;
	padding: 0 5px;
	border-radius: var(--emc-radius-xs);
	background: var(--emc-ok);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	text-align: center;
	line-height: 16px;
}

.emc-checks li.is-warn::before {
	content: "WARN";
	background: var(--emc-warn);
}

.emc-checks li.is-bad::before {
	content: "FAIL";
	background: var(--emc-bad);
}

.emc-help {
	margin: 0;
	padding-left: 20px;
	font-size: 13px;
}

.emc-help li {
	margin-bottom: 5px;
}

.emc-panel--help {
	opacity: 0.92;
}
