/**
 * Signal Tools — Design System v1.0
 *
 * Deliberately neutral: tools must look native on ~30 different themes.
 * Every color/size routes through a CSS variable with a safe fallback.
 * A theme (or the Customizer's Additional CSS) can re-skin every tool
 * on the site by redefining the :root tokens below — nothing else.
 */

:root {
	--st-accent:        #2271b1;   /* buttons, links, focus */
	--st-accent-text:   #ffffff;
	--st-text:          inherit;
	--st-muted:         #6b7280;
	--st-border:        #d7dbe0;
	--st-surface:       #ffffff;
	--st-surface-alt:   #f6f7f8;   /* tool + results background */
	--st-radius:        10px;
	--st-space:         1rem;
	--st-font:          inherit;   /* inherit theme typography */
	--st-max-width:     760px;
}

/* ---------- Page scaffold ---------- */

.st-page {
	max-width: var(--st-max-width);
	margin: 0 auto;
	padding: calc(var(--st-space) * 2) var(--st-space);
	font-family: var(--st-font);
	color: var(--st-text);
}

.st-breadcrumb {
	font-size: 0.85em;
	color: var(--st-muted);
	margin: 0 0 0.5rem;
}
.st-breadcrumb a { color: var(--st-muted); }

.st-title { margin: 0 0 1rem; line-height: 1.2; }

.st-intro { margin-bottom: calc(var(--st-space) * 1.5); }

.st-section { margin-top: calc(var(--st-space) * 2.5); }
.st-section h2 { margin-bottom: 0.75rem; }

/* ---------- Tool container ---------- */

.st-tool {
	background: var(--st-surface-alt);
	border: 1px solid var(--st-border);
	border-radius: var(--st-radius);
	padding: calc(var(--st-space) * 1.5);
	margin: calc(var(--st-space) * 1.5) 0;
}

/* ---------- Form components ---------- */

.st-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
	gap: var(--st-space);
}

.st-input-group { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }

.st-label {
	font-weight: 600;
	font-size: 0.9em;
}

.st-help {
	font-size: 0.8em;
	color: var(--st-muted);
	margin: 0;
}

.st-input,
.st-select {
	width: 100%;
	box-sizing: border-box;
	padding: 0.6rem 0.75rem;
	font: inherit;
	color: inherit;
	background: var(--st-surface);
	border: 1px solid var(--st-border);
	border-radius: calc(var(--st-radius) * 0.6);
}

.st-input:focus,
.st-select:focus {
	outline: 2px solid var(--st-accent);
	outline-offset: 1px;
	border-color: var(--st-accent);
}

.st-fieldset {
	border: none;
	padding: 0;
	margin: var(--st-space) 0 0;
}
.st-fieldset legend {
	font-weight: 600;
	font-size: 0.9em;
	padding: 0;
	margin-bottom: 0.35rem;
}

.st-radio-row { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
.st-radio-row label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.95em; }

/* ---------- Buttons ---------- */

.st-btn {
	display: inline-block;
	padding: 0.7rem 1.6rem;
	font: inherit;
	font-weight: 600;
	color: var(--st-accent-text);
	background: var(--st-accent);
	border: none;
	border-radius: calc(var(--st-radius) * 0.6);
	cursor: pointer;
	transition: filter 0.15s ease;
}
.st-btn:hover  { filter: brightness(1.08); }
.st-btn:focus-visible { outline: 2px solid var(--st-accent); outline-offset: 2px; }

.st-btn-secondary {
	background: transparent;
	color: var(--st-accent);
	border: 1px solid var(--st-accent);
}

.st-actions { margin-top: calc(var(--st-space) * 1.25); display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- Results ---------- */

.st-results {
	margin-top: calc(var(--st-space) * 1.5);
	display: none; /* revealed by SignalTools.reveal() */
}
.st-results.is-visible { display: block; animation: st-fade 0.25s ease; }

@keyframes st-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
	.st-results.is-visible { animation: none; }
}

.st-results-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: var(--st-space);
}

.st-results-card {
	background: var(--st-surface);
	border: 1px solid var(--st-border);
	border-left: 4px solid var(--st-accent);
	border-radius: calc(var(--st-radius) * 0.6);
	padding: var(--st-space);
}

.st-result-value {
	font-size: 1.7em;
	font-weight: 700;
	line-height: 1.15;
	display: block;
}

.st-result-label {
	font-size: 0.82em;
	color: var(--st-muted);
	display: block;
	margin-top: 0.2rem;
}

.st-note {
	font-size: 0.83em;
	color: var(--st-muted);
	margin-top: var(--st-space);
}

.st-error {
	color: #b32d2e;
	font-size: 0.9em;
	margin-top: 0.5rem;
	display: none;
}
.st-error.is-visible { display: block; }

.st-divider { border: none; border-top: 1px solid var(--st-border); margin: calc(var(--st-space) * 1.5) 0; }

/* ---------- FAQ / Sources / Embed ---------- */

.st-faq-item {
	border: 1px solid var(--st-border);
	border-radius: calc(var(--st-radius) * 0.6);
	padding: 0.85rem 1rem;
	margin-bottom: 0.6rem;
	background: var(--st-surface);
}
.st-faq-item summary { font-weight: 600; cursor: pointer; }
.st-faq-answer { margin-top: 0.6rem; }

.st-sources ul { padding-left: 1.2rem; }
.st-sources li { margin-bottom: 0.35rem; font-size: 0.92em; }

.st-embed {
	margin: var(--st-space) 0;
	font-size: 0.9em;
}
.st-embed summary { cursor: pointer; color: var(--st-muted); }
.st-embed textarea {
	width: 100%;
	box-sizing: border-box;
	font-family: monospace;
	font-size: 0.85em;
	margin-top: 0.5rem;
	padding: 0.5rem;
	border: 1px solid var(--st-border);
	border-radius: calc(var(--st-radius) * 0.6);
}

.st-attribution { font-size: 0.8em; color: var(--st-muted); margin-top: 0.75rem; }

/* ---------- Archive grid ---------- */

.st-archive-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: var(--st-space);
	margin-top: calc(var(--st-space) * 1.5);
}

.st-card {
	display: block;
	background: var(--st-surface);
	border: 1px solid var(--st-border);
	border-radius: var(--st-radius);
	padding: calc(var(--st-space) * 1.25);
	text-decoration: none;
	color: inherit;
	transition: border-color 0.15s ease, transform 0.15s ease;
}
.st-card:hover { border-color: var(--st-accent); transform: translateY(-2px); }

.st-card-title { font-size: 1.05em; margin: 0 0 0.4rem; }
.st-card-desc  { font-size: 0.88em; color: var(--st-muted); margin: 0 0 0.75rem; }
.st-card-cta   { font-size: 0.85em; font-weight: 600; color: var(--st-accent); }

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
	.st-tool { padding: var(--st-space); }
	.st-result-value { font-size: 1.4em; }
}
