/* AUTO-GENERATED COPY — do not edit here. Source of truth: shared/css/ */
/* Regenerate with: node scripts/sync-shared.js */
/* MADOLA Output Styles — source of truth for how generated .mda output (headings,
   paragraphs, formulas, graphs, tables) renders. Shared between web/ and app/ via
   scripts/sync-shared.js (same mechanism as shared/js/) — do not edit the copies
   at web/css/shared/madola-output.css or app/css/shared/madola-output.css directly;
   edit this file and run `npm run sync-shared`.

   Every rule is scoped under .madola-output so this file can be loaded alongside
   an app shell (toolbars, panels, modals) without leaking into it — apply the
   .madola-output class to whatever element hosts the generated HTML (e.g. web/'s
   #output, app/'s .preview-host). */

.madola-output {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

.madola-output .container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.madola-output h1,
.madola-output h2,
.madola-output h3 {
    color: #2c3e50;
    margin-top: 1.2em;
    margin-bottom: 0.4em;
}

.madola-output h1:first-child,
.madola-output h2:first-child,
.madola-output h3:first-child {
    margin-top: 0;
}

/* Section headings read as the numbered dividers of an engineering
   calculation sheet: a coloured label with a rule under it, so a long
   report scans as discrete steps rather than one continuous wall. */
.madola-output h2 {
    color: #1f5fa8;
    font-size: 1.05em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #c9d3e0;
    padding-bottom: 0.25em;
    margin-top: 1.6em;
}

.madola-output p {
    margin-top: 0;
    margin-bottom: 0.8em;
}

/* ── Engineering check result box (@check[limit]) ──
   The verdict a calculation sheet ends on: the computed utilisation ratio,
   and whether it is within the allowable limit. Colour is a redundant cue —
   the OK/NG word carries the meaning on its own, so this still reads when
   printed in greyscale or by someone who can't distinguish red from green. */
.madola-output .madola-check {
    display: inline-block;
    min-width: 200px;
    margin: 16px 0;
    border: 1px solid #b8c0cc;
    border-radius: 4px;
    text-align: center;
    background: #f5f7fa;
    overflow: hidden;
    vertical-align: top;
}

.madola-output .madola-check-title {
    background: #dde3ec;
    border-bottom: 1px solid #b8c0cc;
    padding: 5px 14px;
    font-weight: 600;
    font-size: 0.9em;
    letter-spacing: 0.06em;
    color: #2c3e50;
}

.madola-output .madola-check-label {
    padding: 8px 14px 0;
    font-size: 0.9em;
    color: #55606f;
}

.madola-output .madola-check-value {
    padding: 2px 14px;
    font-size: 1.7em;
    font-weight: 700;
    line-height: 1.2;
}

.madola-output .madola-check-verdict {
    padding: 0 14px;
    font-size: 1.3em;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.madola-output .madola-check-note {
    padding: 0 14px 10px;
    font-size: 0.78em;
    color: #6b7280;
}

.madola-output .madola-check-pass .madola-check-value,
.madola-output .madola-check-pass .madola-check-verdict {
    color: #1a7f42;
}

.madola-output .madola-check-fail .madola-check-value,
.madola-output .madola-check-fail .madola-check-verdict {
    color: #c0392b;
}

.madola-output .madola-code {
    background: #f1f2f6;
    border-left: 4px solid #3498db;
    padding: 15px;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    border-radius: 4px;
}

.madola-output .execution-result {
    background: #e8f5e8;
    border-left: 4px solid #27ae60;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.madola-output .math-expression {
    margin: 0 0;
    text-align: center;
    font-size: 1em;
}

.madola-output .math-expression.align-expression {
    margin-left: 0.25in;
}

/* Indent two-column tables to line up with aligned equations */
.madola-output .madola-pair-table {
    /* Align with .math-expression.align-expression (0.25in) minus 10px cell padding */
    margin-left: calc(0.25in - 10px);
}

.madola-output .graph-container {
    margin: 30px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Ensure legacy graph renderers (graph0, graph1, etc.) shrink with the panel */
.madola-output .graph-container > div[id^="graph"] {
    width: 100%;
}

.madola-output .graph-container > div[id^="graph"] svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.madola-output .graph-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #2c3e50;
    text-align: center;
}

/* svg() function output: scale to fit the panel width (capped at 480px) while
   keeping the viewBox's aspect ratio. The cap matters for portrait diagrams
   (e.g. a beam cross-section) - without it, a panel much wider than the
   drawing is tall stretches the SVG to fill that width, blowing up the height
   and the whitespace around the actual content along with it. */
.madola-output .svg-container {
    width: 100%;
    max-width: 480px;
    box-sizing: border-box;
    overflow: hidden;
}

.madola-output .svg-container svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.madola-output .web-graph {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.madola-output .web-graph svg {
    width: 100%;
    height: auto;
    display: block;
    max-width: 100%;
}

.madola-output .axis { stroke: #333; }
.madola-output .grid line { stroke: #ddd; stroke-dasharray: 2,2; }
.madola-output .line { fill: none; stroke: #3498db; stroke-width: 2px; }
.madola-output .dot { fill: #3498db; }

.madola-output .variable-assignment {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

.madola-output .function-definition {
    background: #d4edda;
    border-left: 4px solid #28a745;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.madola-output .output-line {
    background: #f8f9fa;
    border-left: 4px solid #6c757d;
    padding: 10px;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
    border-radius: 4px;
}

/* MathJax Styling */
.madola-output mjx-math {
    font-weight: normal !important;
    font-size: 95% !important;
}

.madola-output mjx-container {
    font-weight: normal !important;
    font-size: 95% !important;
}

.madola-output mjx-container[display="true"] {
    text-align: left !important;
}

.madola-output .MathJax_Display {
    text-align: left !important;
}

/*
   Tighten spacing for display math placed inside table cells.
   MathJax's display containers add vertical margins by default (~0.75em).
   This creates large row heights when we render two-column layouts using
   tables. Limit the override strictly to tables to keep block equations
   elsewhere unaffected.
*/
.madola-output table mjx-container[display="true"] {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Ensure the display container doesn't expand the row vertically */
.madola-output table td mjx-container[display="true"] {
    display: inline-block !important; /* behave like inline equation inside cells */
    vertical-align: middle;
}

/* Reduce any extra padding that MathJax might inject within the math box */
.madola-output table td mjx-container[display="true"] mjx-math {
    line-height: 1.1; /* slightly compact but readable */
}

/* Ensure any HTML text we render in the right column (
   headings or paragraphs injected by @h1-@h4/@p) lines up
   with the math baseline by removing default margins/padding
   and aligning them vertically to middle. */
.madola-output table td > h1,
.madola-output table td > h2,
.madola-output table td > h3,
.madola-output table td > h4,
.madola-output table td > p {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.1; /* match math line-height above */
    vertical-align: middle;
    display: inline-block; /* allow vertical-align to take effect */
}

/* Keep right-column paragraph styling (white-space: pre-wrap) intact */
.madola-output table td > p[style] {
    white-space: pre-wrap !important;
}

/* Data table styles for table() function output */
.madola-output .table-container {
    margin: 20px 0;
    overflow-x: auto;
}

.madola-output .data-table {
    border-collapse: collapse;
    width: auto;
    min-width: 300px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    margin-left: 0.25in;
}

.madola-output .data-table thead {
    background: #3498db;
    color: white;
}

.madola-output .data-table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #2980b9;
}

.madola-output .data-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
}

.madola-output .data-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.madola-output .data-table tbody tr:hover {
    background-color: #e8f4fc;
}

.madola-output .data-table td {
    padding: 6px 12px;
    text-align: right;
}

/* Print styles for PDF output */
@media print {
    .madola-output {
        padding: 0;
        margin: 0;
        background-color: white;
    }

    .madola-output .container {
        max-width: 100%;
        padding: 15px;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
    }

    /* Hide source code blocks */
    .madola-output .madola-code {
        display: none !important;
    }

    /* Hide graph container borders and backgrounds for cleaner print */
    .madola-output .graph-container {
        border: none;
        background: white;
        box-shadow: none;
        page-break-inside: avoid;
    }

    /* Ensure graphs print well */
    .madola-output .graph-container svg {
        max-width: 100%;
        height: auto;
    }

    @page {
        margin: 0.5in;
        size: A4;
    }
}
