/*
 * Site Analyzer
 * Colors and fonts come from the active theme (theme.json presets) so the
 * widget looks native on each brand's site. Fallbacks keep it usable anywhere.
 */
.sa {
	--sa-brand: var(--wp--preset--color--brand, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #b23a17)));
	--sa-ink: var(--wp--preset--color--contrast, currentColor);
	--sa-muted: var(--wp--preset--color--muted, color-mix(in srgb, currentColor 65%, transparent));
	--sa-surface: var(--wp--preset--color--surface, #fff);
	--sa-sand: var(--wp--preset--color--sand, color-mix(in srgb, currentColor 5%, transparent));
	--sa-line: var(--wp--preset--color--line, color-mix(in srgb, currentColor 16%, transparent));
	--sa-good: #1a7f4b;
	--sa-ok: #b7791f;
	--sa-bad: #c0392b;
	--sa-radius: 16px;
	color: var(--sa-ink);
}
.sa *, .sa *::before, .sa *::after { box-sizing: border-box; }
.sa [hidden] { display: none !important; }

/* Form ----------------------------------------------------------------- */
.sa-form {
	display: grid;
	gap: 1.1rem;
	padding: clamp(1.25rem, 3vw, 2rem);
	background: var(--sa-surface);
	border: 1px solid var(--sa-line);
	border-radius: var(--sa-radius);
}
.sa-row { display: grid; gap: 1rem; grid-template-columns: 1.4fr 1fr; }
.sa-field { display: grid; gap: .4rem; }
.sa-field label { font-weight: 600; font-size: .95rem; }
.sa-field input {
	width: 100%;
	padding: .85rem 1rem;
	font: inherit;
	color: inherit;
	background: var(--sa-sand);
	border: 1.5px solid transparent;
	border-radius: 10px;
	transition: border-color .15s, background-color .15s;
}
.sa-field-url input { font-size: 1.15rem; font-weight: 600; }
.sa-field input:hover { border-color: var(--sa-line); }
.sa-field input:focus { outline: none; border-color: var(--sa-brand); background: var(--sa-surface); }
.sa-consent { display: flex; gap: .65rem; align-items: flex-start; font-size: .88rem; line-height: 1.5; color: var(--sa-muted); cursor: pointer; }
.sa-consent input { flex: none; width: 1.1rem; height: 1.1rem; margin-top: .15rem; accent-color: var(--sa-brand); }
.sa-consent a { color: inherit; }
.sa-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.sa-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.sa-submit { cursor: pointer; }
.sa-submit[disabled] { opacity: .55; cursor: progress; }
.sa-hint { font-size: .88rem; color: var(--sa-muted); }
.sa-status { margin: 0; font-size: .95rem; }
.sa-status:empty { display: none; }
.sa-status.sa-error { color: var(--sa-bad); font-weight: 600; }
.sa :focus-visible { outline: 2px solid var(--sa-brand); outline-offset: 2px; }

/* Cloudflare Turnstile: only takes space when it asks the visitor to interact. */
.sa .cf-turnstile { width: 100%; }
.sa .cf-turnstile:empty { display: none; }
.sa .cf-turnstile iframe { display: block; max-width: 100%; border-radius: 8px; }

/* Progress (shown while the analysis runs) ----------------------------- */
.sa-progress {
	margin-top: 1rem;
	padding: clamp(1.25rem, 3vw, 2rem);
	background: var(--sa-surface);
	border: 1px solid var(--sa-line);
	border-radius: var(--sa-radius);
}
.sa-progress-url { margin: 0 0 1rem; font-weight: 700; font-size: 1.1rem; word-break: break-all; }
.sa-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.sa-step { display: flex; align-items: center; gap: .75rem; color: var(--sa-muted); transition: color .3s; }
.sa-step-icon { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 2px solid var(--sa-line); display: grid; place-items: center; }
.sa-step.is-active { color: var(--sa-ink); font-weight: 600; }
.sa-step.is-active .sa-step-icon { border-color: var(--sa-line); border-top-color: var(--sa-brand); animation: sa-spin .8s linear infinite; }
.sa-step.is-done { color: var(--sa-ink); }
.sa-step.is-done .sa-step-icon { border-color: var(--sa-good); background: var(--sa-good); }
.sa-step.is-done .sa-step-icon::after { content: ""; width: .35rem; height: .65rem; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.sa-bar { margin-top: 1.25rem; height: 4px; background: var(--sa-line); border-radius: 2px; overflow: hidden; }
.sa-bar span { display: block; height: 100%; width: 0; background: var(--sa-brand); transition: width 1.2s ease-out; }
@keyframes sa-spin { to { transform: rotate(360deg); } }

/* Result --------------------------------------------------------------- */
.sa-result {
	margin-top: 1rem;
	background: var(--sa-surface);
	border: 1px solid var(--sa-line);
	border-radius: var(--sa-radius);
	overflow: hidden;
}
.sa-result:focus { outline: none; }
.sa-hero { display: grid; grid-template-columns: auto 1fr; gap: clamp(1rem, 3vw, 2rem); align-items: center; padding: clamp(1.25rem, 3vw, 2rem); }
.sa-ring { position: relative; width: clamp(110px, 18vw, 150px); aspect-ratio: 1; }
.sa-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.sa-ring-track { stroke: var(--sa-line); }
.sa-ring-value { stroke: currentColor; stroke-linecap: round; transition: stroke-dashoffset 1.4s cubic-bezier(.22,1,.36,1); }
.sa-ring-num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1; }
.sa-ring-num strong { font-size: clamp(2.2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sa-ring-num small { font-size: .8rem; color: var(--sa-muted); margin-top: .2rem; }
.sa-good { color: var(--sa-good); }
.sa-ok { color: var(--sa-ok); }
.sa-bad { color: var(--sa-bad); }
.sa-url { margin: 0; font-size: .9rem; color: var(--sa-muted); word-break: break-all; }
.sa .sa-kicker { display: block; width: fit-content; margin: 0 0 .35rem; padding: .15rem .55rem; border-radius: 999px; background: color-mix(in srgb, var(--sa-brand) 12%, transparent); color: var(--sa-brand); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sa-headline { margin: .3rem 0 .6rem; font-size: clamp(1.3rem, 2.6vw, 1.75rem); line-height: 1.2; letter-spacing: -.01em; }
.sa-summary { margin: 0; line-height: 1.6; max-width: 62ch; }

.sa-cats { list-style: none; margin: 0; padding: 1.25rem clamp(1.25rem, 3vw, 2rem); display: grid; gap: .85rem; background: var(--sa-sand); border-block: 1px solid var(--sa-line); }
.sa-cat { display: grid; grid-template-columns: 1.5rem 9.5rem 1fr 2.5rem; align-items: center; gap: .75rem; }
.sa-cat svg { width: 1.25rem; height: 1.25rem; color: var(--sa-muted); }
.sa-cat-label { font-weight: 600; font-size: .95rem; color: var(--sa-ink); }
.sa-cat-track { height: .6rem; background: var(--sa-line); border-radius: 999px; overflow: hidden; }
.sa-cat-fill { display: block; height: 100%; width: 0; background: currentColor; border-radius: inherit; transition: width .9s cubic-bezier(.22,1,.36,1); }
.sa-cat-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.sa-body { padding: clamp(1.25rem, 3vw, 2rem); display: grid; gap: 1.75rem; }
.sa-body h4 { margin: 0 0 .9rem; font-size: 1.15rem; }
.sa-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.sa-issue { padding: 1rem 1.15rem; border-radius: 12px; background: var(--sa-sand); border-left: 4px solid currentColor; }
.sa-issue > * { color: var(--sa-ink); }
.sa-issue-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem .75rem; align-items: baseline; }
.sa-issue-title { font-weight: 700; font-size: 1.02rem; }
.sa-pill { font-size: .78rem; font-weight: 700; white-space: nowrap; }
.sa-issue p { margin: .45rem 0 0; line-height: 1.55; }
.sa-fix strong { font-weight: 700; }
.sa-p-high { color: var(--sa-bad); }
.sa-p-medium { color: var(--sa-ok); }
.sa-p-low { color: var(--sa-good); }
.sa-p-high .sa-pill { color: var(--sa-bad); }
.sa-p-medium .sa-pill { color: var(--sa-ok); }
.sa-p-low .sa-pill { color: var(--sa-good); }

.sa-strengths { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.sa-strengths li { display: inline-flex; gap: .45rem; align-items: center; padding: .45rem .8rem; border: 1px solid var(--sa-line); border-radius: 999px; font-size: .9rem; line-height: 1.35; }
.sa-strengths svg { flex: none; width: 1rem; height: 1rem; color: var(--sa-good); }

.sa-close { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; padding: 1.5rem clamp(1.25rem, 3vw, 2rem); background: var(--sa-brand); color: #fff; }
.sa-close .sa-pitch { flex: 1 1 22rem; max-width: 46ch; }
.sa-close p { margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 1.35; }
.sa-close small { display: block; margin-top: .4rem; font-size: .9rem; line-height: 1.5; opacity: .92; }
.sa-close .sa-cta { background: #fff; color: var(--sa-brand); text-decoration: none; font-weight: 700; }
.sa-close .sa-cta:hover { filter: brightness(.95); }
.sa-note { margin: 0; padding: .9rem clamp(1.25rem, 3vw, 2rem); font-size: .85rem; color: var(--sa-muted); }

/* Technical panel */
.sa-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.sa-chip { padding: .35rem .7rem; border-radius: 8px; font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; border: 1px solid currentColor; background: color-mix(in srgb, currentColor 8%, var(--sa-surface)); }
.sa-s-ok { color: var(--sa-good); }
.sa-s-warn { color: var(--sa-ok); }
.sa-s-bad { color: var(--sa-bad); }
.sa-s-info { color: var(--sa-muted); }
.sa-third { width: 100%; margin-top: 1.1rem; border-collapse: collapse; font-size: .9rem; }
.sa-third caption { text-align: left; font-weight: 600; padding-bottom: .5rem; }
.sa-third th, .sa-third td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--sa-line); }
.sa-third th { font-weight: 600; color: var(--sa-muted); }
.sa-third td:nth-child(n+2), .sa-third th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* One orchestrated reveal: hero, then bars, then the rest. */
.sa-reveal .sa-body, .sa-reveal .sa-close { opacity: 0; transform: translateY(8px); transition: opacity .5s ease, transform .5s ease; }
.sa-reveal.is-in .sa-body, .sa-reveal.is-in .sa-close { opacity: 1; transform: none; }
.sa-reveal.is-in .sa-close { transition-delay: .15s; }

/* Corner launcher ------------------------------------------------------ */
.sa-launcher { position: fixed; bottom: calc(20px + var(--sa-lift, 0px)); transition: bottom .25s ease; z-index: 9990; display: flex; flex-direction: column; gap: .75rem; max-width: calc(100vw - 24px); font-size: 16px; }
.sa-launcher.sa-pos-right { right: 20px; align-items: flex-end; }
.sa-launcher.sa-pos-left { left: 20px; align-items: flex-start; }

.sa-bubble {
	display: inline-flex; align-items: center; gap: .55rem;
	min-height: 56px; padding: 0 1.2rem 0 1rem;
	border: 0; border-radius: 999px; cursor: pointer;
	background: var(--sa-brand); color: #fff; font: inherit; font-weight: 700;
	box-shadow: 0 10px 28px -10px color-mix(in srgb, var(--sa-brand) 70%, transparent), 0 2px 6px rgba(0,0,0,.12);
	transition: transform .2s ease;
}
.sa-bubble:hover { transform: translateY(-2px); }
.sa-bubble svg { flex: none; }
.sa-launcher.is-open .sa-bubble-label { display: none; }
.sa-launcher.is-open .sa-bubble { padding: 0 1rem; }

.sa-teaser { position: relative; display: flex; align-items: flex-start; gap: .25rem; max-width: 310px; padding: .8rem .6rem .8rem 1rem; background: var(--sa-surface); color: var(--sa-ink); border: 1px solid var(--sa-line); border-radius: 14px; box-shadow: 0 12px 30px -12px rgba(0,0,0,.3); animation: sa-pop .35s cubic-bezier(.22,1,.36,1); }
.sa-teaser-text { all: unset; cursor: pointer; display: grid; gap: .15rem; line-height: 1.3; }
.sa-teaser-text strong, .sa-panel-hook strong { display: block; font-weight: 800; letter-spacing: -.015em; color: var(--sa-ink); }
.sa-teaser-text strong { font-size: 1.02rem; }
.sa-teaser-text span, .sa-panel-hook span { display: block; font-weight: 500; color: var(--sa-muted); }
.sa-teaser-text span { font-size: .88rem; }
.sa-teaser-text:focus-visible { outline: 2px solid var(--sa-brand); outline-offset: 2px; border-radius: 4px; }
.sa-teaser-close, .sa-panel-close, .sa-modal-close { flex: none; width: 2rem; height: 2rem; border: 0; border-radius: 50%; background: transparent; color: var(--sa-muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.sa-teaser-close:hover, .sa-panel-close:hover, .sa-modal-close:hover { background: var(--sa-sand); color: var(--sa-ink); }

.sa-panel {
	position: relative; width: 360px; max-width: calc(100vw - 24px); max-height: calc(100vh - 120px - var(--sa-lift, 0px)); overflow: auto;
	padding: 1.25rem; background: var(--sa-surface); color: var(--sa-ink);
	border: 1px solid var(--sa-line); border-radius: 18px;
	box-shadow: 0 24px 60px -20px rgba(0,0,0,.35);
	animation: sa-pop .35s cubic-bezier(.22,1,.36,1);
}
.sa-panel-close { position: absolute; top: .6rem; right: .6rem; }
.sa-panel-hook { margin: 0 2rem 1rem 0; line-height: 1.25; }
.sa-panel-hook strong { font-size: 1.3rem; }
.sa-panel-hook span { margin-top: .3rem; font-size: .95rem; line-height: 1.4; }
.sa-panel .sa-form { padding: 0; border: 0; gap: .8rem; background: none; }
.sa-panel .sa-field-url input { font-size: 1.05rem; }
.sa-panel .sa-step2 { display: grid; gap: .8rem; animation: sa-pop .3s ease; }
.sa-panel .sa-submit { width: 100%; text-align: center; }
.sa-panel .sa-progress { margin: 0; padding: .25rem 0 0; border: 0; }
.sa-panel .sa-progress-url { font-size: 1rem; }

.sa-mini { display: grid; gap: 1rem; }
.sa-mini-head { display: flex; gap: .9rem; align-items: center; }
.sa-mini-score { flex: none; width: 72px; height: 72px; border-radius: 50%; border: 6px solid currentColor; display: grid; place-content: center; text-align: center; line-height: 1; }
.sa-mini-score strong { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sa-mini-score small { font-size: .65rem; color: var(--sa-muted); }
.sa-mini-headline { margin: 0; font-weight: 700; line-height: 1.3; }
.sa-mini-cats { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; font-size: .9rem; }
.sa-mini-cats li { display: flex; justify-content: space-between; padding: .3rem 0; border-bottom: 1px solid var(--sa-line); }
.sa-mini-cats li span { color: var(--sa-ink); }
.sa-mini .sa-note { padding: 0; }

.sa-modal { width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: var(--sa-radius); background: var(--sa-surface); color: var(--sa-ink); overflow: auto; }
.sa-modal::backdrop { background: rgba(20, 16, 30, .55); }
.sa-modal-close { position: absolute; top: .6rem; right: .6rem; z-index: 2; background: var(--sa-surface); }
.sa-modal .sa-result { margin: 0; border: 0; border-radius: 0; }

@keyframes sa-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

@media (max-width: 767px) {
	.sa-launcher { bottom: calc(12px + var(--sa-lift, 0px)); }
	.sa-launcher.sa-pos-right { right: 12px; }
	.sa-launcher.sa-pos-left { left: 12px; }
	.sa-bubble { min-height: 52px; }
	.sa-panel { width: calc(100vw - 24px); max-height: calc(100vh - 96px - var(--sa-lift, 0px)); }
}

@media print { .sa-launcher { display: none !important; } }

@media (max-width: 640px) {
	.sa-row { grid-template-columns: 1fr; }
	.sa-hero { grid-template-columns: 1fr; justify-items: start; }
	.sa-cat { grid-template-columns: 1.25rem 1fr 2.25rem; }
	.sa-cat-track { grid-column: 2 / 4; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
	.sa *, .sa *::before, .sa *::after { transition: none !important; animation: none !important; }
	.sa-reveal .sa-body, .sa-reveal .sa-close { opacity: 1; transform: none; }
}
