/* ==========================================================================
   BD Speed Test — UI wrapper originale BACKdigit
   (il motore di misura sotto è LibreSpeed, non modificato)
   ========================================================================== */

.bd-speedtest-widget {
	--bd-st-bg: #ffffff;
	--bd-st-bg-elev: #f6f7fb;
	--bd-st-border: #e6e8f0;
	--bd-st-text: #14151a;
	--bd-st-text-muted: #6b7280;
	--bd-st-accent-1: #6d5efc;
	--bd-st-accent-2: #22d3ee;
	--bd-st-track: #eceefb;
	--bd-st-good: #16c784;
	--bd-st-mid: #f5a623;
	--bd-st-bad: #ef4444;

	max-width: 640px;
	margin: 2.5rem auto;
	padding: 2.25rem 1.75rem 1.75rem;
	border-radius: 24px;
	background: var(--bd-st-bg);
	border: 1px solid var(--bd-st-border);
	box-shadow: 0 20px 50px -20px rgba(31, 30, 90, 0.18);
	text-align: center;
	font-family: inherit;
	position: relative;
	overflow: hidden;
}

.bd-speedtest-widget::before {
	content: "";
	position: absolute;
	top: -60%;
	left: 50%;
	width: 140%;
	height: 140%;
	transform: translateX(-50%);
	background: radial-gradient( circle at top, rgba(109, 94, 252, 0.14), transparent 60% );
	pointer-events: none;
}

.custom-dark .bd-speedtest-widget {
	--bd-st-bg: #15161f;
	--bd-st-bg-elev: #1c1e2b;
	--bd-st-border: #2a2c3d;
	--bd-st-text: #f2f2f7;
	--bd-st-text-muted: #9498ab;
	--bd-st-track: #262838;
	box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}

.bd-st-header {
	position: relative;
	margin-bottom: 1.5rem;
}

.bd-st-title {
	margin: 0 0 0.4rem;
	font-size: clamp(1.35rem, 2.4vw, 1.75rem);
	font-weight: 700;
	color: var(--bd-st-text);
	letter-spacing: -0.02em;
}

.bd-st-subtitle {
	margin: 0;
	font-size: 0.95rem;
	color: var(--bd-st-text-muted);
	line-height: 1.5;
}

/* Gauge */
.bd-st-gauge-wrap {
	position: relative;
	width: 220px;
	height: 220px;
	margin: 0 auto 1.5rem;
}

.bd-st-gauge {
	width: 100%;
	height: 100%;
	transform: rotate(-90deg);
}

.bd-st-gauge-track,
.bd-st-gauge-fill {
	fill: none;
	stroke-width: 14;
	stroke-linecap: round;
}

.bd-st-gauge-track {
	stroke: var(--bd-st-track);
}

