/**
 * Smart Accordion Widget Styles
 * Clean structure with proper z-index stacking
 */

/* Main Container */
.orpheon-smart-accordion {
    display: flex;
    width: 100%;
    overflow: hidden;
    position: relative;
    gap: 2px;
    min-height: 300px; /* Ensure minimum height to prevent collapse */
}

/* Parent container height management */
.elementor-widget-orpheon_smart_accordion {
    display: flex;
    flex-direction: column;
    min-height: 300px; /* Prevent parent from collapsing */
}

.elementor-widget-orpheon_smart_accordion .elementor-widget-container {
    display: flex;
    flex-direction: column;
    flex: 1; /* Take full height of parent */
}

/* Horizontal mode parent containers - fixed height */
.elementor-widget-orpheon_smart_accordion:has(.orpheon-smart-accordion:not(.vertical-mode)) {
    height: auto; /* Let Elementor set height */
    overflow: hidden;
}

.elementor-widget-orpheon_smart_accordion:has(.orpheon-smart-accordion:not(.vertical-mode)) .elementor-widget-container {
    height: auto; /* Let Elementor set height */
    overflow: hidden;
}

/* Horizontal mode (default) */
.orpheon-smart-accordion {
    flex-direction: row;
    /* min-height set by Elementor controls */
}

/* Horizontal mode - fixed height, never changes */
.orpheon-smart-accordion:not(.vertical-mode) {
    height: var(--elementor-height, 400px); /* Use Elementor height or fallback */
    max-height: var(--elementor-height, 400px); /* Lock to set height */
    min-height: var(--elementor-height, 400px); /* Prevent shrinking */
    overflow: hidden; /* Ensure no content escapes */
}

/* Vertical mode */
.orpheon-smart-accordion.vertical-mode {
    flex-direction: column;
    min-height: auto;
}

/* Individual Item */
.orpheon-smart-accordion-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s ease-in-out;
    flex: 1;
    min-height: 80px;
    min-width: 80px; /* Prevent items from collapsing to zero width */
    display: flex;
    flex-direction: column;
}

/* Horizontal mode items - force consistent height */
.orpheon-smart-accordion:not(.vertical-mode) .orpheon-smart-accordion-item {
    height: 100%; /* Force items to match accordion height */
    max-height: 100%; /* Prevent expansion beyond accordion */
    width: auto; /* Ensure width is determined by flex, not content */
}

/* Horizontal mode items - ensure equal distribution before active state */
.orpheon-smart-accordion:not(.vertical-mode) .orpheon-smart-accordion-item:not(.active) {
    flex: 1; /* Equal distribution for all closed items */
    min-width: 100px; /* Minimum width to prevent collapse */
}

/* Horizontal mode items */
.orpheon-smart-accordion:not(.vertical-mode) .orpheon-smart-accordion-item.active {
    flex: 3; /* Default ratio when custom ratio is not enabled */
}

/* Vertical mode items */
.orpheon-smart-accordion.vertical-mode .orpheon-smart-accordion-item {
    width: 100%;
    flex: 1; /* Equal distribution for closed items */
    min-height: 80px;
    height: auto; /* Allow natural height based on content */
    display: flex;
    flex-direction: column;
}

.orpheon-smart-accordion.vertical-mode .orpheon-smart-accordion-item.active {
    flex: 3; /* Give active item more space by default - will be overridden by custom ratio if enabled */
}

/* Vertical mode content should determine height */
.orpheon-smart-accordion.vertical-mode .orpheon-accordion-content {
    flex: 1;
    min-height: 80px;
}

/* Background Image - LOWEST layer */
.orpheon-accordion-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%!important;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    z-index: 1;
    transition: transform 0.6s ease-in-out, opacity 0.4s ease-in-out;
}

/* Background image hover/active effects */
.orpheon-smart-accordion-item:hover .orpheon-accordion-bg,
.orpheon-smart-accordion-item.active .orpheon-accordion-bg {
    transform: scale(1.05);
}

/* Mobile background scaling */
@media (max-width: 767px) {
    .orpheon-smart-accordion-item.active .orpheon-accordion-bg {
        transform: scale(1.1);
    }
}

