/**
 * Freedium Tools — tool interface styles.
 *
 * Scoped to .fd-* classes so the theme owns the page chrome and the plugin
 * owns the tool surfaces. All values follow the theme design tokens where a
 * token exists, with sensible fallbacks when the theme is not active.
 */

.fd-tool {
	--fd-radius: 12px;
	--fd-radius-sm: 8px;

	background: var(--fd-surface, #ffffff);
	border: 1px solid var(--fd-border, #cbd5e1);
	border-radius: var(--fd-radius, 12px);
	box-shadow: var(--fd-shadow, 0 1px 3px rgba(15, 23, 42, 0.08));
	color: var(--fd-text, #0f172a);
	display: grid;
	gap: 1.5rem;
	padding: clamp(1.25rem, 2.5vw, 2rem);
	contain: layout style;
}

.fd-tool__header {
	display: grid;
	gap: 0.5rem;
}

.fd-tool__title {
	font-size: clamp(1.25rem, 2vw, 1.6rem);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.25;
	margin: 0;
}

.fd-tool__intro {
	color: var(--fd-muted);
	font-size: 0.98rem;
	margin: 0;
	max-width: 68ch;
}

.fd-tool__privacy {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 0.75rem;
	margin: 0.25rem 0 0;
}

.fd-tool__privacy-text {
	color: var(--fd-muted);
	font-size: 0.8125rem;
}

.fd-badge {
	align-items: center;
	background: var(--fd-primary-tint);
	border-radius: 999px;
	color: var(--fd-primary-dark);
	display: inline-flex;
	font-size: 0.75rem;
	font-weight: 600;
	gap: 0.4rem;
	padding: 0.25rem 0.625rem;
}

.fd-badge__dot {
	background: var(--fd-primary);
	border-radius: 50%;
	height: 0.375rem;
	width: 0.375rem;
}

.fd-tool__form {
	display: grid;
	gap: 1.25rem;
}

.fd-field {
	display: grid;
	gap: 0.4rem;
}

.fd-field__label {
	color: var(--fd-text);
	font-size: 0.9375rem;
	font-weight: 600;
}

.fd-field__help {
	color: var(--fd-muted);
	font-size: 0.8125rem;
	margin: 0;
}

.fd-field--inline {
	align-items: end;
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
}

.fd-field__custom {
	display: grid;
	gap: 0.4rem;
}

.fd-input,
.fd-textarea,
.fd-select {
	background: var(--fd-surface);
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius-sm);
	color: var(--fd-text);
	font: inherit;
	font-size: 0.9375rem;
	padding: 0.7rem 0.85rem;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	width: 100%;
}

.fd-textarea {
	line-height: 1.65;
	min-height: 12rem;
	resize: vertical;
}

.fd-input--mono {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.875rem;
}

.fd-input--number {
	max-width: 9rem;
}

.fd-input:focus-visible,
.fd-textarea:focus-visible,
.fd-select:focus-visible,
.fd-btn:focus-visible,
.fd-range:focus-visible,
.fd-reader:focus-visible {
	border-color: var(--fd-primary);
	box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.18);
	outline: 2px solid transparent;
	outline-offset: 2px;
}

.fd-actions {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0.625rem;
}

.fd-btn {
	align-items: center;
	background: var(--fd-surface);
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius-sm);
	color: var(--fd-text);
	cursor: pointer;
	display: inline-flex;
	font-size: 0.9375rem;
	font-weight: 600;
	gap: 0.4rem;
	justify-content: center;
	min-height: 2.75rem;
	padding: 0.6rem 1.1rem;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.fd-btn:hover {
	background: var(--fd-bg);
	border-color: var(--fd-border-light, #cbd5e1);
	text-decoration: none;
}

.fd-btn--primary {
	background: var(--fd-primary);
	border-color: var(--fd-primary);
	color: #ffffff;
}

.fd-btn--primary:hover {
	background: var(--fd-primary-dark);
	border-color: var(--fd-primary-dark);
	color: #ffffff;
}

.fd-btn--secondary {
	background: var(--fd-primary-tint);
	border-color: var(--fd-primary);
	color: var(--fd-primary-dark);
}

.fd-btn--secondary:hover {
	background: var(--fd-primary);
	color: #ffffff;
}

.fd-btn--ghost {
	background: transparent;
	border-color: transparent;
	color: var(--fd-muted);
}

.fd-btn--ghost:hover {
	background: var(--fd-bg);
	border-color: var(--fd-border);
	color: var(--fd-text);
}

.fd-btn--small {
	font-size: 0.875rem;
	min-height: 2.25rem;
	padding: 0.4rem 0.8rem;
}

.fd-btn:disabled {
	cursor: progress;
	opacity: 0.7;
}

.fd-fieldset {
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius-sm);
	margin: 0;
	padding: 0.9rem 1rem 1.1rem;
}

.fd-fieldset__legend {
	color: var(--fd-text);
	font-size: 0.875rem;
	font-weight: 600;
	padding: 0 0.4rem;
}

.fd-rules {
	display: grid;
	gap: 0.5rem;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	margin-top: 0.35rem;
}

.fd-check {
	align-items: flex-start;
	display: flex;
	font-size: 0.9rem;
	gap: 0.5rem;
	line-height: 1.5;
}

.fd-check input {
	accent-color: var(--fd-primary);
	flex: 0 0 auto;
	height: 1.05rem;
	margin-top: 0.2rem;
	width: 1.05rem;
}

.fd-check--consent {
	background: var(--fd-bg);
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius-sm);
	padding: 0.75rem 0.9rem;
}

