* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night) var(--wallpaper) center bottom / cover no-repeat;
  color: var(--icon-label);
  font-family: var(--ui);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Area di lavoro: tutto lo schermo sopra la taskbar */
.desktop {
  position: fixed;
  inset: 0 0 var(--task-h) 0;
  overflow: hidden;
}

/* ---------- Icone ---------- */
.icons {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 96px);
  grid-auto-columns: 96px;
  gap: 4px;
  height: 100%;
  padding: 12px;
  align-content: start;
}
.icons-gap {
  grid-row: span 1;
}
.icon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 92px;
  padding: 8px 2px 6px;
  color: var(--icon-label);
  font: 12px/1.25 var(--ui);
  text-align: center;
  text-decoration: none;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: default;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .16s var(--ease), background .16s var(--ease), border-color .16s var(--ease);
}
.icon svg {
  width: 46px;
  height: 46px;
  filter: drop-shadow(1px 3px 3px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}
.icon span {
  text-shadow: var(--icon-shadow);
  pointer-events: none;
}
.icon:hover {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.16), rgba(167, 139, 250, 0.04));
  border-color: var(--glass-hi-soft);
  transform: translateY(-2px);
}
.icon.selected {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.35), rgba(91, 33, 182, 0.28));
  border: 1px solid var(--glass-edge);
}
.icon:active svg { transform: scale(0.94); }
.icon:focus-visible {
  outline: 2px solid var(--v400);
  outline-offset: 1px;
}
/* Etichetta adesiva con un numero vero (es. gli utenti online) */
.icon-badge {
  position: absolute;
  top: 2px;
  right: 6px;
  z-index: 1;
  padding: 2px 7px;
  color: #06280f;
  font: 700 10.5px var(--ui);
  white-space: nowrap;
  background: #4ade80;
  border: 1.5px solid #052e12;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(74, 222, 128, 0.4);
  transform: rotate(11deg);
  pointer-events: none;
}
.icon-badge[hidden] { display: none; }

/* Freccia "collegamento" sulle icone che aprono un altro sito */
.icon.ext::after {
  content: "";
  position: absolute;
  left: 29px;
  top: 36px;
  width: 15px;
  height: 15px;
  background: #14131f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 12 12 4M6 4h6v6' fill='none' stroke='%23a78bfa' stroke-width='2'/%3E%3C/svg%3E") center / 13px no-repeat;
  border: 1px solid var(--glass-edge);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ---------- Taskbar ---------- */
.taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: stretch;
  height: var(--task-h);
  background: var(--bar-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--win-line);
  box-shadow: var(--shadow-bar);
}
.start {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 6px 6px 8px;
  padding: 0 20px 0 14px;
  overflow: hidden;
  color: #fff;
  font: 800 16px/1 var(--ui);
  letter-spacing: -.01em;
  background: linear-gradient(135deg, var(--v600), #9d5cf5);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
  cursor: pointer;
  transition: box-shadow .18s var(--ease), transform .12s var(--ease), filter .16s var(--ease);
}
.start svg, .start span { position: relative; }
.start svg { width: 22px; height: 22px; }
.start:active { transform: scale(0.97); }
.start:hover { filter: brightness(1.08); box-shadow: 0 6px 22px rgba(124, 58, 237, 0.55); transform: translateY(-1px); }
.start[aria-expanded="true"] { background: linear-gradient(135deg, #9d5cf5, var(--v600)); box-shadow: 0 2px 10px rgba(124, 58, 237, 0.5) inset; }
.start:focus-visible, .task:focus-visible, .tray-item:focus-visible {
  outline: 2px solid var(--v400);
  outline-offset: -3px;
}

.tasks {
  flex: 1;
  display: flex;
  gap: 6px;
  min-width: 0;
  padding: 6px 8px;
  overflow: hidden;
}
.task {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 170px;
  max-width: 190px;
  padding: 0 12px;
  overflow: hidden;
  color: var(--win-text);
  font: 12.5px var(--ui);
  text-align: left;
  background: var(--fill-2);
  border: 1px solid var(--win-line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .12s var(--ease-out);
  animation: task-in .24s var(--ease-out);
}
@keyframes task-in { from { opacity: 0; transform: translateY(8px) scale(.94); } to { opacity: 1; transform: none; } }
/* Lineetta sotto il pulsante: dice quale finestra e' in primo piano */
.task::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 3px; height: 2px; border-radius: 2px; background: var(--v300); transform: scaleX(0); opacity: 0; transition: transform .22s var(--ease-out), opacity .22s var(--ease-out); }
.task[aria-pressed="true"]::after { transform: scaleX(1); opacity: .9; }
.task:active { transform: scale(0.97); }
.task svg, .task span { position: relative; }
.task svg { flex-shrink: 0; width: 20px; height: 20px; }
.task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task:hover { background: rgba(167, 139, 250, 0.14); border-color: var(--glass-edge); }
.task[aria-pressed="true"] {
  color: var(--ink-hi);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(167, 139, 250, 0.15));
  border-color: var(--glass-edge);
}

.tray {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  color: var(--win-text);
  font: 12px var(--ui);
  border-left: 1px solid var(--win-line);
}
.tray-item { display: flex; align-items: center; gap: 6px; padding: 5px 6px; white-space: nowrap; background: none; border: 0; border-radius: var(--radius-sm); color: inherit; font: inherit; transition: background .16s var(--ease); }
.tray-item:hover { background: var(--fill-2); }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #57536e;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.dot.on { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
#clock { padding: 5px 6px; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; color: var(--win-muted); }

/* ---------- Menu Start ---------- */
.start-menu {
  position: fixed;
  left: 8px;
  bottom: calc(var(--task-h) + 8px);
  z-index: 10000;
  width: 500px;
  max-width: calc(100vw - 16px);
  overflow: hidden;
  color: var(--win-text);
  background: var(--menu-bg);
  border: 1px solid var(--win-line);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px var(--glass-hi-soft) inset, var(--shadow-pop);
  transform-origin: left bottom;           /* esce dal pulsante Start */
  animation: sm-in .2s var(--ease-out);
}
@keyframes sm-in { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
.start-menu.closing { animation: sm-out .12s ease-out forwards; pointer-events: none; }
@keyframes sm-out { to { opacity: 0; transform: translateY(4px) scale(.97); } }
.sm-cols { display: flex; max-height: min(60vh, 460px); overflow-y: auto; }
.sm-col { flex: 1 1 50%; min-width: 0; }
.sm-col + .sm-col { border-left: 1px solid var(--win-line); }
.start-menu[hidden] { display: none; }
.sm-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  overflow: hidden;
  color: var(--ink-hi);
  font: 700 16px var(--ui);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.22), rgba(124, 58, 237, 0.06));
  border-bottom: 1px solid var(--win-line);
}
.sm-head svg, .sm-head span { position: relative; }
.sm-head svg { width: 30px; height: 30px; }
.sm-list { display: grid; padding: 8px; margin: 0; list-style: none; }
.sm-list li + li.sm-sep { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--win-line); }
.sm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  color: var(--win-text);
  font: 13px var(--ui);
  text-align: left;
  text-decoration: none;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .12s var(--ease);
}
.sm-item svg { flex-shrink: 0; width: 28px; height: 28px; }
.sm-item span { font-weight: 700; }
.sm-item small { display: block; color: var(--win-muted); font-size: 11.5px; font-weight: 400; }
.sm-item:hover, .sm-item:focus-visible { background: linear-gradient(90deg, rgba(167, 139, 250, 0.2), rgba(167, 139, 250, 0.04)); border-color: var(--glass-edge); outline: 0; transform: translateX(2px); }
.sm-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  background: var(--fill-1);
  border-top: 1px solid var(--win-line);
}
/* Pulsanti del footer: pillole con icona */
.sm-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  justify-content: center;
  padding: 9px 14px;
  color: var(--win-text);
  font: 700 12.5px var(--ui);
  text-decoration: none;
  background: var(--fill-2);
  border: 1px solid var(--win-line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .12s var(--ease);
}
.sm-btn svg { flex-shrink: 0; }
.sm-btn:hover { background: var(--fill-3); transform: translateY(-1px); }
.sm-btn:active, .sm-item:active { transform: scale(0.98); }
.sm-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--v600), #9d5cf5);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
}
.sm-btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(124, 58, 237, 0.55); }

