/* Token Waste Reinforcing Loop - layout and styling
   Fixed-height column: title row with loop and zoom buttons, legend, the
   vis-network canvas, shared infobox panel. The height of <main> must equal
   the CANVAS_HEIGHT comment in token-waste-reinforcing-loop.js. */

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
}

main {
    box-sizing: border-box;
    height: 560px;
    display: flex;
    flex-direction: column;
    background-color: aliceblue;
    border: 1px solid silver;
    overflow: hidden;
}

.sim-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    padding: 8px 14px 0 14px;
}

.sim-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: normal;
    color: #111;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
}

.controls .group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.controls button {
    font-size: 15px;
    padding: 3px 10px;
    cursor: pointer;
    border: 1px solid #64748b;
    border-radius: 4px;
    background-color: white;
    color: #111;
}

.controls button[aria-pressed="true"] {
    font-weight: bold;
    box-shadow: inset 0 0 0 2px #111;
}

.controls .loop-button.r {
    border-color: #c62828;
    color: #8e1b1b;
}

.controls .loop-button.b {
    border-color: #1565c0;
    color: #0d3c78;
}

.controls .loop-button.r[aria-pressed="true"] {
    background-color: #ffebee;
    box-shadow: inset 0 0 0 2px #c62828;
}

.controls .loop-button.b[aria-pressed="true"] {
    background-color: #e3f2fd;
    box-shadow: inset 0 0 0 2px #1565c0;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
    padding: 6px 14px 0 14px;
    font-size: 14px;
    color: #334155;
}

.swatch {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
    width: 24px;
    height: 0;
    border-top: 4px solid #37474f;
}

.swatch.r {
    border-top-color: #c62828;
}

.swatch.b {
    border-top-color: #1565c0;
}

/* The vis-network canvas needs an explicit height */
.network {
    flex: 0 0 auto;
    height: 300px;
    width: 100%;
}

/* Shared infobox panel below the diagram */
.infobox {
    flex: 1 1 auto;
    padding: 9px 14px;
    background-color: white;
    border-top: 1px solid silver;
    font-size: 15px;
    line-height: 1.35;
    color: #1f2937;
    overflow: hidden;
}

.infobox h2 {
    margin: 0 0 4px 0;
    font-size: 18px;
    color: #111827;
}

.infobox h2.R {
    color: #c62828;
}

.infobox h2.B {
    color: #1565c0;
}

.infobox h2 .sign {
    font-weight: normal;
}

.infobox p {
    margin: 0 0 5px 0;
}

.infobox .label {
    font-weight: bold;
}

.infobox .note {
    color: #475569;
}

/* One change traced around the selected loop */
.trace .step {
    white-space: nowrap;
    padding: 0 3px;
    border-radius: 3px;
}

.trace .step.up {
    background-color: #e8f5e9;
}

.trace .step.down {
    background-color: #fff3e0;
}

.trace .then {
    color: #64748b;
}

/* Medium iframes, including the usual width of a chapter page: the buttons
   wrap under the title, so the legend and the canvas give up some height */
@media (max-width: 860px) {
    .legend .sign-key {
        display: none;
    }
    .network {
        height: 260px;
    }
}

/* Narrow iframes */
@media (max-width: 640px) {
    .sim-header h1 {
        font-size: 18px;
    }
    .controls button {
        font-size: 13px;
        padding: 3px 8px;
    }
    .legend {
        font-size: 12px;
        gap: 1px 10px;
        padding-top: 4px;
    }
    .legend .sign-key {
        display: none;
    }
    .network {
        height: 240px;
    }
    .infobox {
        font-size: 13px;
        line-height: 1.3;
        padding: 6px 10px;
    }
    .infobox h2 {
        font-size: 15px;
    }
    .infobox p {
        margin-bottom: 4px;
    }
    .trace .step {
        white-space: normal;
    }
}
