/* Specific styles for play section */



/* View Toggle Button */
.play-view-toggle {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 100;
    background: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    transition: opacity 0.2s ease;
    font-size: 1.5rem;
}

.play-view-toggle:focus-visible {
    outline: 2px dashed var(--text-color);
    outline-offset: -2px;
}

/* Div-based Icons */
.play-view-toggle .icon-grid {
    display: grid;
    grid-template-columns: repeat(3, 4px);
    grid-template-rows: repeat(3, 4px);
    gap: 3px;
    margin: auto;
}
.play-view-toggle .icon-grid i,
.play-view-toggle .icon-canvas i {
    background: currentColor;
    width: 4px;
    height: 4px;
    border-radius: 1px;
}
.play-view-toggle .icon-canvas {
    position: relative;
    width: 20px;
    height: 20px;
    margin: auto;
}
.play-view-toggle .icon-canvas i {
    position: absolute;
    border-radius: 50%;
}
.play-view-toggle .icon-canvas i:nth-child(1) { top: 2px; left: 3px; }
.play-view-toggle .icon-canvas i:nth-child(2) { top: 12px; left: 2px; }
.play-view-toggle .icon-canvas i:nth-child(3) { top: 7px; left: 8px; }
.play-view-toggle .icon-canvas i:nth-child(4) { top: 3px; left: 14px; }
.play-view-toggle .icon-canvas i:nth-child(5) { top: 14px; left: 13px; }

/* Default (List) View */
.play-viewport {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    container-type: size;
}

.play-canvas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 2rem 2rem calc(2rem + 80px) 2rem;
    padding-top: calc(2rem + 22px);
}

.play-item {
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.play-item:hover, .play-item:focus {
    transform: translateY(-2px);
    outline: none;
}

.play-thumb {
    width: 100%;
    aspect-ratio: 1;
    display: block;
    object-fit: cover;
    box-shadow: 0 0 0 calc(1px / var(--zoom-scale, 1)) var(--text-color);
    /* transition for initial scatter animation */
    transition: top 0.5s ease-out, left 0.5s ease-out, transform 0.5s ease-out;
}

/* Canvas Mode */
.play-canvas.canvas-mode {
    display: block;
    position: absolute;
    padding: 0;
    width: 0;
    height: 0;
    left: 50cqw;
    top: 50cqh;
    zoom: max(0.4, min(100cqw / 1200, 100cqh / 800));
    transform-origin: 0 0;
}

.play-viewport:has(.canvas-mode) {
    overflow: hidden;
    touch-action: none;
}

.canvas-mode .play-item {
    position: absolute;
    width: 250px;
    height: 250px;
    /* remove transition after initial load or handle in JS */
}

/* Lightbox Overlay */
.play-overlay {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--bg-color) 50%, transparent);
    backdrop-filter: blur(4px);
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.play-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.play-item.lightbox-expanded {
    z-index: 1000 !important;
}



.play-overlay-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 2000;
    background: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    font-size: 2.2rem;
    line-height: 1;
    font-family: 'VT323', monospace;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease-out, visibility 0.25s ease-out;
}

.play-overlay-close.active {
    opacity: 1;
    visibility: visible;
}

.play-overlay-close:focus-visible {
    outline: 2px dashed var(--text-color);
    outline-offset: -2px;
}
.play-item.lightbox-expanded-responsive {
    /* The bounding box container */
    left: 60px !important;
    top: 60px !important;
    right: 60px !important;
    bottom: 140px !important; /* clears bottom play label */
    width: auto !important;
    height: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    container-type: size;
    pointer-events: none !important; /* Allow clicks to pass through to overlay */
}

.play-item.lightbox-expanded-responsive .play-thumb {
    /* Scale mathematically to fit container bounding box while strictly preserving aspect ratio */
    width: min(100cqw, calc(100cqh * var(--aspect, 1))) !important;
    height: min(100cqh, calc(100cqw / var(--aspect, 1))) !important;
    object-fit: cover !important;
    pointer-events: auto !important; /* Re-enable clicks on the image itself */
}
