/*
 * bar-chart-builder — SVG bar chart with draggable bars. Read off
 * values, build from data, or solve a "match the target chart"
 * challenge. Y-axis scale (yStep) configurable for the "choosing a
 * scale" lesson.
 */

.maths-activity .bcb-stage {
    background: #fffaf0;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 0.75rem 0.5rem 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(20, 40, 80, 0.05);
}

.maths-activity .bcb-svg {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 420px;
    aspect-ratio: 720 / 380;
    display: block;
    margin: 0 auto;
    user-select: none;
    touch-action: none;
}

.maths-activity .bcb-axis {
    stroke: #1b5e20;
    stroke-width: 2;
    stroke-linecap: round;
}

.maths-activity .bcb-grid-line {
    stroke: #1b5e20;
    stroke-width: 1;
    opacity: 0.18;
}

.maths-activity .bcb-tick-label {
    fill: #1f2937;
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    font-size: 13px;
    text-anchor: end;
    dominant-baseline: central;
}

.maths-activity .bcb-cat-label {
    fill: #1f2937;
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    font-size: 13px;
    text-anchor: middle;
}

.maths-activity .bcb-axis-label {
    fill: var(--maths-primary-dark, #1b5e20);
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.maths-activity .bcb-axis-label-x { text-anchor: middle; }

.maths-activity .bcb-bar {
    cursor: grab;
    transition: filter 120ms ease-out;
}

.maths-activity .bcb-bar:hover { filter: brightness(1.08); }
.maths-activity .bcb-bar:active,
.maths-activity .bcb-bar.bcb-dragging { cursor: grabbing; }
.maths-activity .bcb-bar:focus { outline: none; filter: drop-shadow(0 0 4px var(--maths-primary, #2E7D32)); }

.maths-activity .bcb-bar-rect-1 { fill: #d84315; }
.maths-activity .bcb-bar-rect-2 { fill: #1565c0; }
.maths-activity .bcb-bar-rect-3 { fill: #2E7D32; }
.maths-activity .bcb-bar-rect-4 { fill: #f9a825; }
.maths-activity .bcb-bar-rect-5 { fill: #6a1b9a; }
.maths-activity .bcb-bar-rect-6 { fill: #00838f; }

.maths-activity .bcb-bar-handle {
    fill: rgba(255, 255, 255, 0.75);
    stroke: #1f2937;
    stroke-width: 1.5;
}

.maths-activity .bcb-bar-value {
    fill: #1f2937;
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 13px;
    text-anchor: middle;
    pointer-events: none;
}

/* Key / legend — shown only for grouped (multiple) bar charts. */
.maths-activity .bcb-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 1.1rem;
    margin: 0.1rem auto 0.6rem;
    padding: 0.4rem 0.75rem;
}

.maths-activity .bcb-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: #1f2937;
}

.maths-activity .bcb-legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex: 0 0 auto;
    box-shadow: 0 1px 2px rgba(20, 40, 80, 0.18);
}

/* The swatch reuses the bar fill classes (fill: is for SVG; set background
 * too so the HTML legend swatch shows the same colour). */
.maths-activity .bcb-legend-swatch.bcb-bar-rect-1 { background: #d84315; }
.maths-activity .bcb-legend-swatch.bcb-bar-rect-2 { background: #1565c0; }
.maths-activity .bcb-legend-swatch.bcb-bar-rect-3 { background: #2E7D32; }
.maths-activity .bcb-legend-swatch.bcb-bar-rect-4 { background: #f9a825; }
.maths-activity .bcb-legend-swatch.bcb-bar-rect-5 { background: #6a1b9a; }
.maths-activity .bcb-legend-swatch.bcb-bar-rect-6 { background: #00838f; }

.maths-activity .bcb-average-line {
    stroke: #1b5e20;
    stroke-width: 2;
    stroke-dasharray: 6 4;
    opacity: 0.7;
}

.maths-activity .bcb-average-label {
    fill: #1b5e20;
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 12px;
    text-anchor: end;
}

.maths-activity .bcb-mode-chip {
    display: inline-block;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    margin-top: 0.25rem;
}

.maths-activity .bcb-target-label {
    font-weight: 800;
    color: #8d4e0b;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.maths-activity .bcb-target-prompt { flex: 1; font-weight: 700; color: #1f2937; }

.maths-activity .bcb-your-turn {
    margin-top: 1.25rem;
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 14px;
    padding: 1rem 1.25rem;
}

.maths-activity .bcb-your-turn-label {
    font-weight: 800;
    color: #33691e;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.maths-activity .bcb-your-turn-list {
    margin: 0;
    padding-left: 1.25rem;
    color: #1f2937;
    font-weight: 600;
}

.maths-activity .bcb-your-turn-list li { margin-bottom: 0.25rem; }

/* Display mode — hide controls, lock interaction */

/* Display mode — read-only chart. Bars are locked, drag handles
 * hidden, target panel / callout / challenge runner all hidden. The
 * SVG max-height is capped so the chart doesn't dominate the lesson
 * page. Your-turn prompts stay — those are display-only discussion
 * prompts.
 */
body.display-mode .bcb-target-panel,
body.display-mode .bcb-callout,
body.display-mode #challengeRunner { display: none !important; }

body.display-mode .bcb-bar { cursor: default !important; pointer-events: none; }
body.display-mode .bcb-bar-handle { display: none; }

body.display-mode .bcb-stage {
    padding: 0.5rem 0.5rem 0.4rem;
    margin-bottom: 0.75rem;
}

body.display-mode .bcb-svg {
    max-height: 280px;
}
