/* INSIDE THE QPU — 3D Lab Stage, Floating Controls, Disclaimer & 3D Callouts */

.lab-stage-layout {
    position: relative;
    display: flex;
    flex: 1 1 0%;
    flex-direction: column;
    min-height: 0;
}

.lab-stage-main {
    position: relative;
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
}

.lab-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.lab-viewport:active {
    cursor: grabbing;
}

.lab-viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    cursor: grab;
}

.lab-viewport canvas.is-hovering-part {
    cursor: pointer;
}

.lab-viewport canvas:active {
    cursor: grabbing;
}

/* Viewport Top & Bottom Badges */
.viewport-badge-lab {
    border-radius: 2px;
    border: 1px solid var(--keycap-border);
    box-shadow: inset 0 -2px 0 var(--keycap-ledger);
}

.viewport-hint-pill {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 20;
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.625rem;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.hover-part-pill {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    max-width: calc(100% - 1.5rem);
    padding: 0.25rem 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: inset 0 -2px 0 var(--lab-accent), 0 4px 12px rgba(0, 0, 0, 0.22);
    pointer-events: none;
}

/* Top-Right Educational Disclaimer Keycap & Popover */
.disclaimer-wrap {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 25;
    transition: opacity 0.15s ease;
}

.disclaimer-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.625rem;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-secondary);
}

.disclaimer-btn[aria-expanded="true"] {
    border-color: var(--lab-accent);
    box-shadow: inset 0 -2px 0 var(--lab-accent), var(--keycap-shadow);
    color: var(--text-primary);
}

.disclaimer-icon {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
    color: var(--lab-accent-text);
}

.disclaimer-popover {
    display: none;
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    width: min(304px, calc(100vw - 1.5rem));
    padding: 0.75rem 0.875rem;
    border-radius: 3px;
    border: 1px solid var(--keycap-border);
    border-top: 2px solid var(--lab-accent);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
}

.disclaimer-popover.is-open {
    display: block;
    animation: fadeSlideIn 0.16s var(--ease-lab);
}

.disclaimer-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.disclaimer-popover-title {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.disclaimer-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
}

.disclaimer-close-icon {
    width: 0.75rem;
    height: 0.75rem;
}

.disclaimer-popover-body {
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.disclaimer-popover-body strong {
    color: var(--text-primary);
}

/* Floating Bottom Viewport Controls & Scale Badge */
.viewport-controls-bar {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 20;
    display: flex;
    flex-wrap: wrap-reverse;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    pointer-events: none;
}

.viewport-controls-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.pulse-trigger-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1rem;
    color: var(--text-primary);
}

.pulse-trigger-key {
    display: none;
    font-size: 10px;
    opacity: 0.5;
}

.viewport-action-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.625rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1rem;
    color: var(--text-secondary);
}

.scale-note-badge {
    display: none;
    align-items: center;
    gap: 0.375rem;
    margin-left: auto;
    padding: 0.375rem 0.625rem;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

/* WebGL Fallback Notice */
.webgl-fallback-notice {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
}

.webgl-fallback-card {
    max-width: 28rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.webgl-fallback-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--lab-accent-text);
}

.webgl-fallback-body {
    font-size: 0.75rem;
    line-height: 1.625;
    color: var(--text-secondary);
}

/* 3D CSS2D Overlay Layer, Interactive Numbered Pins & Temperature Labels */
.lab-label-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.lab-3d-pin {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 2px;
    border-radius: 9999px;
    background: var(--label-bg);
    border: 1px solid var(--border-strong);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.30);
    cursor: pointer;
    user-select: none;
    transition: transform 0.16s var(--ease-lab), border-color 0.16s ease, padding 0.16s ease, gap 0.16s ease;
}

.lab-3d-pin .pin-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 19px;
    height: 19px;
    border-radius: 9999px;
    background: var(--lab-accent);
    color: #080b11;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
}

.lab-3d-pin .pin-name {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-sans);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-primary);
    transition: max-width 0.22s var(--ease-lab), opacity 0.18s ease, padding 0.18s ease;
}

.lab-3d-pin:hover,
.lab-3d-pin.pin-active {
    z-index: 40;
    transform: scale(1.06);
    border-color: var(--lab-accent);
    gap: 5px;
    padding-right: 9px;
}

.lab-3d-pin:hover .pin-name,
.lab-3d-pin.pin-active .pin-name {
    max-width: 320px;
    opacity: 1;
}

.lab-3d-pin.pin-active {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px var(--lab-accent), 0 6px 16px rgba(0, 0, 0, 0.55);
}

.lab-3d-pin.pin-active .pin-num {
    background: #ffffff;
    color: #080b11;
    box-shadow: 0 0 0 1.5px var(--lab-accent);
}

.lab-3d-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--label-bg);
    border: 1px solid var(--border-strong);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    user-select: none;
}

.lab-3d-label .lbl-title {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    white-space: nowrap;
}

.lab-3d-label .lbl-sub {
    font-family: var(--font-sans);
    font-size: 9.5px;
    line-height: 1.2;
    color: var(--text-muted);
    white-space: nowrap;
}

.lab-3d-label.lab-temp-label {
    padding: 2px 6px;
    opacity: 0.92;
}

/* Responsive Breakpoints */
@media (min-width: 640px) {
    .viewport-hint-pill {
        display: flex;
    }
    .pulse-trigger-key {
        display: inline;
    }
}

@media (min-width: 1024px) {
    .lab-stage-layout {
        flex-direction: row;
    }
}

@media (min-width: 1280px) {
    .scale-note-badge {
        display: flex;
    }
}

@media (max-width: 1023px) {
    .viewport-controls-bar {
        bottom: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
    }
}

/* Compact 3D CSS2D labels & pins on narrow mobile viewports */
@media (max-width: 639px) {
    .lab-3d-label {
        padding: 2px 5px;
    }
    .lab-3d-label .lbl-title {
        font-size: 7.5px;
    }
    .lab-3d-label .lbl-sub {
        font-size: 6.8px;
    }
    .lab-3d-label.lab-temp-label {
        padding: 1px 4px;
    }
    .lab-3d-label.lab-temp-label .lbl-title {
        font-size: 8px;
    }
    .lab-3d-pin .pin-num {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

@media (max-height: 500px) {
    .viewport-hint-pill {
        display: none !important;
    }
    .lab-3d-label {
        padding: 2px 5px;
    }
    .lab-3d-label .lbl-title {
        font-size: 7.5px;
    }
    .lab-3d-label .lbl-sub {
        font-size: 6.8px;
    }
    .lab-3d-label.lab-temp-label {
        padding: 1px 4px;
    }
    .lab-3d-label.lab-temp-label .lbl-title {
        font-size: 7.5px;
    }
}
