/* --- BRIGISTICS HARDWARE SCANNER --- */

/* Fix clipping from the parent punchcard wrapper */
#brigistics-scanner-hardware {
    overflow: visible !important;
}

#brigistics-scanner-hardware *{
    user-select: none;
}
/* Layout Wrapper for Spheroid Bay */
.bhs-layout-wrapper {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap; 
    padding: 25px 15px; 
    background: #d4d0c8; /* Deep recessed bay in the plastic casing */
    box-shadow: inset 0 3px 10px rgba(0,0,0,0.15);
    user-select: none;
}

/* --- 1. SPHEROID SCREEN (Light Blueprint) --- */
.bhs-screen-bezel {
    background: #c5c1b9;
    padding: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
    box-shadow: 
        inset 0 2px 4px rgba(255,255,255,0.6),
        0 8px 16px rgba(0,0,0,0.25);
    touch-action: none;
}


.bhs-scene {
    position: relative;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    perspective: 800px;
    transform-style: preserve-3d;
    background-color: transparent; /* Keep parent transparent */
    border: 2px solid var(--primary-dim);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
    overflow: hidden;
    cursor: grab;
}

.bhs-backdrop {
    position: absolute;
    inset: -150px; 
    background-color: var(--bg-panel); 
    
    /* SMALLER, DENSER RADIAL PATTERN */
    background-image: 
        /* 1. Center highlight */
        radial-gradient(circle at center, rgba(255,255,255,0.4) 0%, transparent 60%),
        
        /* 2. Dense Rings (Repeats every 15px) */
        repeating-radial-gradient(circle at center, rgba(23, 104, 218, 0.2) 0, rgba(23, 104, 218, 0.2) 1px, transparent 1px, transparent 15px),
        
        /* 3. Dense Spokes (Repeats every 15 degrees) */
        repeating-conic-gradient(from 0deg at 50% 50%, rgba(23, 104, 218, 0.2) 0deg, rgba(23, 104, 218, 0.2) 1deg, transparent 1deg, transparent 15deg);

    opacity: 1; 
    
    /* Lens mask */
    mask-image: radial-gradient(circle, black 20%, transparent 80%);
    -webkit-mask-image: radial-gradient(circle, black 20%, transparent 80%);
    
    pointer-events: none;
    will-change: transform;
}


/* --- SPHERE ELEMENTS (Zero Inset) --- */

/* 250px viewport */
.bhs-ring, 
.bhs-wireframe-ring, 
.bhs-scanner-plane {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0; /* Changed from 4px to 0 */
    border-radius: 50%;
    pointer-events: none;
    transform-style: preserve-3d;
}

.bhs-wireframe-ring { border: 1px solid rgba(23, 104, 218, 0.2); }

/* --- SPHEROID WIREFRAME (Radius = 125px) --- */

/* Latitudes: Recalculated for R=125 using sin/cos of 30° and 60° */
.rib-lat-1 { transform: rotateX(90deg) translateZ(62.5px) scale(0.866); }   /* +30° */
.rib-lat-2 { transform: rotateX(90deg) translateZ(108.25px) scale(0.500); } /* +60° */
.rib-lat-3 { transform: rotateX(90deg) translateZ(-62.5px) scale(0.866); }  /* -30° */
.rib-lat-4 { transform: rotateX(90deg) translateZ(-108.25px) scale(0.500); }/* -60° */

/* Longitudes: 30° increments (unchanged) */
.rib-lon-1 { transform: rotateY(30deg); }
.rib-lon-2 { transform: rotateY(60deg); }
.rib-lon-3 { transform: rotateY(120deg); }
.rib-lon-4 { transform: rotateY(150deg); }

/* --- ANIMATED SCANNER PLANE --- */

.bhs-scanner-plane {
    background: radial-gradient(circle, rgba(241, 135, 1, 0.02) 0%, rgba(241, 135, 1, 0.05) 70%, rgba(241, 135, 1, 0.8) 100%);
    border: 2px solid rgba(241, 135, 1, 0.1);
    box-shadow: 0 0 15px rgba(241, 135, 1, 0.3), inset 0 0 15px rgba(241, 135, 1, 0.1);
    z-index: 10;
    animation: scanSweep 6s linear infinite; /* Added 'alternate' to bounce back and forth smoothly */
}

/* Recalculated keyframes for R=125px */
@keyframes scanSweep {
    0%   { transform: rotateX(90deg) translateZ(-125px) scale(0.01); opacity: 0; }
    5%   { opacity: 1; }
    25%  { transform: rotateX(90deg) translateZ(-88.3px) scale(0.707); } 
    50%  { transform: rotateX(90deg) translateZ(0px) scale(1.02); }   
    75%  { transform: rotateX(90deg) translateZ(88.3px) scale(0.707); }
    95%  { opacity: 1; }
    100% { transform: rotateX(90deg) translateZ(125px) scale(0.01); opacity: 0; }
}

