/**
 * SnapView Tools — front-end styles
 *
 * Colour and type strategy, in cascade order:
 *   1. Values injected by PHP from theme.json  (--sv-accent etc.)
 *   2. WordPress preset custom properties      (--wp--preset--color--*)
 *   3. Neutral fallbacks defined here
 *
 * Nothing here sets a header, footer, or page container — tool pages are
 * expected to be rendered inside the theme's own layout.
 */

.sv-tool,
.sv-related,
.sv-statusboard,
.sv-disclaimer {
	--sv-accent: var(--wp--preset--color--primary, var(--wp--preset--color--accent, #2f6df6));
	--sv-accent-ink: #fff;
	--sv-surface: var(--wp--preset--color--base, #fff);
	--sv-surface-2: color-mix(in srgb, var(--sv-ink) 4%, var(--sv-surface));
	--sv-ink: var(--wp--preset--color--contrast, #14171f);
	--sv-muted: color-mix(in srgb, var(--sv-ink) 58%, var(--sv-surface));
	--sv-border: color-mix(in srgb, var(--sv-ink) 14%, var(--sv-surface));
	--sv-danger: #c0392b;
	--sv-ok: #1f8a4c;

	--sv-font-body: var(--wp--preset--font-family--body, inherit);
	--sv-font-head: var(--wp--preset--font-family--heading, var(--sv-font-body));

	--sv-radius: 12px;
	--sv-radius-sm: 8px;
	--sv-gap: 14px;

	font-family: var(--sv-font-body);
	color: var(--sv-ink);
	box-sizing: border-box;
}

.sv-tool *,
.sv-tool *::before,
.sv-tool *::after,
.sv-related *,
.sv-statusboard * {
	box-sizing: inherit;
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.sv-tool,
	.sv-related,
	.sv-statusboard {
		--sv-surface-2: #f6f7f9;
		--sv-muted: #5b6472;
		--sv-border: #dfe3e9;
	}
}

/* ------------------------------------------------------------------ */
/* Tool shell                                                          */
/* ------------------------------------------------------------------ */

.sv-tool {
	background: var(--sv-surface);
	border: 1px solid var(--sv-border);
	border-radius: var(--sv-radius);
	padding: clamp(16px, 4vw, 28px);
	margin: 0 0 28px;
}

.sv-tool__head {
	margin-bottom: 18px;
}

.sv-tool__title {
	font-family: var(--sv-font-head);
	font-size: clamp(1.25rem, 3.5vw, 1.6rem);
	line-height: 1.25;
	margin: 0 0 6px;
	color: var(--sv-ink);
}

.sv-tool__sub {
	margin: 0;
	color: var(--sv-muted);
	font-size: 0.95rem;
	line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Input row                                                           */
/* ------------------------------------------------------------------ */

.sv-field__row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.sv-input {
	flex: 1 1 240px;
	min-width: 0;
	width: 100%;
	padding: 13px 14px;
	font: inherit;
	font-size: 1rem;
	color: var(--sv-ink);
	background: var(--sv-surface);
	border: 1.5px solid var(--sv-border);
	border-radius: var(--sv-radius-sm);
	transition: border-color .15s ease, box-shadow .15s ease;
	-webkit-appearance: none;
	appearance: none;
}

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

.sv-input::placeholder {
	color: var(--sv-muted);
	opacity: .7;
}

select.sv-input {
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	padding-right: 36px;
}

.sv-lbl {
	display: block;
	font-size: .85rem;
	font-weight: 600;
	color: var(--sv-muted);
	margin-bottom: 4px;
}

.sv-lbl .sv-input {
	margin-top: 5px;
	font-weight: 400;
	color: var(--sv-ink);
}

.sv-range {
	width: 100%;
	margin-top: 12px;
	accent-color: var(--sv-accent);
}

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

.sv-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 13px 22px;
	font: inherit;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1;
	border: 1.5px solid transparent;
	border-radius: var(--sv-radius-sm);
	cursor: pointer;
	white-space: nowrap;
	transition: transform .12s ease, opacity .15s ease, background-color .15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sv-btn:active { transform: translateY(1px); }

.sv-btn:disabled {
	opacity: .55;
	cursor: not-allowed;
	transform: none;
}

.sv-btn--primary {
	background: var(--sv-accent);
	color: var(--sv-accent-ink);
}

.sv-btn--primary:hover:not(:disabled) {
	background: color-mix(in srgb, var(--sv-accent) 86%, #000);
}

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

.sv-btn--ghost:hover:not(:disabled) {
	color: var(--sv-ink);
	border-color: var(--sv-accent);
}

.sv-btn--block {
	width: 100%;
	margin-top: 14px;
}

.sv-btn--sm {
	padding: 9px 14px;
	font-size: .875rem;
}

/* Hide the paste button where the Clipboard API is unavailable */
.sv-paste { display: none; }
.sv-has-clipboard .sv-paste { display: inline-flex; }

/* ------------------------------------------------------------------ */
/* Spinner                                                             */
/* ------------------------------------------------------------------ */

.sv-spinner {
	display: none;
	width: 15px;
	height: 15px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: sv-spin .6s linear infinite;
}

.sv-btn.is-busy .sv-spinner { display: block; }
.sv-btn.is-busy .sv-btn__label { opacity: .75; }

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

@media (prefers-reduced-motion: reduce) {
	.sv-spinner { animation-duration: 1.8s; }
	.sv-btn, .sv-input { transition: none; }
}

/* ------------------------------------------------------------------ */
/* Messages                                                            */
/* ------------------------------------------------------------------ */

.sv-msg {
	margin: 12px 0 0;
	font-size: .92rem;
	line-height: 1.5;
	color: var(--sv-muted);
	min-height: 1.2em;
}

.sv-msg:empty { margin: 0; min-height: 0; }

.sv-msg--error { color: var(--sv-danger); font-weight: 500; }
.sv-msg--ok { color: var(--sv-ok); }

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

.sv-results {
	margin-top: 20px;
	padding-top: 20px;
	border-top: 1px solid var(--sv-border);
}

.sv-results[hidden] { display: none; }

.sv-preview {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	margin-bottom: 16px;
}

.sv-preview__thumb {
	flex: 0 0 92px;
	width: 92px;
	height: 92px;
	object-fit: cover;
	border-radius: var(--sv-radius-sm);
	background: var(--sv-surface-2);
	border: 1px solid var(--sv-border);
}

.sv-preview__meta { min-width: 0; }

.sv-preview__title {
	font-family: var(--sv-font-head);
	font-size: 1rem;
	font-weight: 600;
	margin: 0 0 4px;
	overflow-wrap: anywhere;
}

.sv-preview__sub {
	margin: 0;
	font-size: .85rem;
	color: var(--sv-muted);
}

.sv-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 8px;
}

.sv-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	background: var(--sv-surface-2);
	border: 1px solid var(--sv-border);
	border-radius: var(--sv-radius-sm);
}

.sv-item__thumb {
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	object-fit: cover;
	border-radius: 6px;
	background: var(--sv-border);
}

.sv-item__info {
	flex: 1 1 auto;
	min-width: 0;
}

.sv-item__label {
	display: block;
	font-weight: 600;
	font-size: .95rem;
	line-height: 1.3;
}

.sv-item__meta {
	display: block;
	font-size: .8rem;
	color: var(--sv-muted);
	margin-top: 2px;
}

.sv-badge {
	display: inline-block;
	padding: 2px 7px;
	margin-left: 6px;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .03em;
	text-transform: uppercase;
	border-radius: 4px;
	background: color-mix(in srgb, var(--sv-accent) 15%, transparent);
	color: var(--sv-accent);
	vertical-align: middle;
}

.sv-badge--mute {
	background: color-mix(in srgb, var(--sv-ink) 10%, transparent);
	color: var(--sv-muted);
}

/* ------------------------------------------------------------------ */
/* Trust strip / disclaimer                                            */
/* ------------------------------------------------------------------ */

.sv-trust {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	margin: 18px 0 0;
	padding: 0;
	font-size: .82rem;
	color: var(--sv-muted);
}

.sv-trust li { display: flex; align-items: center; gap: 6px; }

.sv-trust li::before {
	content: "";
	width: 13px;
	height: 7px;
	border-left: 2px solid var(--sv-accent);
	border-bottom: 2px solid var(--sv-accent);
	transform: rotate(-45deg) translateY(-2px);
	flex: none;
}

.sv-disclaimer {
	margin: 24px 0;
	padding: 14px 16px;
	font-size: .8rem;
	line-height: 1.6;
	color: var(--sv-muted);
	background: var(--sv-surface-2);
	border-left: 3px solid var(--sv-border);
	border-radius: 0 var(--sv-radius-sm) var(--sv-radius-sm) 0;
}

/* ------------------------------------------------------------------ */
/* Drop zone                                                           */
/* ------------------------------------------------------------------ */

.sv-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 36px 20px;
	text-align: center;
	background: var(--sv-surface-2);
	border: 2px dashed var(--sv-border);
	border-radius: var(--sv-radius-sm);
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease;
}

.sv-drop:hover,
.sv-drop:focus-visible,
.sv-drop.is-over {
	border-color: var(--sv-accent);
	background: color-mix(in srgb, var(--sv-accent) 6%, var(--sv-surface));
	outline: none;
}

.sv-drop__title { font-weight: 600; font-size: 1rem; }
.sv-drop__hint { font-size: .85rem; color: var(--sv-muted); }

/* ------------------------------------------------------------------ */
/* Grids                                                               */
/* ------------------------------------------------------------------ */

.sv-grid { display: grid; gap: var(--sv-gap); margin-top: 16px; }
.sv-grid--2 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.sv-grid--3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Key/value output table for calculators */
.sv-kv {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 0;
	border: 1px solid var(--sv-border);
	border-radius: var(--sv-radius-sm);
	overflow: hidden;
}

.sv-kv > * {
	padding: 11px 14px;
	border-bottom: 1px solid var(--sv-border);
	font-size: .92rem;
}

.sv-kv > *:nth-last-child(-n+2) { border-bottom: 0; }
.sv-kv dt { color: var(--sv-muted); margin: 0; }
.sv-kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ */
/* Related tools                                                       */
/* ------------------------------------------------------------------ */

.sv-related { margin: 32px 0; }

.sv-related__title {
	font-family: var(--sv-font-head);
	font-size: 1.15rem;
	margin: 0 0 14px;
}

.sv-related__grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 10px;
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.sv-related__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 16px;
	text-decoration: none;
	color: var(--sv-ink);
	background: var(--sv-surface-2);
	border: 1px solid var(--sv-border);
	border-radius: var(--sv-radius-sm);
	transition: border-color .15s ease, transform .12s ease;
}

.sv-related__item:hover {
	border-color: var(--sv-accent);
	transform: translateY(-1px);
	color: var(--sv-ink);
}

.sv-related__name { font-weight: 600; font-size: .95rem; }
.sv-related__arrow { color: var(--sv-accent); }

/* ------------------------------------------------------------------ */
/* Status board                                                        */
/* ------------------------------------------------------------------ */

.sv-statusboard .sv-list { margin-top: 10px; }

.sv-dot {
	flex: none;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--sv-ok);
}

.sv-dot--down { background: var(--sv-danger); }

/* ------------------------------------------------------------------ */
/* Utilities                                                           */
/* ------------------------------------------------------------------ */

.sv-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 560px) {
	.sv-field__row { flex-direction: column; }
	.sv-field__row .sv-btn { width: 100%; }
	.sv-paste { order: 3; }
	.sv-preview__thumb { flex-basis: 68px; width: 68px; height: 68px; }
	.sv-item { flex-wrap: wrap; }
	.sv-item .sv-btn { width: 100%; }
}

@media (prefers-color-scheme: dark) {
	.sv-tool, .sv-related, .sv-statusboard {
		--sv-surface: var(--wp--preset--color--base, #14171f);
		--sv-ink: var(--wp--preset--color--contrast, #e9ecf1);
	}
}
