/* ==========================================================================
   /play/latency - Edge latency instrument
   Visual language: "Signal Horizon" (website-visual-design.md sections 4-7).
   Dark single theme, signal cyan as the one accent, one amber highlight.
   ========================================================================== */

.lat-body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* base.css gives .badge an explicit display, which would beat the UA [hidden]
   rule; restore hidden for attribute-toggled nodes on this page. */
[hidden] {
    display: none !important;
}

.lat-main {
    flex: 1 0 auto;
}

/* ---------- Header ---------- */
.lat-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(9, 18, 31, 0.74);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.lat-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--header-h);
}
.lat-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
}
.lat-brand:hover {
    color: var(--text);
}
.lat-brand-mark {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    flex-shrink: 0;
}
.lat-brand-name {
    font-size: 1.1rem;
}
.lat-brand-sub {
    padding-left: 10px;
    margin-left: 2px;
    border-left: 1px solid var(--line-strong);
    font-size: 10px;
}
.lat-header-side {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---------- Hero ---------- */
.lat-hero {
    position: relative;
    padding: clamp(48px, 8vw, 96px) 0 0;
    overflow: hidden;
}
.lat-hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: clamp(28px, 4vw, 56px);
    align-items: center;
}
.lat-hero-copy h1 {
    max-width: 20ch;
}
.lat-hero-copy .lead {
    margin-top: 16px;
    max-width: 54ch;
}
.lat-client {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}
.lat-chip {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-2);
}
.lat-chip b {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}
.lat-chip span {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.lat-hero-horizon {
    margin-top: clamp(40px, 6vw, 72px);
}

/* ---------- Nearest node readout ---------- */
.lat-nearest {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 224px;
    padding: 26px 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--bg-2);
    box-shadow: var(--shadow-1);
}
.lat-nearest-label {
    margin: 0 0 10px;
}
.lat-nearest-name {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.2;
}
.lat-nearest-rtt {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 10px 0 0;
}
.lat-nearest-rtt .value {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: clamp(3rem, 6.5vw, 4.4rem);
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--accent);
    transition: color 260ms ease;
}
.lat-nearest-rtt .unit {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--text-dim);
}
.lat-nearest.is-idle .lat-nearest-rtt .value {
    color: var(--text-dim);
}
.lat-nearest-meta {
    margin: 12px 0 0;
    font-size: 11px;
}
.lat-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: auto;
    padding-top: 22px;
}
.lat-summary > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.lat-summary b {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 1rem;
    color: var(--text);
}
.lat-summary span {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* sonar rings: meaningful only while a measurement is in flight */
.lat-sonar {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 220px;
    height: 220px;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 320ms ease;
}
.lat-nearest.is-probing .lat-sonar {
    opacity: 0.45;
}
.lat-sonar span {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    animation: lat-ping 2.4s ease-out infinite;
}
.lat-sonar span:nth-child(2) {
    animation-delay: 0.8s;
}
.lat-sonar span:nth-child(3) {
    animation-delay: 1.6s;
}
@keyframes lat-ping {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(5);
        opacity: 0;
    }
}

/* ---------- Spectrum ---------- */
.lat-spectrum {
    margin: clamp(56px, 8vw, 96px) auto;
}
.lat-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
}
.lat-section-head p {
    margin: 6px 0 0;
}
.lat-target {
    display: flex;
    align-items: center;
    gap: 10px;
}
.lat-target label {
    font-family: var(--font-mono);
    font-size: var(--fs-mono);
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.lat-target select {
    width: auto;
    min-height: 36px;
    padding: 4px 10px;
}

.lat-axis {
    position: relative;
    height: 26px;
    margin-bottom: 12px;
}
.lat-axis-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    white-space: nowrap;
}
.lat-axis-tick.is-first {
    transform: none;
}
.lat-axis-tick.is-last {
    transform: translateX(-100%);
}
.lat-axis-tick::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 15px;
    width: 1px;
    height: 6px;
    background: var(--line-strong);
    transform: translateX(-50%);
}
.lat-axis-tick.is-first::after {
    left: 0;
}
.lat-axis-tick.is-last::after {
    left: 100%;
}
.lat-axis-marker {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--accent);
    white-space: nowrap;
}
.lat-axis-marker::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 15px;
    width: 1px;
    height: 6px;
    background: var(--accent);
    opacity: 0.7;
    transform: translateX(-50%);
}

