﻿/* ============================================================
ECOSYSTEM EXCHANGE MAP - dedicated styles
Abstract architecture: capabilities -> Instant AI Gate -> models.
Full width of the central container. No products, no versions.
Gateway mark: embedded InstantAIGate logo, themed via tokens.
Includes the full-screen viewer (dialog, zoom / pan stage).
Requires tokens.css. English-only code and copy.
============================================================ */
.eam {
    margin-bottom: var(--space-xl);
}

.eam-frame {
    padding: 20px 22px 16px;
    background: radial-gradient(700px 380px at 50% 42%, rgba(91,124,255,0.07), transparent 72%), linear-gradient(180deg, rgba(17,22,42,0.65), rgba(11,15,26,0.25));
    border: 0;
    border-radius: var(--radius-lg);
}

.eam-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.eam-top-right {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.eam-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.eam-legend {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

    .eam-legend i {
        width: 7px;
        height: 7px;
        border-radius: 50%;
    }

.eam-legend-req {
    background: var(--brand);
    box-shadow: 0 0 8px rgba(91,124,255,0.6);
}

.eam-legend-res {
    background: var(--accent-teal);
    box-shadow: 0 0 8px rgba(55,201,165,0.6);
    margin-left: 8px;
}
/* ---------- Expand button ---------- */
.eam-expand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.02);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}

    .eam-expand:hover {
        color: #fff;
        border-color: var(--brand);
        background: var(--brand-soft);
        transform: translateY(-1px);
    }

    .eam-expand:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: 3px;
    }

    .eam-expand svg {
        width: 14px;
        height: 14px;
    }

.eam-svg {
    display: block;
    width: 100%;
    height: auto;
}
/* Layout slot left behind while the SVG lives in the viewer. */
.eam-svg-slot {
    width: 100%;
    aspect-ratio: 1200 / 620;
}
/* ---------- Columns / trunks ---------- */
.eam-col-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    fill: var(--text-faint);
}

.eam-trunk-label {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.14em;
    fill: var(--text-faint);
    opacity: 0.8;
}
/* ---------- Flows ---------- */
.eam-path {
    fill: none;
    stroke: rgba(255,255,255,0.10);
    stroke-width: 1.4;
    transition: stroke 0.25s, opacity 0.25s, stroke-width 0.25s;
}

.eam-flow--ghost .eam-path {
    stroke-dasharray: 4 7;
    opacity: 0.6;
}

.eam-flow.is-route .eam-path {
    stroke: rgba(55,201,165,0.35);
}

.eam-flow.is-hot .eam-path {
    stroke: var(--pc, var(--brand));
    stroke-width: 2.2;
    stroke-dasharray: 7 7;
    animation: eamDash 1.1s linear infinite;
}

@keyframes eamDash {
    to {
        stroke-dashoffset: -28;
    }
}

.eam-packet {
    opacity: 0.3;
    transition: opacity 0.25s;
}

.eam-packet--req {
    fill: var(--pc, var(--brand));
}

.eam-packet--res {
    fill: var(--accent-teal);
}

.eam-flow.is-hot .eam-packet {
    opacity: 1;
}

.eam-flow.is-route .eam-packet {
    opacity: 0.55;
}
/* ---------- Nodes ---------- */
.eam-node {
    cursor: pointer;
}

    .eam-node rect {
        fill: var(--surface);
        stroke: var(--line-strong);
        stroke-width: 1.2;
        transition: stroke 0.25s, fill 0.25s, filter 0.25s;
    }

    .eam-node:hover rect, .eam-node:focus-visible rect, .eam-node.is-active rect {
        stroke: var(--nc, var(--brand));
        fill: var(--surface-raised);
        filter: drop-shadow(0 0 10px rgba(91,124,255,0.22));
    }

    .eam-node:focus-visible {
        outline: none;
    }

        .eam-node:focus-visible rect {
            stroke-width: 2;
        }

