/**
 * Drag Slider Block - Styles
 * Responsive styling for the interactive drag slider
 */

/* Block Container */
.drag-slider-block {
    width: 100%;
    max-width: 1200px;
    margin: 3rem auto;
    padding: 0 20px;
    overflow: visible; /* Allow content to overflow at edges */
}

.drag-slider-container {
    position: relative;
    width: 100%;
}

/* Content Area - Now positioned relative to handle */
.drag-slider-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 400px;
    pointer-events: none;
    z-index: 8;
}

.drag-slider-content-inner {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    /* Border removed - will use background color from inline styles */
}

.drag-slider-content-text {
    width: 100%;
}

.drag-slider-description {
    font-size: 0.9375rem;
    line-height: 1;
    margin: 0;
    color: #333;
    transition: opacity 0.3s ease;
}

/* Arrow removed - no pointer to handle */

/* Track Container */
.drag-slider-track {
    position: relative;
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    margin: 10rem 0 4rem 0;
    padding-top: 120px;
    overflow: visible; /* Allow titles to overflow at edges */
}

/* Line Segments Container */
.drag-slider-line-segments {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    z-index: 0;
}

/* Individual Line Segments (between points) */
.drag-slider-line-segment {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    background: none;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Create dotted pattern with pseudo-element for better control */
.drag-slider-line-segment::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        to right,
        #ddd 0,
        #ddd 5px,
        transparent 5px,
        transparent 10px
    );
}

/* Progress Segments Container */
.drag-slider-progress-segments {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    z-index: 1;
}

/* Individual Progress Segments */
.drag-slider-progress-segment {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background-color: #ddd;
    z-index: 1;
    pointer-events: none;
    box-shadow: 0px 0px 10.4px 0px rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Snap Points Container */
.drag-slider-points {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
    height: 0;
}

/* Individual Snap Point Wrappers */
.drag-slider-point-wrapper {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s ease;
    /* Point itself will be aligned to line, wrapper extends below */
    transform: translateX(-50%);
    min-width: max-content; /* Allow title to take full width needed */
}

.drag-slider-point-wrapper.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Individual Snap Points - These should be on the line */
.drag-slider-point {
    width: var(--icon-size, 50px);
    height: var(--icon-size, 50px);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    /* Center the point itself on the line */
    margin-top: calc(var(--icon-size, 50px) / -2);
}

.drag-slider-point-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Fallback dot if no icon is uploaded */
.drag-slider-point:not(:has(.drag-slider-point-icon)) {
    background-color: #f0f0f0;
    border: 3px solid #ddd;
    border-radius: 50%;
}

.drag-slider-point:not(:has(.drag-slider-point-icon))::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: transparent;
    transition: all 0.3s ease;
}

/* Point Title */
.drag-slider-point-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #666;
    text-align: center;
    white-space: nowrap;
    line-height: 1.3;
    transition: all 0.3s ease;
}

.drag-slider-point-wrapper:hover .drag-slider-point:not(:has(.drag-slider-point-icon)),
.drag-slider-point-wrapper.hover .drag-slider-point:not(:has(.drag-slider-point-icon)) {
    background-color: #e8e8e8;
    border-color: #999;
}

.drag-slider-point-wrapper:hover .drag-slider-point-title,
.drag-slider-point-wrapper.hover .drag-slider-point-title {
    color: #333;
}

.drag-slider-point-wrapper.active .drag-slider-point:not(:has(.drag-slider-point-icon)) {
    background-color: #0073aa;
    border-color: #0073aa;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.drag-slider-point-wrapper.active .drag-slider-point-title {
    color: #0073aa;
    font-weight: 700;
}

/* Draggable Handle */
.drag-slider-handle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    z-index: 10;
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.drag-slider-handle.dragging {
    cursor: grabbing;
}

/* Handle Label */
.drag-slider-handle-label {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: #0073aa;
    white-space: nowrap;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Handle Circle */
.drag-slider-handle-circle {
    width: 60px;
    height: 60px;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11;
}

/* Handle Icon - No circle, just the icon */
.drag-slider-handle-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
    transition: all 0.3s ease;
}

/* Fallback circle if no icon is uploaded */
.drag-slider-handle-circle:not(:has(.drag-slider-handle-icon)) {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.drag-slider-handle-circle:not(:has(.drag-slider-handle-icon))::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid white;
    border-radius: 50%;
    opacity: 0.8;
}

.drag-slider-handle-circle:not(:has(.drag-slider-handle-icon))::after {
    content: '⟷';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    opacity: 0.9;
}

.drag-slider-handle:hover .drag-slider-handle-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.2));
}

