/**
 * Westphal Solutions: Image optimizer (ws-optimizer)
 *
 * Owns everything under the `wsopt` prefix. Reads only theme brand
 * variables from main.css. Drop zone, control strip, result rows.
 */

.wsopt {
	font-family: var(--ws-font);
	color: var(--ws-text);
}

/* ---- Drop zone -------------------------------------------------------------- */
.wsopt__drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 48px 24px;
	border: 2px dashed var(--ws-border);
	border-radius: var(--ws-radius);
	background: var(--ws-surface);
	text-align: center;
	cursor: pointer;
	transition: border-color 0.2s var(--ws-ease), background-color 0.2s var(--ws-ease);
}
.wsopt__drop:hover,
.wsopt__drop:focus-visible,
.wsopt__drop.is-drag {
	border-color: var(--ws-accent);
	outline: 0;
}
.wsopt__drop.is-drag {
	background: color-mix(in srgb, var(--ws-accent) 8%, var(--ws-surface));
}

.wsopt__drop-icon {
	width: 36px;
	height: 36px;
	color: var(--ws-muted);
}
.wsopt__drop:hover .wsopt__drop-icon,
.wsopt__drop.is-drag .wsopt__drop-icon {
	color: var(--ws-heading);
}

.wsopt__drop-title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--ws-heading);
}
.wsopt__browse {
	text-decoration: underline;
	text-underline-offset: 3px;
}
.wsopt__drop-hint {
	margin: 0;
	max-width: 46ch;
	font-size: 0.85rem;
	line-height: 1.5;
	color: var(--ws-muted);
}

/* ---- Control strip ----------------------------------------------------------- */
.wsopt__controls {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 14px 18px;
	margin-top: 16px;
	padding: 16px 18px;
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	background: var(--ws-surface);
}

.wsopt__control {
	display: flex;
	flex-direction: column;
	gap: 6px;
	transition: opacity 0.2s var(--ws-ease);
}
.wsopt__control.is-off { opacity: 0.4; }

.wsopt__label {
	font-size: 12px;
	font-weight: 900;
	letter-spacing: 2px;
	text-transform: uppercase;
	color: var(--ws-muted);
}
.wsopt__label output {
	color: var(--ws-heading);
	margin-left: 4px;
}

.wsopt__select,
.wsopt__num {
	padding: 9px 10px;
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	background: var(--ws-bg);
	color: var(--ws-text);
	font-family: var(--ws-font);
	font-size: 0.9rem;
}
.wsopt__select:focus-visible,
.wsopt__num:focus-visible {
	outline: 0;
	border-color: var(--ws-accent);
	box-shadow: 0 0 0 1px var(--ws-accent);
}
.wsopt__num { width: 90px; }

.wsopt__row {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.85rem;
	color: var(--ws-muted);
}

/* ---- Range slider ------------------------------------------------------------ */
.wsopt__range {
	appearance: none;
	-webkit-appearance: none;
	width: 100%;
	height: 4px;
	margin: 10px 0;
	border-radius: var(--ws-radius-pill);
	background: var(--ws-border);
	cursor: pointer;
}
.wsopt__range::-webkit-slider-thumb {
	appearance: none;
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	border: 2px solid var(--ws-heading);
	border-radius: 50%;
	background: var(--ws-accent);
	cursor: grab;
}
.wsopt__range::-moz-range-thumb {
	width: 14px;
	height: 14px;
	border: 2px solid var(--ws-heading);
	border-radius: 50%;
	background: var(--ws-accent);
	cursor: grab;
}
.wsopt__range:disabled { cursor: not-allowed; }
.wsopt__range:focus-visible {
	outline: 2px solid var(--ws-accent);
	outline-offset: 4px;
}

/* ---- Result rows ------------------------------------------------------------- */
.wsopt__list {
	list-style: none;
	margin: 16px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.wsopt__list:empty { margin: 0; }

.wsopt__item {
	display: flex;
	align-items: center;
	gap: 12px 16px;
	padding: 12px 16px;
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	background: var(--ws-surface);
}

.wsopt__item-thumb {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	border-radius: var(--ws-radius-sm);
	background-color: var(--ws-border);
	background-size: cover;
	background-position: center;
}

.wsopt__item-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	flex: 1;
}
.wsopt__item-name {
	font-weight: 700;
	font-size: 0.95rem;
	color: var(--ws-heading);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.wsopt__item-meta {
	font-size: 0.8rem;
	color: var(--ws-muted);
}

.wsopt__item-side {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
	margin-left: auto;
}

/* ---- Status, badge ------------------------------------------------------------ */
.wsopt__item-status {
	font-size: 0.8rem;
	color: var(--ws-muted);
}
.wsopt__item-status--busy::after {
	content: '';
	display: inline-block;
	width: 12px;
	height: 12px;
	margin-left: 8px;
	vertical-align: -2px;
	border: 2px solid var(--ws-border);
	border-top-color: var(--ws-accent);
	border-radius: 50%;
	animation: wsopt-spin 0.7s linear infinite;
}
.wsopt__item-status--error {
	color: var(--ws-error);
}

@keyframes wsopt-spin {
	to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
	.wsopt__item-status--busy::after { animation: none; }
}

.wsopt__badge {
	padding: 3px 8px;
	border-radius: var(--ws-radius-pill);
	background: var(--ws-accent);
	color: var(--ws-black);
	font-size: 0.72rem;
	font-weight: 900;
	letter-spacing: 0.5px;
}

/* ---- Buttons. Same spec as the site small button. ----------------------------- */
.wsopt__btn {
	display: inline-block;
	padding: 10px 18px;
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	background: transparent;
	color: var(--ws-heading);
	font-family: var(--ws-font);
	font-size: 12px;
	font-weight: 900;
	letter-spacing: 3px;
	text-transform: uppercase;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s var(--ws-ease), color 0.2s var(--ws-ease), border-color 0.2s var(--ws-ease);
}
.wsopt__btn--primary {
	border-color: var(--ws-accent);
	background: var(--ws-accent);
	color: var(--ws-black);
}
.wsopt__btn--primary:hover {
	background: var(--ws-heading);
	border-color: var(--ws-heading);
	color: var(--ws-bg);
}
.wsopt__btn--ghost:hover {
	border-color: var(--ws-heading);
}
.wsopt__btn:focus-visible {
	outline: 2px solid var(--ws-accent);
	outline-offset: 2px;
}

/* ---- Actions row --------------------------------------------------------------- */
.wsopt__actions {
	display: flex;
	gap: 10px;
	margin-top: 16px;
}

/* ---- Mobile --------------------------------------------------------------------- */
@media (max-width: 640px) {
	.wsopt__drop { padding: 36px 16px; }
	.wsopt__controls { grid-template-columns: 1fr; }
	.wsopt__item { flex-wrap: wrap; }
	.wsopt__item-side {
		width: 100%;
		justify-content: space-between;
		margin-left: 0;
	}
	.wsopt__btn { text-align: center; }
	.wsopt__actions { flex-direction: column; }
}
