/* Hydrogen Cost Explorer (teaching model) — scoped styles */

#h2-cost-explorer {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-size: 14px;

    /* Categorical palette (validated light-mode slots, fixed order) */
    --h2c-series-1: #2a78d6;  /* blue    */
    --h2c-series-2: #eb6834;  /* orange  */
    --h2c-series-3: #1baf7a;  /* aqua    */
    --h2c-series-4: #eda100;  /* yellow  */
    --h2c-series-5: #e87ba4;  /* magenta */
    --h2c-series-6: #008300;  /* green   */

    --h2c-surface: #ffffff;
    --h2c-ink: #2d2d2d;
    --h2c-ink-muted: #6b7280;
    --h2c-line: #e5e7eb;
    --h2c-grid: #eeeeee;
    --h2c-accent: #1d4ed8;
}

#h2-cost-explorer h2 {
    margin-bottom: 8px;
    font-size: 1.8em;
}
#h2-cost-explorer > p.h2c-intro {
    margin-bottom: 16px;
    line-height: 1.6;
    color: #444;
}

/* ── Scenario tabs ───────────────────────────────────────────────────────── */
#h2-cost-explorer .h2c-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    border-bottom: 2px solid var(--h2c-line);
    padding-bottom: 8px;
    margin-bottom: 14px;
}
#h2-cost-explorer .h2c-tab {
    background: #f5f6f7;
    border: 1px solid var(--h2c-line);
    border-radius: 6px 6px 0 0;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--h2c-ink);
    display: flex;
    align-items: center;
    gap: 8px;
}
#h2-cost-explorer .h2c-tab:hover { background: #ebedef; }
#h2-cost-explorer .h2c-tab.active {
    background: var(--h2c-surface);
    border-color: var(--h2c-accent);
    border-bottom-color: var(--h2c-surface);
    color: var(--h2c-accent);
    font-weight: 600;
}
#h2-cost-explorer .h2c-tab-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex: none;
}
#h2-cost-explorer .h2c-tab-close {
    border: none;
    background: none;
    color: var(--h2c-ink-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
#h2-cost-explorer .h2c-tab-close:hover { color: #c62828; }
#h2-cost-explorer .h2c-tab-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}
#h2-cost-explorer .h2c-btn {
    background: var(--h2c-surface);
    border: 1px solid var(--h2c-accent);
    color: var(--h2c-accent);
    border-radius: 6px;
    padding: 6px 11px;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
}
#h2-cost-explorer .h2c-btn:hover { background: var(--h2c-accent); color: #fff; }
#h2-cost-explorer .h2c-btn-plain { border-color: #bbb; color: #555; }
#h2-cost-explorer .h2c-btn-plain:hover { background: #555; border-color: #555; }

/* ── Input boxes ─────────────────────────────────────────────────────────── */
#h2-cost-explorer .h2c-boxes {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
#h2-cost-explorer .h2c-box {
    border: 1px solid var(--h2c-line);
    border-radius: 6px;
    overflow: hidden;
}
#h2-cost-explorer .h2c-box-header {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    background: #f7f8f9;
    border-left: 4px solid var(--h2c-box-color, var(--h2c-accent));
}
#h2-cost-explorer .h2c-box-header:hover { background: #f0f1f3; }
#h2-cost-explorer .h2c-box-header h3 {
    margin: 0;
    font-size: 14.5px;
}
#h2-cost-explorer .h2c-box-badge {
    margin-left: auto;
    font-size: 12px;
    color: var(--h2c-ink-muted);
    text-align: right;
    line-height: 1.35;
}
#h2-cost-explorer .h2c-collapse-icon {
    font-size: 14px;
    color: var(--h2c-ink-muted);
    transition: transform 0.2s;
}
#h2-cost-explorer .h2c-collapse-icon.collapsed { transform: rotate(-90deg); }
#h2-cost-explorer .h2c-box-body {
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 18px;
}
#h2-cost-explorer .h2c-box-body.collapsed { display: none; }
#h2-cost-explorer .h2c-box-note {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--h2c-ink-muted);
    line-height: 1.5;
    margin: 0 0 2px;
}
/* ── Stage locking ───────────────────────────────────────────────────────── */
/* Stage-2 parameters and views stay on the page, visibly out of reach, so the
   class can see what is coming without being able to run ahead. */
