/* ==========================================================================
   TechToday Study Guides - Architectural Diagrams Design System
   ========================================================================== */

.study-diagram,
.study-diagram-container,
.concept-diagram-card {
    width: 100%;
    max-width: 1400px;
    margin: 3.5rem auto;
    padding: 1.75rem 2rem;
    background: linear-gradient(180deg, #131720 0%, #0c1017 100%);
    border: 1px solid #283342;
    border-radius: 16px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55), 0 0 1px rgba(56, 189, 248, 0.3);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    box-sizing: border-box;
}

.study-diagram:hover,
.study-diagram-container:hover,
.concept-diagram-card:hover {
    border-color: rgba(56, 189, 248, 0.55);
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.65), 0 0 20px rgba(56, 189, 248, 0.2);
}

.study-diagram-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid #1c2430;
    flex-wrap: wrap;
}

.study-diagram-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #38bdf8;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.diagram-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.study-diagram-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: ui-monospace, monospace;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 10px #38bdf8, 0 0 20px #38bdf8;
    animation: badgePulse 1.8s ease-in-out infinite;
}

.diagram-btn-expand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #475569;
    padding: 0.4rem 0.95rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: ui-monospace, monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}

.diagram-btn-expand:hover {
    background: #38bdf8;
    color: #0b0d10;
    border-color: #38bdf8;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
    transform: translateY(-1px);
}

/* ==========================================================================
   SVG Wrapper & Responsiveness: Zero-Cutoff LTR Scroll
   ========================================================================== */
.study-diagram-svg-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 12px;
    background: #080b0f;
    border: 1px solid #1a222e;
    padding: 1.5rem;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    text-align: left;
}

.study-diagram-svg-wrap::-webkit-scrollbar {
    height: 8px;
}

.study-diagram-svg-wrap::-webkit-scrollbar-track {
    background: #0d1117;
    border-radius: 4px;
}

.study-diagram-svg-wrap::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.study-diagram-svg-wrap::-webkit-scrollbar-thumb:hover {
    background: #38bdf8;
}

/* Base diagram SVG sizing */
.study-diagram>svg,
.study-diagram-container>svg,
.concept-diagram-card>svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
}

/* Wrapped SVG: Guaranteed 960px minimum width with zero negative margin scroll cutoff */
.study-diagram-svg-wrap svg {
    display: block;
    width: 100%;
    min-width: 960px;
    max-width: none;
    height: auto;
    margin: 0;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
}

.study-diagram-caption {
    margin-top: 1.25rem;
    font-size: 0.95rem;
    color: #94a3b8;
    line-height: 1.65;
    text-align: center;
    padding: 0 1rem;
}

/* ==========================================================================
   Prominent, High-Visibility SVG Animations
   ========================================================================== */

@keyframes badgePulse {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(0.85);
        box-shadow: 0 0 6px currentColor;
    }

    50% {
        opacity: 1;
        transform: scale(1.35);
        box-shadow: 0 0 16px currentColor, 0 0 24px currentColor;
    }
}

