/**
 * Custom Portfolio Widget CSS
 * Author: Jeroen de Bruijn
 */

/* Full-width container styles */
.custom-portfolio-outer-container {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
    overflow: hidden; /* Prevent scrolling in the widget container */
}

.custom-portfolio-full-width-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* Prevent scrolling in these containers */
}

/* Grid layout */
.custom-portfolio-grid {
    display: grid;
    grid-gap: 0;
    margin: 0;
    width: 100%;
    position: relative;
    transition: height 0.6s ease-in-out;
    overflow: hidden; /* Prevent scrolling within the grid itself */
}

.custom-portfolio-grid.columns-1 {
    grid-template-columns: 1fr;
}

.custom-portfolio-grid.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.custom-portfolio-grid.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.custom-portfolio-grid.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .custom-portfolio-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .custom-portfolio-grid.columns-4,
    .custom-portfolio-grid.columns-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .custom-portfolio-grid.columns-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Portfolio item styling */
.custom-portfolio-item {
    position: relative;
    overflow: hidden;
    border-radius: 0; /* Remove border radius */
    box-shadow: none; /* Remove shadow for cleaner look */
    cursor: pointer;
    aspect-ratio: 1/1; /* Force square aspect ratio */
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    backface-visibility: hidden;
    max-height: 100%; /* Ensure items don't exceed container height */
}

/*.custom-portfolio-item:hover {*/
/*    transform: translateY(-5px);*/
/*}*/

.custom-portfolio-uniform-height .custom-portfolio-item {
    position: relative;
    padding-bottom: 100%; /* Square aspect ratio fallback */
    height: 0;
}