#h2-cost-explorer .h2c-lock-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #ececec;
    color: #6f6f6f;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
    white-space: nowrap;
    vertical-align: middle;
}
#h2-cost-explorer .h2c-box-locked .h2c-box-header {
    cursor: default;
    background: #fafafa;
}
#h2-cost-explorer .h2c-box-locked .h2c-box-header:hover { background: #fafafa; }
#h2-cost-explorer .h2c-box-locked .h2c-collapse-icon,
#h2-cost-explorer .h2c-box-locked h3 { opacity: 0.45; }
#h2-cost-explorer .h2c-field-locked { opacity: 0.45; pointer-events: none; }
#h2-cost-explorer .h2c-field-locked input,
#h2-cost-explorer .h2c-field-locked select { background: #f2f2f2; color: #767676; }

/* ── Fixed parameters ────────────────────────────────────────────────────── */
/* Sizing the model holds constant, so a chain is scaled by how many units it
   has rather than by two levers at once. The value stays fully legible: it is
   information the student needs, not a gap in the form. */
#h2-cost-explorer .h2c-fixed-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 9px;
    background: #eef1f5;
    color: #6b7785;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    vertical-align: middle;
}
#h2-cost-explorer .h2c-field-fixed input[type="number"],
#h2-cost-explorer .h2c-field-fixed select {
    background: #f4f5f7;
    color: #55606c;
    border-style: dashed;
    cursor: default;
}

#h2-cost-explorer .h2c-mode-btn:disabled {
    opacity: 0.45;
    cursor: default;
    background: #f5f5f5;
}
#h2-cost-explorer .h2c-mode-btn:disabled:hover { background: #f5f5f5; }
#h2-cost-explorer .h2c-stage-note {
    display: inline-block;
    align-self: center;
    margin-left: 4px;
    max-width: 420px;
    color: var(--h2c-ink-muted);
    font-size: 11.5px;
    line-height: 1.4;
}

#h2-cost-explorer .h2c-stage-open {
    color: #1a7f37;
    font-weight: 600;
}

#h2-cost-explorer .h2c-field-section {
    grid-column: 1 / -1;
    margin: 10px 0 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--h2c-line);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--h2c-ink-muted);
}
#h2-cost-explorer .h2c-field-section:first-of-type { margin-top: 2px; }
#h2-cost-explorer .h2c-field label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    margin-bottom: 3px;
}
#h2-cost-explorer .h2c-field-unit { color: var(--h2c-ink-muted); font-weight: 400; }
#h2-cost-explorer .h2c-field input[type="number"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}
#h2-cost-explorer .h2c-field input[type="number"]:focus {
    outline: none;
    border-color: var(--h2c-accent);
}
#h2-cost-explorer .h2c-help {
    display: block;
    font-size: 11px;
    color: #8a8a8a;
    line-height: 1.4;
    margin-top: 2px;
}

/* ── Results ─────────────────────────────────────────────────────────────── */
#h2-cost-explorer .h2c-section-title {
    font-size: 15px;
    font-weight: 700;
    margin: 24px 0 10px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--h2c-line);
}
#h2-cost-explorer .h2c-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    margin: 12px 0 4px;
}
#h2-cost-explorer .h2c-hero-value {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--h2c-ink);
}
#h2-cost-explorer .h2c-hero-label {
    font-size: 13px;
    color: var(--h2c-ink-muted);
}
#h2-cost-explorer .h2c-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}
#h2-cost-explorer .h2c-metric {
    background: #f7f8f9;
    border-left: 4px solid var(--h2c-accent);
    border-radius: 4px;
    padding: 9px 12px;
}
#h2-cost-explorer .h2c-metric-label {
    font-size: 10.5px;
    color: var(--h2c-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
#h2-cost-explorer .h2c-metric-value {
    font-size: 16px;
    font-weight: 700;
    margin-top: 2px;
}
#h2-cost-explorer .h2c-note {
    border-left: 4px solid var(--h2c-series-1);
    background: #f2f7fd;
    padding: 10px 12px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 12.5px;
    line-height: 1.6;
}
#h2-cost-explorer .h2c-note.warn {
    border-left-color: #f9a825;
    background: #fff8e1;
}
#h2-cost-explorer .h2c-note.bad {
    border-left-color: #c62828;
    background: #ffebee;
}
#h2-cost-explorer .h2c-note ul { margin: 4px 0 0 18px; padding: 0; }
#h2-cost-explorer .h2c-note li { margin: 2px 0; }

