/* ==================== */
/* Speedtest (v2)       */
/* ==================== */
/* Extracted from the inline <style> block in speedtest/index.html.
   Consumes the v2 tokens defined in /css/styles.css (which the page
   imports from rolltide.network — one source of truth per UI-V2-Plan §12.5). */

.speedtest-section {
    min-height: calc(100vh - 80px);
    padding-top: 9rem;
    padding-bottom: 4rem;
}

.speedtest-container {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.speedtest-header h1,
.speedtest-header h2 {
    font-family: var(--v2-font-display);
    font-size: clamp(2.25rem, 4vw, 3rem);
    font-weight: 700;
    letter-spacing: var(--v2-tracking-tight);
    line-height: var(--v2-leading-tight);
    color: var(--v2-ink-100);
    margin-bottom: 0.75rem;
}

.speedtest-header p {
    color: var(--v2-ink-300);
    margin-bottom: 2.5rem;
    font-family: var(--v2-font-mono);
    font-size: var(--v2-type-body-sm);
    letter-spacing: var(--v2-tracking-wide);
    text-transform: uppercase;
}

/* ---- Start / Stop button (v2: ghost crimson; "running" warns yellow) */
#startStopBtn {
    position: relative;
    display: inline-block;
    margin: 2rem auto;
    color: var(--v2-ink-100);
    background: transparent;
    border: 1.5px solid var(--v2-crimson);
    border-radius: 8px;
    transition: background-color var(--v2-dur-base) var(--v2-ease-out),
                color var(--v2-dur-base) var(--v2-ease-out),
                box-shadow var(--v2-dur-base) var(--v2-ease-out),
                border-color var(--v2-dur-base) var(--v2-ease-out);
    box-sizing: border-box;
    width: 14em;
    height: 3.5em;
    line-height: 3.5em;
    cursor: pointer;
    font-family: var(--v2-font-display);
    font-size: 1.05em;
    font-weight: 700;
    letter-spacing: var(--v2-tracking-wide);
    text-transform: uppercase;
    overflow: hidden;
}

#startStopBtn:hover {
    background: var(--v2-crimson);
    color: var(--v2-ink-100);
    box-shadow: 0 6px 24px var(--v2-glow-crimson);
}

#startStopBtn:before {
    content: "Start Test";
}

#startStopBtn.running {
    background: var(--v2-bg-300);
    border-color: var(--v2-ink-700);
    color: var(--v2-signal-warn);
    box-shadow: none;
}

#startStopBtn.running:hover {
    background: var(--v2-bg-300);
    color: var(--v2-signal-warn);
    box-shadow: 0 6px 24px rgba(250, 204, 21, 0.18);
}

#startStopBtn.running:before {
    content: "Abort Test";
}

/* Thin crimson progress rail at the bottom of the button. The JS sets
   width on the <span class="startbtn-progress"> via inline style; if a
   reduced-motion user is here, the JS can skip wiring it without
   visual fallout (rail stays at 0% width). */
.startbtn-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: var(--v2-crimson);
    transition: width 220ms linear;
}

/* ---- Scale selector */
.scale-selector {
    margin: 1.5rem 0 2rem;
    text-align: center;
}

.scale-selector-label {
    font-family: var(--v2-font-mono);
    color: var(--v2-ink-500);
    font-size: var(--v2-type-eyebrow);
    margin-bottom: 0.75rem;
    display: block;
    text-transform: uppercase;
    letter-spacing: var(--v2-tracking-wide);
}

.scale-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.scale-btn {
    padding: 0.5rem 1.1rem;
    background: var(--v2-bg-200);
    border: 1px solid var(--v2-ink-700);
    border-radius: 8px;
    color: var(--v2-ink-300);
    cursor: pointer;
    transition: background-color var(--v2-dur-base) var(--v2-ease-out),
                border-color var(--v2-dur-base) var(--v2-ease-out),
                color var(--v2-dur-base) var(--v2-ease-out);
    font-family: var(--v2-font-mono);
    font-weight: 600;
    font-size: var(--v2-type-body-sm);
    text-transform: uppercase;
    letter-spacing: var(--v2-tracking-wide);
}

.scale-btn:hover {
    background: var(--v2-bg-300);
    border-color: var(--v2-ink-500);
    color: var(--v2-ink-100);
}

.scale-btn.active {
    background: var(--v2-crimson);
    border-color: var(--v2-crimson);
    color: var(--v2-ink-100);
    box-shadow: 0 4px 14px var(--v2-glow-crimson);
}

/* ---- Test layout */
#test {
    margin-top: 2rem;
    margin-bottom: 3rem;
}

.testGroup {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.testGroup.all-cards {
    max-width: 1100px;
    margin: 0 auto 2rem;
}

.testArea {
    position: relative;
    background: var(--v2-bg-200);
    border: 1px solid var(--v2-ink-700);
    border-radius: 0.875rem;
    padding: 1.5rem;
    width: 240px;
    min-width: 240px;
    height: 320px;
    transition: background-color var(--v2-dur-base) var(--v2-ease-out),
                border-color var(--v2-dur-base) var(--v2-ease-out),
                transform var(--v2-dur-base) var(--v2-ease-out);
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
    background-image:
        linear-gradient(180deg,
            rgba(244, 236, 231, 0.012) 0%,
            rgba(0, 0, 0, 0.00) 60%);
    box-shadow:
        inset 0 1px 0 var(--v2-surface-highlight),
        var(--v2-surface-shadow);
}


.testArea.combined-metrics {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 320px;
}

.testArea::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent, var(--v2-crimson), transparent);
    opacity: 0;
    transition: opacity var(--v2-dur-base) var(--v2-ease-out);
}

