/* Swipe Gesture Styles for Rivlup */

/* Swipeable container */
.swipeable {
    position: relative;
    touch-action: pan-y; /* Allow vertical scrolling */
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden; /* Hide action icons by default */
}

/* Swipe action backgrounds */
.swipeable::before,
.swipeable::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: -1;
}

/* Left action (revealed when swiping right) */
.swipeable::before {
    left: 0;
    background: linear-gradient(to right, #10b981, #059669);
    border-radius: 1.5rem 0 0 1.5rem;
}

/* Right action (revealed when swiping left) */
.swipeable::after {
    right: 0;
    background: linear-gradient(to left, #ef4444, #dc2626);
    border-radius: 0 1.5rem 1.5rem 0;
}

/* Show background when swiping */
.swipeable.swiping-left::after {
    opacity: 1;
}

.swipeable.swiping-right::before {
    opacity: 1;
}

/* Action icons (using CSS shapes) */
.swipe-action-left,
.swipe-action-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden; /* Completely hide when not swiping */
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
    pointer-events: none;
    z-index: 10;
}

.swipe-action-left {
    left: 20px;
    color: white;
    font-size: 24px;
}

.swipe-action-right {
    right: 20px;
    color: white;
    font-size: 24px;
}

.swipeable.swiping-right .swipe-action-left {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
    transform: translateY(-50%) scale(1.1);
}

.swipeable.swiping-left .swipe-action-right {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
    transform: translateY(-50%) scale(1.1);
}

/* Topic Card Swipe Specific Styles */
.topic-card-swipe {
    /* Inherits overflow: hidden from .swipeable */
}

/* Prevent text selection during swipe */
.swipeable.swiping-left *,
.swipeable.swiping-right * {
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile menu edge swipe indicator */
.edge-swipe-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 9999;
}

.edge-swipe-indicator.active {
    opacity: 1;
}

/* Smooth transitions for swipe reset */
.swipeable.resetting {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease !important;
}

/* Disable hover effects during swipe */
.swipeable.swiping-left,
.swipeable.swiping-right {
    pointer-events: none;
}

/* Action buttons revealed by swipe */
.swipe-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
}

.swipe-actions.left {
    left: 0;
}

.swipe-actions.right {
    right: 0;
}

.swipe-action-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.swipeable.swiping-left .swipe-actions.right .swipe-action-button,
.swipeable.swiping-right .swipe-actions.left .swipe-action-button {
    opacity: 1;
    transform: scale(1);
}

/* Bookmark action (swipe right) */
.swipe-action-bookmark {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

/* Share action (swipe left) */
.swipe-action-share {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

/* Delete action (swipe left, alternative) */
.swipe-action-delete {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

/* Haptic feedback simulation (visual) */
@keyframes haptic-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.swipeable.haptic {
    animation: haptic-pulse 0.1s ease;
}

/* Responsive adjustments */
@media (min-width: 768px) {
    /* Disable swipe gestures on desktop by default */
    .swipeable:not(.swipeable-desktop) {
        touch-action: auto;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .swipe-action-button {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
    }
}
