/* Unique Scroll Handle Design - Dual-sided Teeth/Gear Pointer */

/* Scroll track below each belt */
.scroll-track {
    position: absolute;
    bottom: -30px;
    left: 80px; /* Start after core element */
    right: 10px;
    height: 0; /* Start with no height */
    background: linear-gradient(90deg,
        rgba(30, 30, 40, 0.8) 0%,
        rgba(40, 40, 50, 0.6) 50%,
        rgba(30, 30, 40, 0.8) 100%);
    border-radius: 10px;
    border: 1px solid rgba(100, 100, 120, 0.3);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(255, 255, 255, 0.05);
    z-index: 20;
    overflow: visible;
    transition: opacity 0.3s, height 0.3s, bottom 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* Active scrollable state - fully visible and expanded */
.scroll-track.scrollable {
    opacity: 1;
    visibility: visible;
    height: 20px; /* Full height when scrollable */
    bottom: -30px; /* Normal position */
    border-color: rgba(150, 150, 170, 0.5);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(255, 255, 255, 0.1),
        0 0 10px rgba(100, 150, 255, 0.15);
}

/* Inactive state when no scrolling needed - completely hidden and collapsed */
.scroll-track.no-scroll {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    height: 0;
    bottom: 0; /* Move up to reclaim space */
    transition: opacity 0.3s, visibility 0.3s, height 0.3s, bottom 0.3s;
}

/* Track groove pattern */
.scroll-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg,
        transparent 0px,
        rgba(255, 255, 255, 0.1) 2px,
        transparent 4px,
        transparent 10px);
    transform: translateY(-50%);
    transition: opacity 0.3s;
}

.scrollable.scroll-track::before {
    opacity: 1;
    background: repeating-linear-gradient(90deg,
        transparent 0px,
        rgba(100, 150, 255, 0.2) 2px,
        transparent 4px,
        transparent 10px);
}

.no-scroll.scroll-track::before {
    opacity: 0.3;
}

/* Dual-sided teeth pointer handle */
.scroll-handle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 40px;
    cursor: grab;
    z-index: 25;
    transition: transform 0.2s ease;
}

.scroll-handle:active {
    cursor: grabbing;
    transform: translateY(-50%) scale(1.1);
}

/* Central grip body */
.scroll-handle-body {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 24px;
    background: linear-gradient(135deg,
        rgba(139, 69, 19, 0.9) 0%,
        rgba(160, 82, 45, 0.9) 50%,
        rgba(139, 69, 19, 0.9) 100%);
    border: 2px solid rgba(92, 51, 23, 0.9);
    border-radius: 6px;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* Greyed out handle when no scroll */
.no-scroll .scroll-handle-body {
    background: linear-gradient(135deg,
        rgba(80, 80, 90, 0.6) 0%,
        rgba(100, 100, 110, 0.6) 50%,
        rgba(80, 80, 90, 0.6) 100%);
    border-color: rgba(60, 60, 70, 0.6);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* Active scrollable handle */
.scrollable .scroll-handle-body {
    background: linear-gradient(135deg,
        rgba(160, 82, 45, 1) 0%,
        rgba(180, 100, 60, 1) 50%,
        rgba(160, 82, 45, 1) 100%);
    border-color: rgba(110, 60, 25, 1);
    box-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.7),
        0 0 15px rgba(255, 180, 100, 0.2),
        inset 0 1px 3px rgba(255, 255, 255, 0.3);
}

/* Grip lines on handle */
.scroll-handle-body::before {
    content: '|||';
    color: rgba(255, 255, 255, 0.3);
    font-size: 10px;
    letter-spacing: 2px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Left teeth/gear pointer */
.scroll-handle-left,
.scroll-handle-right {
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    transform: translateY(-50%);
}

.scroll-handle-left {
    left: 5px;
}

.scroll-handle-left::before,
.scroll-handle-left::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
}

/* Main left arrow */
.scroll-handle-left::before {
    border-style: solid;
    border-width: 12px 12px 12px 0;
    border-color: transparent rgba(139, 69, 19, 0.8) transparent transparent;
    right: 0;
    top: -12px;
    filter: drop-shadow(-2px 0 2px rgba(0, 0, 0, 0.4));
    transition: border-color 0.3s;
}

.no-scroll .scroll-handle-left::before {
    border-color: transparent rgba(80, 80, 90, 0.5) transparent transparent;
}

.scrollable .scroll-handle-left::before {
    border-color: transparent rgba(160, 82, 45, 0.9) transparent transparent;
}

/* Left teeth detail - HIDDEN */
.scroll-handle-left::after {
    content: '◀';
    position: absolute;
    right: 2px;
    top: -8px;
    color: rgba(255, 215, 0, 0.6);
    font-size: 16px;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.3);
    display: none !important; /* Hide yellow arrow */
}

/* Right teeth/gear pointer */
.scroll-handle-right {
    right: 5px;
}

.scroll-handle-right::before,
.scroll-handle-right::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
}

/* Main right arrow */
.scroll-handle-right::before {
    border-style: solid;
    border-width: 12px 0 12px 12px;
    border-color: transparent transparent transparent rgba(139, 69, 19, 0.8);
    left: 0;
    top: -12px;
    filter: drop-shadow(2px 0 2px rgba(0, 0, 0, 0.4));
    transition: border-color 0.3s;
}

