/* AL.AI — fleet 3D section (scoped: .fleet-* / .stats-* / .util-*) */

/* .fleet-section's padding and its .section-title override both used to live here. The
   padding moved to styles.css so every section shares one rem value; the title override is
   gone entirely. It was (0,2,0) and this file loads second, so it beat .section-title twice
   over — capping this one heading at 44px while every other section title reached 51.2px,
   and centring it inside its grid column while all the others were left-aligned. Its
   clamp(2rem, 4vw, 2.75rem) was also a bare vw, so it did not respond to browser zoom.
   Inheriting .section-title fixes all three at once. */

.fleet-wrap {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1.5rem;
    align-items: stretch;
}

.fleet-viewport {
    position: relative;
    height: min(62vh, 560px);
    min-height: 380px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: radial-gradient(ellipse at 50% 20%, rgba(90, 157, 232, 0.07), transparent 60%), #0B0A09;
    overflow: hidden;
    contain: layout paint;
}

.fleet-viewport canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: pan-y;
}

.fleet-live {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 6px;
    font: 600 0.62rem ui-monospace, SFMono, monospace;
    letter-spacing: 2px;
    color: var(--grey);
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(5, 5, 7, 0.55);
    backdrop-filter: blur(6px);
    pointer-events: none;
}

/* `display:flex` on a class beats the UA's `[hidden]{display:none}`, so every label
   js/fleet3d.js hides — the always-hidden `control` label, and every label culled for
   being behind the rack or off-frustum in updateLabels() — kept rendering at its last
   projected position. On a phone that put a stray "CONTROL" pill off the left edge. */
.fleet-label[hidden] { display: none; }

.fleet-label {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -130%);
    font: 600 0.68rem/1.5 ui-monospace, SFMono, monospace;
    letter-spacing: 1.5px;
    color: var(--white);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(5, 5, 7, 0.6);
    backdrop-filter: blur(4px);
    pointer-events: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    white-space: nowrap;
}

/* thin tether from the label down to the anchor point it names */
.fleet-label::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: 1px;
    /* js/fleet3d.js lengthens this when it stacks a colliding pill into a higher row,
       so the tether still lands on the anchor the pill names */
    height: var(--fl-tether, 20px);
    transform: translateX(-50%);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.45), transparent);
}

.fleet-label .fl-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3DDC97;
    box-shadow: 0 0 6px rgba(61, 220, 151, 0.8);
}

.fleet-label.warn .fl-dot {
    background: #FFB454;
    box-shadow: 0 0 6px rgba(255, 180, 84, 0.8);
}

.fleet-label .fl-role { display: none; }

.fleet-label.hot {
    border-color: rgba(90, 157, 232, 0.6);
    box-shadow: 0 0 14px rgba(90, 157, 232, 0.25);
}

/* panel cross-highlight: rows of the hovered/focused node */
.spec-grid.hot .spec {
    border-color: rgba(90, 157, 232, 0.45);
    background: rgba(90, 157, 232, 0.06);
}

.util-row.hot {
    color: var(--white);
}

.util-row.hot .util-bar i {
    box-shadow: 0 0 8px rgba(90, 157, 232, 0.5);
}

.fleet-tooltip {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 5;
    max-width: 240px;
    background: rgba(5, 5, 7, 0.92);
    border: 1px solid rgba(90, 157, 232, 0.35);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--grey);
    pointer-events: none;
    backdrop-filter: blur(6px);
    line-height: 1.5;
}

.fleet-tooltip b {
    color: var(--white);
}

.fleet-stats {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--card-bg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.stats-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3DDC97;
    box-shadow: 0 0 8px #3DDC97;
    animation: stats-pulse 2s ease-in-out infinite;
}

@keyframes stats-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.stats-title {
    font: 600 0.75rem ui-monospace, SFMono, monospace;
    letter-spacing: 2px;
    color: var(--white);
}

.stats-updated {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--grey);
    white-space: nowrap;
}

