/* Circuit Lab only — the goals bar, the SVG bench, its parts and its wires.
   Everything else on this page comes from assets/css/game-shell.css. */

.game {
    /* the goals bar above the board and the message line below it */
    --above: 262px;
}

/* ---------- the goals ---------- */
.goals {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    background: var(--tint-warm);
    border-radius: var(--r-md);
    padding: 8px 12px;
    margin-bottom: 10px;
    min-height: 48px;
}
.goal-title {
    margin: 0;
    font-family: "Bricolage Grotesque";
    font-size: 17px;
    font-weight: 700;
}
.goals ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.goals li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 3px 11px 3px 4px;
    font-size: 13.5px;
    font-weight: 600;
    transition:
        background 0.2s,
        border-color 0.2s;
}
.goals li i {
    font-style: normal;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
}
.goals li.done {
    background: #dff6f1;
    border-color: var(--teal);
    color: #0b6b60;
}
.goals li.done i {
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
    animation: tick 0.35s ease-out;
}
.goals li.free {
    padding-left: 11px;
    color: var(--ink-soft);
}
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
@keyframes tick {
    from {
        transform: scale(0.4);
    }
}

.say {
    min-height: 1.5em;
    margin: 10px 4px 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--ink-soft);
}
.say b {
    color: var(--ink);
}
.say[data-tone="warn"] {
    color: #b8391f;
}

/* ---------- the overlay: level picker and two buttons ---------- */
.cl-levels {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 16px auto 0;
    max-width: 380px;
}
.cl-levels button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-family: "Bricolage Grotesque";
    font-size: 18px;
    font-weight: 800;
}
.cl-levels button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}
.cl-levels button[aria-current] {
    background: #fff;
    color: var(--ink);
}
.cl-levels button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.ov-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 18px;
}
.overlay .ov-btns .btn-primary {
    margin-top: 0;
}
.ov-alt[hidden] {
    display: none;
}

/* ---------- the bench ---------- */
.stage svg {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    touch-action: none; /* the finger drags parts and wires, not the page */
    user-select: none;
    -webkit-user-select: none;
}
.tray-bg {
    fill: #f3ebdf;
    stroke: #e2d5c1;
    stroke-width: 2;
}
.tray-title {
    font: 500 11px "DM Mono", monospace;
    letter-spacing: 0.08em;
    fill: var(--ink-soft);
}
.tray-empty {
    font: 600 15px Inter, sans-serif;
    fill: var(--ink-soft);
    text-anchor: middle;
}
.drop-here .slot-bg {
    stroke: var(--coral);
    stroke-dasharray: 6 4;
}

/* a slot in the box */
.slot {
    cursor: grab;
}
.slot-bg {
    fill: #fff;
    stroke: #e2d5c1;
    stroke-width: 1.5;
}
.slot:hover .slot-bg {
    stroke: var(--blue);
}
.slot.empty {
    cursor: default;
    opacity: 0.35;
}
.slot.empty:hover .slot-bg {
    stroke: #e2d5c1;
}
.slot-name {
    font: 700 13px Inter, sans-serif;
    fill: var(--ink);
    text-anchor: middle;
}
.slot-count-bg {
    fill: var(--blue);
}
.slot-count {
    font: 800 13px "Bricolage Grotesque", sans-serif;
    fill: #fff;
    text-anchor: middle;
}

/* a part on the bench */
.part {
    cursor: grab;
    outline: none;
}
.part .hit {
    fill: transparent;
}
.part.lifted {
    cursor: grabbing;
    filter: drop-shadow(0 10px 8px rgba(27, 34, 64, 0.25));
}
.part.switch {
    cursor: pointer;
}
.part:focus-visible .hit {
    stroke: var(--blue);
    stroke-width: 3;
    stroke-dasharray: 6 4;
}
.part-name {
    font: 600 12px Inter, sans-serif;
    fill: var(--ink-soft);
    text-anchor: middle;
    pointer-events: none;
}
.glow,
.rays {
    pointer-events: none;
}
.lead {
    stroke: #8f99ad;
    stroke-width: 4;
    stroke-linecap: round;
}

.bat-body {
    fill: #2b2f3a;
    transition: fill 0.2s;
}
.part.hot .bat-body {
    animation: hot 0.5s ease-in-out infinite alternate;
}
@keyframes hot {
    to {
        fill: #d6402a;
    }
}
.bat-sign {
    font: 800 22px Inter, sans-serif;
    fill: #2b2f3a;
    text-anchor: middle;
}
.bat-sign.light {
    fill: #fff;
}
.bat-volts {
    font: 700 13px "DM Mono", monospace;
    fill: #ffc53d;
    text-anchor: middle;
}

.sw-state {
    font: 800 12px "DM Mono", monospace;
    fill: #0b8f80;
    text-anchor: middle;
}
.open .sw-state {
    fill: var(--ink-soft);
}
.lever {
    transform-box: fill-box;
    transform-origin: 0% 50%;
    transition: transform 0.15s ease-out;
}
.open .lever {
    transform: rotate(-32deg);
}

.led-body {
    fill: #9b2c2c;
    stroke: #6e1b1b;
    stroke-width: 2;
}
.led-rim {
    fill: #b83434;
}
/* an LED with too much electricity: flickering, with a warning ring */
.part.burnt .led-body {
    animation: overload 0.18s steps(2) infinite;
}
.part.burnt .led-rim {
    fill: #3a3f52;
}
@keyframes overload {
    50% {
        fill: #fff2c4;
    }
}