.no-scroll .scroll-handle-right::before {
    border-color: transparent transparent transparent rgba(80, 80, 90, 0.5);
}

.scrollable .scroll-handle-right::before {
    border-color: transparent transparent transparent rgba(160, 82, 45, 0.9);
}

/* Right teeth detail - HIDDEN */
.scroll-handle-right::after {
    content: '▶';
    position: absolute;
    left: 2px;
    top: -8px;
    color: rgba(255, 215, 0, 0.6);
    font-size: 16px;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.3);
    display: none !important; /* Hide yellow arrow */
}

/* Hover effects - only for scrollable state */
.scrollable .scroll-handle:hover .scroll-handle-body {
    background: linear-gradient(135deg,
        rgba(180, 100, 60, 1) 0%,
        rgba(200, 120, 80, 1) 50%,
        rgba(180, 100, 60, 1) 100%);
    box-shadow: 
        0 3px 12px rgba(0, 0, 0, 0.8),
        0 0 25px rgba(255, 215, 0, 0.3),
        inset 0 1px 3px rgba(255, 255, 255, 0.4);
}

/* No hover effect for non-scrollable */
.no-scroll .scroll-handle:hover .scroll-handle-body {
    background: linear-gradient(135deg,
        rgba(80, 80, 90, 0.6) 0%,
        rgba(100, 100, 110, 0.6) 50%,
        rgba(80, 80, 90, 0.6) 100%);
    cursor: default;
}

.scroll-handle:hover .scroll-handle-left::after,
.scroll-handle:hover .scroll-handle-right::after {
    color: rgba(255, 215, 0, 0.9);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
    display: none !important; /* Keep hidden on hover */
}

/* Active/dragging state - only for scrollable */
.scrollable .scroll-handle.dragging .scroll-handle-body {
    background: linear-gradient(135deg,
        rgba(200, 120, 80, 1) 0%,
        rgba(220, 140, 100, 1) 50%,
        rgba(200, 120, 80, 1) 100%);
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.9),
        0 0 35px rgba(255, 215, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

.scrollable .scroll-handle.dragging .scroll-handle-left::before {
    border-right-color: rgba(200, 120, 80, 1);
}

.scrollable .scroll-handle.dragging .scroll-handle-right::before {
    border-left-color: rgba(200, 120, 80, 1);
}

/* Element type specific colors */
.fire-group .scroll-handle:hover .scroll-handle-body {
    box-shadow: 
        0 3px 12px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(255, 87, 34, 0.3);
}

.water-group .scroll-handle:hover .scroll-handle-body {
    box-shadow: 
        0 3px 12px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(33, 150, 243, 0.3);
}

.earth-group .scroll-handle:hover .scroll-handle-body {
    box-shadow: 
        0 3px 12px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(139, 69, 19, 0.3);
}

.air-group .scroll-handle:hover .scroll-handle-body {
    box-shadow: 
        0 3px 12px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(150, 200, 255, 0.3);
}

/* Position indicators on track */
.scroll-track-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg,
        rgba(255, 215, 0, 0.1) 0%,
        rgba(255, 215, 0, 0.2) 50%,
        rgba(255, 215, 0, 0.1) 100%);
    border-radius: 10px;
    pointer-events: none;
    transition: width 0.1s ease-out, opacity 0.3s;
}

.no-scroll .scroll-track-fill {
    opacity: 0.3;
}

.scrollable .scroll-track-fill {
    background: linear-gradient(90deg,
        rgba(100, 150, 255, 0.15) 0%,
        rgba(100, 150, 255, 0.25) 50%,
        rgba(100, 150, 255, 0.15) 100%);
    opacity: 1;
}

/* Adjust belt container dynamically based on scroll track visibility */
.element-group {
    position: relative;
    margin-bottom: 10px; /* Minimal bottom margin by default */
    transition: margin-bottom 0.3s ease;
}

/* When scroll track is visible, add space */
.element-group.has-scroll {
    margin-bottom: 35px; /* Space for visible scroll track */
}

/* Hide native scrollbar completely */
.kinetic-scroll-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.kinetic-scroll-container::-webkit-scrollbar {
    display: none;
}

/* Smooth scroll behavior */
.kinetic-scroll-container {
    scroll-behavior: auto; /* We'll handle smoothness in JS */
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling on iOS */
    transform: translateZ(0); /* Force GPU acceleration */
    backface-visibility: hidden; /* Prevent flickering */
    will-change: scroll-position; /* Optimize for scrolling */
}

/* Fade in animation when scroll becomes available */
@keyframes fadeInScroll {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade out animation when scroll is no longer needed */
@keyframes fadeOutScroll {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(5px);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .scroll-track {
        bottom: -25px;
        left: 65px;
    }
    
    .scroll-track.scrollable {
        height: 16px;
        bottom: -25px;
    }
    
    .scroll-track.no-scroll {
        height: 0;
        bottom: 0;
    }
    
    .scroll-handle {
        width: 50px;
        height: 32px;
    }
    
    .scroll-handle-body {
        width: 32px;
        height: 20px;
    }
    
    .scroll-handle-left::before {
        border-width: 10px 10px 10px 0;
        top: -10px;
    }
    
    .scroll-handle-right::before {
        border-width: 10px 0 10px 10px;
        top: -10px;
    }
    
    .element-group {
        margin-bottom: 25px;
    }
}