/* Pill Grid Layout */
.loophole-pill-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin: 30px 0;
    width: 100%;
    position: relative;
}

/* Row-based staggering - this is the key change */
/* Each row should have 3 items (3 columns) */
/* First row - items 1,2,3 - no offset */
/* Second row - items 4,5,6 - offset left */
.loophole-pill-grid .loophole-pill-container:nth-child(3n+1):nth-child(n+4):nth-child(-n+6),
.loophole-pill-grid .loophole-pill-container:nth-child(3n+2):nth-child(n+4):nth-child(-n+6),
.loophole-pill-grid .loophole-pill-container:nth-child(3n+3):nth-child(n+4):nth-child(-n+6),
.loophole-pill-grid .loophole-pill-container:nth-child(3n+1):nth-child(n+10):nth-child(-n+12),
.loophole-pill-grid .loophole-pill-container:nth-child(3n+2):nth-child(n+10):nth-child(-n+12),
.loophole-pill-grid .loophole-pill-container:nth-child(3n+3):nth-child(n+10):nth-child(-n+12) {
    transform: translateX(35px);
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .loophole-pill-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Reset staggering for 2-column layout */
    .loophole-pill-grid .loophole-pill-container {
        transform: translateX(0) !important;
    }
    
    /* New staggering for 2-column layout */
    .loophole-pill-grid .loophole-pill-container:nth-child(2n) {
        transform: translateY(15px) !important;
    }
}

@media (max-width: 576px) {
    .loophole-pill-grid {
        grid-template-columns: 1fr;
    }
    
    /* Remove staggering for single column */
    .loophole-pill-grid .loophole-pill-container {
        transform: translateX(0) !important;
        transform: translateY(0) !important;
    }
}

/* Loading State Placeholder */
.loophole-pill-container.loading {
    background-color: #f0f0f0;
    height: 80px;
    border-radius: 12px;
    animation: pulse 1.5s infinite alternate;
}

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

/* Pill Container Styling */
.loophole-pill-container {
    background-color: #f8f8f8;
    border-radius: 12px;
    padding: 40px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: box-shadow 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    cursor: pointer;
    border: 1px solid #eaeaea;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 290px;
    opacity: 0;
    transform: translateX(30px);
}

/* Animation for loading pills */
.loophole-pill-container.loaded {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Staggered animation timing - ONLY for loading/initial appearance */
.loophole-pill-container:nth-child(1).loaded { transition-delay: 0.05s; }
.loophole-pill-container:nth-child(2).loaded { transition-delay: 0.1s; }
.loophole-pill-container:nth-child(3).loaded { transition-delay: 0.15s; }
.loophole-pill-container:nth-child(4).loaded { transition-delay: 0.2s; }
.loophole-pill-container:nth-child(5).loaded { transition-delay: 0.25s; }
.loophole-pill-container:nth-child(6).loaded { transition-delay: 0.3s; }
.loophole-pill-container:nth-child(7).loaded { transition-delay: 0.35s; }
.loophole-pill-container:nth-child(8).loaded { transition-delay: 0.4s; }
.loophole-pill-container:nth-child(9).loaded { transition-delay: 0.45s; }
.loophole-pill-container:nth-child(10).loaded { transition-delay: 0.5s; }
.loophole-pill-container:nth-child(11).loaded { transition-delay: 0.55s; }
.loophole-pill-container:nth-child(12).loaded { transition-delay: 0.6s; }

.loophole-pill-container:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background-color: #f9f9f9;
}

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

/* Popup Styling */
.loophole-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-popup-container {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    position: absolute;
    top: 50%;
    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-popup-container.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

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

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

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

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

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

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

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

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

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

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

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

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

/* Get More Ideas Button Styling */
.loophole-more-ideas-container {
    display: flex !important;
    justify-content: flex-end;
    margin-top: 20px;
    margin-bottom: 30px;
}

.loophole-more-ideas-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: #757575;
    font-size: 13px;
    cursor: pointer;
    padding: 8px 12px;
    position: absolute;
    margin-right: 15px;
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.2s;
}

.loophole-more-ideas-button:hover {
    background-color: rgba(67, 97, 238, 0.1);
    transform: translateY(-1px);
}

.loophole-more-ideas-button svg {
    width: 14px;
    height: 14px;
}

.loophole-more-ideas-button.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loophole-more-ideas-button.loading svg {
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

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