/**
 * Westphal Solutions — Text tools engine (ws-textkit)
 *
 * Owns everything under the `wstk` prefix. Reads only the theme brand variables
 * from main.css. One full-width text box, grouped action buttons below, then an
 * optional find/replace row. Built to stay usable on a phone.
 */

.wstk {
	--wstk-mono: 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;

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

/* ---- The text box ---------------------------------------------------------- */
.wstk__box {
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	background: var(--ws-surface);
	overflow: hidden;
	transition: border-color 0.2s var(--ws-ease), box-shadow 0.2s var(--ws-ease);
}
.wstk__box:focus-within {
	border-color: var(--ws-accent);
	box-shadow: inset 0 0 0 1px var(--ws-accent);
}

.wstk__input {
	display: block;
	width: 100%;
	min-height: 240px;
	resize: vertical;
	border: 0;
	margin: 0;
	padding: 16px 18px;
	font-family: var(--ws-font);
	font-size: 1rem;
	line-height: 1.6;
	color: var(--ws-text);
	background: var(--ws-bg);
}
.wstk__input:focus { outline: 0; }

/* Bottom bar inside the box: stats on the left, tools on the right */
.wstk__boxbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 16px;
	padding: 10px 14px;
	border-top: 1px solid var(--ws-border);
	background: var(--ws-bg);
}

.wstk__stats {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 18px;
}
.wstk__stat {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
}
.wstk__stat b {
	font-size: 0.95rem;
	font-weight: 900;
	color: var(--ws-heading);
	font-variant-numeric: tabular-nums;
}
.wstk__stat span {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--ws-muted);
}

/* Utility buttons (undo / clear / copy / download) */
.wstk__tools {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.wstk__tool {
	display: inline-flex;
	align-items: center;
	min-height: 38px;
	padding: 8px 13px;
	font-family: var(--ws-font);
	font-size: 0.82rem;
	font-weight: 700;
	line-height: 1;
	color: var(--ws-text);
	background: var(--ws-surface);
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	cursor: pointer;
	transition: transform 0.15s var(--ws-ease),
				border-color 0.2s var(--ws-ease),
				background-color 0.2s var(--ws-ease),
				color 0.2s var(--ws-ease);
}
.wstk__tool:hover { border-color: var(--ws-accent); }
.wstk__tool:active { transform: translateY(1px); }
.wstk__tool:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 2px; }
.wstk__tool:disabled { opacity: 0.4; cursor: default; }
.wstk__tool:disabled:hover { border-color: var(--ws-border); }
.wstk__tool--clear:hover { border-color: var(--ws-error); color: var(--ws-error); }
.wstk__tool.is-done {
	background: var(--ws-slate);
	border-color: var(--ws-slate);
	color: var(--ws-white);
}

/* ---- Action groups --------------------------------------------------------- */
.wstk__group { margin-top: 16px; }
.wstk__grouplabel {
	display: block;
	margin-bottom: 7px;
	font-size: 0.7rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ws-muted);
}

.wstk__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
}
.wstk__action {
	min-height: 42px;
	padding: 10px 16px;
	font-family: var(--ws-font);
	font-size: 0.88rem;
	font-weight: 700;
	line-height: 1;
	color: var(--ws-text);
	background: var(--ws-surface);
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	cursor: pointer;
	transition: transform 0.15s var(--ws-ease),
				border-color 0.2s var(--ws-ease),
				background-color 0.2s var(--ws-ease),
				color 0.2s var(--ws-ease);
}
.wstk__action:hover { border-color: var(--ws-accent); background: var(--ws-bg); }
.wstk__action:active { transform: translateY(1px); }
.wstk__action:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 2px; }

/* ---- Find and replace ------------------------------------------------------ */
.wstk__find {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}
.wstk__field {
	flex: 1 1 220px;
	min-width: 0;
	min-height: 42px;
	padding: 10px 13px;
	font-family: var(--ws-font);
	font-size: 0.92rem;
	color: var(--ws-text);
	background: var(--ws-surface);
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
}
.wstk__field:focus {
	outline: 0;
	border-color: var(--ws-accent);
	box-shadow: inset 0 0 0 1px var(--ws-accent);
}
.wstk__find-run {
	flex: 0 0 auto;
	min-height: 42px;
	padding: 10px 20px;
	font-family: var(--ws-font);
	font-size: 0.88rem;
	font-weight: 800;
	line-height: 1;
	color: var(--ws-black);
	background: var(--ws-accent);
	border: 1px solid var(--ws-accent);
	border-radius: var(--ws-radius);
	cursor: pointer;
	transition: transform 0.15s var(--ws-ease), filter 0.2s var(--ws-ease);
}
.wstk__find-run:hover { filter: brightness(0.94); }
.wstk__find-run:active { transform: translateY(1px); }
.wstk__find-run:focus-visible { outline: 2px solid var(--ws-slate); outline-offset: 2px; }

/* ---- Footnote -------------------------------------------------------------- */
.wstk__note {
	margin: 14px 0 0;
	font-size: 0.8rem;
	line-height: 1.5;
	color: var(--ws-muted);
}

/* ---- Phone ----------------------------------------------------------------- */
@media (max-width: 640px) {
	.wstk__input { min-height: 170px; padding: 14px; }
	.wstk__boxbar { padding: 10px 12px; }
	.wstk__stats { gap: 4px 14px; }

	/* let every tap target stretch so they are easy to hit */
	.wstk__tools { width: 100%; }
	.wstk__tool { flex: 1 1 auto; justify-content: center; }

	/* find/replace stacks: each input full width, button full width */
	.wstk__field { flex-basis: 100%; }
	.wstk__find-run { flex: 1 1 100%; }
}
