/* Mouse Test CSS */
/* Styles specific to mouse testing functionality */

.mouse-container {
    width: 90%;
    max-width: 1200px;
    margin: 3px auto; /* Reduced from 6px to 3px (half again) */
    text-align: center;
}

.mouse-grid {
    display: block; /* Always visible - changed from none */
    margin-top: 32px;
    width: 100%;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    background: rgba(255, 255, 255, 0.1);
    padding: 24px 24px 16px 24px; /* Reduced bottom padding */
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    box-sizing: border-box;
}

.mouse-visualization {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto; /* Ensure rows are properly spaced */
    gap: 24px;
    margin-top: 16px;
    margin-bottom: 0; /* Reduced to pull up click section */
    align-items: start; /* Align items to the start of the grid area */
      height: auto;
    justify-items: center; /* Center items within their grid cell */
}

.graph {
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    aspect-ratio: 1/1; /* Maintain 1:1 for a square aspect ratio */
    width: 100%; /* Take full width of the parent grid cell */
    max-width: 225px; /* Reduced size of the graph */
    max-height: 300px; /* Explicitly match max-width for 1:1 aspect ratio */
    overflow: hidden; /* Ensure canvas doesn't overflow its container if JS sizes it unexpectedly */
    height: 225px; /* Adjust height to match reduced width */
}

#mouseGraph, #mouseDelta, #mouseRelativePosition {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.click-test-section {
    margin-top: 24px; /* Add spacing to prevent overlap */
    padding-top: 16px; /* Add padding for better separation */
}

.click-counters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px; /* Add spacing below counters */
}

.click-counter {
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
}

.click-counter.left-click {
    border: 2px solid rgba(52, 152, 219, 0.5);
}

.click-counter.right-click {
    border: 2px solid rgba(231, 76, 60, 0.5);
}

.counter-label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.counter-value {
    display: block;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
}

.click-test-area {
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.click-test-area:hover {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
}

.click-test-area:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.98);
}

.click-instruction {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    pointer-events: none;
}

/* Specific styles for mouse test inside the mic-keyboard-wrapper */
.mic-keyboard-wrapper .mouse-container {
    width: 100%;
    margin: 0;
}

.mic-keyboard-wrapper .mouse-grid {
    margin-top: 16px; /* Reduced from 32px for tighter stacking */
    max-width: none; /* Remove max-width constraint in stacked layout */
    padding: 16px; /* Reduced padding for more compact display */
}

.mic-keyboard-wrapper .mouse-visualization {
    height: 300px;
    gap: 12px;
    margin-bottom: -30px;
    padding-bottom: 0px;
}

.mic-keyboard-wrapper .click-test-section {
    margin-top: -50px;
    padding-top: 0px;
}

/* Responsive adjustments for the stacked layout */
@media (max-width: 1200px) {
    .mic-keyboard-wrapper .mouse-grid {
        padding: 20px; /* Restore padding on smaller screens */
    }
}

/* Added media query for stacking graphs on smaller screens */
@media (max-width: 767px) {
    .mouse-visualization {
        grid-template-columns: 1fr; /* Stack graphs vertically */
        row-gap: 150px; /* Add consistent spacing between rows */
        height: auto; /* Allow container to expand vertically */
    }

    .graph {
        width: 100%;
        max-width: 300px; /* Adjust max-width for smaller screens */
        height: auto; /* Allow height to adjust proportionally */
        aspect-ratio: 1/1; /* Maintain 1:1 aspect ratio */
        margin-bottom: 0; /* Remove individual margin-bottom */
    }
}

@media (min-width: 768px) {
    .mouse-visualization {
        grid-template-columns: 1fr 1fr 1fr; /* Three columns layout */
        align-items: center; /* Center items vertically */
        justify-items: center; /* Center items horizontally */
    }

    .graph:nth-child(2) {
        grid-column: 2; /* Place the button graph in the center column */
    }
}
