/* OpenPress Word Counter interface (tasks 040 foundation, 040B results and interaction). Loaded on the Word Counter Free Tool page only,
   after free-tool-single.css, inside the .op-free-tool-interface frame. Uses the theme's global tokens (--op-bg, --op-bg-elevated,
   --op-text, --op-text-muted, --op-border, --op-border-strong, --op-link, --op-btn-bg, --op-focus, --op-transition ...) and the shared
   .op-btn, so light and dark follow the theme switch (prefers-color-scheme plus :root[data-theme]). The only colour this file adds is
   the scoped error accent below (the theme has none; the other tools scope theirs the same way).
   Presentation only: no counting happens here (see word-counter.js). Reduced motion: main.css zeroes transitions globally. */

.op-wc { --op-wc-error: #B42318; }
@media (prefers-color-scheme: dark) {
	.op-wc { --op-wc-error: #F97066; }
	:root[data-theme="light"] .op-wc { --op-wc-error: #B42318; }
}
:root[data-theme="dark"] .op-wc { --op-wc-error: #F97066; }

.op-wc {
	display: grid;
	gap: 1.5rem;
	min-width: 0;
}

/* Heading ----------------------------------------------------------------- */
.op-wc__intro { display: grid; gap: 0.25rem; min-width: 0; }
.op-wc__heading { margin: 0; color: var(--op-text); font-family: var(--op-font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; overflow-wrap: anywhere; }
.op-wc__lede { margin: 0; color: var(--op-text-muted); font-size: 0.875rem; line-height: 1.4; }

/* Writing area: the textarea leads ----------------------------------------- */
.op-wc__editor { display: grid; gap: 0.75rem; min-width: 0; }
.op-wc__editor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; min-width: 0; }
.op-wc__label { color: var(--op-text); font-size: 1rem; font-weight: 600; line-height: 1.3; }

.op-wc__input {
	display: block;
	width: 100%;
	min-width: 0;
	max-width: 100%;
	min-height: 13rem;
	height: 14rem;
	margin: 0;
	padding: 1rem;
	background: var(--op-bg);
	border: 1px solid var(--op-border-strong);
	border-radius: 0.75rem;
	color: var(--op-text);
	font-family: inherit;
	font-size: 1rem;
	line-height: 1.6;
	resize: vertical; /* height only: the width is the layout's */
	transition: border-color var(--op-transition), background-color var(--op-transition);
}
.op-wc__input::placeholder { color: var(--op-text-muted); opacity: 1; }
.op-wc__input:hover { border-color: color-mix(in srgb, var(--op-btn-bg) 45%, var(--op-border-strong)); }
.op-wc__input:focus { border-color: var(--op-focus); background: var(--op-bg-elevated); }
.op-wc__input:focus-visible { outline: 3px solid var(--op-focus); outline-offset: 2px; }

/* "Clear text": secondary and quiet; dimmed while there is nothing to clear (aria-disabled keeps it reachable by keyboard). */
.op-wc__clear {
	min-height: 2.75rem;
	padding: 0 1rem;
	border-radius: 0.75rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--op-text-muted);
	transition: color var(--op-transition), background-color var(--op-transition), opacity var(--op-transition), transform var(--op-transition);
}
.op-wc__clear:hover { color: var(--op-text); }
.op-wc__clear:focus-visible { outline: 3px solid var(--op-focus); outline-offset: 2px; }
.op-wc__clear[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: auto; }
.op-wc__clear[aria-disabled="true"]:hover { background: transparent; color: var(--op-text-muted); text-decoration: none; }
.op-wc__clear[aria-disabled="true"]:active { transform: none; }

.op-wc__trust { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0; color: var(--op-text-muted); font-size: 0.8125rem; line-height: 1.4; }
.op-wc__trust svg { flex: none; margin-top: 1px; color: var(--op-link); }
.op-wc__trust span { min-width: 0; overflow-wrap: anywhere; }

/* Shown only when the statistics cannot be calculated (the [hidden] attribute hides it otherwise). */
.op-wc__error { margin: 0; padding: 0.75rem 1rem; color: var(--op-wc-error); background: color-mix(in srgb, var(--op-wc-error) 8%, var(--op-bg-elevated)); border: 1px solid color-mix(in srgb, var(--op-wc-error) 40%, var(--op-border)); border-radius: 0.75rem; font-size: 0.875rem; font-weight: 600; line-height: 1.4; }
.op-wc__error[hidden] { display: none; }

/* Statistics: a compact dashboard. Mobile: words full width, then pairs. ---------------------- */
.op-wc__results { display: grid; gap: 0.75rem; min-width: 0; }
.op-wc__results-title { margin: 0; color: var(--op-text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.op-wc__stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin: 0; min-width: 0; }
.op-wc__stat {
	--op-wc-value-size: 1.25rem;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 0.25rem;
	min-width: 0;
	min-height: 5rem; /* fixed floor: values changing from "0" to "12,345" never move the layout */
	padding: 0.75rem;
	background: var(--op-bg-elevated);
	border: 1px solid var(--op-border);
	border-radius: 0.75rem;
	box-shadow: var(--op-shadow-sm);
}
.op-wc__stat-label { margin: 0; color: var(--op-text-muted); font-size: 0.8125rem; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.op-wc__stat-value {
	margin: 0;
	color: var(--op-text);
	font-size: calc(var(--op-wc-value-size) * var(--op-wc-scale, 1));
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.01em;
	line-height: 1.2;
	white-space: nowrap; /* a count never wraps mid-number: long ones shrink (data-size, set by the script) instead */
	transition: color var(--op-transition);
}
.op-wc__stat-value[data-size="l"] { --op-wc-scale: 0.82; }
.op-wc__stat-value[data-size="xl"] { --op-wc-scale: 0.68; }
/* Nothing typed yet: the zeros read as a quiet resting state, not as results. */
.op-wc[data-state="empty"] .op-wc__stat-value { color: var(--op-text-muted); }

/* The word count leads: a soft blue-tinted surface and the largest number. */
.op-wc__stat--primary {
	grid-column: 1 / -1;
	background: color-mix(in srgb, var(--op-btn-bg) 7%, var(--op-bg-elevated));
	border-color: color-mix(in srgb, var(--op-btn-bg) 40%, var(--op-border));
	--op-wc-value-size: 1.875rem;
}
.op-wc__stat--primary .op-wc__stat-label { color: var(--op-text); font-weight: 600; }
/* Odd one out on mobile (reading time is the 6th card: words + 5): it spans the row so no card is left alone. */
.op-wc__stat[data-stat="reading-time"] { grid-column: 1 / -1; }

@media (min-width: 768px) {
	.op-wc__input { min-height: 16rem; height: 18rem; }
	.op-wc__stat { padding: 0.75rem 1rem; --op-wc-value-size: 1.5rem; }
	.op-wc__stat--primary { --op-wc-value-size: 1.875rem; }
	.op-wc__stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.op-wc__stat--primary,
	.op-wc__stat[data-stat="reading-time"] { grid-column: auto; }
}
@media (min-width: 1024px) {
	.op-wc__stats { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.5rem; }
	.op-wc__stat { padding: 0.75rem; --op-wc-value-size: 1.25rem; }
	.op-wc__stat--primary { --op-wc-value-size: 1.5rem; }
}
@media (max-width: 480px) {
	.op-wc__editor-head { gap: 0.25rem 0.5rem; }
	.op-wc__clear { padding: 0 0.5rem; }
	.op-wc__input { min-height: 12rem; height: 12rem; padding: 0.75rem; }
}
