/* ===================================================================
   Icons — the desktop icon and the icon art every icon uses (desktop,
   dock, All Apps), then edit mode: jiggle and delete badges.
   =================================================================== */

/**************** Icons ****************/
.desktop-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 13px 8px 10px;
    border-radius: 16px;
    text-decoration: none;
    color: white;
    transition: background 0.15s ease, transform 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
    width: 114px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.desktop-icon:hover { background: var(--w-12); color: white; transform: scale(1.06); }
.desktop-icon.pressed { transform: scale(0.91) !important; transition: transform 0.07s ease !important; }

.icon-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Icon tile, drawn like a macOS app icon: one squircle surface whose
   fill is a flattened, blurred copy of the favicon (so it reads as the
   logo's own colour), with the crisp favicon sitting directly on it.
   .icon-art carries the shadow; the inner .icon-tile carries the
   squircle mask. They have to be separate elements: a mask clips
   everything on its own element, shadows included. */
:root {
    /* Superellipse (n=5): the usual stand-in for Apple's continuous-corner
       icon shape. A border-radius gives circular corners, which read
       as "rounded rectangle" rather than "Mac icon". */
    --squircle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M100.0 50.0L100.0 66.8L99.8 72.1L99.6 76.0L99.3 79.1L98.9 81.8L98.4 84.0L97.9 86.1L97.2 87.9L96.4 89.5L95.6 91.0L94.6 92.3L93.5 93.5L92.3 94.6L91.0 95.6L89.5 96.4L87.9 97.2L86.1 97.9L84.0 98.4L81.8 98.9L79.1 99.3L76.0 99.6L72.1 99.8L66.8 100.0L50.0 100.0L33.2 100.0L27.9 99.8L24.0 99.6L20.9 99.3L18.2 98.9L16.0 98.4L13.9 97.9L12.1 97.2L10.5 96.4L9.0 95.6L7.7 94.6L6.5 93.5L5.4 92.3L4.4 91.0L3.6 89.5L2.8 87.9L2.1 86.1L1.6 84.0L1.1 81.8L0.7 79.1L0.4 76.0L0.2 72.1L0.0 66.8L0.0 50.0L0.0 33.2L0.2 27.9L0.4 24.0L0.7 20.9L1.1 18.2L1.6 16.0L2.1 13.9L2.8 12.1L3.6 10.5L4.4 9.0L5.4 7.7L6.5 6.5L7.7 5.4L9.0 4.4L10.5 3.6L12.1 2.8L13.9 2.1L16.0 1.6L18.2 1.1L20.9 0.7L24.0 0.4L27.9 0.2L33.2 0.0L50.0 0.0L66.8 0.0L72.1 0.2L76.0 0.4L79.1 0.7L81.8 1.1L84.0 1.6L86.1 2.1L87.9 2.8L89.5 3.6L91.0 4.4L92.3 5.4L93.5 6.5L94.6 7.7L95.6 9.0L96.4 10.5L97.2 12.1L97.9 13.9L98.4 16.0L98.9 18.2L99.3 20.9L99.6 24.0L99.8 27.9L100.0 33.2Z'/%3E%3C/svg%3E");
    /* Separation from the wallpaper, in three parts: a hairline that
       traces the edge (does most of the work on busy or light
       wallpaper), a tight contact shadow, and a soft ambient one. */
    --icon-shadow: drop-shadow(0 0 0.5px var(--k-55))
                   drop-shadow(0 1px 1.5px var(--k-30))
                   drop-shadow(0 4px 8px var(--k-30));
    --icon-shadow-lift: drop-shadow(0 0 0.5px var(--k-55))
                        drop-shadow(0 2px 3px var(--k-30))
                        drop-shadow(0 10px 18px var(--k-35));
}
.icon-art {
    position: relative;
    display: block;
    filter: var(--icon-shadow);
    transition: filter 0.18s ease;
}
.icon-tile {
    position: absolute; inset: 0;
    overflow: hidden;
    -webkit-mask: var(--squircle) center / 100% 100% no-repeat;
            mask: var(--squircle) center / 100% 100% no-repeat;
}
/* Top-down light, as macOS draws it: a little brighter at the top,
   a little darker at the bottom. */
.icon-tile::after {
    content: '';
    position: absolute; inset: 0;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(180deg,
        rgba(255,255,255,0.16) 0%,
        rgba(255,255,255,0) 42%,
        rgba(0,0,0,0) 62%,
        rgba(0,0,0,0.12) 100%);
}
/* Lift on hover: shadow deepens as the icon scales up. */
.desktop-icon:hover .icon-art,
.dock-icon:hover    .icon-art { filter: var(--icon-shadow-lift); }
/* Colour plate = the favicon blown up and blurred until it is nearly
   flat. A milder blur leaves a smeared halo that frames the logo
   like a second tile. */
.icon-bloom {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    /* Opaque white under the bloom: where the favicon is transparent,
       the plate stays light instead of showing the wallpaper. */
    background: #fff;
    transform: scale(2.4);
    filter: blur(16px) saturate(1.6);
    z-index: 0; pointer-events: none;
}
/* Crisp favicon at 80%, drawn flat onto the plate. No shadow of its
   own: a shadow would outline a square favicon and turn it back into
   a card floating on the tile. */
.icon-sharp {
    position: absolute;
    top: 10%; left: 10%;
    width: 80%; height: 80%;
    object-fit: contain;
    object-position: center;
    /* Round the favicon at its OWN box, not the tile. A full-bleed square
       favicon fills this box so its opaque corners get rounded; a glyph
       with transparent corners is unaffected — the alpha does the sorting
       for free, so no detection is needed. */
    border-radius: 22%;
    z-index: 2;
}
/* Static app-icon fallback assets use this same bloom + sharp pipeline,
   so restricted-network icons keep the colored tile background instead
   of entering a separate placeholder rendering mode. */
/* per-context sizing */
.desktop-icon  .icon-art { width: 68px; height: 68px; }
.dock-icon     .icon-art { width: 68px; height: 68px; }
.miller-link   .icon-art { width: 20px; height: 20px;
                           filter: drop-shadow(0 0 0.5px var(--k-55)) drop-shadow(0 1px 1px var(--k-30)); }
.miller-link  .icon-bloom { filter: blur(6px) saturate(1.6); }
.desktop-icon-label {
    font-size: 0.78rem;
    font-weight: 400;
    text-align: center;
    line-height: 1.2;
    text-shadow: 0 1px 4px var(--k-85);
    max-width: 104px;
    display: block;
}

/**************** Edit mode ****************/
@keyframes jiggle {
    0%, 100% { transform: rotate(-2deg); }
    50%       { transform: rotate(2deg); }
}
.desktop.editing .desktop-icon {
    animation: jiggle 0.22s ease-in-out infinite;
}
.desktop.editing .desktop-grid .desktop-icon:nth-child(even) {
    animation-delay: 0.11s;
}

/* ✕ badge on icons */
.icon-delete {
    position: absolute;
    top: 7px; left: 17px;
    width: 18px; height: 18px;
    background: var(--badge-bg);
    border: 1.5px solid var(--w-55);
    border-radius: 50%;
    color: white;
    font-size: 10px; font-weight: 700;
    display: none;
    align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 5;
    font-family: inherit; line-height: 1; padding: 0;
    transition: background 0.12s;
}
.icon-delete:hover { background: var(--danger-badge); }
.desktop.editing .icon-delete { display: flex; }
