/**
 * Before-After Image Comparison Styles
 *
 * @package Fotoshopcu Core
 */

/* Before-After Image Comparison Styles */
.before-after-gallery {
    margin: 30px 0 40px;
    padding: 0;
    display: block !important;
    width: 100%;
    visibility: visible !important;
    overflow: visible;
    max-width: 100%;
}

/* Otomatik kaydırma animasyonu için stiller */
@keyframes sliderPulse {
    0% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); transform: translate(-50%, -50%) scale(1); }
    50% { box-shadow: 0 4px 12px rgba(252, 211, 7, 0.6); transform: translate(-50%, -50%) scale(1.1); }
    100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); transform: translate(-50%, -50%) scale(1); }
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

.auto-animate .slider-button {
    animation: sliderPulse 2s infinite ease-in-out;
}

.gallery-container {
    display: flex;
    gap: 25px;
    max-width: 100%;
    padding: 10px 0;
    align-items: flex-start;
    margin: 0;
    visibility: visible !important;
    overflow: visible;
}

.main-comparison {
    flex: 0 0 70%;
    max-width: 70%;
    position: relative;
    border-radius: 12px;
    aspect-ratio: 1/1; /* Square format */
    height: auto;
    width: 700px; /* Set fixed width for service page */
    max-height: 700px; /* Set fixed height for service page */
}

/* Service page specific styles */
.service-single .main-comparison,
body.single-fotoshopcu_service .main-comparison {
    width: 700px !important;
    height: 700px !important;
    max-width: 100%;
}

/* Post editor styles */
.block-editor-block-list__block .main-comparison {
    width: 700px !important;
    height: 700px !important;
    max-width: 100%;
}

.main-comparison.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 25;
    border-radius: 12px;
    pointer-events: none; /* do not block scroll */
}

.main-comparison.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--main-color, #fcd307);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    z-index: 30;
    pointer-events: none; /* do not block scroll */
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.comparison-container {
    position: relative;
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 12px;
    aspect-ratio: 1/1; /* Square format */
}

/* Fix image comparison container structure */
.img-comp-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* Square format (100%) */
    overflow: hidden;
    border-radius: 12px;
    background-color: transparent;
    contain: layout paint; /* isolate heavy paints */
}

/* Before image container (left side) covers the full width */
.img-comp-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    max-width: 100%;
    clip-path: inset(0 50% 0 0); /* Show only left half initially */
    will-change: clip-path;
}

/* After image container (right side) */
.img-comp-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 2;
    clip-path: inset(0 0 0 50%); /* Initially show only right half */
    will-change: clip-path;
}

/* Properly align image content */
.img-comp-before img, 
.img-comp-after img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
    image-rendering: high-quality;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Slider divider styling - updated to match new design */
.img-comp-slider {
    position: absolute;
    z-index: 20;
    top: 0;
    bottom: 0;
    width: 0;
    background-color: transparent !important;
    cursor: ew-resize;
    left: 50%;
    transform: translateX(-50%);
}

/* Hide slider divider line completely */
.single-fotoshopcu_service .img-comp-slider,
.single-fotoshopcu_service .comparison-container .img-comp-slider,
.single-fotoshopcu_service .img-comp-container .img-comp-slider,
.portfolio-single .img-comp-slider,
.portfolio-single .comparison-container .img-comp-slider,
.portfolio-single .img-comp-container .img-comp-slider {
    width: 0 !important;
    background-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
}