.bd-st-gauge-fill {
	stroke: url(#bd-st-gauge-gradient);
	stroke-dasharray: 597; /* 2 * PI * 95 */
	stroke-dashoffset: 597;
	transition: stroke-dashoffset 0.35s ease-out;
}

.bd-st-gauge-center {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.bd-st-gauge-value {
	font-size: 2.6rem;
	font-weight: 800;
	color: var(--bd-st-text);
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.bd-st-gauge-unit {
	font-size: 0.85rem;
	color: var(--bd-st-text-muted);
	margin-top: 0.15rem;
}

.bd-st-gauge-label {
	margin-top: 0.5rem;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	padding: 0.25rem 0.7rem;
	border-radius: 999px;
	background: linear-gradient( 90deg, var(--bd-st-accent-1), var(--bd-st-accent-2) );
	color: #fff;
}

.bd-st-gauge-wrap.is-testing .bd-st-gauge-fill {
	animation: bd-st-pulse 1.6s ease-in-out infinite;
}

@keyframes bd-st-pulse {
	0%, 100% { filter: drop-shadow(0 0 0 rgba(109, 94, 252, 0)); }
	50% { filter: drop-shadow(0 0 10px rgba(109, 94, 252, 0.55)); }
}

/* Metrics grid */
.bd-st-metrics {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0.75rem;
	margin-bottom: 1.5rem;
}

.bd-st-metric {
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 14px;
	padding: 0.85rem 0.5rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
}

.bd-st-metric-icon {
	font-size: 1rem;
	opacity: 0.65;
}

.bd-st-metric-value {
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--bd-st-text);
	font-variant-numeric: tabular-nums;
}

.bd-st-metric-label {
	font-size: 0.68rem;
	color: var(--bd-st-text-muted);
	text-align: center;
}

@media (max-width: 480px) {
	.bd-st-metrics {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* Start button */
.bd-st-start-btn {
	appearance: none;
	border: none;
	cursor: pointer;
	padding: 0.9rem 2.4rem;
	font-size: 1rem;
	font-weight: 700;
	color: #fff;
	border-radius: 999px;
	background: linear-gradient( 90deg, var(--bd-st-accent-1), var(--bd-st-accent-2) );
	box-shadow: 0 12px 30px -10px rgba(109, 94, 252, 0.55);
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	margin: 0.25rem 0 1.25rem;
}

.bd-st-start-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 16px 34px -8px rgba(109, 94, 252, 0.65);
}

.bd-st-start-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

/* Gaming result */
.bd-st-gaming-result {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

@keyframes bd-st-fade-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

.bd-st-gaming-badge {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 0.75rem;
}

.bd-st-gaming-icon {
	font-size: 1.6rem;
}

.bd-st-gaming-title {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--bd-st-text);
}

.bd-st-gaming-breakdown {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.5rem;
}

.bd-st-gaming-breakdown li {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	font-size: 0.88rem;
	color: var(--bd-st-text-muted);
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 10px;
	padding: 0.55rem 0.85rem;
}

.bd-st-gaming-breakdown .bd-st-tag {
	font-weight: 700;
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 0.2rem 0.55rem;
	border-radius: 999px;
	color: #fff;
}

.bd-st-tag--good { background: var(--bd-st-good); }
.bd-st-tag--mid { background: var(--bd-st-mid); }
.bd-st-tag--bad { background: var(--bd-st-bad); }

/* IP / GeoIP info */
.bd-st-ipinfo {
	margin: 0.6rem 0 1.5rem;
	font-size: 0.78rem;
	color: var(--bd-st-text-muted);
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 999px;
	padding: 0.4rem 1rem;
	display: inline-block;
}

/* Section titles (usage profile, history) */
.bd-st-section-title {
	margin: 0 0 0.9rem;
	font-size: 1rem;
	font-weight: 700;
	color: var(--bd-st-text);
	text-align: left;
}

/* Usage profile ("cosa puoi fare con questa velocità") */
.bd-st-usage-result {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

.bd-st-usage-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0.6rem;
}

@media (max-width: 480px) {
	.bd-st-usage-grid {
		grid-template-columns: 1fr;
	}
}

.bd-st-usage-item {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-left: 3px solid var(--bd-st-good);
	border-radius: 10px;
	padding: 0.65rem 0.8rem;
}

.bd-st-usage-item.is-limited {
	border-left-color: var(--bd-st-mid);
}

.bd-st-usage-icon {
	font-size: 1.15rem;
	line-height: 1;
}

.bd-st-usage-text {
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
}

.bd-st-usage-label {
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--bd-st-text);
}

.bd-st-usage-detail {
	font-size: 0.75rem;
	color: var(--bd-st-text-muted);
}

/* History */
.bd-st-history {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

.bd-st-history-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.75rem;
}

.bd-st-history-head .bd-st-section-title {
	margin: 0;
}

.bd-st-history-clear {
	appearance: none;
	border: none;
	background: none;
	cursor: pointer;
	font-size: 0.72rem;
	color: var(--bd-st-text-muted);
	text-decoration: underline;
	padding: 0;
}

.bd-st-history-clear:hover {
	color: var(--bd-st-bad);
}

.bd-st-history-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.4rem;
}

.bd-st-history-item {
	display: grid;
	grid-template-columns: auto 1fr 1fr auto;
	align-items: center;
	gap: 0.6rem;
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 10px;
	padding: 0.5rem 0.8rem;
	font-size: 0.78rem;
	color: var(--bd-st-text);
}

@media (max-width: 480px) {
	.bd-st-history-item {
		grid-template-columns: 1fr 1fr;
		row-gap: 0.25rem;
	}
}

.bd-st-history-date {
	color: var(--bd-st-text-muted);
	font-variant-numeric: tabular-nums;
}

.bd-st-history-metric {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.bd-st-delta {
	font-size: 0.68rem;
	font-weight: 700;
	margin-left: 0.2rem;
}

.bd-st-delta--up { color: var(--bd-st-good); }
.bd-st-delta--down { color: var(--bd-st-bad); }
.bd-st-delta--flat { color: var(--bd-st-text-muted); }

.bd-st-history-note {
	margin: 0.75rem 0 0;
	font-size: 0.68rem;
	color: var(--bd-st-text-muted);
}

/* Connection hint (WiFi/Ethernet) */
.bd-st-connection-hint {
	margin: 0.4rem 0 1rem;
	font-size: 0.75rem;
	color: var(--bd-st-text-muted);
}

/* Bufferbloat */
.bd-st-bufferbloat {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

.bd-st-bufferbloat-badge {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 0.5rem;
}

.bd-st-bufferbloat-grade {
	font-size: 1.6rem;
	font-weight: 800;
	width: 2.4rem;
	height: 2.4rem;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	flex-shrink: 0;
}

.bd-st-bufferbloat-grade--good { background: var(--bd-st-good); }
.bd-st-bufferbloat-grade--mid { background: var(--bd-st-mid); }
.bd-st-bufferbloat-grade--bad { background: var(--bd-st-bad); }

.bd-st-bufferbloat-text {
	font-size: 0.92rem;
	font-weight: 600;
	color: var(--bd-st-text);
}

.bd-st-bufferbloat-explain {
	margin: 0;
	font-size: 0.78rem;
	color: var(--bd-st-text-muted);
	line-height: 1.5;
}

/* Chart andamento */
.bd-st-chart-wrap {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

.bd-st-chart {
	width: 100%;
	height: 120px;
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 12px;
}

.bd-st-chart-line {
	fill: none;
	stroke-width: 2.5;
	stroke-linejoin: round;
	stroke-linecap: round;
}

.bd-st-chart-line--dl { stroke: var(--bd-st-accent-1); }
.bd-st-chart-line--ul { stroke: var(--bd-st-accent-2); }

.bd-st-chart-legend {
	display: flex;
	gap: 1.25rem;
	margin-top: 0.6rem;
	font-size: 0.75rem;
	color: var(--bd-st-text-muted);
}

.bd-st-legend-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	margin-right: 0.3rem;
}

.bd-st-legend-dot--dl { background: var(--bd-st-accent-1); }
.bd-st-legend-dot--ul { background: var(--bd-st-accent-2); }

/* Confronto con la media */
.bd-st-compare {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

.bd-st-compare-text {
	margin: 0 0 0.6rem;
	font-size: 0.85rem;
	color: var(--bd-st-text);
}

.bd-st-compare-bar {
	height: 10px;
	border-radius: 999px;
	background: var(--bd-st-track);
	overflow: hidden;
}

.bd-st-compare-bar-fill {
	height: 100%;
	border-radius: 999px;
	background: linear-gradient( 90deg, var(--bd-st-accent-1), var(--bd-st-accent-2) );
	width: 0%;
	transition: width 0.5s ease-out;
}

/* Condivisione */
.bd-st-share {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.bd-st-share-btn {
	appearance: none;
	cursor: pointer;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--bd-st-text);
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 999px;
	padding: 0.55rem 1.1rem;
	transition: transform 0.15s ease, border-color 0.15s ease;
}

.bd-st-share-btn:hover {
	transform: translateY(-1px);
	border-color: var(--bd-st-accent-1);
}

/* Stepper delle fasi (Ping → Download → Upload) */
.bd-st-phases {
	list-style: none;
	margin: 0 0 1.5rem;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
}

.bd-st-phase {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	opacity: 0.4;
	transition: opacity 0.25s ease;
}

.bd-st-phase:not(:last-child)::after {
	content: "";
	width: 24px;
	height: 2px;
	background: var(--bd-st-track);
	margin-left: 0.5rem;
}

.bd-st-phase-dot {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--bd-st-track);
	color: var(--bd-st-text-muted);
	font-size: 0.72rem;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.25s ease, color 0.25s ease;
}

.bd-st-phase-label {
	font-size: 0.72rem;
	font-weight: 600;
	color: var(--bd-st-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.bd-st-phase.is-active {
	opacity: 1;
}

.bd-st-phase.is-active .bd-st-phase-dot {
	background: linear-gradient( 90deg, var(--bd-st-accent-1), var(--bd-st-accent-2) );
	color: #fff;
	animation: bd-st-pulse 1.4s ease-in-out infinite;
}

.bd-st-phase.is-active .bd-st-phase-label {
	color: var(--bd-st-text);
}

.bd-st-phase.is-done {
	opacity: 1;
}

.bd-st-phase.is-done .bd-st-phase-dot {
	background: var(--bd-st-good);
	color: #fff;
}

.bd-st-phase.is-done .bd-st-phase-dot::before {
	content: "✓";
}

.bd-st-phase.is-done .bd-st-phase-dot > * {
	display: none;
}

/* Testo di stato sotto il cerchio */
.bd-st-phase-status {
	margin: 0 0 0.25rem;
	font-size: 0.85rem;
	color: var(--bd-st-text-muted);
	min-height: 1.3em;
}

/* Campo velocità da contratto (opzionale, pre-test) */
.bd-st-contract {
	margin: 0 0 1.5rem;
	text-align: left;
	font-size: 0.78rem;
}

.bd-st-contract summary {
	cursor: pointer;
	color: var(--bd-st-text-muted);
	text-align: center;
	list-style: none;
}

.bd-st-contract summary::-webkit-details-marker {
	display: none;
}

.bd-st-contract summary::before {
	content: "⚙️ ";
}

.bd-st-contract-fields {
	margin-top: 0.75rem;
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 12px;
	padding: 0.9rem 1rem;
}

.bd-st-contract-fields label {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	font-size: 0.78rem;
	color: var(--bd-st-text-muted);
}

.bd-st-contract-input {
	padding: 0.55rem 0.75rem;
	border-radius: 8px;
	border: 1px solid var(--bd-st-border);
	background: var(--bd-st-bg);
	color: var(--bd-st-text);
	font-size: 0.9rem;
	max-width: 180px;
}

/* Diagnosi in parole semplici */
.bd-st-diagnosis {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

.bd-st-diagnosis-text {
	margin: 0;
	font-size: 0.88rem;
	line-height: 1.6;
	color: var(--bd-st-text);
}

/* AGCOM */
.bd-st-agcom {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bd-st-border);
	text-align: left;
	animation: bd-st-fade-in 0.4s ease-out;
}

.bd-st-agcom-badge {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 0.5rem;
}

.bd-st-agcom-icon {
	font-size: 1.3rem;
}

.bd-st-agcom-text {
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--bd-st-text);
}

.bd-st-agcom-explain {
	margin: 0 0 0.85rem;
	font-size: 0.78rem;
	line-height: 1.55;
	color: var(--bd-st-text-muted);
}

.bd-st-agcom-btn {
	appearance: none;
	cursor: pointer;
	font-size: 0.8rem;
	font-weight: 700;
	color: #fff;
	background: linear-gradient( 90deg, var(--bd-st-mid), var(--bd-st-bad) );
	border: none;
	border-radius: 999px;
	padding: 0.6rem 1.2rem;
}

/* Selettore server (VPS / Cloudflare Edge) */
.bd-st-server-select {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	margin-bottom: 1.25rem;
}

.bd-st-server-select-label {
	font-size: 0.75rem;
	color: var(--bd-st-text-muted);
}

.bd-st-server-toggle {
	display: inline-flex;
	background: var(--bd-st-bg-elev);
	border: 1px solid var(--bd-st-border);
	border-radius: 999px;
	padding: 0.2rem;
}

.bd-st-server-btn {
	appearance: none;
	border: none;
	cursor: pointer;
	background: transparent;
	color: var(--bd-st-text-muted);
	font-size: 0.72rem;
	font-weight: 600;
	padding: 0.4rem 0.85rem;
	border-radius: 999px;
	transition: background 0.2s ease, color 0.2s ease;
}

.bd-st-server-btn.is-active {
	background: linear-gradient( 90deg, var(--bd-st-accent-1), var(--bd-st-accent-2) );
	color: #fff;
}

/* Attribution */
.bd-st-attribution {
	margin: 1.5rem 0 0;
	font-size: 0.72rem;
	color: var(--bd-st-text-muted);
}

.bd-st-attribution a {
	color: var(--bd-st-accent-1);
	text-decoration: none;
}

.custom-dark .bd-st-attribution a {
	color: var(--bd-st-accent-2);
}

/* ==========================================================================
   Contenuto SEO/FAQ — fuori dalla card del widget, stile editoriale
   ========================================================================== */

.bd-st-seo-content {
	max-width: 720px;
	margin: 2.5rem auto 0;
	padding: 0 0.5rem;
	color: inherit;
}

.bd-st-seo-intro h2,
.bd-st-seo-faq h2 {
	font-size: 1.3rem;
	font-weight: 700;
	margin: 0 0 0.75rem;
}

.bd-st-seo-intro p {
	line-height: 1.7;
	margin: 0 0 1rem;
	opacity: 0.9;
}

.bd-st-seo-faq {
	margin-top: 2rem;
}

.bd-st-faq-item {
	border: 1px solid rgba(128, 128, 128, 0.25);
	border-radius: 12px;
	padding: 0.85rem 1.1rem;
	margin-bottom: 0.6rem;
}

.bd-st-faq-item summary {
	cursor: pointer;
	font-weight: 600;
	font-size: 0.95rem;
	list-style: none;
}

.bd-st-faq-item summary::-webkit-details-marker {
	display: none;
}

.bd-st-faq-item summary::before {
	content: "+ ";
	color: #6d5efc;
	font-weight: 800;
}

.bd-st-faq-item[open] summary::before {
	content: "– ";
}

.bd-st-faq-item p {
	margin: 0.6rem 0 0;
	font-size: 0.9rem;
	line-height: 1.6;
	opacity: 0.85;
}
