/* Stone Visualizer — front-end widget
   Palette evokes a stone showroom: warm ledger-paper background, near-black
   basalt ink, and a brushed-brass accent (used sparingly) instead of the
   generic warm-cream/terracotta combination. Headings use a serif stack to
   read like a stone catalogue; UI chrome uses the system sans stack. */

.sv-widget {
	--sv-ink: #1E1C1A;
	--sv-paper: #F2EFE9;
	--sv-panel: #FFFFFF;
	--sv-line: #DBD4C7;
	--sv-mute: #8A8377;
	--sv-brass: #A67C4E;
	--sv-brass-dark: #7C5B36;
	--sv-success: #4C6B4F;
	--sv-error: #8C3B2E;
	--sv-radius: 10px;

	--sv-font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
	--sv-font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

	max-width: 760px;
	margin: 0 auto;
	color: var(--sv-ink);
	font-family: var(--sv-font-body);
	background: var(--sv-paper);
	border: 1px solid var(--sv-line);
	border-radius: 14px;
	padding: 32px;
	box-sizing: border-box;
}
.sv-widget *, .sv-widget *::before, .sv-widget *::after { box-sizing: border-box; }
.sv-widget img { max-width: 100%; display: block; }

.sv-widget-empty {
	padding: 20px;
	font-family: var(--sv-font-body);
	background: #FBF5EC;
	border: 1px dashed var(--sv-line);
	border-radius: 10px;
}

/* ---------- Header ---------- */
.sv-head { margin-bottom: 28px; }
.sv-heading {
	font-family: var(--sv-font-display);
	font-weight: 400;
	font-size: 28px;
	line-height: 1.25;
	margin: 0 0 8px;
	letter-spacing: 0.2px;
}
.sv-description {
	margin: 0;
	color: var(--sv-mute);
	font-size: 15px;
	line-height: 1.6;
}

/* ---------- Steps ---------- */
.sv-step {
	padding: 22px 0;
	border-top: 1px solid var(--sv-line);
}
.sv-step:first-of-type { border-top: none; padding-top: 0; }

.sv-step-label {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 600;
	font-size: 15px;
	margin-bottom: 14px;
}
.sv-step-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--sv-ink);
	color: var(--sv-paper);
	font-family: var(--sv-font-display);
	font-size: 13px;
	flex: none;
}
.sv-step.is-complete .sv-step-num { background: var(--sv-success); }

/* ---------- Step 1: dropzone ---------- */
.sv-dropzone {
	display: block;
	position: relative;
	border: 1.5px dashed var(--sv-line);
	border-radius: var(--sv-radius);
	background: var(--sv-panel);
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease;
	overflow: hidden;
}
.sv-dropzone:hover, .sv-dropzone.is-dragover {
	border-color: var(--sv-brass);
	background: #FBF7F0;
}
.sv-dropzone-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 40px 20px;
	color: var(--sv-mute);
	text-align: center;
}
.sv-dropzone-empty svg { color: var(--sv-brass); }
.sv-dropzone-text { font-size: 15px; color: var(--sv-ink); font-weight: 500; }
.sv-dropzone-sub { font-size: 13px; }

.sv-dropzone-preview { position: relative; }
.sv-dropzone-preview .sv-preview-img {
	width: 100%;
	max-height: 320px;
	object-fit: cover;
}
.sv-preview-change {
	position: absolute;
	right: 12px;
	bottom: 12px;
	background: rgba(30,28,26,0.82);
	color: #fff;
	font-size: 13px;
	padding: 6px 12px;
	border-radius: 20px;
}

/* ---------- Step 2: surface pills ---------- */
.sv-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}
.sv-pill {
	position: relative;
	cursor: pointer;
}
.sv-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.sv-pill span {
	display: inline-block;
	padding: 9px 18px;
	border-radius: 22px;
	border: 1.5px solid var(--sv-line);
	background: var(--sv-panel);
	font-size: 14px;
	transition: all .15s ease;
}
.sv-pill input:checked + span {
	background: var(--sv-ink);
	border-color: var(--sv-ink);
	color: var(--sv-paper);
}
.sv-pill input:focus-visible + span {
	outline: 2px solid var(--sv-brass);
	outline-offset: 2px;
}

/* ---------- Step 3: category tabs + swatch chips (signature element) ---------- */
.sv-cat-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-bottom: 18px;
	border-bottom: 1px solid var(--sv-line);
}
.sv-cat-tab {
	appearance: none;
	background: none;
	border: none;
	border-bottom: 2px solid transparent;
	padding: 8px 4px;
	margin-right: 18px;
	font-family: var(--sv-font-body);
	font-size: 14px;
	color: var(--sv-mute);
	cursor: pointer;
}
.sv-cat-tab.is-active {
	color: var(--sv-ink);
	border-bottom-color: var(--sv-brass);
	font-weight: 600;
}

.sv-swatch-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 14px;
}

.sv-swatch { cursor: pointer; }
.sv-swatch input { position: absolute; opacity: 0; width: 0; height: 0; }