.eam-node--ghost rect {
    fill: transparent;
    stroke-dasharray: 5 6;
    stroke: rgba(122,139,168,0.5);
}

.eam-node--ghost:hover rect, .eam-node--ghost.is-active rect {
    fill: rgba(122,139,168,0.06);
}

.eam-node-icon {
    color: var(--nc, var(--brand));
}

.eam-node-title {
    font-size: 13px;
    font-weight: 700;
    fill: var(--text-primary);
}

.eam-node-micro {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.08em;
    fill: var(--text-faint);
}

.eam-node:hover .eam-node-title, .eam-node.is-active .eam-node-title {
    fill: var(--nc, var(--brand));
}
/* ---------- Gateway ---------- */
.eam-gate rect:first-of-type {
    fill: url(#eamGateGrad);
    stroke: rgba(91,124,255,0.55);
    stroke-width: 1.4;
}

.eam-gate-ring {
    fill: none;
    stroke: rgba(91,124,255,0.4);
    stroke-width: 1.2;
    animation: eamPulse 3.2s ease-in-out infinite;
}
/* Brand mark: body inherits the gate accent, bolt carries the
teal energy cue. Nested viewBox keeps proportions at any scale. */
.eam-gate-icon {
    color: var(--brand-bright);
}

.eam-gate-logo {
    display: block;
    overflow: visible;
}

.eam-gate-logo-body {
    fill: currentColor;
}

.eam-gate-logo-bolt {
    fill: var(--accent-teal);
    filter: drop-shadow(0 0 5px rgba(55,201,165,0.4));
}

.eam-gate-title {
    font-size: 17px;
    font-weight: 800;
    fill: #fff;
}

.eam-gate-sub {
    font-family: var(--font-mono);
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.18em;
    fill: var(--brand-bright);
}

.eam-gate-div {
    stroke: rgba(255,255,255,0.1);
    stroke-width: 1;
}

.eam-gate-row {
    font-size: 10.5px;
    fill: var(--text-muted);
}

.eam-gate-chip {
    fill: rgba(91,124,255,0.12);
    stroke: rgba(91,124,255,0.4);
}

.eam-gate-chip-text {
    font-family: var(--font-mono);
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.16em;
    fill: var(--brand-bright);
}

@keyframes eamPulse {
    0%,100% {
        opacity: 0.35;
        transform: scale(0.92);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.06);
    }
}
/* ---------- Foundation bar ---------- */
.eam-base {
    fill: rgba(91,124,255,0.06);
    stroke: rgba(91,124,255,0.22);
}

.eam-base-text {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.18em;
    fill: var(--text-muted);
}
/* ---------- Caption ---------- */
.eam-caption {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0 0;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
    font-size: 0.86rem;
    line-height: 1.6;
    color: var(--text-muted);
    min-height: 44px;
}

    .eam-caption i {
        flex: none;
        width: 7px;
        height: 7px;
        margin-top: 7px;
        border-radius: 50%;
        background: var(--brand);
        box-shadow: 0 0 8px rgba(91,124,255,0.6);
    }

.eam-hint {
    margin: 8px 0 0;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}
/* ---------- Mobile fallback ---------- */
.eam-mobile {
    display: none;
}

.eam-mobile-label {
    margin: 0 0 10px;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.eam-mobile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.eam-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
}

    .eam-chip i {
        flex: none;
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--nc, var(--brand));
    }

    .eam-chip:hover, .eam-chip.is-active {
        border-color: var(--nc, var(--brand));
        background: var(--brand-soft);
    }

.eam-chip--ghost {
    border-style: dashed;
    color: var(--text-muted);
}

.eam-mobile-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px;
    margin-bottom: 16px;
    text-align: center;
    background: linear-gradient(135deg, rgba(91,124,255,0.12), rgba(55,201,165,0.05));
    border-radius: var(--radius-md);
}

    .eam-mobile-gate b {
        font-size: 1rem;
        color: #fff;
    }

    .eam-mobile-gate span {
        font-size: 0.76rem;
        color: var(--text-muted);
    }

    .eam-mobile-gate em {
        font-style: normal;
        font-family: var(--font-mono);
        font-size: 0.62rem;
        font-weight: 700;
        letter-spacing: 0.16em;
        color: var(--brand-bright);
    }
