/**
 * Inspiration HTF - Frontend Styles
 * Premium grid gallery with PhotoSwipe 5
 */

/* ============================================
   Grid Layout - Masonry Style
   ============================================ */

.ihtf-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: 8px;
    gap: 8px;
    margin: 20px 0;
}

@media (min-width: 640px) {
    .ihtf-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 10px;
        margin: 30px 0;
    }
}

@media (min-width: 768px) {
    .ihtf-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        grid-auto-rows: 10px;
        gap: 16px;
        margin: 40px 0;
    }
}

@media (min-width: 1024px) {
    .ihtf-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 20px;
    }
}

@media (min-width: 1280px) {
    .ihtf-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 24px;
    }
}

/* Grid Item */
.ihtf-grid-item {
    position: relative;
    overflow: hidden;
    display: block;
    text-decoration: none;
    color: inherit;
}

.ihtf-grid-item-inner {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.ihtf-grid-item:hover .ihtf-grid-item-inner {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.ihtf-grid-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ihtf-grid-item:hover img {
    transform: scale(1.05);
}

/* Overlay */
.ihtf-grid-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.6) 0%,
        rgba(0, 0, 0, 0.2) 40%,
        rgba(0, 0, 0, 0) 70%
    );
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 12px;
    pointer-events: none;
}

.ihtf-grid-item:hover .ihtf-grid-item-overlay {
    opacity: 1;
}

/* View Label */
.ihtf-view-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #1a1a1a;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-transform: lowercase;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(8px);
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    margin-bottom: 0;
}

.ihtf-grid-item:hover .ihtf-view-label {
    transform: translateY(0);
    opacity: 1;
}

.ihtf-view-label:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.ihtf-view-label svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Desktop: Add margin-bottom for spacing */
@media (hover: hover) and (pointer: fine) {
    .ihtf-view-label {
        margin-bottom: 30px;
    }
}

/* Mobile: Always show overlay */
@media (hover: none) and (pointer: coarse) {
    .ihtf-grid-item-overlay {
        opacity: 1;
        background: transparent;
        align-items: flex-end;
        justify-content: flex-end;
        padding: 16px;
        padding-bottom: 26px;
    }

    .ihtf-view-label {
        transform: translateY(0);
        opacity: 1;
        padding: 10px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
        width: 44px;
        height: 44px;
        gap: 0;
        margin-bottom: 0;
    }

    .ihtf-view-label span {
        display: none;
    }

    .ihtf-view-label svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   PhotoSwipe Customization
   ============================================ */

/* PhotoSwipe Root - Override z-index so product modal can go above */
:root {
    --pswp-root-z-index: 100000;
}

.pswp {
    z-index: 100000 !important;
    --pswp-root-z-index: 100000 !important;
}

/* Hide all default PhotoSwipe UI elements */
.pswp__button--zoom,
.pswp__button--close,
.pswp__counter,
.pswp__preloader,
.pswp__top-bar .pswp__button:not(.pswp__button--custom-close) {
    display: none !important;
}

/* Clear PhotoSwipe top bar styling */
.pswp__top-bar {
    background: transparent !important;
    backdrop-filter: none !important;
}

/* Custom Close Button */
.pswp__button--custom-close {
    position: absolute !important;
    top: 16px !important;
    right: 16px !important;
    width: 44px !important;
    height: 44px !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 100 !important;
}

.pswp__button--custom-close:hover {
    background: rgba(0, 0, 0, 0.8) !important;
    transform: scale(1.05) rotate(90deg) !important;
}

.pswp__button--custom-close svg {
    width: 20px !important;
    height: 20px !important;
    stroke: #fff !important;
}

@media (min-width: 1024px) {
    .pswp__button--custom-close {
        top: 24px !important;
        right: 24px !important;
        width: 48px !important;
        height: 48px !important;
    }

    .pswp__button--custom-close svg {
        width: 22px !important;
        height: 22px !important;
    }
}

/* Counter */
.pswp__counter-wrap {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.pswp__counter {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 767px) {
    .pswp__counter-wrap {
        top: 16px;
    }

    .pswp__counter {
        font-size: 11px;
        padding: 6px 12px;
        font-weight: 500;
        letter-spacing: 0.3px;
    }
}

/* Product Info Button - Clean & Simple */
.pswp__button--product {
    /* Reset all */
    all: unset;

    /* Position */
    position: fixed !important;
    bottom: 40px;
    left: 50%;
    z-index: 20 !important;

    /* Transform for centering */
    transform: translateX(-50%);

    /* Display */
    display: none;

    /* Layout */
    box-sizing: border-box !important;

    /* Styling */
    background: #1a1a1a !important;
    color: #fff !important;
    padding: 16px 32px !important;
    border-radius: 24px !important;
    border: none !important;
    outline: none !important;

    /* Typography */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    text-align: center !important;
    white-space: nowrap !important;

    /* Interaction */
    cursor: pointer !important;
    user-select: none !important;

    /* Transition */
    transition: all 0.2s ease !important;

    /* Shadow */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3) !important;
}

.pswp__button--product[style*="display: flex"],
.pswp__button--product[style*="display:flex"],
.pswp__button--product[style*="display: block"],
.pswp__button--product[style*="display:block"] {
    display: block !important;
    text-align: center !important;
}

.pswp__button--product:hover {
    background: #000 !important;
    transform: translateX(-50%) translateY(-2px) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
    border: none !important;
    outline: none !important;
}

.pswp__button--product:active {
    transform: translateX(-50%) scale(0.98) !important;
    border: none !important;
    outline: none !important;
}

.pswp__button--product:focus {
    border: none !important;
    outline: none !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3) !important;
}

