/* ============================================
   Homilla Portfolio Slider - Main Styles
   v1.4.0
   ============================================ */

.homilla-portfolio-slider {
    position: relative;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    padding: 20px 0;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Allow vertical page scroll to pass through; JS handles horizontal drag. */
    touch-action: pan-y;
}

.homilla-portfolio-slider:active {
    cursor: grabbing;
}

/* ============================================
   Slider Track & Items
   ============================================ */

.hps-track {
    display: flex;
    gap: var(--hps-gap, 20px);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.hps-item {
    position: relative;
    flex-shrink: 0;
    width: auto;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.6s ease;
}

.hps-item:hover {
    transform: scale(1.015);
    opacity: 0.95;
    z-index: 2;
}

.hps-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    /* Prevent iOS from treating image as draggable content */
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-touch-callout: none;
    pointer-events: none; /* clicks pass through to .hps-item */
}

.hps-item:hover img {
    transform: scale(1.03);
}

/* ============================================
   Designer Overlay
   ============================================ */

.hps-designer-overlay {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.hps-designer-overlay.top-left    { top: 20px;    left: 20px;  }
.hps-designer-overlay.top-right   { top: 20px;    right: 20px; }
.hps-designer-overlay.bottom-left { bottom: 20px; left: 20px;  }
.hps-designer-overlay.bottom-right{ bottom: 20px; right: 20px; }

.hps-designer-photo-wrapper {
    width: var(--hps-designer-size, 80px);
    height: var(--hps-designer-size, 80px);
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.5s ease;
    flex-shrink: 0;
    display: block;
    position: relative;
    cursor: pointer;
    pointer-events: auto; /* re-enable for the clickable wrapper */
}

.hps-designer-photo-wrapper:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.hps-designer-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.hps-designer-name {
    display: none;
}

/* ============================================
   Lightbox
   ============================================ */

.hps-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.4s;
    pointer-events: none;
    /* Safari: force its own compositing layer so transforms don't cause repaint bugs */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.hps-lightbox.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.hps-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    cursor: pointer;
    transition: opacity 0.5s ease;
}

.hps-lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    box-sizing: border-box;
}

.hps-lightbox-image-container {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hps-lightbox-image {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    /* Start at 0 opacity — JS fades it in once the image is decoded.
       This prevents Safari from showing a blank/broken image frame. */
    opacity: 0;
    display: block;
    position: relative;
    z-index: 1;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    user-drag: none;
    cursor: grab;
    cursor: -webkit-grab;
    /* Safari: ensure the image is its own compositing layer */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform, opacity;
}

.hps-lightbox-image:active {
    cursor: grabbing;
    cursor: -webkit-grabbing;
}

/* Loading spinner shown while the full-res image is decoding */
.hps-lightbox-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 0;
    animation: hps-spin 0.8s linear infinite;
}

.hps-lightbox-spinner.is-visible {
    opacity: 1;
}

@keyframes hps-spin {
    to { transform: rotate(360deg); }
}

/* Lightbox Controls */
.hps-lightbox-close,
.hps-lightbox-prev,
.hps-lightbox-next {
    position: absolute;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* Prevent button from becoming a tap-drag target */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.hps-lightbox-close svg,
.hps-lightbox-prev svg,
.hps-lightbox-next svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.hps-lightbox-close:hover,
.hps-lightbox-prev:hover,
.hps-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.7);
    transform: scale(1.05);
}

.hps-lightbox-close { top: 20px; right: 20px; }

.hps-lightbox-prev {
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
}

.hps-lightbox-next {
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
}

.hps-lightbox-prev:hover { transform: translateY(-50%) scale(1.05); }
.hps-lightbox-next:hover { transform: translateY(-50%) scale(1.05); }

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .hps-item {
        min-width: 350px !important;
        max-width: 500px !important;
    }

    .hps-lightbox-prev,
    .hps-lightbox-next {
        width: 45px;
        height: 45px;
    }

    .hps-lightbox-prev svg,
    .hps-lightbox-next svg {
        width: 22px;
        height: 22px;
    }

    .hps-lightbox-prev { left: 20px; }
    .hps-lightbox-next { right: 20px; }
}

/* Desktop */
@media (min-width: 1025px) {
    .hps-track {
        padding: 0 2%;
    }

    .hps-item {
        min-width: 400px !important;
        max-width: 550px !important;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .homilla-portfolio-slider {
        padding: 15px 0;
        overflow-x: hidden;
        /* On mobile, allow vertical scroll (pan-y) and pinch-zoom.
           JS blocks horizontal scroll only when the user is dragging the slider. */
        touch-action: pan-y;
    }

    .hps-track {
        gap: 12px;
        padding: 0 15vw;
    }

    .hps-designer-overlay.top-left,
    .hps-designer-overlay.top-right    { top: 12px; }

    .hps-designer-overlay.top-left,
    .hps-designer-overlay.bottom-left  { left: 12px; }

    .hps-designer-overlay.top-right,
    .hps-designer-overlay.bottom-right { right: 12px; }

    .hps-designer-overlay.bottom-left,
    .hps-designer-overlay.bottom-right { bottom: 12px; }

    .hps-lightbox-content {
        padding: 40px 10px;
    }

    .hps-lightbox-image {
        max-width: 94vw;
        max-height: 80vh;
    }

    .hps-lightbox-close {
        width: 40px;
        height: 40px;
        top: 15px;
        right: 15px;
    }

    .hps-lightbox-close svg {
        width: 22px;
        height: 22px;
    }

    .hps-lightbox-prev,
    .hps-lightbox-next {
        width: 40px;
        height: 40px;
    }

    .hps-lightbox-prev svg,
    .hps-lightbox-next svg {
        width: 20px;
        height: 20px;
    }

    .hps-lightbox-prev { left: 10px; }
    .hps-lightbox-next { right: 10px; }
}

/* ============================================
   Navigation Arrows
   ============================================ */

.hps-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.7;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: 0;
}

.hps-nav-arrow:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.hps-nav-arrow svg {
    width: 22px;
    height: 22px;
    color: #333;
}

.hps-nav-prev { left: 6.5%; }
.hps-nav-next { right: 6.5%; }

@media (min-width: 1025px) {
    .hps-nav-arrow {
        width: 48px;
        height: 48px;
    }

    .hps-nav-arrow svg {
        width: 24px;
        height: 24px;
    }

    .hps-nav-prev { left: 40px; }
    .hps-nav-next { right: 40px; }
}

@media (max-width: 768px) {
    .hps-nav-arrow {
        width: 40px;
        height: 40px;
    }

    .hps-nav-arrow svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   Performance & Accessibility
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .hps-track,
    .hps-item,
    .hps-item img,
    .hps-designer-overlay,
    .hps-lightbox,
    .hps-lightbox-image {
        transition: none !important;
        animation: none !important;
    }
    .hps-lightbox-spinner {
        animation: none !important;
    }
}

/* Force GPU acceleration on key elements */
.hps-track,
.hps-item,
.hps-lightbox-image-container {
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
