/* Mobile Pills Layout */
.loophole-mobile-container {
    width: 100%;
    margin: 20px 0;
    overflow: hidden;
}

.loophole-mobile-row {
    position: relative;
    width: 100%;
    overflow-x: auto;
    margin-bottom: 0px;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: none; /* Hide scrollbar - Firefox */
    /* Fix the left scrolling issue by ensuring overflow is properly handled */
    overflow: auto;
    touch-action: pan-y pan-x; /* Ensures horizontal swipe works properly */
    cursor: grab; /* Indicates content is draggable */
    transition: opacity 0.8s ease-in; /* Smooth fade-in effect */
}

.loophole-mobile-row::-webkit-scrollbar {
    display: none; /* Hide scrollbar - Chrome/Safari */
}

.loophole-mobile-inner {
    display: flex;
    position: relative;
    will-change: transform; /* Performance optimization for animations */
    pointer-events: auto;
    /* Adjust transition for smoother control */
    transition: transform 0.01s linear;
}

/* Ensure touch interaction works well */
.loophole-mobile-row:active {
    cursor: grabbing;
}

/* Make sure cloned pills match the originals exactly */
.loophole-mobile-pill.clone {
    opacity: 1;
    transform: scale(1);
    transition: none !important; /* Disable transitions for clones to prevent flashing */
}

/* Individual pill styling */
.loophole-mobile-pill {
    flex: 0 0 auto;
    width: 290px;
    height: 82px;
    margin: 0 8px;
    background-color: #f8f8f8;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid #eaeaea;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    opacity: 0;
    transform: scale(0.95);
    /* Add these for better touch behavior */
    user-select: none;
    -webkit-user-select: none;
}

.loophole-mobile-pill.loaded {
    opacity: 1;
    transform: scale(1);
}

/* Staggered animation timing */
.loophole-mobile-pill:nth-child(1) { transition-delay: 0.05s; }
.loophole-mobile-pill:nth-child(2) { transition-delay: 0.1s; }
.loophole-mobile-pill:nth-child(3) { transition-delay: 0.15s; }
.loophole-mobile-pill:nth-child(4) { transition-delay: 0.2s; }
.loophole-mobile-pill:nth-child(5) { transition-delay: 0.25s; }
.loophole-mobile-pill:nth-child(6) { transition-delay: 0.3s; }

.loophole-mobile-pill .highlight {
    color: #4361ee;
    font-weight: 600;
}

/* Loading state */
.loophole-mobile-pill.loading {
    background-color: #f0f0f0;
    animation: mobile-pulse 1.5s infinite alternate;
}

@keyframes mobile-pulse {
    0% { opacity: 0.5; }
    100% { opacity: 0.8; }
}

/* Mobile Popup Styling */
.loophole-mobile-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.loophole-mobile-popup-container {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: none;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.loophole-mobile-popup-container.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.loophole-mobile-popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.loophole-mobile-popup-close:hover {
    color: #333;
}

.loophole-mobile-popup-content {
    padding: 30px 30px 15px 30px;
}

.loophole-mobile-popup-text {
    font-size: 15px;
    line-height: 17px;
    margin-bottom: 20px;
    margin-right: 15px;
}

.loophole-mobile-popup-text .highlight {
    color: #4361ee;
    font-weight: 600;
}

.loophole-mobile-popup-content h4 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #333;
}

.loophole-mobile-popup-approach {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 20px;
}

.loophole-mobile-popup-approach ol {
    padding-left: 20px;
}

.loophole-mobile-popup-approach li {
    margin-bottom: 15px;
}

.loophole-mobile-popup-approach strong {
    color: #4361ee;
}

/* Disclaimer Styling */
.loophole-mobile-popup-disclaimer {
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.loophole-mobile-popup-disclaimer p {
    font-size: 9px;
    line-height: 10px;
    color: #777;
    margin: 0;
}

/* Device-specific display rules */
@media (max-width: 767px) {
    .loophole-pill-grid,
    .loophole-more-ideas-container {
        display: none !important;
    }
    
    .loophole-mobile-container {
        display: block;
    }
}

@media (min-width: 768px) {
    .loophole-mobile-container {
        display: none;
    }
}

/* Prevent body scroll when mobile popup is open */
body:has(.loophole-mobile-popup-container.active) {
    overflow: hidden !important;
}

/* Fallback class for browsers that don't support :has() */
body.loophole-mobile-popup-open {
    overflow: hidden !important;
}