.sv-swatch-photo {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	border-radius: 8px;
	overflow: hidden;
	border: 2px solid transparent;
	background: #E8E2D6;
	/* Cut-corner "sample chip" silhouette — the signature visual element,
	   evoking a physical stone swatch cut from a showroom board. */
	clip-path: polygon(0 0, 100% 0, 100% 82%, 82% 100%, 0 100%);
	box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
	transition: transform .15s ease, box-shadow .15s ease;
}
.sv-swatch-photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
/* Subtle polished sheen overlay */
.sv-swatch-photo::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 30%, rgba(0,0,0,0.06) 100%);
	pointer-events: none;
}
.sv-swatch:hover .sv-swatch-photo { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(30,28,26,0.14); }

.sv-swatch-check {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--sv-brass);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: scale(0.6);
	transition: all .15s ease;
	z-index: 2;
}
.sv-swatch input:checked ~ .sv-swatch-photo { border-color: var(--sv-brass); }
.sv-swatch input:checked ~ .sv-swatch-photo .sv-swatch-check { opacity: 1; transform: scale(1); }
.sv-swatch input:focus-visible ~ .sv-swatch-photo { outline: 2px solid var(--sv-brass); outline-offset: 2px; }

.sv-swatch-name {
	display: block;
	margin-top: 8px;
	font-size: 13px;
	line-height: 1.3;
	text-align: center;
	color: var(--sv-ink);
}

/* ---------- Step 4: generate ---------- */
.sv-generate-btn {
	appearance: none;
	width: 100%;
	padding: 15px 20px;
	border: none;
	border-radius: 10px;
	background: linear-gradient(135deg, var(--sv-brass) 0%, var(--sv-brass-dark) 100%);
	color: #fff;
	font-family: var(--sv-font-body);
	font-size: 16px;
	font-weight: 600;
	letter-spacing: 0.2px;
	cursor: pointer;
	transition: filter .15s ease, transform .05s ease;
}
.sv-generate-btn:hover { filter: brightness(1.06); }
.sv-generate-btn:active { transform: translateY(1px); }
.sv-generate-btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

.sv-status {
	margin-top: 14px;
	font-size: 14px;
	min-height: 1.4em;
}
.sv-status.is-loading { color: var(--sv-mute); display: flex; align-items: center; gap: 10px; }
.sv-status.is-error { color: var(--sv-error); }

.sv-spinner {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	border: 2px solid var(--sv-line);
	border-top-color: var(--sv-brass);
	animation: sv-spin 0.8s linear infinite;
	flex: none;
}
@keyframes sv-spin { to { transform: rotate(360deg); } }

/* ---------- Result / before-after compare ---------- */
.sv-result {
	margin-top: 28px;
	padding-top: 28px;
	border-top: 1px solid var(--sv-line);
}
.sv-compare {
	position: relative;
	border-radius: var(--sv-radius);
	overflow: hidden;
	background: #000;
	user-select: none;
}
.sv-compare-after, .sv-compare-before-wrap img {
	width: 100%;
	display: block;
}
.sv-compare-before-wrap {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 50%;
	overflow: hidden;
	border-right: 2px solid #fff;
}
.sv-compare-before-wrap img {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: var(--sv-compare-img-w, 100%);
	max-width: none;
	object-fit: cover;
}
.sv-compare-slider {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	appearance: none;
	background: transparent;
	cursor: ew-resize;
}
.sv-compare-slider::-webkit-slider-thumb {
	appearance: none;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--sv-brass);
	box-shadow: 0 2px 8px rgba(0,0,0,0.3);
	cursor: ew-resize;
}
.sv-compare-slider::-moz-range-thumb {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--sv-brass);
	cursor: ew-resize;
}
.sv-compare-slider::-webkit-slider-runnable-track { background: transparent; }
.sv-compare-slider::-moz-range-track { background: transparent; }
.sv-compare-tag {
	position: absolute;
	top: 10px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.4px;
	text-transform: uppercase;
	color: #fff;
	background: rgba(30,28,26,0.6);
	padding: 4px 10px;
	border-radius: 4px;
	pointer-events: none;
}
.sv-compare-tag-before { left: 10px; }
.sv-compare-tag-after { right: 10px; }

.sv-result-actions {
	display: flex;
	gap: 12px;
	margin-top: 18px;
}
.sv-download-btn, .sv-reset-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 11px 18px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
}
.sv-download-btn { background: var(--sv-ink); color: var(--sv-paper); border: none; }
.sv-reset-btn { background: transparent; color: var(--sv-ink); border: 1.5px solid var(--sv-line); }
.sv-reset-btn:hover { border-color: var(--sv-brass); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
	.sv-widget { padding: 22px 18px; }
	.sv-heading { font-size: 23px; }
	.sv-swatch-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
	.sv-result-actions { flex-direction: column; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.sv-swatch:hover .sv-swatch-photo { transform: none; }
	.sv-spinner { animation-duration: 1.6s; }
}