.fd-required {
	color: #b91c1c;
}

.fd-hint,
.fd-note {
	color: var(--fd-muted);
	font-size: 0.8125rem;
	margin: 0;
}

.fd-note {
	border-top: 1px dashed var(--fd-border);
	padding-top: 0.85rem;
}

.fd-hp {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

.fd-status {
	color: var(--fd-muted);
	font-size: 0.875rem;
	margin: 0;
	min-height: 1.25rem;
}

.fd-status--success {
	color: var(--fd-success, #059669);
}

.fd-status--error {
	color: var(--fd-error, #dc2626);
}

.fd-status--info {
	color: var(--fd-info, #0284c7);
}

.fd-notice {
	background: var(--fd-bg);
	border: 1px solid var(--fd-border);
	border-left: 4px solid var(--fd-muted);
	border-radius: var(--fd-radius-sm);
	font-size: 0.9rem;
	margin: 0;
	padding: 0.75rem 0.9rem;
}

.fd-notice--success {
	background: var(--fd-success-bg, #ecfdf5);
	border-left-color: var(--fd-success, #059669);
}

.fd-notice--error {
	background: var(--fd-error-bg, #fef2f2);
	border-left-color: var(--fd-error, #dc2626);
}

.fd-notice--info {
	background: var(--fd-info-bg, #f0f9ff);
	border-left-color: var(--fd-info, #0284c7);
}

.fd-tool__output {
	display: grid;
	gap: 1.1rem;
}

.fd-toolbar {
	align-items: center;
	background: var(--fd-bg);
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius-sm);
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	padding: 0.85rem 1rem;
}

.fd-control {
	align-items: center;
	display: flex;
	gap: 0.5rem;
}

.fd-control__label {
	color: var(--fd-muted);
	font-size: 0.8125rem;
	font-weight: 600;
	white-space: nowrap;
}

.fd-control__value {
	color: var(--fd-text);
	font-size: 0.8125rem;
	font-variant-numeric: tabular-nums;
	min-width: 2.75rem;
	text-align: right;
}

.fd-range {
	accent-color: var(--fd-primary);
	width: clamp(6rem, 12vw, 9rem);
}

.fd-toolbar__buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-left: auto;
}

.fd-stats {
	display: grid;
	gap: 0.5rem;
	grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
	margin: 0;
}

.fd-stat {
	background: var(--fd-bg);
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius-sm);
	display: grid;
	gap: 0.15rem;
	padding: 0.6rem 0.75rem;
}

.fd-stat dt {
	color: var(--fd-muted);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.fd-stat dd {
	color: var(--fd-text);
	font-size: 1.05rem;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	margin: 0;
}

.fd-stat--accent {
	background: var(--fd-primary-tint);
	border-color: var(--fd-primary);
}

.fd-reader-shell {
	background: var(--fd-bg);
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius);
	overflow: hidden;
	padding: clamp(1rem, 3vw, 2.25rem);
}

.fd-reader {
	--fd-reader-font-size: 19px;
	--fd-reader-line-height: 1.7;
	--fd-reader-width: 720px;

	color: var(--fd-text);
	font-size: var(--fd-reader-font-size);
	line-height: var(--fd-reader-line-height);
	margin: 0 auto;
	max-width: min(100%, var(--fd-reader-width));
	overflow-wrap: break-word;
}

.fd-reader--compact {
	font-size: 1rem;
	line-height: 1.65;
}

.fd-reader > * + * {
	margin-top: 1.1em;
}

.fd-reader p,
.fd-reader li {
	hyphens: auto;
}

.fd-reader h2 {
	font-size: 1.45em;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.25;
	margin-top: 1.8em;
}

.fd-reader h3 {
	font-size: 1.2em;
	font-weight: 700;
	line-height: 1.3;
	margin-top: 1.6em;
}

.fd-reader h4,
.fd-reader h5,
.fd-reader h6 {
	font-size: 1.05em;
	font-weight: 700;
	margin-top: 1.4em;
}

.fd-reader h2,
.fd-reader h3,
.fd-reader h4,
.fd-reader h5,
.fd-reader h6 {
	color: var(--fd-headings, var(--fd-text, #0f172a));
}

.fd-reader h2:first-child,
.fd-reader h3:first-child {
	margin-top: 0;
}

.fd-reader a {
	color: var(--fd-primary-dark);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.15em;
}

.fd-reader a:hover {
	text-decoration-thickness: 2px;
}

.fd-reader strong {
	font-weight: 700;
}

.fd-reader blockquote {
	border-left: 4px solid var(--fd-primary, #059669);
	color: var(--fd-text, #0f172a);
	opacity: 0.92;
	font-style: italic;
	margin-inline: 0;
	padding: 0.25rem 0 0.25rem 1.1rem;
}

.fd-reader ul,
.fd-reader ol {
	padding-left: 1.4em;
}

.fd-reader li + li {
	margin-top: 0.35em;
}

.fd-reader code {
	background: var(--fd-primary-tint, #ecfdf5);
	border: 1px solid var(--fd-border, #cbd5e1);
	border-radius: 6px;
	color: var(--fd-text, #0f172a);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.88em;
	padding: 0.1em 0.35em;
}

.fd-reader pre {
	background: #0f172a;
	border-radius: var(--fd-radius-sm);
	color: #e2e8f0;
	overflow-x: auto;
	padding: 1rem 1.1rem;
}

.fd-reader pre code {
	background: none;
	border: 0;
	color: inherit;
	font-size: 0.85em;
	padding: 0;
}

.fd-reader hr {
	border: 0;
	border-top: 1px solid var(--fd-border);
	margin: 2em 0;
}

.fd-reader img {
	border-radius: var(--fd-radius-sm);
	height: auto;
	max-width: 100%;
}

.fd-reader figure {
	margin: 1.5em 0;
}

.fd-reader figcaption {
	color: var(--fd-muted);
	font-size: 0.85em;
	margin-top: 0.5rem;
	text-align: center;
}

.fd-reader table {
	border-collapse: collapse;
	display: block;
	font-size: 0.925em;
	overflow-x: auto;
	width: 100%;
}

.fd-reader th,
.fd-reader td {
	border: 1px solid var(--fd-border);
	padding: 0.5rem 0.7rem;
	text-align: left;
}

.fd-reader th {
	background: var(--fd-bg, #f8fafc);
	color: var(--fd-headings, var(--fd-text, #0f172a));
	font-weight: 700;
}

.fd-reader [data-fd-state="empty"],
.fd-empty {
	color: var(--fd-muted);
	font-style: italic;
}

.fd-result {
	background: var(--fd-bg);
	border: 1px solid var(--fd-border);
	border-radius: var(--fd-radius-sm);
	display: grid;
	gap: 0.85rem;
	padding: 1rem;
}

.fd-result__title {
	font-size: 0.9375rem;
	font-weight: 700;
	margin: 0;
}

.fd-result__row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.fd-result__row .fd-input {
	flex: 1 1 16rem;
}

.fd-result__actions {
	margin: 0;
}

.fd-facts {
	display: grid;
	gap: 0.5rem;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
	margin: 0;
}

.fd-fact dt {
	color: var(--fd-muted);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.fd-fact dd {
	font-size: 0.9rem;
	font-weight: 600;
	margin: 0.15rem 0 0;
	overflow-wrap: anywhere;
}

.fd-changes {
	color: var(--fd-muted);
	display: grid;
	font-size: 0.875rem;
	gap: 0.35rem;
	margin: 0;
	padding-left: 1.2rem;
}

.fd-empty-state {
	padding: 0.25rem 0;
}

.fd-contact {
	gap: 1.1rem;
}

.fd-turnstile {
	justify-items: start;
}

@media (max-width: 640px) {
	.fd-tool {
		padding: 1.25rem;
	}

	.fd-actions {
		align-items: stretch;
		flex-direction: column;
	}

	.fd-actions .fd-btn {
		width: 100%;
	}

	.fd-toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.fd-control {
		justify-content: space-between;
	}

	.fd-range {
		flex: 1 1 auto;
		width: auto;
	}

	.fd-toolbar__buttons {
		margin-left: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fd-btn {
		transition: none;
	}

	.fd-tool * {
		scroll-behavior: auto;
	}
}

/* Print: keep only the reading content. */
@media print {
	body * {
		visibility: hidden;
	}

	.fd-reader,
	.fd-reader * {
		visibility: visible;
	}

	.fd-reader {
		color: #000;
		left: 0;
		margin: 0;
		max-width: 100%;
		top: 0;
		width: 100%;
	}

	.fd-reader a {
		color: #000;
	}

	.fd-toolbar,
	.fd-stats,
	.fd-status,
	.fd-notice,
	.fd-btn,
	.fd-note,
	.fd-hint,
	.fd-result__actions {
		display: none !important;
	}
}