.drag-slider-handle:hover .drag-slider-handle-circle:not(:has(.drag-slider-handle-icon)) {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.drag-slider-handle-circle.dragging .drag-slider-handle-icon {
    transform: scale(1.15);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
}

.drag-slider-handle-circle.dragging:not(:has(.drag-slider-handle-icon)) {
    transform: scale(1.15);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* Responsive Styles */

/* Tablets */
@media screen and (max-width: 768px) {
    .drag-slider-block {
        margin: 2rem auto;
        padding: 0 15px;
    }
    
    .drag-slider-content {
        max-width: 350px;
        margin-bottom: 1.5rem;
    }
    
    .drag-slider-content-inner {
        gap: 0.875rem;
        padding: 0.875rem 1.25rem;
    }
    
    .drag-slider-content-icon {
        width: 40px;
        height: 40px;
    }
    
    .drag-slider-description {
        font-size: 0.875rem;
    }
    
    .drag-slider-track {
        margin: 8rem 0 3rem 0;
        padding-top: 100px;
    }
    
    .drag-slider-handle {
        width: 50px;
        height: 50px;
    }
    
    .drag-slider-handle-circle {
        width: 50px;
        height: 50px;
    }
    
    .drag-slider-handle-circle::before {
        width: 34px;
        height: 34px;
    }
    
    .drag-slider-handle-circle::after {
        font-size: 1.25rem;
    }
    
    .drag-slider-point {
        width: 44px;
        height: 44px;
    }
    
    .drag-slider-point::before {
        width: 38px;
        height: 38px;
    }
    
    .drag-slider-point-title {
        font-size: 0.8125rem;
        max-width: 80px;
    }
}

/* Mobile - VERTICAL MODE */
@media screen and (max-width: 480px) {
    .drag-slider-block {
        margin: 1.5rem auto;
        padding: 0 10px;
    }
    
    /* Content stays above the handle on mobile too */
    .drag-slider-content {
        /* Keep same positioning as desktop */
        max-width: 280px;
    }
    
    .drag-slider-content-inner {
        padding: 0.75rem 1rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* Circle content on mobile - scale down proportionally */
    .drag-slider-content-inner[style*="width:"] {
        width: auto !important;
        height: auto !important;
        max-width: 140px !important;
        max-height: 140px !important;
        aspect-ratio: 1;
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .drag-slider-description {
        font-size: 0.8125rem;
    }
    
    /* Vertical track */
    .drag-slider-track {
        height: 800px;
        width: 100%;
        max-width: 100%;
        margin: 4rem auto;
        padding-top: 20px;
        padding-left: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    /* Vertical line segments container */
    .drag-slider-line-segments {
        left: 50%;
        top: 0;
        bottom: 0;
        right: auto;
        width: 0;
        height: 100%;
        transform: translateX(-50%);
    }
    
    /* Vertical progress segments container */
    .drag-slider-progress-segments {
        left: 50%;
        top: 0;
        bottom: 0;
        right: auto;
        width: 0;
        height: 100%;
        transform: translateX(-50%);
    }
    
    /* Vertical line segments */
    .drag-slider-line-segment {
        left: 50% !important;
        right: auto !important;
        width: 2px !important;
        transform: translateX(-50%) !important;
        background: none !important;
    }
    
    .drag-slider-line-segment::before {
        background-image: repeating-linear-gradient(
            to bottom,
            #ddd 0,
            #ddd 5px,
            transparent 5px,
            transparent 10px
        ) !important;
    }
    
    /* Vertical progress segments */
    .drag-slider-progress-segment {
        left: 50% !important;
        right: auto !important;
        width: 4px !important;
        transform: translateX(-50%) !important;
    }
    
    /* Points Container - Vertical */
    .drag-slider-points {
        top: 0;
        bottom: 0;
        left: 50%;
        right: auto;
        width: 0;
        height: 100%;
        transform: translateX(-50%);
    }
    
    /* Point wrapper - positioned vertically by JavaScript */
    .drag-slider-point-wrapper {
        flex-direction: column;
        gap: 1rem;
    }
    
    .drag-slider-point-title {
        font-size: 0.75rem;
        max-width: 100px;
        white-space: normal;
        text-align: center;
    }
    
    .drag-slider-point {
        width: var(--icon-size, 38px) !important;
        height: var(--icon-size, 38px) !important;
        border-width: 2px;
        margin-top: 0 !important;
    }
    
    .drag-slider-point::before {
        width: 32px;
        height: 32px;
    }
    
    /* Handle - vertical movement */
    .drag-slider-handle {
        width: 44px;
        height: 44px;
    }
    
    .drag-slider-handle-circle {
        width: 44px;
        height: 44px;
    }
    
    .drag-slider-handle-circle::before {
        width: 30px;
        height: 30px;
        border-width: 2px;
    }
    
    .drag-slider-handle-circle:not(:has(.drag-slider-handle-icon))::after {
        content: '↕';
        font-size: 1.125rem;
    }
    
    .drag-slider-handle-label {
        font-size: 0.6875rem;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 0.5rem;
    }
}

/* Editor Styles */
.block-editor-block-list__block[data-type="acf/drag-slider"] {
    margin: 2rem 0;
}

/* Animation States */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.drag-slider-point-wrapper.hover .drag-slider-point::before {
    background-color: rgba(0, 115, 170, 0.1);
}

.drag-slider-point-wrapper.active .drag-slider-point::before {
    background-color: rgba(0, 115, 170, 0.15);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .drag-slider-handle,
    .drag-slider-handle-circle,
    .drag-slider-point,
    .drag-slider-point-wrapper,
    .drag-slider-description,
    .drag-slider-handle-label,
    .drag-slider-content-icon img {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus States for Accessibility */
.drag-slider-handle:focus {
    outline: 2px solid #0073aa;
    outline-offset: 4px;
}

.drag-slider-point-wrapper:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.drag-slider-point-wrapper:focus .drag-slider-point {
    border-color: #0073aa;
}

/* Print Styles */
@media print {
    .drag-slider-handle {
        display: none;
    }
    
    .drag-slider-line {
        background: #ddd;
    }
}

