/* =========================================================
   Seed — desktop shell styles
   Vanilla, no dependencies.
   ========================================================= */
:root {
  --bg-1: #0b1220;
  --bg-2: #1a2540;
  --ink: #e8eef9;
  --muted: #94a3b8;
  --line: rgba(255,255,255,0.10);
  --accent: #60a5fa;
  --accent-2: #3b82f6;
  --win-bg: #ffffff;
  --win-ink: #0f172a;
  --titlebar: #f1f5f9;
  --titlebar-active: #dbeafe;
  --shadow: 0 10px 30px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.25);
  --taskbar-h: 44px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg-1);
  overflow: hidden;
  user-select: none;
}

/* ---------- desktop area ---------- */
#desktop {
  position: absolute;
  inset: 0 0 var(--taskbar-h) 0;
  overflow: hidden;
}
#wallpaper {
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 800px at 20% 10%, #1e3a8a33, transparent 60%),
    radial-gradient(900px 600px at 90% 90%, #0ea5e933, transparent 60%),
    linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  z-index: 0;
}

/* ---------- desktop icons ---------- */
#desktop-icons {
  position: absolute; inset: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 96px);
  grid-auto-rows: 96px;
  gap: 8px;
  align-content: start;
  z-index: 1;
}
.desk-icon {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 6px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  color: var(--ink);
  transition: background 0.12s;
}
.desk-icon:hover { background: rgba(255,255,255,0.06); }
.desk-icon:focus { outline: 2px solid var(--accent); }
.desk-icon .icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 24px;
}
.desk-icon .icon svg { width: 30px; height: 30px; }
.desk-icon .label {
  font-size: 12px; line-height: 1.2;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- windows ---------- */
#windows {
  position: absolute; inset: 0;
  z-index: 2;
  pointer-events: none; /* container; windows themselves capture pointer */
}
.win {
  position: absolute;
  background: var(--win-bg);
  color: var(--win-ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  min-width: 280px;
  min-height: 180px;
  border: 1px solid rgba(0,0,0,0.2);
}
.win.dragging, .win.resizing { user-select: none; }
.win.maximized { border-radius: 0; }
.win.minimized { display: none; }

.win-titlebar {
  height: 34px;
  background: var(--titlebar);
  display: flex; align-items: center;
  padding: 0 8px;
  gap: 8px;
  cursor: grab;
  border-bottom: 1px solid #e2e8f0;
  flex: 0 0 auto;
}
.win.active .win-titlebar { background: var(--titlebar-active); }
.win-titlebar.dragging { cursor: grabbing; }
.win-title {
  flex: 1;
  font-size: 13px; font-weight: 600;
  color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: none;
}
.win-controls { display: flex; gap: 4px; }
.win-btn {
  width: 22px; height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #475569;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
}
.win-btn:hover { background: rgba(15,23,42,0.08); }
.win-btn.close:hover { background: #ef4444; color: white; }

.win-body {
  flex: 1 1 auto;
  position: relative;
  background: white;
  overflow: hidden;
}
.win-body iframe {
  width: 100%; height: 100%;
  border: 0;
  display: block;
  background: white;
}
.win-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.25) 50%, rgba(0,0,0,0.25) 60%, transparent 60%, transparent 70%, rgba(0,0,0,0.25) 70%, rgba(0,0,0,0.25) 80%, transparent 80%);
  z-index: 2;
}
/* While dragging/resizing, cover iframes so they don't eat events */
#windows.suppress-iframes .win-body { pointer-events: none; }

/* ---------- taskbar ---------- */
#taskbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--taskbar-h);
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 8px;
  gap: 8px;
  z-index: 10;
}
#start-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
#start-btn:hover { background: rgba(255,255,255,0.10); }
#task-windows {
  flex: 1;
  display: flex; align-items: center; gap: 4px;
  overflow-x: auto;
}
.task-btn {
  height: 30px;
  max-width: 200px;
  padding: 0 10px;
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.task-btn.active { background: rgba(96,165,250,0.25); border-color: var(--accent); }
.task-btn:hover { background: rgba(255,255,255,0.10); }
#taskbar-clock {
  font-size: 12px;
  color: var(--muted);
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- launcher (start menu) ---------- */
#launcher {
  position: absolute;
  left: 8px;
  bottom: calc(var(--taskbar-h) + 8px);
  width: 360px;
  max-height: 60vh;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 20;
  overflow: hidden;
  display: flex; flex-direction: column;
}
#launcher.hidden { display: none; }
.launcher-header { padding: 10px; border-bottom: 1px solid var(--line); }
#launcher-search {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}
#launcher-search:focus { border-color: var(--accent); }
#launcher-tree {
  overflow-y: auto;
  padding: 6px;
}
.tree-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.tree-item:hover { background: rgba(255,255,255,0.08); }
.tree-item .ti-icon { width: 20px; height: 20px; display: grid; place-items: center; opacity: 0.85; }
.tree-folder > .tree-item { font-weight: 600; color: var(--accent); }
.tree-children { margin-left: 16px; }
.tree-folder.collapsed .tree-children { display: none; }
.tree-empty { padding: 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- single-app / mobile mode ---------- */
body.solo-mode #desktop,
body.solo-mode #taskbar,
body.solo-mode #launcher { display: none; }
#solo {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  background: white;
  z-index: 50;
}
body.solo-mode #solo { display: flex; }
#solo-bar {
  height: 40px;
  background: var(--bg-1);
  color: var(--ink);
  display: flex; align-items: center;
  padding: 0 8px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
#solo-bar .solo-title { flex: 1; font-size: 13px; font-weight: 600; }
#solo-bar .btn-link {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
#solo-bar .btn-link:hover { background: rgba(255,255,255,0.08); }
#solo iframe { flex: 1; width: 100%; border: 0; background: white; }

/* On phones, desktop is replaced with solo-mode regardless. */
@media (max-width: 768px) {
  body:not(.solo-mode) #desktop-icons { grid-template-columns: repeat(auto-fill, 84px); }
  body:not(.solo-mode) .win { border-radius: 0; }
}
