/* Wallpaper host and desktop icon grid. */

.wallpaper { position: fixed; inset: 0; z-index: 0; background: var(--bg); overflow: hidden; }
.wallpaper canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wallpaper-atmosphere { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
html.is-immersed .wallpaper-atmosphere { pointer-events: auto; }
.wallpaper::after {
  /* A quiet veil at the edges keeps icon labels readable on busy wallpapers. */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 0.28), transparent 26%),
    linear-gradient(270deg, rgb(0 0 0 / 0.22), transparent 22%),
    linear-gradient(0deg, rgb(0 0 0 / 0.30), transparent 18%);
}

.desktop {
  position: fixed; inset: 0 0 var(--taskbar-h) 0; z-index: 10;
  padding: 14px 10px;
}
.desktop-icons {
  list-style: none; margin: 0; padding: 0 4px;
  height: 100%;
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

/* Two banks of the river. Islands stack down each bank and, when the screen
   runs out of height, wrap into another column towards the middle. */
.dbank {
  display: flex; flex-direction: column; flex-wrap: wrap;
  align-content: flex-start;
  gap: 34px 18px;
  min-height: 0; max-height: 100%;
}
.dbank.is-right { align-content: flex-end; flex-wrap: wrap-reverse; justify-content: space-between; }
.dbank:empty { display: none; }

/* Three icons to a row, read left to right. On the right bank a short last
   row sits against the edge, so the Recycle Bin keeps its corner. */
.dgroup {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; align-content: flex-start;
  width: calc(var(--icon-cell-w) * 3 + 4px);
  gap: 0 2px;
}
.dbank.is-right .dgroup { justify-content: flex-end; }
.dgroup .dicon { flex: none; }
.dhead {
  flex: 0 0 100%;
  padding: 0 10px 2px;
  font: italic 400 22px/1.1 var(--font-display);
  letter-spacing: 0.005em;
  color: var(--text-on-wallpaper);
  text-shadow: var(--text-shadow-wallpaper);
  opacity: 0.82;
  user-select: none;
}
.dbank.is-right .dhead { text-align: right; }

.dicon {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  width: var(--icon-cell-w); height: var(--icon-cell-h);
  padding: 8px 4px 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-on-wallpaper);
  text-align: center;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.dicon:focus-visible { box-shadow: none; }
.dicon:hover .tile { transform: translateY(-2px); border-color: rgb(255 255 255 / 0.2); }
.dicon[aria-selected="true"] { background: rgb(255 255 255 / 0.09); border-color: rgb(255 255 255 / 0.14); }
.dicon[aria-selected="true"] .label { background: var(--selection); }
.dicon:focus-visible .tile { box-shadow: var(--focus); }

.tile {
  position: relative;
  display: grid; place-items: center; flex: none;
  width: var(--tile); height: var(--tile);
  border-radius: var(--r-tile);
  background: var(--tile-bg);
  border: 1px solid var(--tile-line);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 8px 20px -10px rgb(0 0 0 / 0.6), var(--highlight);
  color: var(--tile-glyph);
  transition: transform var(--dur-2) var(--ease-spring), border-color var(--dur-1) var(--ease-out);
}
.tile .glyph { width: var(--glyph); height: var(--glyph); }
.tile img.xp-icon { display: none; width: 48px; height: 48px; image-rendering: auto; }
.tile .corner {
  position: absolute; top: -6px; right: -8px;
  height: 16px; padding: 0 5px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; line-height: 16px; letter-spacing: 0.03em;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.4);
}
.tile .corner.team { background: var(--teal); color: var(--ink); }
.dicon .label {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  max-width: 100%; padding: 1px 5px; border-radius: 5px;
  font-size: 12px; font-weight: 500; line-height: 1.3;
  text-shadow: var(--text-shadow-wallpaper);
  overflow: hidden; word-break: break-word;
}

.dicon.is-hatching .tile { animation: hatch 900ms var(--ease-spring); }
@keyframes hatch {
  0% { transform: scale(0.2) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

/* Phones: a home-screen grid, no free windows. */
@media (max-width: 720px) {
  :root { --icon-cell-w: 25vw; --icon-cell-h: 98px; }
  .desktop { padding: 18px 0 8px; overflow-y: auto; }
  .desktop-icons { flex-direction: column; gap: 18px; height: auto; padding: 0; }
  .dbank { display: contents; }
  .dgroup, .dbank.is-right .dgroup { display: grid; width: auto; grid-template-columns: repeat(4, 1fr); justify-items: center; justify-content: stretch; }
  .dhead { grid-column: 1 / -1; }
  .dgroup .dicon { height: auto; min-height: var(--icon-cell-h); }
  .dhead, .dbank.is-right .dhead { text-align: left; padding: 0 18px 6px; }
  .dicon { width: 100%; }
}

/* Immersive mode: a live page is the wallpaper and the desktop steps aside. */
.immerse-exit { position: fixed; z-index: 150; top: 14px; left: 50%; translate: -50% 0; display: none; box-shadow: var(--shadow-pop); }
html.is-immersed .immerse-exit { display: inline-flex; }
html.is-immersed .desktop,
html.is-immersed .windows,
html.is-immersed .taskbar,
html.is-immersed .toasts { opacity: 0; pointer-events: none; transition: opacity var(--dur-3) var(--ease-out); }
html.is-immersed .wallpaper::after { display: none; }

/* Rendered app icons (see iconTile in dom.js): the art fills the tile, the glyph waits underneath. */
.tile img.art-icon { display: none; }
.tile.has-art { background: #0B0D10; border-color: rgb(255 255 255 / 0.1); }
.tile.has-art .glyph { display: none; }
.tile.has-art img.art-icon { display: block; position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; pointer-events: none; }