/* Update default sphere state to prevent a visual "jump" on load */
.bhs-sphere {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    transform: translateZ(0px) rotateX(-15deg) rotateY(0deg); /* Changed Z to 0px */
}

.bhs-scene:active { cursor: grabbing; }

/* Holographic Depth Planes */
.bhs-ring {
    position: absolute;
    top: 4px; left: 4px; right: 4px; bottom: 4px;
    border: 1px dashed rgba(23, 104, 218, 0.25);
    border-radius: 50%;
    pointer-events: none; 
}
.ring-x { 
    transform: rotateX(90deg); 
    background: rgba(23, 218, 82, 0.1);
    border: 2px solid rgba(23, 218, 82, 0.15);
}
.ring-y { 
    transform: rotateY(90deg); 
    background: rgba(241, 135, 1, 0.1); 
    border: 2px solid rgba(241, 135, 1, 0.15);
}
.ring-z { 
    transform: rotateZ(0deg); 
    border: 2px solid rgba(23, 104, 218, 0.1);
    background: rgba(23, 104, 218, 0.1); 
}

.bhs-node {
    position: absolute;
    top: 50%; left: 50%;
    border-radius: 50%;
    transform-style: preserve-3d;
    backface-visibility: hidden; 
    cursor: crosshair;
    box-shadow: 0 0 3px currentColor;
    border: 1px solid var(--bg-body);
    transform: translate(-50%, -50%) rotateY(var(--ry)) rotateX(var(--rx)) translateZ(var(--rz));
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bhs-node.targeted {
    box-shadow: 0 0 0 2px var(--bg-body), 0 0 0 4px var(--primary);
    transform: translate(-50%, -50%) rotateY(var(--ry)) rotateX(var(--rx)) translateZ(var(--rz)) scale(2);
    z-index: 100;
}

/* The Hardware Crosshair */
.bhs-crosshair {
    position: absolute;
    top: 50%; left: 50%;
    width: 30px; height: 30px; /* Shrunk */
    transform: translate(-50%, -50%);
    border: 2px solid rgba(23, 104, 218, 0.6); 
    border-radius: 50%;
    pointer-events: none; 
    z-index: 50;
    transition: transform 0.2s, opacity 0.2s, border-color 0.2s;
}
.bhs-crosshair::before, .bhs-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(23, 104, 218, 0.6); 
}
.bhs-crosshair::before { top: 50%; left: -8px; right: -8px; height: 2px; transform: translateY(-50%); }
.bhs-crosshair::after { left: 50%; top: -8px; bottom: -8px; width: 2px; transform: translateX(-50%); }

.bhs-crosshair.locked {
    transform: translate(-50%, -50%) scale(1.2);
    border-color: var(--orange);
}
.bhs-crosshair.locked::before, .bhs-crosshair.locked::after { background: var(--orange); }

/* --- 2. FLEXIBLE READOUT PANEL --- */
.bhs-readout-panel {
    background: var(--bg-panel);
    border: 1px solid var(--primary-dim);
    padding: 15px; /* Shrunk */
    border-radius: 4px;
    
    flex: 1 1 240px; /* Adapts to available space */
    max-width: 100%;
    min-height: 250px;
    max-height: 250px;
    box-sizing: border-box;
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
    overflow: hidden; 
}

.bhs-readout-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.bhs-empty-title {
    color: var(--primary);
    font-family: monospace;
    font-size: 10px;
    margin-bottom: 15px;
    text-align: center;
    letter-spacing: 0.1em;
}
.bhs-empty-subtitle {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: 20px;
    letter-spacing: 0.2em;
    animation: pulseScan 1.5s infinite alternate;
    text-align: center;
}
.bhs-empty-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 80%;
}
.bhs-empty-bar {
    height: 4px;
    background: var(--primary-dim);
    width: 100%;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}
.bhs-empty-bar::after {
    content: '';
    position: absolute;
    top: 0; left: -50%; width: 50%; height: 100%;
    background: var(--primary);
    animation: scanBar 2s linear infinite;
}
.bhs-empty-bar:nth-child(2)::after { animation-delay: 0.6s; }
.bhs-empty-bar:nth-child(3)::after { animation-delay: 1.2s; }

@keyframes scanBar { 0% { left: -50%; } 100% { left: 100%; } }
@keyframes pulseScan { 0% { opacity: 0.3; } 100% { opacity: 1; } }

