/*
 * Kurzlink Studio – Frontend
 * Bewusst niedrige Spezifität (:where), damit das Theme jederzeit übersteuern kann.
 * Farben, Schriften, Radien und Buttons kommen aus theme.json bzw. dem Theme.
 */
:where(.ks-shortener) {
	--ks-accent: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, currentColor));
	--ks-line: color-mix(in srgb, currentColor 18%, transparent);
	--ks-soft: color-mix(in srgb, currentColor 5%, transparent);
	--ks-radius: var(--wp--custom--border-radius, 0.6em);
	--ks-gap: var(--wp--style--block-gap, 0.75rem);
	container-type: inline-size;
	font: inherit;
	color: inherit;
	max-width: 100%;
}

:where(.ks-shortener) * { box-sizing: border-box; }

:where(.ks-shortener__title) { margin: 0 0 var(--ks-gap); }

:where(.ks-shortener__row) {
	display: flex;
	gap: 0.5rem;
	align-items: stretch;
}

@container (max-width: 480px) {
	:where(.ks-shortener__row) { flex-direction: column; }
}

:where(.ks-shortener__input) {
	flex: 1 1 auto;
	min-width: 0;
	font: inherit;
	color: inherit;
	padding: 0.8em 1em;
	border: 1px solid var(--ks-line);
	border-radius: var(--ks-radius);
	background: var(--wp--preset--color--base, transparent);
	transition: border-color .15s, box-shadow .15s;
}

:where(.ks-shortener__input):focus {
	outline: none;
	border-color: var(--ks-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ks-accent) 22%, transparent);
}

:where(.ks-shortener__input[aria-invalid="true"]) { border-color: #d63638; }

:where(.ks-shortener__btn) {
	cursor: pointer;
	white-space: nowrap;
	font: inherit;
	font-weight: 600;
	border-radius: var(--ks-radius);
	padding: 0.8em 1.4em;
	position: relative;
}

:where(.ks-shortener__btn[aria-busy="true"]) { color: transparent !important; pointer-events: none; }
:where(.ks-shortener__btn[aria-busy="true"])::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 1.1em;
	height: 1.1em;
	border: 2px solid currentColor;
	border-color: #fff #fff transparent transparent;
	border-radius: 50%;
	animation: ks-spin .7s linear infinite;
}

@keyframes ks-spin { to { transform: rotate(360deg); } }

:where(.ks-shortener__more) { margin-top: 0.6rem; font-size: 0.9em; }
:where(.ks-shortener__more) summary { cursor: pointer; opacity: .8; width: fit-content; }
:where(.ks-shortener__slug) {
	display: flex;
	align-items: center;
	margin-top: 0.5rem;
	border: 1px solid var(--ks-line);
	border-radius: var(--ks-radius);
	overflow: hidden;
}
:where(.ks-shortener__slug) .ks-shortener__input { border: 0; border-radius: 0; box-shadow: none; padding-left: 0.2em; }
:where(.ks-shortener__base) { padding: 0.8em 0 0.8em 1em; opacity: .65; white-space: nowrap; }

:where(.ks-shortener__msg) { margin: 0.5rem 0 0; min-height: 1.2em; font-size: 0.9em; color: #d63638; }
:where(.ks-shortener__msg):empty { display: none; }

:where(.ks-shortener__result) {
	margin-top: var(--ks-gap);
	padding: 1rem;
	border: 1px solid var(--ks-line);
	border-radius: var(--ks-radius);
	background: var(--ks-soft);
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 1rem;
	align-items: center;
	animation: ks-in .25s ease-out;
}

@container (max-width: 480px) {
	:where(.ks-shortener__result) { grid-template-columns: 1fr; }
}

@keyframes ks-in { from { opacity: 0; transform: translateY(6px); } }

:where(.ks-shortener__short) {
	font-weight: 700;
	font-size: 1.15em;
	word-break: break-all;
	color: var(--ks-accent);
	text-decoration: none;
}
:where(.ks-shortener__long) { margin: .25rem 0 .75rem; font-size: .85em; opacity: .7; word-break: break-all; }
:where(.ks-shortener__actions) { display: flex; flex-wrap: wrap; gap: .5rem; }
:where(.ks-shortener__actions) button,
:where(.ks-shortener__actions) a {
	font: inherit;
	font-size: .9em;
	cursor: pointer;
	padding: .5em .9em;
	border-radius: var(--ks-radius);
	border: 1px solid var(--ks-line);
	background: transparent;
	color: inherit;
	text-decoration: none;
}
:where(.ks-shortener__actions) button:hover,
:where(.ks-shortener__actions) a:hover { border-color: var(--ks-accent); }
:where(.ks-shortener__qr) { background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
:where(.ks-shortener__qr) svg { width: 120px; height: 120px; display: block; }

:where(.ks-hp) { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
:where(.ks-sr) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
	:where(.ks-shortener) *, :where(.ks-shortener) *::after { animation: none !important; transition: none !important; }
}

:where(.ks-shortener) [hidden] { display: none !important; }