/* Portfolio item inner container */
.custom-portfolio-item-inner {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* For uniform height items, position the inner content absolutely */
.custom-portfolio-uniform-height .custom-portfolio-item-inner,
.custom-portfolio-uniform-height .custom-portfolio-item .portfolio_item_top_wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Image styling */
.custom-portfolio-image {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.custom-portfolio-zoom-image .custom-portfolio-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.custom-portfolio-zoom-image .custom-portfolio-item:hover img {
    transform: scale(1.05);
}

/* Play button styling */
.portfolio-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: all 0.3s ease;
    opacity: 0; /* Hide by default */
    visibility: hidden; /* Hide by default */
}

.portfolio-play-button span {
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 15px 0 15px 26px;
    border-color: transparent transparent transparent #ffffff;
    margin-left: 8px; /* Optical centering adjustment */
}

/* Show play button only on hover */
.custom-portfolio-item:hover .portfolio-play-button {
    opacity: 0.8;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    background: rgba(0, 0, 0, 0.7);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

/* Video indicator hover effect */
.custom-portfolio-item:hover .video-indicator {
    opacity: 0.7;
    transform: scale(1.1);
}

/* No image styling */
.portfolio-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Special styling for items without images */
.custom-portfolio-no-image .custom-portfolio-content {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
}

.custom-portfolio-no-image .custom-portfolio-content h3 {
    margin: 0;
    font-size: 22px;
    line-height: 1.3;
    max-width: 90%;
}

/* Hover effect specifically for portfolio items without images */
.custom-portfolio-no-image:hover .custom-portfolio-content-no-image {
    background-color: rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
    transition: all 0.3s ease;
}

.custom-portfolio-no-image:hover h3 {
    color: #000;
}

.custom-portfolio-no-image:hover p {
    color: #333;
}

/* Entry thumbnail popover content styling */
.entry-thumbnail-popover-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.entry-thumbnail-popover-content.always-visible,
.custom-portfolio-item:hover .entry-thumbnail-popover-content {
    opacity: 1;
}

.portfolio_item-title {
    margin: 0 0 5px;
    text-align: center;
    width: 100%;
    max-width: 90%;
}

.portfolio_item-title a {
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    line-height: 1.3;
}

/* Content styling */
.custom-portfolio-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    z-index: 2;
    text-align: center;
    transition: all 0.3s ease;
    display: none;
    overflow: hidden; /* Prevent scrolling inside content overlay */
}

/* Duplicate of custom-portfolio-content for items without featured images */
.custom-portfolio-content-no-image {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: inherit !important;
    color: #fff;
    z-index: 2;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    top: 0;
}

.custom-portfolio-content-no-image h3 {
    color: #333;
    margin-bottom: 10px;
}

.custom-portfolio-content-no-image p {
    color: #666;
    opacity: 1 !important;
    transform: none !important;
    margin: 0;
}

/* On hover, expand to full tile with centered content */
.custom-portfolio-item:hover .custom-portfolio-content,
.custom-portfolio-item:hover .custom-portfolio-content-no-image,
.custom-portfolio-item:hover .entry-thumbnail-popover-content {
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.custom-portfolio-always-show-title .custom-portfolio-content {
    opacity: 1;
}

.entry-thumbnail-popover-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    z-index: 2;
    padding: 15px;
    transition: opacity 0.3s ease;
}

.entry-thumbnail-popover-content.always-visible {
    opacity: 1;
}

.portfolio_item-title,
.custom-portfolio-content h3 {
    margin: 0 0 10px;
    font-size: 18px;
    color: #fff;
    text-align: center;
    width: 100%;
}

.portfolio_item-title a,
.custom-portfolio-content a {
    color: #fff;
    text-decoration: none;
}

/* Only show subtitle on hover */
.portfolio_item-subtitle {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition-delay: 0.1s;
    margin: 5px 0;
    font-size: 14px;
    line-height: 1.4;
    font-weight: normal;
    color: #f5f5f5;
    text-align: center;
    width: 100%;
    max-width: 90%;
}

.custom-portfolio-item:hover .portfolio_item-subtitle {
    opacity: 1;
    transform: translateY(0);
}

.custom-portfolio-content p {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    color: #f5f5f5;
    text-align: center;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition-delay: 0.1s;
}

.custom-portfolio-item:hover .custom-portfolio-content p {
    opacity: 0.9;
    transform: translateY(0);
}

/* Entry meta styling */
.entry-meta {
    margin-top: 5px;
    text-align: center;
    width: 100%;
}

.entry-meta ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.entry-meta li {
    margin: 0 5px;
    font-size: 13px;
    opacity: 0.8;
}

/* Link styling */
.custom-portfolio-video-link,
.custom-portfolio-content-link {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 3px;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.3s ease;
}

.custom-portfolio-video-link:hover,
.custom-portfolio-content-link:hover {
    background: rgba(255, 255, 255, 0.3);
    text-decoration: none;
}

/* Magnific Popup Overrides */
.mfp-bg {
    opacity: 0.7 !important; /* More transparent background overlay */
    background: #000 !important; /* Black background */
}

.mfp-wrap {
    z-index: 999999 !important; /* Ensure popup appears above everything */
}

.mfp-container {
    padding: 0 !important;
}

/* Increase popup content size to 90% */
.mfp-content {
    max-width: 90% !important;
    width: 90% !important;
    margin: 0 auto;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
}

/* Make iframe videos responsive with 70% size */
.mfp-iframe-holder .mfp-content {
    max-width: 70% !important;
    width: 70% !important;
    height: 70vh !important;
}

.mfp-iframe-scaler iframe {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.mfp-iframe-holder .mfp-content {
    background-color: #000;
    padding: 0;
    border-radius: 4px;
    overflow: hidden;
}

.mfp-close {
    color: #fff !important; /* White close button for visibility */
    opacity: 1 !important;
    font-size: 40px !important;
    right: 10px !important;
    top: 10px !important;
}

/* Special styling for close button in text-based popups */
.portfolio-content-lightbox .mfp-close {
    color: #333 !important; /* Match the text color in content popup */
}

/* Add specific class for video popup close button */
.mfp-iframe-holder .mfp-close {
    color: #fff !important; /* White for video popup */
    opacity: 1 !important;
    font-size: 40px !important;
    right: 10px !important;
    top: 10px !important;
}

/* Make the animation more pronounced */
.mfp-fade.mfp-bg {
    opacity: 0;
    transition: all 0.3s ease-out;
}

.mfp-fade.mfp-bg.mfp-ready {
    opacity: 0.9;
}

.mfp-fade.mfp-bg.mfp-removing {
    opacity: 0;
}

.mfp-fade.mfp-wrap .mfp-content {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease-out;
}

.mfp-fade.mfp-wrap.mfp-ready .mfp-content {
    opacity: 1;
    transform: scale(1);
}

.mfp-fade.mfp-wrap.mfp-removing .mfp-content {
    opacity: 0;
    transform: scale(0.8);
}

/* Custom lightbox styling - updated for proper background color targeting */
.portfolio-content-lightbox {
    position: relative;
    background: #fff;
    max-width: 800px;
    margin: 20px auto;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    padding: 40px;
    overflow: hidden;
    max-height: 80vh; /* Allow scrolling only in the lightbox popup */
    overflow-y: auto; /* Allow scrolling only in the lightbox popup */
    display: flex;
    flex-direction: column;
}

/* Make sure the background color properly applies to content popup */
.mfp-fade.portfolio-content-popup .mfp-content .portfolio-content-lightbox {
    background: #fff;
}

.portfolio-content-lightbox .portfolio-title {
    margin-top: 0;
    color: #333;
    font-size: 28px;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    font-weight: 600;
}

.portfolio-content-lightbox .portfolio-subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 0;
    font-weight: normal;
}

.portfolio-content-lightbox .portfolio-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 15px;
    font-size: 16px;
    line-height: 1.6;
}

/* Override WordPress default content styling */
.portfolio-content-lightbox .portfolio-content p {
    margin-bottom: 1.2em;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
}