/* Remove any white lines around slider button */
.single-fotoshopcu_service .slider-button::before,
.single-fotoshopcu_service .slider-button::after {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Updated slider button to match design and use favicon */
.slider-button {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fcd307 !important; /* Bright yellow circle */
    background-color: #fcd307 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: none !important;
    outline: none !important;
    transition: transform 0.2s ease;
    z-index: 15;
    overflow: hidden;
    opacity: 0.7 !important;
}

/* Remove any white borders or outlines from slider button */
.single-fotoshopcu_service .slider-button,
.portfolio-single .slider-button {
    border: none !important;
    outline: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

/* Replace text with favicon image */
.slider-button::before {
    content: '';
    width: 24px;
    height: 24px;
    background-image: url('/favicon.ico');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

/* Add a more dynamic approach that will work with any WordPress site */
.slider-button::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background-image: url('/wp-content/uploads/favicon.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
}

/* For WordPress sites that load their favicon differently */
@media screen and (min-width: 1px) {
    .slider-button img.favicon {
        width: 24px;
        height: 24px;
        object-fit: contain;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
}

/* Add JavaScript to dynamically add the favicon to the slider button */
@media screen and (min-width: 1px) {
    /* This is just a CSS hook - we'll add actual JavaScript to fotoshopcu-core */
    .js-favicon-loaded .slider-button::before {
        /* No background image when JS loaded the favicon */
        background-image: none;
    }
}

/* Position labels horizontally on sides of the center button with updated design */
.slider-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #fcd307 !important;
    background-color: #fcd307 !important;
    color: #000 !important;
    font-weight: bold;
    font-size: 0.95rem;
    padding: 0 15px;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    border: none !important;
    z-index: 14;
    opacity: 0.7 !important;
}

.slider-label-before {
    right: calc(50% + 15px);
}

.slider-label-after {
    left: calc(50% + 15px);
}

/* Remove previous overlay text */
.img-comp-before::after,
.img-comp-after::after {
    display: none;
}

/* Thumbnails Gallery */
.thumbnails-gallery {
    flex: 0 0 25%;
    max-width: 20%;
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: 100%; /* Ensure it doesn't exceed main comparison height */
    margin: 0 auto; /* center on desktop */
}

.thumbnails-title {
    display: none;
}

.thumbnails-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: auto;
    overflow: hidden;
    justify-content: flex-start; /* Align to top */
}

/* Complete rewrite of thumbnail structure for better display */
.thumbnail-before-after {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* Square format */
    overflow: hidden;
    border-radius: 8px;
}

/* Position the before and after sections side by side */
.thumbnail-before, 
.thumbnail-after {
    position: absolute;
    top: 0;
    height: 100%; /* Full height */
    overflow: hidden;
}

.thumbnail-before {
    left: 0;
    width: 50%;
}

.thumbnail-after {
    right: 0;
    width: 50%;
}

/* Fix thumbnail images */
.thumbnail-before img, 
.thumbnail-after img {
    position: absolute;
    top: 0;
    height: 100%;
    object-fit: cover;
}

/* Set proper width and position for each image */
.thumbnail-before img {
    width: 100%;
    left: 0;
}

.thumbnail-after img {
    width: 100%;
    left: 0;
}

/* Add a visible divider between before/after */
.thumbnail-divider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%; /* Full height */
    background-color: #FFCC00;
    z-index: 5;
    transform: translateX(-50%);
    box-shadow: 0 0 4px rgba(255, 204, 0, 0.5);
}

/* Make sure the overlay covers both before/after sections */
.thumbnail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Full height */
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 4;
}

.thumbnail-pair:hover .thumbnail-overlay {
    opacity: 1;
}