@media (max-width: 1023px) {
    .pswp__button--product {
        bottom: 24px !important;
        left: 16px !important;
        right: 16px !important;
        transform: none !important;
        padding: 14px 24px !important;
        font-size: 14px !important;
    }

    .pswp__button--product:hover {
        transform: translateY(-2px) !important;
    }

    .pswp__button--product:active {
        transform: scale(0.98) !important;
    }
}

@keyframes slideUpFade {
    from {
        transform: translateX(-50%) translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@media (max-width: 1023px) {
    @keyframes slideUpFade {
        from {
            transform: translateY(30px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* PhotoSwipe Navigation - Premium styling */
.pswp__button--arrow {
    width: 48px !important;
    height: 48px !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 50% !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    overflow: visible !important;
    position: absolute !important;
}

.pswp__button--arrow:hover {
    background: rgba(0, 0, 0, 0.8) !important;
}

.pswp__button--arrow--prev,
.pswp__button--arrow--next {
    top: 50% !important;
    margin: 0 !important;
}

.pswp__button--arrow--prev {
    left: 20px !important;
    transform: translateY(-50%) !important;
}

.pswp__button--arrow--next {
    right: 20px !important;
    transform: translateY(-50%) !important;
}

.pswp__button--arrow--prev:hover {
    transform: translateY(-50%) scale(1.05) !important;
}

.pswp__button--arrow--next:hover {
    transform: translateY(-50%) scale(1.05) !important;
}

/* PhotoSwipe SVG - Force absolute centering */
.pswp__button--arrow .pswp__icn {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 20px !important;
    height: 20px !important;
    transform: translate(-42%, -50%) !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pswp__button--arrow--next .pswp__icn {
    transform: translate(-58%, -50%) scaleX(-1) !important;
}

.pswp__button--arrow svg {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 20px !important;
    height: 20px !important;
    display: block !important;
}

.pswp__button--arrow path,
.pswp__button--arrow use {
    fill: #fff !important;
    stroke: none !important;
}

/* Hide shadow use element */
.pswp__button--arrow .pswp__icn-shadow {
    display: none !important;
}

@media (max-width: 767px) {
    .pswp__button--arrow {
        width: 40px !important;
        height: 40px !important;
    }

    .pswp__button--arrow--prev {
        left: 10px !important;
    }

    .pswp__button--arrow--next {
        right: 10px !important;
    }

    .pswp__button--arrow .pswp__icn {
        width: 20px !important;
        height: 20px !important;
    }
}

/* ============================================
   Product Modal
   ============================================ */

.ihtf-product-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 200000 !important; /* Way above PhotoSwipe (100000) */
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden !important;
}

.ihtf-product-modal.active {
    display: block;
    opacity: 1;
}

/* Backdrop */
.ihtf-product-modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    z-index: 1 !important;
}

@media (min-width: 1024px) {
    .ihtf-product-modal-backdrop {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* Content Container - Mobile: Fullscreen */
.ihtf-product-modal-content {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #fff;
    border-radius: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
    z-index: 2 !important;
}

.ihtf-product-modal.active .ihtf-product-modal-content {
    transform: translateY(0);
}

/* Desktop: Full width horizontal layout from bottom */
@media (min-width: 1024px) {
    .ihtf-product-modal-content {
        top: auto !important;
        bottom: 0 !important;
        height: 450px;
        max-height: 450px;
        border-radius: 0;
        display: flex;
        flex-direction: row;
        overflow: hidden;
    }
}

/* Close Button - Minimalist */
.ihtf-product-modal-close {
    position: fixed;
    top: 8px;
    right: 8px;
    background: none !important;
    border: none !important;
    outline: none !important;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    width: 44px;
    height: 44px;
}

.ihtf-product-modal-close:hover {
    color: #1a1a1a !important;
    background: none !important;
    border: none !important;
    outline: none !important;
    transform: rotate(90deg);
}

@media (min-width: 1024px) {
    .ihtf-product-modal-close:hover {
        color: #666 !important;
    }
}

.ihtf-product-modal-close:focus {
    background: none !important;
    border: none !important;
    outline: none !important;
}

.ihtf-product-modal-close:active {
    background: none !important;
    border: none !important;
    outline: none !important;
}

.ihtf-product-modal-close svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.5;
    display: block;
}

@media (min-width: 1024px) {
    .ihtf-product-modal-close {
        position: absolute;
        top: 24px;
        right: 24px;
        color: #666;
    }

    .ihtf-product-modal-close svg {
        width: 32px;
        height: 32px;
    }
}

/* Handle Bar - Hidden on mobile now (fullscreen) */
.ihtf-product-modal-content::before {
    content: '';
    display: none;
}

/* Loading State */
.ihtf-product-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    min-height: 100vh;
}

@media (min-width: 1024px) {
    .ihtf-product-modal-loading {
        min-height: 450px;
        padding: 48px;
    }
}

.ihtf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Product Content */
.ihtf-product-modal-body {
    padding: 32px 24px 40px 24px;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
    min-height: auto;
}

.ihtf-product-modal-body.loaded {
    opacity: 1;
}

/* Desktop: Horizontal layout */
@media (min-width: 1024px) {
    .ihtf-product-modal-body {
        flex-direction: row;
        padding: 0;
        height: 100%;
        min-height: 450px;
    }
}

/* Product Image */
.ihtf-product-image {
    margin-bottom: 20px;
    display: block;
    max-height: 40vh; /* 40% van viewport hoogte op mobiel */
    overflow: hidden;
}

.ihtf-product-image img {
    width: 100%;
    height: 100%;
    max-height: 40vh;
    object-fit: cover;
    display: block;
}

@media (min-width: 1024px) {
    .ihtf-product-image {
        display: block;
        width: 50%;
        max-width: 600px;
        height: 450px;
        max-height: none;
        flex-shrink: 0;
        overflow: hidden;
        margin-bottom: 0;
    }

    .ihtf-product-image img {
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: cover;
        display: block;
    }
}

/* Product Details */
.ihtf-product-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

@media (min-width: 1024px) {
    .ihtf-product-details {
        padding: 48px 56px;
        justify-content: center;
        max-width: 700px;
    }
}

.ihtf-product-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: #1a1a1a;
    line-height: 1.3;
}

@media (min-width: 1024px) {
    .ihtf-product-title {
        font-size: 24px;
        margin-bottom: 16px;
    }
}

.ihtf-product-description {
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    margin-bottom: 20px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

@media (min-width: 1024px) {
    .ihtf-product-description {
        font-size: 15px;
        line-height: 1.6;
        margin-bottom: 24px;
        -webkit-line-clamp: 4;
    }
}

/* Price */
.ihtf-product-price-wrap {
    margin-bottom: 16px;
}

@media (min-width: 1024px) {
    .ihtf-product-price-wrap {
        margin-bottom: 20px;
    }
}

.ihtf-product-price {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    color: #1a1a1a;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 50px;
    text-transform: lowercase;
}

@media (min-width: 1024px) {
    .ihtf-product-price {
        font-size: 13px;
        padding: 7px 14px;
    }
}

/* Button */
.ihtf-product-button {
    display: block;
    width: 100%;
    background: #1a1a1a;
    color: #fff !important;
    text-align: center;
    padding: 15px 28px;
    border-radius: 0;
    font-size: 13px !important;
    font-weight: 600;
    text-decoration: none !important;
    text-transform: none;
    transition: all 0.2s ease;
    border: none;
}

.ihtf-product-button:hover {
    background: #000;
    color: #fff !important;
}

@media (min-width: 1024px) {
    .ihtf-product-button {
        padding: 15px 32px;
        font-size: 13px !important;
        border-radius: 0;
    }
}

/* Empty State */
.ihtf-product-modal-empty {
    text-align: center;
    padding: 60px 24px;
    display: none;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
}

@media (min-width: 1024px) {
    .ihtf-product-modal-empty {
        min-height: 450px;
        padding: 48px;
    }
}

.ihtf-product-modal-empty p {
    color: #999;
    font-size: 15px;
    text-transform: lowercase;
}

/* ============================================
   Accessibility
   ============================================ */

.ihtf-grid-item:focus,
.ihtf-view-label:focus,
.ihtf-product-button:focus,
.ihtf-product-modal-close:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Remove outline for PhotoSwipe product button - not accessible via keyboard anyway */
.pswp__button--product:focus-visible {
    outline: none !important;
}

/* ============================================
   Performance Optimizations
   ============================================ */

.ihtf-grid-item,
.ihtf-grid-item-inner,
.ihtf-product-modal-content {
    will-change: transform;
}

.ihtf-grid-item img {
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
