/* ============================================================
   Área de trabalho: wallpaper, ícones, seleção, menu de contexto
   ============================================================ */

#wallpaper {
  position: fixed; inset: 0;
  background-image: var(--wall);
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
  transition: opacity var(--t5) var(--ease), transform var(--t5) var(--ease-out),
    filter var(--t4) var(--ease);
}
#os.entering #wallpaper { animation: wallIn 900ms var(--ease-out); }
@keyframes wallIn { from { transform: scale(1.09); opacity: 0.4; } to { transform: scale(1.02); opacity: 1; } }

#wallpaper-tint {
  position: fixed; inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.06), transparent 22%, rgba(0, 0, 0, 0.18));
}
[data-theme="light"] #wallpaper-tint { background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.06)); }

#workarea {
  position: absolute;
  inset: 0 0 var(--taskbar-h) 0;
}

/* -------------------------- Ícones -------------------------- */
#icons {
  position: absolute; inset: 0;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 6.4rem);
  grid-auto-columns: 5.9rem;
  align-content: start;
  justify-content: start;
  gap: 0.25rem;
  padding: 0.6rem;
  overflow: hidden;
}

.dicon {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 0.55rem 0.3rem 0.4rem;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  text-align: center;
  cursor: default;
  transition: background var(--t2) var(--ease), border-color var(--t2) var(--ease),
    transform var(--t2) var(--ease);
  animation: iconIn var(--t4) var(--ease-out) backwards;
}
@keyframes iconIn { from { opacity: 0; transform: translateY(8px) scale(0.94); } to { opacity: 1; transform: none; } }

.dicon:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.14); }
.dicon.selected {
  background: color-mix(in srgb, var(--accent) 34%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.dicon:active { transform: scale(0.96); }
.dicon .ico { width: 2.85rem; height: 2.85rem; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35)); }
.dicon .label {
  font-size: 0.72rem; line-height: 1.25; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
/* papéis de parede claros pedem rótulos escuros */
[data-wall-dark="false"] .dicon .label {
  color: #12141d;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.85);
}
[data-wall-dark="false"] .dicon:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
}

/* -------------------------- Menu de contexto -------------------------- */
#contextmenu {
  position: fixed;
  /* acima da tela de login (--z-shell), senão o menu de energia do login
     fica escondido atrás dela */
  z-index: 9200;
  min-width: 12.5rem;
  padding: 0.32rem;
  border-radius: var(--r-md);
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur)) saturate(1.6);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.6);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  display: none;
  transform-origin: top left;
}
#contextmenu.show { display: block; animation: ctxIn 150ms var(--ease-out); }
@keyframes ctxIn { from { opacity: 0; transform: scale(0.94) translateY(-4px); } to { opacity: 1; transform: none; } }

.ctx-item {
  display: flex; align-items: center; gap: 0.65rem;
  width: 100%; height: 2.1rem; padding: 0 0.6rem;
  border-radius: var(--r-sm);
  font-size: 0.8125rem; color: var(--text);
  transition: background var(--t1) var(--ease);
}
.ctx-item:hover { background: var(--hover); }
.ctx-item svg { width: 1rem; height: 1rem; color: var(--text-dim); flex: none; }
.ctx-item .kbd { margin-left: auto; font-size: 0.7rem; color: var(--text-mute); }
.ctx-sep { height: 1px; margin: 0.28rem 0.45rem; background: var(--line); }

/* -------------------------- Toasts -------------------------- */
#toasts {
  position: fixed; right: 0.75rem; bottom: calc(var(--taskbar-h) + 0.6rem);
  z-index: var(--z-toast);
  display: flex; flex-direction: column-reverse; gap: 0.5rem;
  width: min(21rem, calc(100vw - 1.5rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.75rem 0.8rem;
  border-radius: var(--r-md);
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur)) saturate(1.5);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.5);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  animation: toastIn var(--t3) var(--ease-out);
}
.toast.out { animation: toastOut var(--t3) var(--ease-in) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px) scale(0.96); } }
.toast .t-ico { width: 1.9rem; height: 1.9rem; flex: none; border-radius: var(--r-sm); }
.toast .t-title { font-size: 0.8rem; font-weight: 600; }
.toast .t-body { font-size: 0.76rem; color: var(--text-dim); }
.toast .t-close { margin-left: auto; }

@media (max-width: 760px) {
  #icons {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, minmax(4.9rem, 1fr));
    grid-template-rows: none;
    grid-auto-rows: 6rem;
    justify-content: stretch;
  }
  .dicon .ico { width: 2.5rem; height: 2.5rem; }
  #toasts { left: 0.5rem; right: 0.5rem; width: auto; }
}