/* ---------- Senza JavaScript ---------- */
.nojs {
  position: fixed;
  inset: 0 0 var(--task-h) 0;
  padding: 24px;
  overflow: auto;
  background: rgba(5, 2, 26, 0.85);
}

/* ---------- Mobile: griglia di app ---------- */
@media (max-width: 719px) {
  .icons {
    grid-auto-flow: row;
    grid-template-rows: none;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    grid-auto-columns: auto;
    gap: 6px;
    padding: 16px 10px;
    overflow-y: auto;
    align-content: start;
  }
  .icon { width: 100%; }
  .icon svg { width: 48px; height: 48px; }
  .tasks { display: none; }
  .tray { margin-left: auto; }
  .start { padding-right: 20px; }
  .start-menu { left: 4px; width: calc(100vw - 8px); }
  .sm-cols { flex-direction: column; max-height: min(64vh, 520px); }
  .sm-col + .sm-col { border-left: 0; border-top: 1px solid var(--win-line); }
  .sm-foot { flex-wrap: wrap; }
}

/* ---------- Aurora sullo sfondo: gradienti statici, niente blur pesante ---------- */
.desktop::before, .desktop::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
}
.desktop::before {
  top: -10%;
  right: -6%;
  width: 55vmax;
  height: 55vmax;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.22), transparent 70%);
}
.desktop::after {
  bottom: -14%;
  left: -8%;
  width: 42vmax;
  height: 42vmax;
  background: radial-gradient(circle, rgba(232, 121, 249, 0.14), transparent 70%);
}
@media (max-width: 719px) {
  .desktop::before, .desktop::after { display: none; }
}

/* ---------- Dettagli che il browser sceglie da solo ---------- */
::selection { color: #fff; background: rgba(139, 92, 246, 0.55); }
* { scrollbar-width: thin; scrollbar-color: rgba(167, 139, 250, 0.35) transparent; }
input, textarea, select { caret-color: var(--v400); accent-color: var(--v500); }
/* Hover solo dove c'e' un vero mouse: sul touch resterebbe "appiccicato" dopo il tocco */
@media (hover: none) {
  .icon:hover, .start:hover, .sm-btn:hover, .sm-item:hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .task { animation: none; }
  .start-menu { animation: none; }
  .start-menu.closing { animation: none; }
  .task::after { transition: none; }
}