/* ============================================================
FULL-SCREEN VIEWER
============================================================ */
body.eam-fs-open {
    overflow: hidden;
}

.eam-fullscreen {
    position: fixed;
    inset: 0;
    z-index: var(--z-toast, 1200);
    display: flex;
    padding: clamp(10px, 2vw, 26px);
    opacity: 0;
    transition: opacity 0.22s var(--ease-out);
}

    .eam-fullscreen[hidden] {
        display: none;
    }

    .eam-fullscreen.is-open {
        opacity: 1;
    }

.eam-fs-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(1200px 700px at 50% 30%, rgba(22,32,74,0.55), transparent 70%), rgba(5,8,16,0.94);
    backdrop-filter: blur(10px);
}

.eam-fs-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: linear-gradient(180deg, rgba(17,22,42,0.92), rgba(11,15,26,0.96));
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-2);
    transform: translateY(10px) scale(0.985);
    transition: transform 0.24s var(--ease-out);
}

.eam-fullscreen.is-open .eam-fs-panel {
    transform: none;
}

.eam-fs-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(11,15,26,0.6);
}

.eam-fs-meta {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-width: 0;
}

.eam-fs-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.eam-fs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.02);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

    .eam-fs-btn:hover {
        color: #fff;
        border-color: var(--brand);
        background: var(--brand-soft);
    }

    .eam-fs-btn:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: 2px;
    }

    .eam-fs-btn svg {
        width: 15px;
        height: 15px;
    }

.eam-fs-btn--close {
    border-color: rgba(91,124,255,0.45);
    color: var(--text-primary);
}

.eam-fs-zoom {
    min-width: 52px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

.eam-fs-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 1.6vw, 22px);
    overflow: hidden;
    touch-action: none;
    background-image: linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.022) 1px, transparent 1px);
    background-size: 40px 40px;
    cursor: default;
}

    .eam-fs-stage.is-zoomed {
        cursor: grab;
    }

    .eam-fs-stage.is-dragging {
        cursor: grabbing;
    }

    .eam-fs-stage .eam-svg {
        display: block;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        transform-origin: 50% 50%;
        transition: transform 0.16s var(--ease-out);
        will-change: transform;
    }

    .eam-fs-stage.is-dragging .eam-svg {
        transition: none;
    }

.eam-fs-caption {
    margin: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    min-height: 0;
    background: rgba(11,15,26,0.6);
}
/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .eam-svg {
        display: none;
    }

    .eam-svg-slot {
        display: none;
    }

    .eam-mobile {
        display: block;
    }

    .eam-frame {
        padding: 16px 14px 12px;
    }

    .eam-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .eam-top-right {
        width: 100%;
        justify-content: space-between;
    }

    .eam-caption {
        font-size: 0.82rem;
    }

    .eam-fullscreen {
        padding: 0;
    }

    .eam-fs-panel {
        border: 0;
        border-radius: 0;
    }

    .eam-fs-head {
        padding: 10px 12px;
    }

    .eam-fs-meta .eam-legend {
        display: none;
    }

    .eam-fs-btn--close span {
        display: none;
    }

    .eam-fs-caption {
        font-size: 0.78rem;
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .eam-mobile-grid {
        grid-template-columns: 1fr;
    }
}
/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .eam-flow.is-hot .eam-path, .eam-gate-ring {
        animation: none !important;
    }

    .eam-path, .eam-packet, .eam-node rect, .eam-chip, .eam-expand, .eam-fs-btn, .eam-fullscreen, .eam-fs-panel, .eam-fs-stage .eam-svg {
        transition: none !important;
    }
}
