/* Category List View */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
}

.category-card-preview {
    background-color: var(--bg-color-card);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s;
    perspective: 1000px; /* Enable 3D perspective */
}

/* Optimization: Only animate when in view */
.category-card-preview .carousel-container,
.category-card-preview .carousel-item {
    animation-play-state: paused;
}

.category-card-preview.in-view .carousel-container,
.category-card-preview.in-view .carousel-item {
    animation-play-state: running;
}

.category-card-preview:active {
    transform: scale(0.98);
}

.cat-preview-title {
    font-size: 1.2rem;
    font-weight: 700;
    z-index: 2;
    text-align: center;
    color: var(--text-color-main);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.carousel-container {
    width: 280px;
    height: 280px;
    position: relative;
    animation: spin-ring 30s linear infinite;
    transform-style: preserve-3d;
    margin-top: 1rem;
    border-radius: 50%;
    /* No visual ring */
    /* border: 1px dashed rgba(255, 93, 93, 0.2); */
}

@keyframes spin-ring {
    0% { transform: rotateX(60deg) rotateZ(0deg); }
    100% { transform: rotateX(60deg) rotateZ(360deg); }
}

.carousel-item-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    margin-left: -60px; /* Half width */
    margin-top: -60px;  /* Half height */
    z-index: 10;
    transform-style: preserve-3d;
}

.carousel-item {
    width: 100%;
    height: 100%;
    /* removed border-radius: 50%; so pngs shape is preserved if needed, or if they are square. But assume they are rectangular/irregular pngs, border-radius might cut them. User said "they are pngs", implied transparency. */
    background-size: contain; /* changed from cover to contain to respect png boundaries */
    background-position: center;
    background-repeat: no-repeat;
    /* removed border and box-shadow */
    /* Counter spin to keep images upright */
    animation: counter-spin-ring 30s linear infinite;
}

@keyframes counter-spin-ring {
    0% { transform: rotateZ(0deg) rotateX(-60deg); }
    100% { transform: rotateZ(-360deg) rotateX(-60deg); }
}

/* Category Detail View adjustments */
.back-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-color-accent);
    background: var(--bg-color-secondary);
    position: sticky;
    top: 70px;
    z-index: 95;
    margin-bottom: 1rem;
    border-radius: 8px;
    margin-top: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.back-nav:hover {
    background: rgba(255,255,255,0.05);
}