.stats-sub {
    font-size: 0.8rem;
    color: var(--grey);
    margin-top: -0.5rem;
}

.stats-node {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-name {
    font-size: 1.3rem;
    letter-spacing: -0.3px;
    color: var(--white);
}

.stats-name .stats-role {
    display: block;
    font-size: 0.85rem;
    color: var(--grey);
    font-weight: 400;
}

.spec-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem 1.2rem;
}

.spec {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
}

.spec small {
    display: block;
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--grey);
    margin-bottom: 2px;
}

.spec b {
    font-family: ui-monospace, SFMono, monospace;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--white);
}

.util-rows {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.util-row {
    display: grid;
    grid-template-columns: 9rem 1fr 2.6rem;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.8rem;
    color: var(--grey);
    font-variant-numeric: tabular-nums;
}

.util-bar {
    height: 6px;
    background: var(--track);
    border-radius: 4px;
    overflow: hidden;
    display: block;
}

.util-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--deep-violet), var(--electric));
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.util-pct {
    font-family: ui-monospace, SFMono, monospace;
    text-align: right;
}

.stats-foot {
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--grey);
    border-top: 1px solid var(--border);
    padding-top: 0.9rem;
}

.fleet-fallback {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.fleet-fallback .fleet-card {
    padding: 1.5rem;
}

.fleet-card-role {
    color: var(--grey) !important;
    font-size: 0.85rem !important;
    margin-bottom: 0.75rem;
}

.fleet-card-spec {
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--grey) !important;
    margin-top: 0.6rem;
    margin-bottom: 0 !important;
}

.fleet-card-val {
    font-family: ui-monospace, SFMono, monospace;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
}

.fleet-card-val span {
    display: block;
}

.fleet-fallback-note {
    grid-column: 1 / -1;
    color: var(--grey);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

@media (max-width: 900px) {
    .fleet-wrap {
        grid-template-columns: 1fr;
    }

    .fleet-viewport {
        height: 55dvh;
        min-height: 320px;
    }

    .fleet-fallback {
        grid-template-columns: 1fr;
    }

    .util-row {
        grid-template-columns: 7rem 1fr 2.4rem;
    }

    .spec-grid {
        gap: 0.7rem 0.9rem;
    }
}

/* Two spec columns inside a ~340px phone leaves ~150px per cell, which wraps values like
   "Retrieval over company knowledge — RAG, nothing leaves" to one or two words per line.
   Also keep the floating 3D labels and the tap tooltip inside the frame. */
@media (max-width: 600px) {
    /* styles.css:954 sets `.fleet-stats .spec-grid { repeat(2, 1fr) }` — an (0,2,0)
       selector that beats a bare `.spec-grid` no matter the file order. Match its
       specificity here (fleet3d.css loads after styles.css, so equal specificity wins). */
    .fleet-stats .spec-grid,
    .fleet-fallback .spec-grid,
    .spec-grid {
        grid-template-columns: 1fr;
    }

    .fleet-tooltip {
        max-width: min(240px, calc(100vw - 2rem));
    }

    .fleet-label {
        max-width: calc(100vw - 1.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .stats-dot {
        animation: none;
    }
}

/* ---- light theme: the scene re-lights itself in fleet3d.js (applySceneTheme);
   these overrides cover the 2D chrome that sits over the canvas ---- */
[data-theme="light"] .fleet-viewport {
    background: radial-gradient(ellipse at 50% 20%, rgba(23, 52, 87, 0.10), transparent 60%), #F5F1EA;
}
[data-theme="light"] .fleet-live {
    background: rgba(20, 18, 15, 0.50);
}
[data-theme="light"] .fleet-label {
    background: rgba(20, 18, 15, 0.55);
}
[data-theme="light"] .fleet-label::after {
    background: linear-gradient(to bottom, rgba(20, 18, 15, 0.50), transparent);
}
[data-theme="light"] .fleet-tooltip {
    background: rgba(251, 249, 245, 0.96);
}
