/* WC Visual Search – front-end */
.wcvs, .wcvs-fab, .wcvs-trigger {
	--acc: var(--wcvs-accent, #8a2f5c);
	--acc-tint: #f6ecf1;
	--ink: #1f1723;
	--muted: #7a6f80;
	--line: #eee7ec;
	--wash: #f5f1f4;
}
@supports (color: color-mix(in srgb, red, blue)) {
	.wcvs, .wcvs-fab, .wcvs-trigger { --acc-tint: color-mix(in srgb, var(--acc) 10%, #fff); }
}

.wcvs-lock { overflow: hidden; }

/* ---------- Launchers ---------- */
.wcvs-fab {
	position: fixed;
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	z-index: 9990;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 52px;
	padding: 0 20px;
	border: 0;
	border-radius: 26px;
	background: var(--acc);
	color: #fff;
	font: inherit;
	font-size: .95rem;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(31, 23, 35, .28);
}
.wcvs-fab--left { left: 18px; }
.wcvs-fab--right { right: 18px; }
.wcvs-fab svg, .wcvs-trigger svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
@media (max-width: 480px) {
	.wcvs-fab { width: 54px; height: 54px; padding: 0; justify-content: center; border-radius: 50%; }
	.wcvs-fab span { display: none; }
}
.wcvs-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 46px;
	padding: 0 20px;
	border: 0;
	border-radius: 14px;
	background: var(--acc-tint);
	color: var(--acc);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

/* ---------- Modal shell ---------- */
.wcvs {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	font: inherit;
	color: var(--ink);
	direction: inherit;
	-webkit-tap-highlight-color: transparent;
}
.wcvs[hidden] { display: none; }
.wcvs *, .wcvs *::before, .wcvs *::after { box-sizing: border-box; }
.wcvs [hidden] { display: none !important; }
.wcvs button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; margin: 0; line-height: 1.3; }
.wcvs button:focus-visible, .wcvs a:focus-visible, .wcvs-fab:focus-visible, .wcvs-trigger:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.wcvs svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.wcvs .wcvs__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(31, 23, 35, .56);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	opacity: 0;
	transition: opacity .22s;
}
.wcvs.is-open .wcvs__backdrop { opacity: 1; }

.wcvs .wcvs__sheet {
	position: relative;
	width: 100%;
	max-height: 92vh;
	max-height: 92dvh;
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 28px 28px 0 0;
	box-shadow: 0 -12px 40px rgba(31, 23, 35, .22);
	transform: translateY(24px);
	opacity: 0;
	transition: transform .26s cubic-bezier(.2, .8, .2, 1), opacity .2s;
	outline: 0;
}
.wcvs.is-open .wcvs__sheet { transform: none; opacity: 1; }
.wcvs .wcvs__grab { flex: none; width: 40px; height: 4px; margin: 10px auto 0; border-radius: 2px; background: var(--line); }
.wcvs .wcvs__head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 20px 6px; }
.wcvs .wcvs__title { margin: 0; padding: 0; font-size: 1.06rem; font-weight: 700; line-height: 1.5; color: var(--ink); }
.wcvs .wcvs__icon { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--wash); color: var(--ink); }
.wcvs .wcvs__icon svg { width: 20px; height: 20px; }
.wcvs .wcvs__body {
	overflow: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 4px 20px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Viewfinder ---------- */
.wcvs .wcvs__frame {
	--br: var(--acc);
	position: relative;
	width: min(100%, 400px);
	aspect-ratio: 1 / 1;
	margin: 8px auto 0;
	border-radius: 24px;
	overflow: hidden;
	background: var(--wash);
	display: grid;
	place-items: center;
}
.wcvs[data-state="camera"] .wcvs__frame,
.wcvs[data-state="scan"] .wcvs__frame { --br: #fff; background: #140f18; }

.wcvs .wcvs__video,
.wcvs .wcvs__shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; margin: 0; border: 0; border-radius: 0; }
.wcvs[data-state="camera"] .wcvs__video { display: block; }
.wcvs[data-state="scan"] .wcvs__shot { display: block; }

.wcvs .wcvs__hint {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 0 40px;
	text-align: center;
	font-size: .92rem;
	line-height: 1.8;
	color: var(--muted);
}
.wcvs .wcvs__hint svg { width: 44px; height: 44px; color: var(--acc); }
.wcvs[data-state="camera"] .wcvs__hint,
.wcvs[data-state="scan"] .wcvs__hint { display: none; }

.wcvs .wcvs__c {
	position: absolute;
	z-index: 2;
	width: 34px;
	height: 34px;
	border: 0 solid var(--br);
	pointer-events: none;
	filter: drop-shadow(0 0 1px rgba(0, 0, 0, .4));
}
.wcvs .wcvs__c.a { top: 16px; left: 16px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 12px; }
.wcvs .wcvs__c.b { top: 16px; right: 16px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 12px; }
.wcvs .wcvs__c.c { bottom: 16px; left: 16px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 12px; }
.wcvs .wcvs__c.d { bottom: 16px; right: 16px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 12px; }

.wcvs .wcvs__scan {
	display: none;
	position: absolute;
	z-index: 1;
	inset-inline: 0;
	top: 0;
	height: 22%;
	pointer-events: none;
	background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, .2) 46%, #fff 50%, rgba(255, 255, 255, .2) 54%, rgba(255, 255, 255, 0));
}
.wcvs[data-state="scan"] .wcvs__scan { display: block; animation: wcvs-scan 1.6s cubic-bezier(.45, 0, .55, 1) infinite alternate; }
@keyframes wcvs-scan { from { transform: translateY(0); } to { transform: translateY(354%); } }

