/* ==========================================================================
   Desktop Files — macOS-style icon grid
   ========================================================================== */

/* Finder's desktop grid: icons fill the right-hand column top to bottom, then
   wrap into the next column to the LEFT — they never slide under the Dock
   (the last icon used to sit behind it on a 900px-tall screen). */
.desktop-files {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(auto-fill, 106px);
    grid-auto-columns: 110px;
    direction: rtl;
    gap: 2px 4px;
    align-content: start;
    height: calc(100% - 96px);
}

.desktop-icon {
    direction: ltr;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 110px;
    padding: 7px 4px 5px;
    border-radius: 7px;
    cursor: default;
    text-align: center;
    transition: background 0.12s ease;
    animation: desktop-icon-in 0.36s ease both;
    animation-delay: calc(var(--stagger, 0) * 60ms);
}

@keyframes desktop-icon-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.desktop-icon-art {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 5px;
}

.desktop-icon-art img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.45));
    pointer-events: none;
}

/* macOS labels are plain text with a shadow; the blue pill appears only on
   selection. */
.desktop-icon-label {
    font-size: 11.5px;
    line-height: 1.35;
    font-weight: 500;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.8);
    padding: 2px 5px;
    border-radius: 6px;
    max-width: 100%;
    text-wrap: balance;
    word-break: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.desktop-icon:hover .desktop-icon-label {
    background: rgba(0, 0, 0, 0.28);
}

.desktop-icon.selected .desktop-icon-art img {
    filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.45)) brightness(0.86);
}

.desktop-icon.selected .desktop-icon-label {
    background: var(--accent);
    color: #fff;
    text-shadow: none;
}

.desktop-icon:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 1px;
}

@media (max-width: 768px) {
    .desktop-files { grid-template-rows: repeat(auto-fill, 100px); grid-auto-columns: 86px; height: calc(100% - 84px); }
    .desktop-icon { width: 86px; padding: 5px 2px 3px; }
    .desktop-icon-label { font-size: 10.5px; padding: 1px 3px; overflow-wrap: normal; word-break: normal; }
    .desktop-icon-art { width: 48px; height: 48px; }
    .desktop-icon-label { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    .desktop-icon { animation: none; }
}
