/* diagram-blog.css - Default styles for DiagramBlog.js */
:root{
    --db-bg: #ffffff;
    --db-border: #dcdfe6;
    --db-shadow: rgba(0,0,0,0.08);
    --db-accent: #55607a;
}
body {
    font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
}

#blog-container, .diagram-blog-container {
    position: relative;
    width: 100%;
    padding-bottom: 60px; /* Reduced padding, JS now sets min-height */
}

.blog-block {
    position: absolute;
    background-color: var(--db-bg);
    border: 1px solid var(--db-border);
    border-radius: 8px;
    box-shadow: 0 6px 18px var(--db-shadow);
    padding: 12px;
    padding-top: 30px;
    box-sizing: border-box;
    min-width: 140px;
    max-width: 320px; /* Added max-width to prevent blocks from becoming too wide */
    
    text-align: center;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, top .2s ease, left .2s ease; /* Added transition for position */
    z-index: 10; /* Ensure blocks render above arrows */
}

.blog-block:hover{ transform: translateY(-4px); box-shadow: 0 14px 36px rgba(0,0,0,0.12); }

.block-type{
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 4px;
    background: #eef1f6;
    color: #515a66;
    font-weight: 600;
}

/* Block content styling */
.block-content{
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: normal;
    overflow: visible;
    text-align: left;
}

/* Images in blocks */
.block-type-Image img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 4px;
    object-fit: cover;
    display: block;
}

/* Audio in blocks */
.block-type-Sound audio {
    width: 100%;
    height: 30px;
}

/* Arrow SVG styling */
.arrow-svg{ 
    pointer-events: none; 
    position: absolute; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    overflow: visible;
    z-index: 1;
}

