/* helpers/paniclab/style.css */

#helper-paniclab {
    --color-panic-accent: #6d28d9; /* Violet theme */
    --color-panic-highlight: #c084fc;
    height: calc(100vh - 56px); /* Lock view height to remaining viewport */
    overflow: hidden;
    box-sizing: border-box;
}

/* 1. Main Viewport Panel Layout */
#helper-paniclab .panel {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%; /* Fit 100% of locked viewport height */
    overflow: hidden;
}

/* Top part: Controls Row Split (Layout above 425px) */
#helper-paniclab .panic-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 16px;
    flex-shrink: 0;
}

#helper-paniclab .panic-buttons-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1.1;
    justify-content: center;
}

#helper-paniclab .panic-buttons-col button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 700;
}

#helper-paniclab .panic-previews-col {
    flex-grow: 1;
    display: flex;
    gap: 12px;
    justify-content: stretch;
    align-items: stretch;
    box-sizing: border-box;
}

#helper-paniclab .target-card-preview-wrapper,
#helper-paniclab .current-card-preview-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
}

#helper-paniclab .panic-previews-col .panic-card {
    width: 100%;
    height: 100%;
    aspect-ratio: auto !important; /* Override playfield card aspect ratio */
    border: 1px solid var(--color-border) !important;
    border-radius: var(--border-radius-sm);
    background-color: var(--color-bg-surface) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01) !important;
    pointer-events: none;
    padding: 6px; /* Match standard playfield card padding */
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
}

#helper-paniclab .panic-previews-col .panic-card .card-svg {
    width: 44px !important;
    height: 66px !important;
    max-width: 44px;
    max-height: 66px;
    display: block;
    margin: auto;
}

/* Bottom part: Playfield Viewport Grid */
#helper-paniclab .panic-viewport {
    background-color: transparent;
    border: none;
    padding: 4px; /* Added tiny padding to prevent card shadows from getting clipped */
    margin: 0;
    flex-grow: 1;
    overflow: visible; /* Prevent card hover shadow clipping */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Cards Grid (5x5) */
#helper-paniclab .panic-board-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-content: center;
}

/* Individual Card Design */
#helper-paniclab .panic-card {
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01);
    
    width: 100%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 8 / 9;
    margin: auto;
    position: relative;
    
    min-width: 0;
    min-height: 0;
}

#helper-paniclab .panic-card:hover {
    border-color: var(--color-panic-highlight);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.05);
}

/* SVG graphics within cards */
#helper-paniclab .card-svg {
    width: 100%;
    height: 100%;
    max-height: 100%;
    display: block;
}

/* Highlight states */
#helper-paniclab .panic-card.user-guessed {
    border-color: var(--color-panic-accent) !important;
    background-color: rgba(109, 40, 217, 0.04) !important;
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15) !important;
}

#helper-paniclab .panic-card.selected-correct {
    border-color: var(--color-success) !important;
    background-color: rgba(21, 128, 61, 0.04) !important;
    box-shadow: 0 0 0 4px rgba(21, 128, 61, 0.15) !important;
    animation: successBounce 0.4s ease-out;
}

#helper-paniclab .panic-card.selected-wrong {
    border-color: var(--color-destructive) !important;
    background-color: rgba(185, 28, 28, 0.04) !important;
    box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.15) !important;
    animation: shakeError 0.4s ease-in-out;
}

#helper-paniclab .panic-card.highlight-solved {
    border-color: var(--color-success) !important;
    background-color: rgba(21, 128, 61, 0.04) !important;
    box-shadow: 0 0 0 4px rgba(21, 128, 61, 0.15) !important;
}

/* Scanning highlight step (step-by-step solver) */
#helper-paniclab .panic-card.scanning-step {
    border-color: #eab308 !important; /* Yellow-500 */
    background-color: rgba(234, 179, 8, 0.08) !important;
    box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.25) !important;
    transform: scale(1.05);
    z-index: 10;
}

/* Animations */
@keyframes successBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Mobile responsive layout (max-width / mobile screen under 768px) */
@media (max-width: 768px) {
    #helper-paniclab {
        padding-top: 0;
        padding-bottom: 0;
    }
    #helper-paniclab .panel {
        gap: 10px;
        margin: 0 auto;
        height: 100%;
        border-radius: 0; /* Flush on mobile screen edges */
    }
    
    #helper-paniclab .panic-controls-row {
        flex-direction: column;
        gap: 8px;
    }
    
    #helper-paniclab .panic-buttons-col {
        flex-direction: row;
        width: 100%;
    }
    
    #helper-paniclab .panic-buttons-col button {
        flex: 1;
        padding: 8px;
        font-size: 0.8rem;
    }
    
    #helper-paniclab .panic-previews-col {
        width: 100%;
        padding: 8px 0;
        gap: 12px;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        box-sizing: border-box;
        display: flex;
        flex-direction: row;
        justify-content: stretch;
        align-items: stretch;
    }

    #helper-paniclab .panic-previews-col .target-card-preview-wrapper,
    #helper-paniclab .panic-previews-col .current-card-preview-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: stretch;
    }
    
    #helper-paniclab .panic-previews-col .panic-card {
        width: 100%;
        height: 80px;
        aspect-ratio: auto !important; /* Override playfield card aspect ratio */
        border: 1px solid var(--color-border) !important;
        background-color: var(--color-bg-surface) !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01) !important;
        padding: 3px; /* Match mobile playfield card padding */
        border-radius: var(--border-radius-sm) !important;
        display: flex;
        justify-content: center;
        align-items: center;
        box-sizing: border-box;
    }

    #helper-paniclab .panic-previews-col .panic-card .card-svg {
        width: 32px !important;
        height: 48px !important;
        max-width: 32px;
        max-height: 48px;
        display: block;
        margin: auto;
    }
    
    #helper-paniclab .panic-viewport {
        padding: 0;
    }
    
    #helper-paniclab .panic-board-grid {
        gap: 6px;
    }
    
    #helper-paniclab .panic-card {
        padding: 3px;
    }
}