.portfolio-content-lightbox .portfolio-content h1,
.portfolio-content-lightbox .portfolio-content h2,
.portfolio-content-lightbox .portfolio-content h3,
.portfolio-content-lightbox .portfolio-content h4,
.portfolio-content-lightbox .portfolio-content h5,
.portfolio-content-lightbox .portfolio-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    color: #333;
    font-weight: 600;
    line-height: 1.3;
}

.portfolio-content-lightbox .portfolio-content img {
    max-width: 100%;
    height: auto;
    margin: 1.5em 0;
    border-radius: 5px;
}

.portfolio-content-lightbox .portfolio-content ul,
.portfolio-content-lightbox .portfolio-content ol {
    margin-left: 1.5em;
    margin-bottom: 1.5em;
}

.portfolio-content-lightbox .portfolio-content li {
    margin-bottom: 0.5em;
}

.portfolio-content-lightbox .portfolio-content blockquote {
    border-left: 4px solid #eee;
    padding-left: 1.5em;
    margin-left: 0;
    font-style: italic;
    color: #666;
}

.portfolio-content-lightbox .portfolio-content a {
    color: #0073aa;
    text-decoration: none;
}

.portfolio-content-lightbox .portfolio-content a:hover {
    text-decoration: underline;
}

/* Make sure iframe video popups can be styled too */
.mfp-iframe-scaler iframe {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

/* Enhanced styling for the iframe holder to support background color */
.mfp-iframe-holder .mfp-content {
    padding: 0;
    border-radius: 4px;
    overflow: hidden;
}

/* Make sure the background color properly applies to video popup */
.mfp-fade.portfolio-video-popup .mfp-iframe-holder .mfp-content,
.mfp-fade.portfolio-video-popup .mfp-iframe-scaler {
    background-color: #000;
}

/* Override the hardcoded black background in iframe */
.mfp-fade.portfolio-video-popup .mfp-iframe-scaler iframe {
    background: transparent !important; /* Use transparent to let parent background show through */
}

/* Ensure the video popup background color takes precedence */
.mfp-fade.portfolio-video-popup .mfp-iframe-holder {
    padding-top: 0;
    padding-bottom: 0;
}

.mfp-fade.portfolio-video-popup .mfp-content {
    padding: 20px;
    border-radius: 4px;
    overflow: hidden;
}

/* Additional media queries for responsiveness */

/* Portfolio category filter */
.custom-portfolio-category-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 30px;
    gap: 20px;
}

.custom-portfolio-category-filter a {
    position: relative;
    text-decoration: none;
    transition: all 0.3s ease;
}

.custom-portfolio-category-filter a:hover,
.custom-portfolio-category-filter a.active {
    opacity: 1;
}

.custom-portfolio-category-filter a:after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    transition: width 0.3s ease;
}

.custom-portfolio-category-filter a:hover:after,
.custom-portfolio-category-filter a.active:after {
    width: 100%;
}

/* Add "All" category styling */
.custom-portfolio-category-filter a[data-category="all"] {
    font-weight: 500;
}

/* Filtered items - move completely off-screen without opacity changes */
.custom-portfolio-item.filtered {
    position: absolute;
    pointer-events: none;
    visibility: hidden;
    transform: translateX(100%); /* Move completely off-screen */
}

/* Animation styles for portfolio items - pure movement transitions */
.custom-portfolio-item {
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    backface-visibility: hidden;
}

/* Item movement states */
.custom-portfolio-item.move-out-right {
    transform: translateX(100%);
}

.custom-portfolio-item.move-out-left {
    transform: translateX(-100%);
}

.custom-portfolio-item.move-out-top {
    transform: translateY(-100%);
}

.custom-portfolio-item.move-out-bottom {
    transform: translateY(100%);
}

.custom-portfolio-item.move-in {
    transform: translateX(0);
}

/* Ensure each portfolio item has its own transform origin */
.custom-portfolio-grid {
    position: relative;
    transition: height 0.6s ease-in-out;
}

/* Ensure smooth reflow of grid items */
.custom-portfolio-grid::after {
    content: '';
    display: block;
    clear: both;
}

/* Loading indicator */
.portfolio-content-loading {
    text-align: center;
    padding: 60px;
    background: #fff;
    border-radius: 5px;
}

.portfolio-content-loading .spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto;
    background-color: #333;
    border-radius: 100%;
    animation: portfolio-spinner-pulse 1s infinite ease-in-out;
}

@keyframes portfolio-spinner-pulse {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1.0);
        opacity: 0;
    }
}

/* Ensure the main portfolio container doesn't scroll */
.custom-portfolio-template {
    overflow: hidden; /* Prevent scrolling in the widget container */
}

/* Only allow scrolling in the lightbox popup content */
.custom-portfolio-outer-container,
.custom-portfolio-full-width-wrapper,
.custom-portfolio-widget {
    overflow: hidden; /* Prevent scrolling in these containers */
}