#h2-cost-explorer .h2c-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
}
#h2-cost-explorer .h2c-chart-box { min-width: 0; }
#h2-cost-explorer .h2c-chart-title {
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 2px;
}
#h2-cost-explorer .h2c-chart-sub {
    font-size: 11.5px;
    color: var(--h2c-ink-muted);
    margin-bottom: 8px;
}
#h2-cost-explorer .h2c-chart-container { height: 330px; }

#h2-cost-explorer table.h2c-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    margin: 10px 0;
}
#h2-cost-explorer table.h2c-table th {
    background: #f7f8f9;
    text-align: right;
    padding: 7px 9px;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
}
#h2-cost-explorer table.h2c-table th:first-child { text-align: left; }
#h2-cost-explorer table.h2c-table td {
    padding: 6px 9px;
    border-bottom: 1px solid #f0f0f0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
#h2-cost-explorer table.h2c-table td:first-child { text-align: left; }
#h2-cost-explorer table.h2c-table tr.h2c-row-total td {
    font-weight: 700;
    border-top: 2px solid #ccc;
    background: #fbfbfb;
}
#h2-cost-explorer table.h2c-table tr.h2c-row-sub td:first-child { padding-left: 20px; color: #555; }
#h2-cost-explorer .h2c-swatch {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    margin-right: 6px;
}
#h2-cost-explorer details.h2c-method {
    margin: 18px 0 6px;
    border: 1px solid var(--h2c-line);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 12.5px;
    line-height: 1.65;
}
#h2-cost-explorer details.h2c-method summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
}
#h2-cost-explorer details.h2c-method ul { margin: 6px 0 6px 18px; padding: 0; }
#h2-cost-explorer details.h2c-method code {
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

@media (max-width: 700px) {
    #h2-cost-explorer .h2c-box-body { grid-template-columns: 1fr; }
    #h2-cost-explorer .h2c-metrics  { grid-template-columns: 1fr; }
}

/* ── Flow diagram ────────────────────────────────────────────────────────── */
#h2-cost-explorer .h2c-flow-svg {
    width: 100%;
    height: auto;
    display: block;
}
#h2-cost-explorer .h2c-flow-svg text {
    font-family: inherit;
    text-anchor: middle;
}
#h2-cost-explorer .h2c-flow-cap {
    font-size: 11px;
    fill: var(--h2c-ink-muted);
}
#h2-cost-explorer .h2c-flow-name {
    font-size: 12.5px;
    font-weight: 600;
    fill: var(--h2c-ink);
}
#h2-cost-explorer .h2c-flow-foot {
    font-size: 11px;
    fill: var(--h2c-ink-muted);
}
#h2-cost-explorer .h2c-flow-flag {
    font-size: 11px;
    font-weight: 700;
    fill: #c62828;
}
/* Left-hand scale: how much of the capacity is used, how much is idle.
   Needs the element selector to beat the `.h2c-flow-svg text` centring rule. */
#h2-cost-explorer .h2c-flow-svg text.h2c-flow-axis {
    font-size: 11px;
    text-anchor: end;
}
#h2-cost-explorer .h2c-flow-bracket-used {
    stroke: #2a78d6;
    stroke-width: 1.5;
}
#h2-cost-explorer .h2c-flow-bracket-used-text {
    fill: #2a78d6;
    font-weight: 600;
    stroke: none;
}
#h2-cost-explorer .h2c-flow-bracket-idle {
    stroke: #b0b6bd;
    stroke-width: 1.5;
}
#h2-cost-explorer .h2c-flow-bracket-idle-text {
    fill: var(--h2c-ink-muted);
    stroke: none;
}
#h2-cost-explorer .h2c-flow-guide {
    stroke: #9ec5f4;
    stroke-width: 1;
}
#h2-cost-explorer .h2c-flow-arrow {
    fill: #ffffff;
    opacity: 0.9;
}
#h2-cost-explorer .h2c-flow-legend-hint { font-style: italic; }
#h2-cost-explorer .h2c-flow-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    font-size: 11.5px;
    color: var(--h2c-ink-muted);
    margin-top: 4px;
}
#h2-cost-explorer .h2c-flow-legend span span { vertical-align: middle; }
#h2-cost-explorer .h2c-flow-key {
    display: inline-block;
    width: 22px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
}
#h2-cost-explorer .h2c-flow-key-hatch {
    background: repeating-linear-gradient(45deg, #b9bec4 0 2.5px, #ffffff 2.5px 6px);
    border: 1px solid #dde1e5;
}
#h2-cost-explorer .h2c-flow-empty {
    font-size: 12.5px;
    color: var(--h2c-ink-muted);
    margin: 8px 0;
}

