/* grid.css - Grid layout and template styles */

/* Grid container */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    max-width: 432px; /* Same as HD preview width */
    margin: 0 auto;
    box-sizing: border-box;
    padding: 0 10px;
}

/* Grid item */
.grid-item {
    max-width: 144px; /* 432px HD preview width ÷ 3 = 144px per grid item */
    width: 100%;
    margin: 0 auto;
}

/* Grid item template */
.kilo-flyers-template {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding-bottom: 177.78%; /* Portrait aspect ratio to match HD preview (1080x1920) */
    border-radius: 8px;
    background: #000000;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Remove aspect ratio variations - use single portrait ratio */
.kilo-flyers-template.square,
.kilo-flyers-template.portrait,
.kilo-flyers-template.standard {
    padding-bottom: 177.78%; /* All use portrait aspect ratio */
}

/* Template hover and selected states */
.kilo-flyers-template:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.kilo-flyers-template.selected {
    border: 2px solid #4a9eff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.2);
}

/* Template images */
.kilo-flyers-template img.background,
.kilo-flyers-template img.foreground {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kilo-flyers-template img.background {
    z-index: 1;
}

.kilo-flyers-template img.foreground {
    z-index: 3;
}

/* Portrait styles moved to portraitDefaults.css */

/* Grid loading state */
.grid-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Grid empty state */
.grid-empty {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .grid {
        gap: 12px;
        padding: 0 8px;
        max-height: 65vh;
        max-width: 360px; /* Same as HD preview mobile width */
    }
    
    .grid-item {
        max-width: 120px; /* 360px HD preview mobile width ÷ 3 = 120px per grid item */
    }
    
    .kilo-flyers-template {
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .grid {
        gap: 8px;
        padding: 0 5px;
        max-height: 60vh;
        max-width: 308px; /* Same as HD preview small mobile width */
    }
    
    .grid-item {
        max-width: 102px; /* 308px HD preview small mobile width ÷ 3 = ~102px per grid item */
    }
    
    .kilo-flyers-template {
        border-radius: 4px;
    }
}