.res-ohms {
    font: 700 13px "DM Mono", monospace;
    fill: var(--ink-soft);
    text-anchor: middle;
}

/* the part a level brings in, flagged in the box */
.new-bg {
    fill: var(--coral);
}
.new-txt {
    font: 800 11px Inter, sans-serif;
    letter-spacing: 0.05em;
    fill: #fff;
    text-anchor: middle;
}

.leg-sign {
    font: 800 15px Inter, sans-serif;
    fill: var(--ink);
    text-anchor: middle;
}

/* the metal ends wires clip on to */
.end {
    fill: #e3e7ef;
    stroke: #6b7288;
    stroke-width: 2.5;
    cursor: crosshair;
    transition: r 0.12s;
}
.end.plus {
    stroke: #d6402a;
}
.end.minus {
    stroke: #2b2f3a;
}
.end.target,
.end.pending {
    fill: var(--yellow);
    stroke: var(--ink);
    r: 13;
}
.end.pending {
    animation: blink 0.8s ease-in-out infinite alternate;
}
@keyframes blink {
    to {
        fill: #fff;
    }
}

/* the wires */
.wire {
    cursor: pointer;
}
.wire-hit {
    stroke: transparent;
    stroke-width: 22;
    stroke-linecap: round;
}
.wire-shade {
    stroke: rgba(27, 34, 64, 0.35);
    stroke-width: 8;
    stroke-linecap: round;
    pointer-events: none;
}
.wire-core {
    stroke-width: 5;
    stroke-linecap: round;
    pointer-events: none;
}
.wire:hover .wire-shade {
    stroke: rgba(27, 34, 64, 0.6);
    stroke-width: 10;
}
/* the electricity: little dots running round the loop */
.wire-flow {
    stroke: #fffbe0;
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-dasharray: 0.1 18;
    pointer-events: none;
}
.wire-live {
    stroke: var(--ink);
    stroke-width: 4;
    stroke-dasharray: 8 6;
    stroke-linecap: round;
    pointer-events: none;
    opacity: 0.7;
}

/* ---------- the tall board, for phones ----------
   game.js switches to a 480-wide viewBox below 520px, so parts draw bigger;
   these keep the words and the metal ends a comfortable size on it. */
.narrow .part-name {
    font-size: 15px;
}
.narrow .slot-name {
    font-size: 15px;
}
.narrow .tray-title {
    font-size: 13px;
}
.narrow .end {
    r: 12;
}
.narrow .end.target,
.narrow .end.pending {
    r: 16;
}
.narrow .wire-hit {
    stroke-width: 30;
}

@media (prefers-reduced-motion: reduce) {
    .part.burnt .led-body,
    .part.hot .bat-body,
    .end.pending,
    .goals li.done i {
        animation: none;
    }
    .part.hot .bat-body {
        fill: #d6402a;
    }
}

@media (max-width: 560px) {
    /* the hint goes above the board, where it's seen without scrolling */
    .board-card {
        display: flex;
        flex-direction: column;
    }
    .stage {
        order: 2;
    }
    .say {
        order: 1;
        margin: 0 4px 8px;
        min-height: 2.8em;
    }
    .goals {
        padding: 6px 10px;
        margin-bottom: 8px;
    }
    .goal-title {
        font-size: 15px;
    }
    .goals li {
        font-size: 12.5px;
    }
    .say {
        font-size: 14px;
        line-height: 1.35;
    }
    .overlay {
        padding: 12px;
    }
    .overlay h2 {
        font-size: 22px;
    }
    .overlay p {
        font-size: 13px;
        margin-top: 6px;
    }
    .cl-levels {
        margin-top: 10px;
    }
    .cl-levels {
        gap: 5px;
    }
    .cl-levels button {
        /* all eight on one row, so the start button stays in view */
        width: 30px;
        height: 30px;
        border-radius: 9px;
        font-size: 14px;
    }
    .ov-btns {
        margin-top: 12px;
    }
    .overlay .btn-primary {
        padding: 10px 20px;
    }
}

/* ---------- a level's video, on its intro screen ---------- */
/* The video is as big as the board allows: the stage is a size container,
   so 100cqw is the board's width and 100cqw × --board-aspect its height.
   Take away the title, caption and button (about 170px) and what's left is
   the video's height; ×16/9 gives its width. */
.stage {
    container-type: inline-size;
}
.ov-video {
    width: 100%;
    width: min(100%, calc((100cqw * var(--board-aspect, 0.75) - 170px) * 16 / 9));
    margin: 10px auto 0;
}
/* while a video plays, the intro words (they're in the hint line too) and the
   level buttons (behind "Levels") step aside for it */
.overlay.has-video {
    padding: 12px;
}
.overlay.has-video > div {
    width: 100%;
}
.overlay.has-video h2 {
    font-size: clamp(20px, 3vw, 30px);
}
.overlay.has-video #ovText,
.overlay.has-video .cl-levels {
    display: none;
}
.overlay.has-video .ov-btns {
    margin-top: 10px;
}
.ov-video[hidden] {
    display: none;
}
.ov-video iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: var(--r-sm);
    background: #000;
}
.ov-video figcaption {
    margin-top: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}
/* a short board can't fit the intro words, a video and the buttons — let the
   overlay's card scroll rather than spill off the top */
.overlay > div {
    max-height: 100%;
    overflow-y: auto;
}