.wcvs .wcvs__status { min-height: 1.6em; margin: 14px 0 0; padding: 0; text-align: center; font-size: .92rem; line-height: 1.7; color: var(--muted); }
.wcvs .wcvs__status[data-tone="error"] { color: #b3261e; }

/* ---------- Buttons ---------- */
.wcvs .wcvs__actions { display: none; gap: 10px; margin: 16px auto 0; width: min(100%, 400px); }
.wcvs[data-state="start"] .wcvs__actions--start { display: flex; }
.wcvs[data-state="camera"] .wcvs__actions--camera { display: flex; align-items: center; justify-content: space-between; }
.wcvs .wcvs__btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 18px; border-radius: 16px; font-size: .95rem; font-weight: 600; text-align: center; }
.wcvs .wcvs__btn svg { width: 20px; height: 20px; flex: none; }
.wcvs .wcvs__actions--start .wcvs__btn { flex: 1 1 0; padding: 0 10px; }
.wcvs .wcvs__btn--primary { background: var(--acc); color: #fff; }
.wcvs .wcvs__btn--soft { background: var(--acc-tint); color: var(--acc); }
.wcvs .wcvs__btn--ghost { color: var(--muted); font-weight: 500; }
.wcvs .wcvs__btn--sm { height: 40px; padding: 0 14px; border-radius: 12px; font-size: .86rem; flex: none; }
.wcvs .wcvs__slot { width: 88px; display: flex; justify-content: center; }
.wcvs .wcvs__shutter {
	width: 72px;
	height: 72px;
	border-radius: 50%;
	background: var(--acc);
	border: 4px solid var(--acc);
	box-shadow: inset 0 0 0 4px #fff;
	transition: transform .12s;
}
.wcvs .wcvs__shutter:active { transform: scale(.93); }

/* ---------- Results ---------- */
.wcvs .wcvs__results { display: none; }
.wcvs[data-state="results"] .wcvs__results { display: block; }
.wcvs[data-state="results"] .wcvs__capture { display: none; }

.wcvs .wcvs__query { display: flex; align-items: center; gap: 12px; padding: 8px 0 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.wcvs .wcvs__thumb { flex: none; width: 56px; height: 56px; margin: 0; border-radius: 14px; object-fit: cover; background: var(--wash); }
.wcvs .wcvs__qtext { flex: 1; min-width: 0; }
.wcvs .wcvs__qtext strong { display: block; font-size: .98rem; line-height: 1.5; }
.wcvs .wcvs__sub { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: .82rem; line-height: 1.6; color: var(--muted); }
.wcvs .wcvs__weak-ico { color: var(--acc); font-size: .9em; }

.wcvs .wcvs__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
.wcvs a.wcvs-card { display: block; min-width: 0; color: inherit; text-decoration: none; }
.wcvs .wcvs-card__media { position: relative; display: block; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 16px; background: var(--wash); }
.wcvs .wcvs-card__media img { display: block; width: 100%; height: 100%; margin: 0; object-fit: cover; border: 0; border-radius: 0; }
.wcvs .wcvs-card.is-out .wcvs-card__media img { opacity: .5; }
.wcvs .wcvs-card__flags { position: absolute; top: 8px; inset-inline: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.wcvs .wcvs-card__flag { padding: 3px 9px; border-radius: 8px; background: #fff; color: var(--ink); font-size: .72rem; font-weight: 600; line-height: 1.6; }
.wcvs .wcvs-card__flag.is-best { background: var(--acc); color: #fff; }
.wcvs .wcvs-card__flag.is-sale { background: var(--ink); color: #fff; }
.wcvs .wcvs-card__flag.is-out { color: var(--muted); }
.wcvs .wcvs-card__match { position: absolute; bottom: 8px; inset-inline-end: 8px; padding: 3px 8px; border-radius: 8px; background: rgba(20, 15, 24, .62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.6; letter-spacing: .02em; }
.wcvs a.wcvs-card { animation: wcvs-card-in .32s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes wcvs-card-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.wcvs .wcvs-card__title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 10px; font-size: .88rem; font-weight: 500; line-height: 1.7; }
.wcvs a.wcvs-card:hover .wcvs-card__title { color: var(--acc); }
.wcvs .wcvs-card__price { display: block; margin-top: 2px; font-size: .9rem; font-weight: 700; line-height: 1.6; }
.wcvs .wcvs-card__price del { margin-inline-end: 6px; font-weight: 400; opacity: .5; }
.wcvs .wcvs-card__price ins { text-decoration: none; background: none; }

.wcvs .wcvs-sk__m { aspect-ratio: 3 / 4; border-radius: 16px; background: var(--wash); }
.wcvs .wcvs-sk__l { height: 12px; width: 82%; margin-top: 12px; border-radius: 6px; background: var(--wash); }
.wcvs .wcvs-sk__l--s { width: 46%; margin-top: 8px; }
.wcvs .wcvs-sk { animation: wcvs-pulse 1.2s ease-in-out infinite; }
@keyframes wcvs-pulse { 50% { opacity: .5; } }

.wcvs .wcvs__msg { padding: 32px 8px 8px; text-align: center; }
.wcvs .wcvs__msg p { margin: 0 0 18px; font-size: .95rem; line-height: 1.9; color: var(--muted); }

/* ---------- Desktop ---------- */
@media (min-width: 720px) {
	.wcvs { align-items: center; }
	.wcvs .wcvs__sheet { width: min(720px, 92vw); max-height: 88vh; border-radius: 28px; transform: translateY(12px) scale(.98); box-shadow: 0 30px 80px rgba(31, 23, 35, .3); }
	.wcvs.is-open .wcvs__sheet { transform: none; }
	.wcvs .wcvs__grab { display: none; }
	.wcvs .wcvs__head { padding: 22px 28px 8px; }
	.wcvs .wcvs__body { padding: 4px 28px 28px; }
	.wcvs .wcvs__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
	.wcvs .wcvs__sheet, .wcvs .wcvs__backdrop { transition: none; }
	.wcvs[data-state="scan"] .wcvs__scan { animation: none; transform: translateY(177%); }
	.wcvs .wcvs-sk { animation: none; }
	.wcvs a.wcvs-card { animation: none; }
}