@keyframes pulseFlow {
    0% {
        stroke-dashoffset: 30;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes v8Flow {
    0% {
        stroke-dashoffset: 30;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes pyFlow {
    0% {
        stroke-dashoffset: 30;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes awsFlow {
    0% {
        stroke-dashoffset: 30;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes cicdPulse {
    0% {
        stroke-dashoffset: 30;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes nodePulseGlow {

    0%,
    100% {
        stroke-opacity: 0.4;
        opacity: 0.75;
        filter: drop-shadow(0 0 2px currentColor);
    }

    50% {
        stroke-opacity: 1;
        opacity: 1;
        filter: drop-shadow(0 0 10px currentColor);
    }
}

@keyframes loopSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes dotPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.75;
    }

    50% {
        transform: scale(1.4);
        opacity: 1;
        filter: drop-shadow(0 0 12px currentColor);
    }
}

/* Bold Animated Flow Lines */
.dash-animated {
    stroke-dasharray: 9 6 !important;
    stroke-width: 2.8px !important;
    filter: drop-shadow(0 0 6px currentColor) !important;
    animation: pulseFlow 1.6s linear infinite !important;
}

.dash-fast,
.flow-fast {
    stroke-dasharray: 8 5 !important;
    stroke-width: 2.8px !important;
    filter: drop-shadow(0 0 7px currentColor) !important;
    animation: pulseFlow 1.0s linear infinite !important;
}

/* Pulsing Glowing Elements & Node Borders (No text distortion) */
.node-glow,
.gil-border,
.az-border,
.sync-glow {
    animation: nodePulseGlow 2.4s ease-in-out infinite !important;
}

.diagram-pulse-fast {
    animation: badgePulse 1.2s ease-in-out infinite;
}

.diagram-pulse-med {
    animation: badgePulse 2.0s ease-in-out infinite;
}

.diagram-pulse-slow {
    animation: badgePulse 3.0s ease-in-out infinite;
}

.loop-indicator,
.sync-indicator {
    animation: loopSpin 6s linear infinite !important;
    filter: drop-shadow(0 0 8px currentColor);
}

.packet-dot {
    filter: drop-shadow(0 0 8px currentColor) drop-shadow(0 0 14px currentColor);
    animation: dotPulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {

    .dash-animated,
    .dash-fast,
    .flow-fast,
    .node-glow,
    .gil-border,
    .az-border,
    .sync-glow,
    .badge-pulse,
    .loop-indicator,
    .sync-indicator,
    .packet-dot,
    .diagram-pulse-fast,
    .diagram-pulse-med,
    .diagram-pulse-slow {
        animation: none !important;
    }
}

/* ==========================================================================
   Interactive Lightbox / Fullscreen Modal
   ========================================================================== */
.diagram-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 15, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
}

.diagram-modal-overlay.active {
    display: flex;
}

.diagram-modal-content {
    background: #0f131a;
    border: 1px solid rgba(56, 189, 248, 0.5);
    border-radius: 18px;
    padding: 2rem;
    width: 96vw;
    max-width: 1700px;
    max-height: 94vh;
    overflow-y: auto;
    overflow-x: auto;
    box-shadow: 0 35px 90px -10px rgba(0, 0, 0, 0.95), 0 0 35px rgba(56, 189, 248, 0.2);
    box-sizing: border-box;
    position: relative;
}

.diagram-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #1c2430;
}

.diagram-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #38bdf8;
    font-family: ui-monospace, monospace;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.diagram-modal-close {
    background: #1e293b;
    border: 1px solid #475569;
    color: #f8fafc;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.diagram-modal-close:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
}

.diagram-modal-body {
    width: 100%;
    background: #06090d;
    padding: 2rem 1.5rem;
    border-radius: 14px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.diagram-modal-body svg {
    display: block;
    width: 100%;
    max-width: 1550px;
    height: auto;
    margin: 0 auto;
}

@media (max-width: 640px) {

    .study-diagram,
    .study-diagram-container,
    .concept-diagram-card {
        margin: 2rem auto;
        padding: 1rem;
        border-radius: 12px;
    }

    .study-diagram-header {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .study-diagram-title {
        font-size: 0.9rem;
    }

    .study-diagram-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.65rem;
    }

    .diagram-btn-expand {
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem;
    }

    .study-diagram-svg-wrap {
        padding: 0.75rem;
    }

    .diagram-modal-overlay {
        padding: 0.5rem;
    }

    .diagram-modal-content {
        padding: 1rem;
        width: 100vw;
        max-height: 98vh;
        border-radius: 12px;
    }

    .diagram-modal-header {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .diagram-modal-title {
        font-size: 1rem;
    }

    .diagram-modal-body {
        padding: 1rem 0.5rem;
    }
}