/* =================================================================
   MNIST CNN Builder - Feature Map Visualizer Styles
   Combined CSS file for all feature map visualization styles
   ================================================================= */

/* =================================================================
   FEATURE MAP QUALITY ENHANCEMENT
   ================================================================= */

/* Debug styles to verify CSS is loading */
body::after {
    content: "Feature map styles loaded (combined v1)";
    position: fixed;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 255, 0, 0.2);
    color: lime;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 3px;
    z-index: 9999;
    pointer-events: none;
}

/* Anti-aliasing reset - prevent browsers from auto-smoothing text */
* {
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
    text-rendering: optimizeSpeed;
    font-smooth: never;
}

/* Improve image rendering quality - MAXIMUM QUALITY SETTINGS */
img, 
canvas, 
.feature-map-item img, 
.feature-map-canvas,
.feature-maps-grid canvas,
#image-preview canvas {
    image-rendering: -webkit-optimize-contrast !important;  /* Chrome */
    image-rendering: crisp-edges !important;                /* Firefox */
    image-rendering: pixelated !important;                  /* Modern browsers */
    -ms-interpolation-mode: nearest-neighbor !important;    /* IE */
    transform: translateZ(0) !important;          /* Force GPU acceleration */
    backface-visibility: hidden !important;       /* Additional GPU hint */
    object-fit: none !important;                 /* Prevent browser scaling */
    filter: contrast(1.05) !important;           /* Slightly boost contrast */
    image-orientation: none !important;          /* Prevent auto-orientation */
    will-change: transform !important;           /* Hint for GPU acceleration */
}

/* Feature map ULTRA crisp mode */
.feature-maps-grid {
    image-rendering: pixelated !important;
}

.feature-maps-grid canvas {
    image-rendering: pixelated !important;
    image-rendering: -moz-crisp-edges !important;
    image-rendering: crisp-edges !important;
    filter: contrast(1.05) brightness(1.02) !important;  /* Enhance visibility */
    border: none !important;
    outline: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

/* Feature map container enhancements */
.feature-maps-container {
    image-rendering: pixelated !important;
    font-family: 'Courier Prime', monospace, 'Courier New', Courier !important;
}

/* Text rendering - make sure text is sharp */
.feature-map-label,
.layer-info h3,
.layer-info p,
.range-indicator,
.layer-name, 
.guide-label,
.neuron-number,
.activation-value,
.feature-maps-container h3 {
    font-family: 'Courier Prime', monospace, 'Courier New', Courier !important;
    text-rendering: geometricPrecision !important;
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: grayscale !important;
    font-smooth: never !important;
    font-weight: bold !important;
    letter-spacing: 0.5px !important;
}

.feature-map-item {
    position: relative;
    margin: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    background: #1e2338;
    transition: transform 0.2s ease;
    padding: 12px;
    border: 2px solid rgba(100, 200, 255, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.feature-map-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
    display: block;
}

/* Fix for scaling issues */
.visualization-section img,
.visualization-section canvas {
    width: auto !important;
    height: auto !important;
    max-width: 100%;
}

/* Improve filter display */
.filter-display {
    image-rendering: pixelated;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Specific for kernel visualization */
.kernel-visualization img,
.kernel-visualization canvas {
    image-rendering: pixelated;
    width: 100% !important;
    height: auto !important;
}

/* Fix for SVG renderings if they're used */
svg[width="28"][height="28"],
svg.feature-map-svg {
    shape-rendering: crispEdges;
}

/* Improve canvas rendering */
canvas.feature-map-canvas {
    image-rendering: pixelated;
}

/* Fix for canvas resizing issues */
canvas {
    margin: 0 !important;
    padding: 0 !important;
}

/* =================================================================
   DENSE LAYER ACTIVATION VISUALIZATION
   ================================================================= */

/* Dense layer activation container */
.dense-layer-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 20px 10px;
    box-sizing: border-box;
    margin: 0 auto;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* Dense activation bars container */
.dense-bars-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 180px;
    gap: 2px; /* Slightly wider for better visibility */
    position: relative;
    margin-bottom: 20px;
    padding-bottom: 25px; /* Space for labels */
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    overflow-x: auto; /* Allow horizontal scrolling if needed */
}

/* Individual activation bar */
.dense-activation-bar {
    width: 10px; /* Fixed width */
    min-width: 10px;
    margin-right: 2px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Bar element */
.dense-bar {
    width: 8px !important; /* Fixed width for better visibility */
    min-width: 8px !important;
    background: linear-gradient(to top, #9775fa, #b197fc);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    transition: height 0.3s ease;
    display: inline-block !important;
}

/* Neuron number label */
.neuron-number {
    position: absolute;
    bottom: -20px;
    font-size: 8px;
    color: #2d3748; /* Dark text for better visibility */
    transform: rotate(-45deg);
    white-space: nowrap;
    text-align: center;
    font-weight: bold;
}

/* Neuron value tooltip */
.activation-value {
    position: absolute;
    bottom: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 5px;
    border-radius: 3px;
    font-size: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
    transform: translateX(-50%);
}

.dense-activation-bar:hover .activation-value {
    opacity: 1;
}

/* Zero baseline indicator */
.zero-baseline {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.5);
}

/* Horizontal guide lines */
.guide-line {
    position: absolute;
    width: 100%;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.1);
}

/* Label for guide lines */
.guide-label {
    position: absolute;
    right: 0;
    transform: translateY(-50%);
    font-size: 10px;
    color: #4a5568; /* Dark text for better visibility */
    padding: 0 5px;
}

/* Range indicators */
.range-indicator {
    margin: 10px 0;
    font-size: 12px;
    color: #2d3748; /* Dark text for better visibility */
    text-align: center;
}

/* Ensure bars fit properly */
@media screen and (max-width: 768px) {
    .dense-bars-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