.arrow-line{ 
    stroke: #506070; 
    stroke-width: 2.5; 
    fill: none; 
    stroke-linecap: round;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.arrow-line:hover {
    opacity: 1;
    stroke-width: 3;
}

.arrow-head{ 
    fill: #506070; 
}

.arrow-label{ 
    font-size: 12px; 
    fill: #2f3a45; 
    font-weight: 600; 
    text-anchor: middle; 
    dominant-baseline: middle;
    background: white;
    padding: 2px 6px;
}

/* Popup styling */
.diagram-popup{
    position: fixed; 
    left: 50%; 
    top: 50%; 
    transform: translate(-50%, -50%) scale(0.98);
    background: white; 
    border-radius: 12px; 
    padding: 24px; 
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 820px; 
    width: 94%; 
    max-height: 85vh; 
    overflow: auto; 
    z-index: 9999; 
    opacity: 0; 
    visibility: hidden; 
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.diagram-popup.visible{ 
    opacity: 1; 
    visibility: visible; 
    transform: translate(-50%, -50%) scale(1); 
}

.diagram-popup-close{ 
    position: absolute; 
    right: 16px; 
    top: 16px; 
    background: #f0f2f5; 
    border: none; 
    width: 36px; 
    height: 36px; 
    border-radius: 50%; 
    cursor: pointer; 
    font-size: 20px;
    line-height: 1;
    transition: background 0.2s ease;
}

.diagram-popup-close:hover {
    background: #e2e8f0;
}

.diagram-popup-content{ 
    font-size: 15px; 
    line-height: 1.7;
}

.diagram-popup-content h1,
.diagram-popup-content h2,
.diagram-popup-content h3,
.diagram-popup-content h4,
.diagram-popup-content h5,
.diagram-popup-content h6 {
    color: #1a202c;
    font-weight: 700;
    margin-top: 24px;
    margin-bottom: 12px;
    line-height: 1.3;
}

.diagram-popup-content h1 { font-size: 2em; }
.diagram-popup-content h2 { font-size: 1.6em; }
.diagram-popup-content h3 { font-size: 1.3em; border-bottom: 2px solid #e2e8f0; padding-bottom: 6px; }
.diagram-popup-content h4 { font-size: 1.15em; }
.diagram-popup-content h5 { font-size: 1.05em; color: #4a5568; }
.diagram-popup-content h6 { font-size: 0.95em; color: #718096; text-transform: uppercase; letter-spacing: 0.5px; }

.diagram-popup-content h1:first-child,
.diagram-popup-content h2:first-child,
.diagram-popup-content h3:first-child { 
    margin-top: 0; 
}

.diagram-popup-content p:first-child { 
    margin-top: 0; 
}

.diagram-popup-content p:last-child { 
    margin-bottom: 0; 
}

/* Popup content images and audio */
.diagram-popup-content img,
.diagram-popup-content audio {
    max-width: 100%;
    border-radius: 6px;
    margin: 12px 0;
}

/* Code block improvements */
.code-block-wrapper {
    position: relative;
    margin: 12px 0;
}

.code-lang-label {
    position: absolute;
    top: 8px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #a8b3c1;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
}

/* Improved code block styling */
.blog-code, .blog-block pre {
    background: #282c34;
    color: #abb2bf;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.6;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 400px;
    max-width: 100%;
    border: 1px solid #3e4451;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    
    /* Better scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #4a5568 #2d3748;
}

/* Webkit scrollbar styling */
.blog-code::-webkit-scrollbar,
.blog-block pre::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.blog-code::-webkit-scrollbar-track,
.blog-block pre::-webkit-scrollbar-track {
    background: #2d3748;
    border-radius: 4px;
}

.blog-code::-webkit-scrollbar-thumb,
.blog-block pre::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

.blog-code::-webkit-scrollbar-thumb:hover,
.blog-block pre::-webkit-scrollbar-thumb:hover {
    background: #5a6678;
}

.blog-code code,
.blog-block pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
    white-space: pre;
    word-break: normal;
    display: block;
}

/* Inline code - improved contrast */
.inline-code { 
    background: #f3f4f6; 
    color: #e53e3e;
    padding: 3px 7px; 
    border-radius: 4px; 
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    border: 1px solid #e2e8f0;
}

/* Math block improvements */
.math-block { 
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    padding: 16px; 
    border-radius: 8px; 
    font-family: 'Times New Roman', 'Georgia', serif; 
    margin: 12px 0;
    border: 1px solid #fde68a;
    box-shadow: 0 2px 6px rgba(251, 191, 36, 0.1);
    text-align: center;
    overflow-x: auto;
}

/* Inline math improvements */
.math-inline { 
    background: #fffbeb; 
    color: #92400e;
    padding: 2px 8px; 
    border-radius: 4px; 
    font-style: italic;
    border: 1px solid #fde68a;
    font-family: 'Times New Roman', serif;
}

/* Popup content code blocks */
.diagram-popup-content pre {
    background: #282c34;
    color: #abb2bf;
    padding: 16px;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.92em;
    overflow-x: auto;
    max-height: 500px;
    border: 1px solid #3e4451;
}

.diagram-popup-content pre::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.diagram-popup-content pre::-webkit-scrollbar-track {
    background: #2d3748;
    border-radius: 4px;
}

.diagram-popup-content pre::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

.diagram-popup-content pre code {
    background: transparent;
    padding: 0;
    white-space: pre;
    font-family: inherit;
    color: inherit;
}

/* Mobile improvements */
@media (max-width:700px) {
    .blog-block { 
        max-width: 96vw !important; 
    }
    
    .blog-code, .blog-block pre { 
        font-size: 0.85em; 
        padding: 12px;
        max-height: 300px;
    }
    
    .code-lang-label {
        font-size: 10px;
        padding: 2px 8px;
        top: 6px;
        right: 8px;
    }
}

/* Small responsive tweak */
@media (max-width: 640px){
    .blog-block{ min-width: 120px; }
}

/* Video embed styles moved out of JS for easier customization */
.video-embed {
    position: relative;
    padding-bottom: 50%; /* wider aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    min-height: 150px;
    max-height: 420px;
    width: 100%;
}
.video-embed .video-frame,
.video-embed video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 8px;
    object-fit: contain;
}

/* Video-specific block sizing */
.blog-block.video-block {
    box-sizing: border-box;
}

@media (max-width: 700px) {
    .video-embed { min-height: 120px; }
    .blog-block.video-block { min-width: 88vw; max-width: 96vw; }
}

@media (min-width: 701px) {
    .blog-block.video-block { min-width: 420px; max-width: 640px; }
}