/* Clickable Flowchart Anatomy - Mermaid MicroSim
   Layout: diagram in the left 2/3, information panel in the right 1/3.
   The panel moves below the diagram under 600px. No internal scroll capture.
   All text is at least 16px. */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: aliceblue;
    color: #1f2937;
    font-size: 16px;
}

main { display: block; }

.container {
    display: flex;
    width: 100%;
    align-items: stretch;
}

/* Left 2/3: diagram */
.diagram-panel {
    width: 66.67%;
    background: aliceblue;
    padding: 8px;
    overflow: visible;
    position: relative;
}

.mermaid-box { width: 100%; text-align: center; }
.mermaid-box svg { max-width: 100%; height: auto; }
.mermaid-box.broken svg { opacity: 0.35; filter: grayscale(0.8); }

/* Overlay banner over the dimmed diagram (does not change the layout height) */
.diagram-status {
    position: absolute;
    top: 45%;
    left: 8%;
    right: 8%;
    z-index: 5;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Node, edge-label and edge interactivity */
.mermaid-box .node { cursor: pointer; }
.mermaid-box .node:focus { outline: none; }
/* Mermaid writes classDef colors as inline !important styles, so highlight
   with a glow filter instead of overriding the stroke */
.mermaid-box .node.hl { filter: drop-shadow(0 0 4px #f59e0b) drop-shadow(0 0 4px #f59e0b); }
.mermaid-box .edgeLabel { cursor: pointer; font-size: 16px; }
.mermaid-box g.edgeLabel.hl { filter: drop-shadow(0 0 3px #f59e0b) drop-shadow(0 0 3px #f59e0b); }
.mermaid-box .edge-hit { cursor: pointer; }
.mermaid-box path.flowchart-link.hl { filter: drop-shadow(0 0 3px #f59e0b) drop-shadow(0 0 3px #f59e0b); }

/* Right 1/3: information panel */
.info-panel {
    width: 33.33%;
    background: #f8f9fa;
    border-left: 1px solid #dee2e6;
    padding: 8px 10px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

#break-btn {
    font-size: 16px;
    padding: 4px 12px;
    border-radius: 5px;
    border: 1px solid #b91c1c;
    background: #fee2e2;
    color: #991b1b;
    cursor: pointer;
}

#break-btn[aria-pressed="true"] { background: #b91c1c; color: white; }
#break-btn:focus-visible, .key-item:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }

.card {
    background: white;
    border: 1px solid #e2e8f0;
    border-left: 5px solid #667eea;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 16px;
    line-height: 1.35;
}

.card.error { border-left-color: #dc2626; }
.card-title { font-weight: bold; color: #4338ca; margin-bottom: 4px; }
.card.error .card-title { color: #b91c1c; }
.card-row { margin-bottom: 4px; }
.card-row b { color: #334155; }

.code {
    display: block;
    font-family: "Courier New", Courier, monospace;
    font-size: 16px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 6px;
    margin-top: 3px;
    white-space: pre-wrap;
    word-break: break-word;
}

.card.error .code { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }

.shape-key {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 14px;
    background: white;
    border-top: 1px solid #cbd5e1;
    padding: 4px 10px;
}

.key-title { font-weight: bold; font-size: 16px; }

.key-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    font-size: 16px;
    text-align: left;
    padding: 2px 0;
    cursor: pointer;
    color: #1f2937;
}

.key-item:hover { color: #4338ca; text-decoration: underline; }
.k-shape { fill: #e0e7ff; stroke: #4338ca; stroke-width: 1.5; }

@media (max-width: 599px) {
    .container { flex-direction: column; }
    .diagram-panel, .info-panel { width: 100%; }
    .info-panel { border-left: none; border-top: 1px solid #dee2e6; }
}
