/* ============================================================
   Spaces & overlays: Mission Control, Stage Manager, Cmd+Tab
   app switcher, Quick Look. Uses shared theme tokens so dark
   mode adapts automatically (see APP_CONTRACT.md).
   ============================================================ */

/* ============ Mission Control ============ */
#mission-control {
  position: fixed;
  inset: 0;
  z-index: 9200;
  background: rgba(10, 10, 14, 0.55);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  opacity: 0;
  transition: opacity 0.22s var(--ease-out);
}
#mission-control.hidden { display: none; }
#mission-control.show { opacity: 1; }

.mc-stage {
  position: absolute;
  inset: 0;
}
/* Each tile is a live-positioned scaled clone wrapper. */
.mc-tile {
  position: absolute;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  border: 2px solid transparent;
  transition: transform 0.18s var(--ease-out), border-color 0.12s ease;
  transform-origin: top left;
  background: var(--win-bg);
}
.mc-tile:hover { border-color: var(--accent); transform: scale(1.015); }
.mc-tile-title {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.6));
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.mc-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* ============ Cmd+Tab app switcher ============ */
#app-switcher {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  z-index: 9600;
  display: flex;
  gap: 8px;
  padding: 18px;
  max-width: 90vw;
  flex-wrap: wrap;
  justify-content: center;
  border-radius: 22px;
  background: var(--menu-bg, rgba(40, 40, 44, 0.7));
  border: 0.5px solid var(--menu-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s var(--ease-out);
}
#app-switcher.hidden { display: none; }
#app-switcher.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.as-item {
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 4px;
  border-radius: 12px;
}
.as-item.selected { background: rgba(255, 255, 255, 0.18); }
.as-app-icon {
  width: 64px; height: 64px;
  border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.as-app-name {
  font-size: 11.5px;
  color: var(--menu-fg, #fff);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.as-item.selected .as-app-name { opacity: 1; }

/* ============ Stage Manager strip ============ */
#stage-strip {
  position: fixed;
  left: 10px;
  top: calc(var(--menubar-h) + 14px);
  bottom: 110px;
  width: 132px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px;
  overflow: hidden auto;
  pointer-events: none;
}
#stage-strip.hidden { display: none; }
.stage-card {
  pointer-events: auto;
  position: relative;
  height: 86px;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  background: var(--win-bg);
  border: 0.5px solid var(--win-border);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
  transform: scale(0.92);
  transform-origin: left center;
  transition: transform 0.16s var(--ease-out);
  color: var(--win-fg);
}
.stage-card:hover { transform: scale(1); }
.stage-card-bar {
  height: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  background: var(--titlebar-bg);
  border-bottom: 0.5px solid var(--win-border);
}
.stage-card-bar .dot { width: 7px; height: 7px; border-radius: 50%; }
.stage-card-body {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
}
.stage-card-glyph { font-size: 26px; line-height: 1; }
.stage-card-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.stage-on #stage-strip { display: flex; }

/* Selection ring for Quick Look-able items (Finder files, desktop icons). */
.ql-selected { background: rgba(10, 132, 255, 0.22); border-radius: 6px; }

/* ============ Quick Look ============ */
#quicklook {
  position: fixed;
  inset: 0;
  z-index: 9400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.16s ease;
}
#quicklook.hidden { display: none; }
#quicklook.show { opacity: 1; }
.ql-panel {
  width: min(620px, 84vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  background: var(--win-bg);
  color: var(--win-fg);
  border: 0.5px solid var(--win-border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  transform: scale(0.95);
  transition: transform 0.18s var(--ease-spring);
}
#quicklook.show .ql-panel { transform: scale(1); }
.ql-bar {
  height: 40px;
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--titlebar-bg-active);
  border-bottom: 0.5px solid var(--win-border);
}
.ql-close {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--tl-red);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  cursor: default;
}
.ql-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--titlebar-fg-active);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ql-body {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 160px;
}
.ql-image {
  width: 100%;
  height: 360px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.ql-doc { padding: 26px 30px; font-size: 14px; line-height: 1.6; }
.ql-doc h1 { font-size: 20px; margin-bottom: 10px; }
.ql-info { padding: 24px 26px; }
.ql-info .ql-glyph { font-size: 64px; text-align: center; margin-bottom: 12px; }
.ql-info .ql-name { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 16px; }
.ql-info .ql-row {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 5px 0; font-size: 13px;
  border-top: 0.5px solid var(--win-border);
}
.ql-info .ql-row span:first-child { color: var(--win-muted); }
