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

/* Main Container */
.orpheon-smart-accordion {
    display: flex;
    width: 100%;
    overflow: hidden;
    position: relative;
    height: 100%; /* Ensure it takes full height of parent */
}

/* Horizontal mode - height from items */
.orpheon-smart-accordion:not([style*="flex-direction: column"]) {
    height: auto;
}

/* Vertical mode - needs defined height to distribute properly */
.orpheon-smart-accordion[style*="flex-direction: column"] {
    height: 100vh; /* Full viewport height for vertical mode */
    min-height: 600px; /* Minimum usable height */
}

/* Individual Item */
.orpheon-smart-accordion-item {
    position: relative;
    flex: 1;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s ease-in-out;
    min-height: 200px;
}

/* Active state - takes more space */
.orpheon-smart-accordion-item.active {
    flex: 4;
}

/* Background Image - LOWEST layer */
.orpheon-accordion-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%!important;
    height: 100%!important;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    z-index: 0;
}

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

/* Active state gets darker overlay */
.orpheon-smart-accordion-item.active::before {
    background: rgba(0, 0, 0, 0.6);
}

/* Content Wrapper - TOP layer, must fill parent completely */
.orpheon-accordion-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    height: 100%;
    padding: 2rem;
}

/* 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-bottom: 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([style*="flex-direction: column"]) .orpheon-opened-content {
    justify-content: flex-end;
    align-items: flex-start;
}

/* Vertical Layout - Opened Content centered/flexible */
.orpheon-smart-accordion[style*="flex-direction: column"] .orpheon-opened-content {
    justify-content: center;
    align-items: flex-start;
}

/* Animation for opened content - only on frontend */
body:not(.elementor-editor-active) .orpheon-smart-accordion-item.active .orpheon-opened-content {
    animation: fadeIn 0.4s ease-in-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(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 */
.orpheon-accordion-button {
    display: inline-block;
    text-decoration: none;
    text-align: center;
    padding: 0.75rem 2rem;
    background: #ffffff;
    color: #000000;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.3s ease-in-out;
    cursor: pointer;
}

.orpheon-accordion-button:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

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

/* Vertical layout adjustments - Proper flex-based sizing */
.orpheon-smart-accordion[style*="flex-direction: column"] .orpheon-smart-accordion-item {
    width: 100%;
    flex: 1 1 0; /* Equal distribution, can grow and shrink */
    min-height: 100px;
    max-height: none; /* Allow flex to control height */
}

.orpheon-smart-accordion[style*="flex-direction: column"] .orpheon-smart-accordion-item.active {
    flex: 4 1 0; /* Active takes 4x space (40% with 5 items) */
    min-height: 200px; /* Larger min for active */
}

/* Mobile default vertical layout - force vertical behavior */
@media (max-width: 767px) {
    .orpheon-smart-accordion {
        flex-direction: column !important;
        height: 100vh !important; /* Full viewport height for proper distribution */
        min-height: 500px !important; /* Minimum mobile height */
    }
    
    .orpheon-smart-accordion .orpheon-smart-accordion-item {
        width: 100%;
        flex: 1 1 0; /* Flex-grow, flex-shrink, flex-basis */
        min-height: 80px; /* Smaller min for mobile */
    }
    
    .orpheon-smart-accordion .orpheon-smart-accordion-item.active {
        flex: 4 1 0; /* Active takes 40% of total height */
    }
}

/* Tablet considerations */
@media (min-width: 768px) and (max-width: 1024px) {
    .orpheon-smart-accordion[style*="flex-direction: column"] {
        height: 100vh;
        min-height: 600px;
    }
    
    .orpheon-smart-accordion[style*="flex-direction: column"] .orpheon-smart-accordion-item {
        width: 100%;
        flex: 1 1 0;
        min-height: 100px;
    }
    
    .orpheon-smart-accordion[style*="flex-direction: column"] .orpheon-smart-accordion-item.active {
        flex: 4 1 0; /* Active takes 40% of total height */
    }
}

/* 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;
    }
}
