/* ============================
   IMAGE COMPARISON SECTION CSS
   ============================ */

html, body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* === Grid Layout === */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    width: 100%;
}

@media (max-width: 1200px) {
    .comparison-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .comparison-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .comparison-grid {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .comparison-container {
        max-width: 100%;
    }
}

/* === Individual Comparison Item === */
.comparison-container {
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

.image-comparison {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 85.6%; /* Maintain 250x214 aspect ratio */
    overflow: hidden;
    border: none;
    margin: 0 auto;
}

/* === Base Images === */
.image-comparison img {
    position: absolute;
    top: 0;
    left: 0;
    width: 250px;
    height: 214px;
    object-fit: cover;
}

/* Before image overlay */
.image-before {
    width: 50%;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.2s ease-out;
}

/* === Comparison Handle === */
.comparison-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background-color: #ffffff;
    cursor: ew-resize;
    z-index: 10;
    transform: translateX(-50%);
    transition: background-color 0.3s ease;
}

.comparison-handle::before {
    content: "↔";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background-color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #333333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* Hover effect for handle */
.comparison-handle:hover::before {
    background-color: #f3f3f3;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Handle feedback during drag */
.image-comparison.sliding .comparison-handle::before {
    transform: translate(-50%, -50%) scale(1.05);
}

/* === Labels === */
.image-label {
    position: absolute;
    bottom: 20px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 4px;
    font-size: 14px;
    z-index: 5;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}

.label-before {
    left: 20px;
}

.label-after {
    right: 20px;
}

/* === Responsive Adjustments === */
@media (max-width: 768px) {
    .comparison-handle::before {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .image-label {
        font-size: 12px;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .comparison-grid {
        gap: 15px;
    }

    .comparison-handle::before {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .image-label {
        font-size: 11px;
    }
}