.testArea:hover {
    background: var(--v2-bg-300);
    border-color: var(--v2-ink-500);
    transform: translateY(-2px);
    box-shadow:
        inset 0 1px 0 rgba(244, 236, 231, 0.07),
        0 12px 28px rgba(0, 0, 0, 0.55);
}

.testArea:hover::before {
    opacity: 0.5;
}

.metric-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 2rem;
}

.metric-item {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.metric-divider {
    width: 120px;
    height: 1px;
    background: linear-gradient(to right,
        transparent, var(--v2-ink-700), transparent);
}

.metric-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.metric-value .meterText {
    font-size: 2.2rem;
    white-space: nowrap;
}

.metric-value .unit {
    font-size: 1rem;
    color: var(--v2-ink-300);
    white-space: nowrap;
}

.testArea canvas {
    width: 180px !important;
    height: 140px !important;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

/* ---- Test card labels and live readouts */
.testName {
    font-family: var(--v2-font-mono);
    font-size: var(--v2-type-eyebrow);
    color: var(--v2-ink-500);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: var(--v2-tracking-wide);
    font-weight: 600;
    width: 100%;
    text-align: center;
}

/* Live readouts — mono tabular. Warm-white while idle; crimson while

#startStopBtn.running ~ #test .meterText,

.meterText:empty:before {
    color: var(--v2-ink-500) !important;
    content: "—";
    -webkit-text-fill-color: var(--v2-ink-500);
}

.unit {
    font-family: var(--v2-font-mono);
    font-size: var(--v2-type-eyebrow);
    color: var(--v2-ink-500);
    text-transform: uppercase;
    letter-spacing: var(--v2-tracking-wide);
    width: 100%;
    text-align: center;
    margin-top: 0.25rem;
}

#ipArea {
    background: var(--v2-bg-200);
    border: 1px solid var(--v2-ink-700);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-top: 2rem;
    display: inline-block;
    min-width: 300px;
    font-family: var(--v2-font-mono);
    color: var(--v2-ink-300);
    font-size: var(--v2-type-body-sm);
    letter-spacing: var(--v2-tracking-wide);
    text-transform: uppercase;
}

#ipArea strong {
    color: var(--v2-ink-500);
    font-weight: 600;
}

#ipArea span {
    color: var(--v2-ink-100);
    font-weight: 600;
    margin-left: 0.5rem;
    font-family: var(--v2-font-mono);
    font-variant-numeric: tabular-nums;
    text-transform: none;
    letter-spacing: var(--v2-tracking-mono);
}

/* ---- Explainer card at bottom */
.test-info {
    position: relative;
    background: var(--v2-bg-200);
    border: 1px solid var(--v2-ink-700);
    border-radius: 0.875rem;
    padding: 2rem;
    margin-top: 3rem;
    text-align: left;
    background-image:
        linear-gradient(180deg,
            rgba(244, 236, 231, 0.012) 0%,
            rgba(0, 0, 0, 0.00) 60%);
    box-shadow:
        inset 0 1px 0 var(--v2-surface-highlight),
        var(--v2-surface-shadow);
}

.test-info h3 {
    position: relative;
    color: var(--v2-ink-100);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    padding-top: 0.85rem;
}

.test-info h3::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 1px;
    background: var(--v2-crimson);
}

.test-info p {
    color: var(--v2-ink-300);
    line-height: var(--v2-leading-body);
    margin-bottom: 0.5rem;
}

.test-info ul {
    list-style: none;
    padding-left: 0;
}

.test-info li {
    color: var(--v2-ink-300);
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.test-info li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--v2-crimson);
}

.test-info li strong {
    color: var(--v2-ink-100);
}

@media (max-width: 768px) {
    .testGroup.all-cards {
        flex-direction: column;
        gap: 1.5rem;
    }

    .testArea {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .testArea {
        width: 100%;
    }

    .metric-value .meterText {
        font-size: 1.85rem;
    }
}

@media (max-width: 480px) {
    .speedtest-header h1,
.speedtest-header h2 {
        font-size: 1.65rem;
    }

    .testArea {
        height: 260px;
        padding: 1rem;
    }

    .testArea canvas {
        width: 140px !important;
        height: 110px !important;
    }

    .meterText {
        font-size: 1.6rem;
    }
}

/* ==================== */
/* Accessibility        */
/* ==================== */
/* Screen-reader-only text: used by the live region that announces test
   progress and results, which are otherwise conveyed only by the gauges. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus ring. This page pulls the main site's styles.css from another
   origin, so it repeats the rule locally rather than depending on that
   request having succeeded. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--v2-ink-100, #F4ECE7);
    outline-offset: 3px;
    border-radius: 2px;
    box-shadow: 0 0 0 5px rgba(7, 6, 10, 0.9);
}

/* ==================== */
/* Reduced Motion       */
/* ==================== */
/* This file had no reduced-motion handling at all. The gauge needle and the
   progress bar are the two moving parts here; the needle's easing is driven
   by JS (see oscillate() in index.html), which checks the same preference. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .startbtn-progress {
        transition: none !important;
    }
}
