.diagram-container {
    width: 96%;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    background-color: rgba(var(--blue-darker), 0.4);
    border: 1px solid rgba(var(--blue-mid), 0.2);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.diagram-header {
    background-color: rgba(var(--blue-mid), 0.2);
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(var(--blue-mid), 0.3);
}

.diagram-title {
    margin: 0;
    color: rgb(var(--blue-mid));
    font-family: monospace;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.svg-wrapper {
    position: relative;
    width: 100%;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.architecture-svg {
    width: 100%;
    max-width: 900px;
    height: auto;
    min-height: 250px;
}

/* Boundary Box Styles */
.boundary-rect {
    fill: rgba(var(--blue-mid), 0.05);
    stroke: rgba(var(--blue-mid), 0.4);
    stroke-width: 1.5px;
    stroke-dasharray: 6 6;
}

.boundary-title {
    fill: rgb(var(--blue-mid));
    font-family: monospace;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Node Styles */
.node-rect {
    fill: #081a14;
    stroke: rgb(var(--blue-mid));
    stroke-width: 1.5px;
    transition: all 0.3s ease;
}

.interactive-node:hover {
    cursor: pointer;
}

.interactive-node:hover .node-rect,
.node-rect.active {
    stroke: rgb(var(--blue-bright));
    stroke-width: 2px;
    filter: drop-shadow(0 0 5px rgb(var(--blue-bright)));
    fill: rgba(var(--blue-mid), 0.1);
}

.node-text {
    fill: #E0E0E0;
    font-family: monospace;
    font-size: 16px;
    font-weight: bold;
}

.node-subtext {
    fill: #d1dbd7;
    font-family: monospace;
    font-size: 13px;
}

/* Path Styles */
.path-line {
    fill: none;
    stroke-width: 1.5px;
}

.static-path {
    stroke: rgba(var(--blue-mid), 0.3);
}

.sub-path {
    stroke: rgba(var(--blue-mid), 0.5);
    stroke-width: 1px;
}

.return-path {
    stroke: rgba(139, 157, 150, 0.5);
    stroke-width: 1px;
}

.path-label {
    fill: rgb(var(--blue-mid));
    font-family: monospace;
    font-size: 13px;
    text-anchor: middle;
}

.return-label,
.sub-label {
    fill: #d1dbd7;
    font-size: 11px;
}

/* Animated Pulse Logic */
.pulse-path {
    stroke: rgb(var(--blue-bright));
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 4px rgb(var(--blue-bright)));
    stroke-dasharray: 10, 1000;
    animation: pulse-flow linear infinite;
    will-change: stroke-dashoffset, opacity;
}

/* Stagger the animations to simulate sequential logic flow */
.path-1 {
    animation-duration: 2s;
    animation-delay: 0s;
}

.path-2 {
    animation-duration: 2s;
    animation-delay: 1.5s;
}

.path-3 {
    animation-duration: 2s;
    animation-delay: 3.0s;
}

.path-4 {
    animation-duration: 3s;
    animation-delay: 4.5s;
}

.path-5 {
    animation-duration: 2.5s;
    animation-delay: 6.5s;
}

@keyframes pulse-flow {
    0% {
        stroke-dashoffset: 1000;
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        stroke-dashoffset: 0;
        opacity: 0;
    }
}

/* Tooltip Overlay */
.tooltip-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    max-width: 300px;
    /* Solid-enough bg without backdrop-filter: at 0.85 alpha the
       backdrop is barely visible anyway, and backdrop-filter forces
       the browser to re-rasterize everything behind this rect on every
       frame the tooltip is shown. Same readability, no per-frame cost. */
    background-color: rgba(var(--blue-darker), 0.92);
    border: 1px solid rgb(var(--blue-mid));
    border-radius: 4px;
    padding: 1rem;
    color: #E0E0E0;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    animation: fade-in 0.2s ease-out;
    z-index: 10;
}

.tooltip-overlay span {
    color: rgb(var(--blue-bright));
    font-weight: bold;
    display: block;
    margin-bottom: 0.4rem;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness (Stacking) */
@media (max-width: 850px) {
    .svg-wrapper {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 1.5rem;
        /* Room for touch scrollbar */
    }

    .architecture-svg {
        /* Enforce a minimum width so the vector graph and its text remain highly legible.
           It will horizontal-scroll natively inside the robust wrapper overflow bounds. */
        min-height: 200px;
        min-width: 650px;
    }

    .node-text {
        font-size: 16px;
    }

    .tooltip-overlay {
        bottom: 1rem;
        top: auto;
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}