.thumbnail-overlay span {
    background-color: var(--main-color, #fcd307);
    color: #333;
    font-weight: 600;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
    display: inline-block;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

/* Enhance the clickable thumbnails */
.thumbnail-pair {
    cursor: pointer;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: none;
    transition: all 0.2s ease;
    flex: 0 0 calc(33.333% - 7px);
    max-width: 100%;
    margin-bottom: 10px;
    aspect-ratio: 1/1; /* Make square */
    opacity: 0.85;
    border: 1px solid rgba(255, 255, 255, 0.5);
    height: auto;
}

/* Add mini before/after labels to thumbnails */
.thumbnail-before::before,
.thumbnail-after::before {
    content: '';
    position: absolute;
    top: 5px;
    background-color: #FFCC00;
    color: #000000;
    font-size: 8px;
    padding: 2px 4px;
    border-radius: 2px;
    z-index: 5;
    font-weight: bold;
    opacity: 0.9;
}

.thumbnail-before::before {
    content: 'Ö';
    left: 5px;
}

.thumbnail-after::before {
    content: 'S';
    right: 5px;
}

/* Add highlight border to active thumbnail */
.thumbnail-pair.active {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: none;
    border: 2px solid var(--main-color, #fcd307);
}

.thumbnail-pair:hover {
    opacity: 0.95;
    transform: translateY(-2px);
    box-shadow: none;
}

/* Fix responsive adjustments */
@media (max-width: 992px) {
    .gallery-container {
        flex-direction: column;
        max-width: 100%;
        gap: 15px;
    }
    
    .main-comparison,
    .service-single .main-comparison,
    body.single-fotoshopcu_service .main-comparison {
        flex: 0 0 100%;
        max-width: 700px;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1/1;
        margin: 0 auto;
    }
    
    .thumbnails-gallery {
        flex: 0 0 100%;
        max-width: 700px;
        width: 100%;
        margin: 0 auto;
    }
    
    .thumbnails-container {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 10px;
    }
    
    .thumbnail-pair {
        flex: 0 0 calc(20% - 8px);
        max-width: calc(20% - 8px);
    }
}

@media (max-width: 768px) {
    .before-after-gallery {
        margin: 20px 0 30px;
        width: 100%;
        display: block !important;
    }

    .gallery-container {
        padding: 0;
        gap: 15px;
        max-width: 100%;
        margin: 0;
        display: flex !important;
    }
    
    .main-comparison,
    .service-single .main-comparison,
    body.single-fotoshopcu_service .main-comparison {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1/1;
    }
    
    .thumbnails-gallery {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .thumbnails-container {
        flex-direction: row;
        gap: 10px;
    }
    
    .thumbnail-pair {
        flex: 0 0 calc(33.33% - 8px);
        max-width: calc(33.33% - 8px);
        height: auto;
        aspect-ratio: 1/1;
        margin-bottom: 0;
    }
    
    .thumbnail-before::before,
    .thumbnail-after::before {
        font-size: 7px;
        padding: 1px 3px;
    }
}

@media (max-width: 576px) {
    .gallery-container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    
    .main-comparison {
        margin-bottom: 10px;
    }
    
    .thumbnails-container {
        flex-direction: row;
        gap: 8px;
    }
    
    .thumbnail-pair {
        flex: 0 0 calc(33.33% - 6px);
        max-width: calc(33.33% - 6px);
    }
    
    .img-comp-before::after,
    .img-comp-after::after {
        font-size: 1rem;
    }
    
    .slider-button {
        width: 50px;
        height: 50px;
        font-size: 12px;
    }
    
    .slider-label {
        font-size: 0.8rem;
    }
}

/* Add a more specific style for really small screens */
@media (max-width: 400px) {
    .thumbnail-pair {
        flex: 0 0 calc(33.33% - 4px);
        max-width: calc(33.33% - 4px);
    }
    
    .thumbnail-before::before,
    .thumbnail-after::before {
        font-size: 6px;
        padding: 1px 2px;
    }
    
    .slider-button {
        width: 40px;
        height: 40px;
        font-size: 10px;
    }
    
    .slider-label {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
    
    .slider-label-before {
        right: calc(50% + 25px);
    }
    
    .slider-label-after {
        left: calc(50% + 25px);
    }
}

/* Add back the hover effect for the slider button */
.slider-button:hover,
.portfolio-single .slider-button:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
    background: #fcd307 !important;
    background-color: #fcd307 !important;
    border: none !important;
    opacity: 1 !important;
}

.single-fotoshopcu_service .slider-button:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
    background: #fcd307 !important;
    background-color: #fcd307 !important;
    border: none !important;
    opacity: 0.9 !important;
}

.single-fotoshopcu_service .slider-label:hover {
    opacity: 0.9 !important;
}

/* Force opacity and background for service page slider elements */
.single-fotoshopcu_service .slider-button,
.single-fotoshopcu_service .img-comp-slider .slider-button {
    background: #fcd307 !important;
    background-color: #fcd307 !important;
    opacity: 0.7 !important;
}

.portfolio-single .slider-button,
.portfolio-single .img-comp-slider .slider-button {
    background: #fcd307 !important;
    background-color: #fcd307 !important;
    opacity: 1 !important;
}

.single-fotoshopcu_service .slider-label,
.single-fotoshopcu_service .slider-label-before,
.single-fotoshopcu_service .slider-label-after,
.single-fotoshopcu_service .img-comp-slider .slider-label {
    background: #fcd307 !important;
    background-color: #fcd307 !important;
    opacity: 0.7 !important;
    color: #000 !important;
}

.portfolio-single .slider-label,
.portfolio-single .slider-label-before,
.portfolio-single .slider-label-after,
.portfolio-single .img-comp-slider .slider-label {
    background: #fcd307 !important;
    background-color: #fcd307 !important;
    opacity: 1 !important;
    color: #000 !important;
} 