/* Flow diagrams: one per configuration, stacked in one view */
#h2-cost-explorer .h2c-flow-defs {
    position: absolute;
    width: 0;
    height: 0;
}
#h2-cost-explorer .h2c-flow-item { margin-bottom: 10px; }
#h2-cost-explorer .h2c-flow-caption {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    font-size: 12.5px;
    margin-bottom: -6px;
}
#h2-cost-explorer .h2c-flow-caption-name { font-weight: 600; }
#h2-cost-explorer .h2c-flow-caption-meta { color: var(--h2c-ink-muted); font-size: 11.5px; }
#h2-cost-explorer .h2c-flow-caption-short { color: #c62828; font-weight: 600; }

/* The unmet-demand alert sits above everything else */
#h2-cost-explorer .h2c-alert-card {
    margin: 4px 0 18px;
    font-size: 13px;
}

/* ── Result modes ────────────────────────────────────────────────────────── */
#h2-cost-explorer .h2c-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 18px 0 4px;
}
#h2-cost-explorer .h2c-mode-btn {
    background: #f5f6f7;
    border: 1px solid var(--h2c-line);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    color: var(--h2c-ink);
    cursor: pointer;
}
#h2-cost-explorer .h2c-mode-btn:hover { background: #ebedef; }
#h2-cost-explorer .h2c-mode-btn.active {
    background: var(--h2c-accent);
    border-color: var(--h2c-accent);
    color: #fff;
    font-weight: 600;
}
#h2-cost-explorer #h2c-learning-box .h2c-box { margin-bottom: 0; }
#h2-cost-explorer select {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    background: #fff;
}

/* ── Projection figures, one per configuration ───────────────────────────── */
#h2-cost-explorer .h2c-future-figure {
    border-top: 1px solid var(--h2c-line);
    padding-top: 12px;
    margin-top: 16px;
}
#h2-cost-explorer .h2c-future-figure-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    font-size: 12.5px;
    margin-bottom: 6px;
}
#h2-cost-explorer .h2c-future-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
#h2-cost-explorer .h2c-chart-small { height: 240px; }
@media (max-width: 700px) {
    #h2-cost-explorer .h2c-future-pair { grid-template-columns: 1fr; }
}

/* Legends for the paired projection figures, kept out of the canvas so both
   charts in a pair keep the same plot height */
#h2-cost-explorer .h2c-mini-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    font-size: 10.5px;
    color: var(--h2c-ink);
    margin-top: 6px;
    min-height: 28px;
    align-content: flex-start;
}
#h2-cost-explorer .h2c-mini-key {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    margin-right: 5px;
}

#h2-cost-explorer .h2c-mini-key-dash {
    background: repeating-linear-gradient(90deg, #3f3f3d 0 5px, transparent 5px 8px);
    border-radius: 0;
    height: 3px;
    width: 16px;
    margin-bottom: 2px;
}

/* Deployment reference figures inside the learning box */
#h2-cost-explorer .h2c-deploy-figs {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--h2c-line);
}
#h2-cost-explorer .h2c-deploy-title {
    font-size: 11.5px;
    font-weight: 600;
    margin-bottom: 2px;
}
#h2-cost-explorer .h2c-deploy-canvas { height: 130px; }
#h2-cost-explorer .h2c-deploy-note {
    grid-column: 1 / -1;
    font-size: 11px;
    color: var(--h2c-ink-muted);
    line-height: 1.5;
    margin: 2px 0 0;
}
@media (max-width: 700px) {
    #h2-cost-explorer .h2c-deploy-figs { grid-template-columns: 1fr; }
}