.lat-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ---------- Row ---------- */
.lat-row {
    position: relative;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-2);
    box-shadow: var(--shadow-1);
    animation: lat-row-in 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.lat-row:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-2);
}
.lat-row.is-nearest {
    border-color: rgba(224, 161, 74, 0.42);
}
@keyframes lat-row-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.lat-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}
.lat-row-id {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}
.lat-code {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    flex-shrink: 0;
}
.lat-row-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lat-row-value {
    display: flex;
    align-items: baseline;
    gap: 10px;
    white-space: nowrap;
}
.lat-ms {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 1.9rem;
    line-height: 1;
    letter-spacing: -0.02em;
}
.lat-ms-unit {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-dim);
}
.lat-row-domain {
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Grade colors ---------- */
.lat-grade-excellent {
    color: var(--accent);
}
.lat-grade-good {
    color: var(--success);
}
.lat-grade-fair {
    color: var(--text-soft);
}
.lat-grade-poor {
    color: var(--danger);
}
.lat-grade-none {
    color: var(--text-dim);
}
.lat-badge-excellent {
    color: var(--accent);
    border-color: var(--line-strong);
    background: var(--accent-dim);
}
.lat-badge-good {
    color: var(--success);
    border-color: rgba(104, 217, 172, 0.28);
    background: rgba(104, 217, 172, 0.12);
}
.lat-badge-fair {
    color: var(--text-soft);
}
.lat-badge-poor {
    color: var(--danger);
    border-color: rgba(255, 123, 123, 0.28);
    background: rgba(255, 123, 123, 0.12);
}
.lat-badge-none {
    color: var(--text-dim);
}
.lat-badge-nearest {
    color: var(--accent-strong);
    border-color: rgba(224, 161, 74, 0.32);
    background: rgba(224, 161, 74, 0.14);
}

/* ---------- Track ---------- */
.lat-track {
    position: relative;
    height: 12px;
    margin: 18px 0 14px;
    border-radius: 999px;
    background: rgba(167, 207, 255, 0.07);
}
.lat-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0.26;
    transition: width 720ms cubic-bezier(0.16, 1, 0.3, 1), opacity 300ms ease;
}
.lat-dot {
    position: absolute;
    top: 50%;
    left: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px rgba(9, 18, 31, 0.9);
    transform: translate(-50%, -50%);
    transition: left 720ms cubic-bezier(0.16, 1, 0.3, 1);
}
.lat-threshold {
    position: absolute;
    top: -5px;
    bottom: -5px;
    width: 0;
    border-left: 1px dashed rgba(167, 207, 255, 0.42);
    pointer-events: none;
    transition: left 300ms ease;
}
.lat-row.is-probing .lat-track::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, rgba(134, 215, 255, 0.3), transparent);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    animation: lat-sweep 1.4s linear infinite;
}
@keyframes lat-sweep {
    from {
        background-position: -60% 0;
    }
    to {
        background-position: 160% 0;
    }
}

/* ---------- Stats ---------- */
.lat-row-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
}
.lat-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}
.lat-stat span {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.lat-stat b {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-soft);
}

/* ---------- Empty state ---------- */
.lat-empty {
    padding: 56px 24px;
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-md);
}
.lat-empty .mono {
    display: block;
    margin-bottom: 8px;
    color: var(--accent);
}
.lat-empty h3 {
    margin-bottom: 6px;
}
.lat-empty p {
    margin: 0 auto;
}

/* ---------- Method ---------- */
.lat-method {
    margin: 0 auto clamp(56px, 8vw, 96px);
}
.lat-method-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: clamp(24px, 4vw, 44px);
    align-items: start;
}
.lat-method-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.lat-method-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-2);
}
.lat-method-item b {
    display: block;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.lat-method-item p {
    margin: 2px 0 0;
    font-size: var(--fs-small);
}
.lat-method-glyph {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--accent);
}
.lat-tip {
    margin-top: 18px;
    font-size: var(--fs-small);
    color: var(--text-dim);
}

/* ---------- Footer ---------- */
.lat-footer {
    flex-shrink: 0;
}
.lat-footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    padding: 22px 32px;
}
.lat-footer-inner p {
    margin: 0;
    font-size: var(--fs-small);
    color: var(--text-dim);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .lat-hero-inner,
    .lat-method-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .lat-nearest {
        min-height: 0;
    }
    .lat-nearest .lat-summary {
        margin-top: 4px;
    }
}
@media (max-width: 640px) {
    .lat-hero {
        padding-top: 40px;
    }
    .lat-header-side .lat-run {
        min-height: 40px;
        padding: 0 14px;
    }
    .lat-brand-sub {
        display: none;
    }
    .lat-row {
        padding: 18px;
    }
    .lat-ms {
        font-size: 1.6rem;
    }
    .lat-section-head {
        align-items: flex-start;
    }
    .lat-footer-inner {
        padding: 20px;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .lat-row,
    .lat-bar,
    .lat-dot,
    .lat-threshold {
        animation: none;
        transition: none;
    }
    .lat-sonar {
        display: none;
    }
    .lat-row.is-probing .lat-track::after {
        animation: none;
        opacity: 0;
    }
}
