/* ============================================================
   SPEED TEST — Premium Live Gauge
   ============================================================ */

.tool-page:has(.speed-test) {
    max-width: 720px;
}

.speed-test {
    position: relative;
    background: linear-gradient(160deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    border-radius: 28px;
    padding: 36px 32px 28px;
    overflow: hidden;
    color: #fff;
    box-shadow: 0 24px 60px rgba(67, 97, 238, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.st-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    opacity: 0.45;
}

.st-glow-1 {
    width: 280px;
    height: 280px;
    background: #4361ee;
    top: -80px;
    right: -60px;
    animation: stPulse 4s ease-in-out infinite;
}

.st-glow-2 {
    width: 220px;
    height: 220px;
    background: #06d6a0;
    bottom: -60px;
    left: -40px;
    animation: stPulse 4s ease-in-out infinite 2s;
}

@keyframes stPulse {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(1.08); }
}

.st-header {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.st-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    backdrop-filter: blur(8px);
}

.st-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #06d6a0;
    box-shadow: 0 0 10px #06d6a0;
}

.st-live-badge.running .st-live-dot {
    animation: stBlink 0.8s ease-in-out infinite;
    background: #f59e0b;
    box-shadow: 0 0 10px #f59e0b;
}

.st-live-badge.done .st-live-dot {
    background: #06d6a0;
    box-shadow: 0 0 12px #06d6a0;
}

@keyframes stBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.st-subtitle {
    margin-top: 10px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
}

/* ── Gauge ── */
.st-gauge-wrap {
    position: relative;
    width: 260px;
    height: 260px;
    margin: 0 auto 20px;
    z-index: 1;
}

.st-gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.st-gauge-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 14;
}

.st-gauge-fill {
    fill: none;
    stroke: url(#stGrad);
    stroke-width: 14;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.15s ease-out;
    filter: drop-shadow(0 0 8px rgba(6, 214, 160, 0.5));
}

.st-gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.st-speed-value {
    font-size: 3.2rem;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(135deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-variant-numeric: tabular-nums;
    transition: transform 0.1s;
}

.st-speed-value.tick {
    transform: scale(1.04);
}

.st-speed-unit {
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

.st-phase-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #06d6a0;
    margin-top: 8px;
    padding: 4px 12px;
    background: rgba(6, 214, 160, 0.12);
    border-radius: 999px;
}

/* ── Progress ── */
.st-progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-bottom: 28px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.st-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #06d6a0, #4361ee);
    border-radius: 4px;
    transition: width 0.2s ease;
    box-shadow: 0 0 12px rgba(6, 214, 160, 0.6);
}

/* ── Metrics ── */
.st-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.st-metric {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px 10px;
    text-align: center;
    transition: all 0.3s;
}

.st-metric.active {
    background: rgba(67, 97, 238, 0.2);
    border-color: rgba(67, 97, 238, 0.45);
    box-shadow: 0 8px 24px rgba(67, 97, 238, 0.2);
    transform: translateY(-2px);
}

.st-metric.done {
    border-color: rgba(6, 214, 160, 0.35);
}

.st-metric-icon {
    margin-bottom: 8px;
    opacity: 0.7;
}

.st-metric-icon i {
    width: 20px;
    height: 20px;
}

.st-metric-val {
    font-size: 1.5rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.st-metric-lbl {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.st-metric-sub {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.35);
}

/* ── Result Panel ── */
.st-result-panel {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    animation: stSlideUp 0.4s ease;
    position: relative;
    z-index: 1;
}

@keyframes stSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.st-rating {
    font-size: 1.6rem;
    font-weight: 900;
    background: linear-gradient(135deg, #06d6a0, #4361ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.st-rating-desc {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    margin-bottom: 16px;
}

.st-result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.st-result-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 10px 8px;
}

.st-result-item span {
    display: block;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 4px;
}

.st-result-item strong {
    font-size: 0.95rem;
    font-weight: 800;
}

/* ── Actions ── */
.st-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.st-btn-start,
.st-btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 36px;
    border: none;
    border-radius: 16px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.st-btn-start {
    background: linear-gradient(135deg, #06d6a0, #4361ee);
    color: #fff;
    box-shadow: 0 8px 28px rgba(6, 214, 160, 0.35);
}

.st-btn-start:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 14px 36px rgba(6, 214, 160, 0.45);
}

.st-btn-start:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.st-btn-start i,
.st-btn-retry i {
    width: 20px;
    height: 20px;
}

.st-btn-retry {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.st-btn-retry:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.st-note {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 20px;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

@media (max-width: 500px) {
    .speed-test {
        padding: 28px 18px 22px;
        border-radius: 20px;
    }

    .st-gauge-wrap {
        width: 220px;
        height: 220px;
    }

    .st-speed-value {
        font-size: 2.6rem;
    }

    .st-metrics {
        gap: 8px;
    }

    .st-metric-val {
        font-size: 1.2rem;
    }

    .st-result-grid {
        grid-template-columns: 1fr;
    }

    .st-actions {
        flex-direction: column;
    }

    .st-btn-start,
    .st-btn-retry {
        width: 100%;
        justify-content: center;
    }
}
