/* Copyright (c) 2026 Yuheng. All rights reserved. Unauthorised copying, reuse or redistribution is not permitted. */
/* ==========================================
   CIRCUIT LAB: 2D / 3D VIEW
   The segmented switch in the toolbar and the 3D scene that fades in over the flat board.
   The scene itself reuses the .b3d look of the PC builder's 3D case.
========================================== */

.cl-view-switch {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    padding: 3px;
    border: 1px solid var(--t-border-dce4f0);
    border-radius: 12px;
    background: var(--t-surface-f7f9fc);
}

.cl-view-switch::before {
    content: "";
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc(50% - 3px);
    border-radius: 9px;
    background: linear-gradient(135deg, #4C82DA, #2F5FB8);
    box-shadow: 0 4px 12px rgba(47, 95, 184, 0.35);
    transition: transform 0.42s cubic-bezier(0.3, 1.45, 0.5, 1);
}

.cl-view-switch[data-view="3d"]::before {
    transform: translateX(100%);
}

.cl-view-button {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 62px;
    padding: 6px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--t-text-7b8798);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: color 0.25s ease;
}

.cl-view-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.5s cubic-bezier(0.3, 1.45, 0.5, 1);
}

.cl-view-button[aria-pressed="true"] {
    color: #FFFFFF;
}

.cl-view-button[aria-pressed="true"] svg {
    transform: rotate(-12deg) scale(1.08);
}

.cl-view-button:not([aria-pressed="true"]):hover {
    color: var(--t-text-3f72c5);
}

.cl-view-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.cl-view-button:focus-visible {
    outline: 2px solid var(--t-text-3f72c5);
    outline-offset: 2px;
}

/* the 3D scene sits over the flat board */

.c3d-host {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.c3d-host.is-live {
    pointer-events: auto;
}

.c3d-host .b3d {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 0;
    transform: scale(1.015);
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.c3d-host .b3d.is-shown {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.c3d-host.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 3px solid rgba(76, 130, 218, 0.25);
    border-top-color: #4C82DA;
    border-radius: 50%;
    animation: c3d-spin 0.8s linear infinite;
}

@keyframes c3d-spin {
    to { transform: rotate(360deg); }
}

.cl-board {
    transition: opacity 0.5s ease;
}

.cl-workspace.is-view3d .cl-board {
    opacity: 0;
    pointer-events: none;
}

.cl-workspace.is-view3d .cl-zoom-view,
.cl-workspace.is-view3d .cl-stage-hint {
    display: none;
}

.c3d .b3d-badge span.c3d-hint {
    transition: opacity 0.9s ease, max-height 0.9s ease;
    max-height: 40px;
}

.c3d .b3d-badge span.c3d-hint.is-faded {
    opacity: 0;
    max-height: 0;
}

.c3d .b3d-tip {
    left: 0;
    top: 0;
    line-height: 1.35;
}

.c3d .b3d-tip span {
    color: #8F99AB;
    font-size: 11.5px;
    font-weight: 600;
}

.c3d .b3d-pill button[aria-pressed="true"] {
    background: rgba(139, 188, 255, 0.18);
    color: #8BBCFF;
}

@media (max-width: 760px) {
    .c3d .b3d-controls .b3d-wide span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cl-view-switch::before,
    .cl-view-button svg,
    .c3d-host .b3d {
        transition-duration: 0.01s;
    }
}