/* Overlay using ::before - MIDDLE layer */
.orpheon-smart-accordion-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: background 0.4s ease-in-out;
    pointer-events: none;
    z-index: 2;
}

/* Content Wrapper - Normal flow positioning */
.orpheon-accordion-content {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    height: 100%;
    flex: 1;
    padding: 2rem;
    box-sizing: border-box;
}

/* Horizontal mode content height constraint */
.orpheon-smart-accordion:not(.vertical-mode) .orpheon-accordion-content {
    height: 100%; /* Force full height */
    max-height: 100%; /* Never exceed parent */
    overflow: hidden;
}

/* Closed Content */
.orpheon-closed-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
}

.orpheon-smart-accordion-item.active .orpheon-closed-content {
    display: none;
}

/* Closed Icon */
.orpheon-closed-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}

.orpheon-closed-icon,
.orpheon-closed-icon i,
.orpheon-closed-icon svg,
.orpheon-closed-icon svg path {
    color: #ffffff;
    fill: #ffffff;
}

.orpheon-closed-icon svg {
    width: 2rem;
    height: 2rem;
}

.orpheon-closed-icon i {
    font-size: 2rem;
}

/* Closed Title */
.orpheon-closed-title {
    margin: 0;
    text-align: center;
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Opened Content */
.orpheon-opened-content {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: 15px;
    align-items: flex-start;
    justify-content: flex-end;
}

.orpheon-smart-accordion-item.active .orpheon-opened-content {
    display: flex;
}

/* Horizontal Layout - Opened Content aligned to bottom/start */
.orpheon-smart-accordion:not(.vertical-mode) .orpheon-opened-content {
    justify-content: flex-end;
    align-items: flex-start;
    height: 100%; /* Force full height */
    max-height: 100%; /* Never exceed parent */
    overflow: hidden;
}

/* Vertical Layout - Opened Content centered/flexible */
.orpheon-smart-accordion.vertical-mode .orpheon-opened-content {
    justify-content: center;
    align-items: flex-start;
    max-height: none; /* No height constraint in vertical mode */
    overflow: visible;
}

/* Animation for opened content - works in both frontend and editor */
.orpheon-smart-accordion-item.active .orpheon-opened-content {
    animation: var(--accordion-animation, fadeIn) var(--accordion-duration, 0.4s) var(--accordion-easing, ease-in-out) forwards;
}

/* Default animation keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide Up animation */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide Down animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scale animation */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide Right animation */
@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide Left animation */
@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Opened Number */
.orpheon-opened-number {
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    margin: 0;
    color: #ffffff;
    opacity: 0.9;
}

/* Opened Title */
.orpheon-opened-title {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
}

/* Opened Description */
.orpheon-opened-description {
    margin: 0;
    color: #ffffff;
    font-size: 1rem;
    line-height: 1.6;
    opacity: 0.95;
}

/* Button - Minimal base styles, styling controlled by Elementor */
.orpheon-accordion-button {
    display: inline-block;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

/* Hover effects for desktop */
@media (hover: hover) {
    .orpheon-smart-accordion-item:hover:not(.active) {
        opacity: 0.9;
    }
}



/* Mobile responsive */
@media (max-width: 767px) {
    .orpheon-smart-accordion {
        flex-direction: column !important;
        gap: 1px;
    }
    
    .orpheon-smart-accordion-item {
        flex: 0 0 auto !important;
        min-height: 60px;
    }
    
    .orpheon-smart-accordion-item.active {
        flex: 1 1 auto !important;
    }
}



/* Accessibility */
.orpheon-smart-accordion-item:focus {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.orpheon-smart-accordion-item:focus:not(:focus-visible) {
    outline: none;
}

/* Loading state optimization */
.orpheon-accordion-bg[loading="lazy"] {
    background-color: #f0f0f0;
}

/* Print styles */
@media print {
    .orpheon-smart-accordion-item {
        flex: 1;
        page-break-inside: avoid;
    }
    
    .orpheon-closed-content,
    .orpheon-opened-content {
        display: flex;
    }
}