.bhs-readout-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
    position: relative;
    z-index: 2;
}
.bhs-readout-label {
    font-size: var(--fs-xs);
    color: var(--orange);
    font-family: "Fustat", sans-serif;
    font-weight: 700;
    letter-spacing: 0.1em;
}
.bhs-readout-title {
    font-family: "Libertinus Math", serif;
    color: var(--primary);
    margin: 0;
    line-height: 1.2;
    font-size: 1.2em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.bhs-readout-meta {
    font-family: "Fustat", sans-serif;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
}
.bhs-readout-desc {
    font-family: "Fustat", sans-serif;
    font-size: var(--fs-sm);
    color: var(--text-main);
    margin-bottom: auto; 
    overflow: hidden;
    text-overflow: ellipsis;
}
.bhs-readout-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-shrink: 0;
}
.bhs-readout-actions button {
    flex: 1;
    font-size: var(--fs-xs);
    padding: 8px 5px;
}

#bhs-btn-play {
    background: var(--primary);
    color: var(--bg-body);
}

/* --- 3. TIMELINE BAY --- */
.bhs-timeline-bay {
    background: #e0dcd5; 
    padding: 15px; 
    border-radius: 0 0 4px 4px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Prevents stretching parent */
}





.spacetime-timeline-container {
    /* FIX: display: block restores natural horizontal overflow */
    display: block; 
    overflow-x: auto;
    white-space: nowrap;
    
    /* Reduced padding, 35px protects the angled labels */
    padding: 15px 15px 35px 15px; 
    margin-top: 10px;
    
    width: 100%;
    box-sizing: border-box;
    scrollbar-width: thin;
    
    background-color: var(--bg-body);
    background-image: 
        repeating-linear-gradient(rgba(23, 104, 218, 0.08), rgba(23, 104, 218, 0.08) 1px, transparent 1px, transparent 20px),
        repeating-linear-gradient(90deg, rgba(23, 104, 218, 0.08), rgba(23, 104, 218, 0.08) 1px, transparent 1px, transparent 20px);
    
    border: 1px solid var(--primary-dim);
    border-radius: 4px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.05);
    min-height: 100px;
}

.st-track {
    /* FIX: Inline-flex allows the child elements to push the width beyond 100% */
    display: inline-flex;
    align-items: flex-end;
    gap: 4px; 
    padding-bottom: 2px;
    border-bottom: 2px solid var(--primary);
    min-width: max-content;
    position: relative;
    z-index: 2;
}

.st-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 8px;
    position: relative;
}

.st-spike {
    width: 6px;
    border-radius: 1px 1px 0 0;
    cursor: pointer;
    transition: filter 0.2s, transform 0.1s;
    min-height: 4px;
}

@media(hover: hover){
    .st-spike:hover {
        filter: brightness(1.2);
        transform: scaleY(1.2);
        transform-origin: bottom;
    }
}

.st-spike.active {
    box-shadow: 0 0 0 2px var(--bg-body), 0 0 0 5px var(--orange);
    transform: scaleY(1.4);
    transform-origin: bottom;
    z-index: 10;
}

.st-axis-label {
    position: absolute;
    top: 100%; 
    margin-top: 10px; 
    
    /* Anchor to the horizontal center of the node */
    left: 50%;
    
    /* FIX: Pull the label back by 50% of its own width to center it perfectly.
       This fixes the labels feeling "too far to the right" */
    transform: translateX(-50%);
    
    font-family: "Fustat", monospace;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    pointer-events: none;
}

/* FIX: The first label needs to start at the left edge of the node 
   to prevent it from being pushed off the screen */
.st-axis-label.st-label-first {
    left: 0;
    transform: translateX(0);
}

/* --- TODAY MARKER --- */
.st-today-marker {
    width: 2px;
    height: 0px; /* Anchors it to the bottom of the flex track */
    position: relative;
    z-index: 5;
}

.st-today-tick {
    position: absolute;
    top: 2px; /* Punches through the track's padding and border */
    left: 0;
    width: 2px;
    height: 12px;
    background: var(--orange);
    box-shadow: 0 0 5px var(--orange);
}

.st-today-label {
    position: absolute;
    top: 18px; /* Hangs just below the tick */
    left: 50%;
    transform: translateX(-50%);
    font-family: "Fustat", monospace;
    font-size: 10px;
    font-weight: 700;
    color: var(--orange);
    text-shadow: 0 0 5px rgba(241, 135, 1, 0.4);
    pointer-events: none;
    white-space: nowrap;
}

/* 1. Modern Standard (Firefox, newer Chrome/Edge) */
.spacetime-timeline-container {
    /* Format: thumb-color track-color */
    scrollbar-color: #d4d0c8 #928f8a !important; 
}

/* 2. WebKit Fallback (Safari, older Chrome) */
.spacetime-timeline-container::-webkit-scrollbar {
    height: 8px; /* CRITICAL: Horizontal scrollbars need a height, or they disappear! */
}

.spacetime-timeline-container::-webkit-scrollbar-track {
    background: #d4d0c8;
    border-radius: 4px;
}

.spacetime-timeline-container::-webkit-scrollbar-thumb {
    background: #d4d0c8;
    border-radius: 4px;
}