/* Visual composition component styles */

.visual-composition {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* Prevent layout shifts during asset loading */
    min-height: 300px;
}

/* Background layer - lowest z-index */
.composition-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 60%;
    height: 60%;
    object-fit: cover;
    z-index: 1;
    /* Prevent layout shifts */
    min-height: 300px;
    background-color: transparent;
}

/* Video layer - middle z-index */
.composition-video-wrap {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50%;
    max-width: 50%;
    z-index: 2;
}

.composition-video {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Prevent layout shifts */
    min-height: 300px;
    background-color: transparent;

    /* SVG masks default to alpha; luminance matches PNG mask behavior (white = visible) */
    mask: url('../assets/mask.svg') center / cover no-repeat luminance;
    -webkit-mask: url('../assets/mask.svg') center / cover no-repeat;
    -webkit-mask-source-type: luminance;
    mask-mode: luminance;
}

.composition-mute {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 2;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: rgba(30, 30, 30, 0.18);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
}

.composition-mute:hover,
.composition-mute:focus-visible {
    background: rgba(30, 30, 30, 0.35);
    outline: none;
}

.composition-mute-icon {
    width: 1.1rem;
    height: 1.1rem;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cline x1='23' y1='9' x2='17' y2='15'/%3E%3Cline x1='17' y1='9' x2='23' y2='15'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cline x1='23' y1='9' x2='17' y2='15'/%3E%3Cline x1='17' y1='9' x2='23' y2='15'/%3E%3C/svg%3E") center / contain no-repeat;
}

.composition-mute[aria-pressed="false"] .composition-mute-icon {
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cpath d='M19.07 4.93a10 10 0 0 1 0 14.14'/%3E%3Cpath d='M15.54 8.46a5 5 0 0 1 0 7.07'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cpath d='M19.07 4.93a10 10 0 0 1 0 14.14'/%3E%3Cpath d='M15.54 8.46a5 5 0 0 1 0 7.07'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Front overlay layer - highest z-index */
.composition-front {
    position: absolute;
    top: -10%;
    left: -29%;
    width: 90%;
    height: 90%;
    object-fit: cover;
    z-index: 3;
    pointer-events: none;
    /* Allow interaction with elements below if needed */
    /* Prevent layout shifts */
    min-height: 300px;
    background-color: transparent;
}

/* Responsive Visual Composition Adjustments */

/* Desktop (> 1024px) */
@media (min-width: 1025px) {
    .visual-composition {
        width: 100%;
        height: 100%;
    }

    .composition-video-wrap {
        width: 50%;
        max-width: 50%;
    }

    .composition-video {
        mask-size: cover;
        -webkit-mask-size: cover;
    }
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .visual-composition {
        width: 100%;
        height: 100%;
    }

    .composition-video-wrap {
        width: 50%;
        max-width: 50%;
    }

    .composition-video {
        max-height: 95%;
        mask-size: contain;
        -webkit-mask-size: contain;
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    .visual-composition {
        height: 60vh;
        min-height: 400px;
        width: 100%;
    }

    .composition-video-wrap {
        width: 50%;
        max-width: 50%;
    }

    .composition-video {
        max-height: 90%;
        mask-size: contain;
        -webkit-mask-size: contain;
    }

    .composition-background,
    .composition-front {
        object-fit: contain;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 479px) {
    .visual-composition {
        height: 50vh;
        min-height: 300px;
    }

    .composition-video-wrap {
        width: 50%;
        max-width: 50%;
    }

    .composition-video {
        max-height: 85%;
        mask-size: contain;
        -webkit-mask-size: contain;
    }
}

/* Ensure proper aspect ratio maintenance */
.composition-background,
.composition-front {
    object-position: center;
}

.composition-video {
    object-position: center;
}

/* Loading states for better UX */
.composition-background,
.composition-front {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.composition-background.loaded,
.composition-front.loaded {
    opacity: 1;
}

/* Video loading state */
.composition-video {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.composition-video.loaded {
    opacity: 1 !important;
}

/* Video error state */
.composition-video.error {
    display: none !important;
}

/* Video fallback styling */
.video-fallback {
    font-family: var(--font-main, 'Questrial-Regular', Arial, sans-serif);
    backdrop-filter: blur(2px);
}

.video-fallback span {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Play prompt styling */
.play-prompt {
    font-family: var(--font-main, 'Questrial-Regular', Arial, sans-serif);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.play-prompt:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.05);
}

/* Video playing state */
.composition-video.playing {
    opacity: 1;
}

/* Fallback for browsers without mask support */
@supports not (mask: url('')) and not (-webkit-mask: url('')) {
    .composition-video {
        /* Video will display normally without masking in unsupported browsers */
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
}

/* Enhanced video controls for better browser compliance */
.composition-video::-webkit-media-controls {
    display: none !important;
}

.composition-video::-webkit-media-controls-panel {
    display: none !important;
}

.composition-video::-webkit-media-controls-play-button {
    display: none !important;
}

.composition-video::-webkit-media-controls-start-playback-button {
    display: none !important;
}