/* ============================================================
   Ubuntu 26.04 — Window manager (Yaru CSD chrome)
   ============================================================ */

#workspace {
  position: fixed; inset: var(--workspace-inset);
  overflow: hidden;
  background: #000;
}

.win-layer { position: absolute; inset: 0; pointer-events: none; }
.win-layer > * { pointer-events: auto; }

.win {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--window-bg); color: var(--window-fg);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.1);
  min-width: 200px; min-height: 120px;
  transition: box-shadow var(--speed-normal) var(--ease-out);
  will-change: transform;
}
.win.anim-open { animation: win-open var(--speed-slow) var(--ease-spring); }
@keyframes win-open {
  from { opacity: 0; transform: scale(.88) translateY(14px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.win.anim-close { animation: win-close var(--speed-normal) var(--ease-out) forwards; pointer-events: none !important; }
@keyframes win-close { to { opacity: 0; transform: scale(.9); } }

.win.focused { box-shadow: 0 14px 40px rgba(0,0,0,.28), 0 3px 8px rgba(0,0,0,.14); z-index: auto; }
.win.backdrop {
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  filter: brightness(.97) saturate(.92);
  transition: filter var(--speed-normal);
}
.win.minimized { display: none; }
.win.maximized {
  border-radius: 0;
  box-shadow: none;
}
.win.maximized .titlebar { border-radius: 0; }

/* focus ring (keyboard nav) */
.win.focused.keyboard .win-frame { box-shadow: inset 0 0 0 2px var(--focus-ring); border-radius: 12px; }

.win-frame {
  position: absolute; inset: 0;
  border-radius: 12px;
  pointer-events: none;
  border: 1px solid rgba(0,0,0,.14);
}
.win.maximized .win-frame { border: none; border-radius: 0; }
[data-theme="dark"] .win-frame { border-color: rgba(255,255,255,.08); }

/* ---------- titlebar ---------- */
.titlebar {
  display: flex; align-items: center; gap: 10px;
  height: var(--titlebar-height); flex: none;
  padding: 0 12px 0 14px;
  border-radius: 12px 12px 0 0;
  background: var(--headerbar-bg);
  border-bottom: 1px solid var(--headerbar-border);
  cursor: grab;
  touch-action: none;
}
.win.maximized .titlebar { border-radius: 0; }
.titlebar.dragging { cursor: grabbing; }
.titlebar .tb-icon { width: 20px; height: 20px; flex: none; }
.titlebar .tb-icon img { width: 100%; height: 100%; object-fit: contain; }
.titlebar .tb-icon svg { width: 100%; height: 100%; }
.titlebar .tb-title {
  flex: 1; min-width: 0;
  font-size: var(--fs-m);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--headerbar-fg);
}
.titlebar .tb-title.dirty::after { content: " •"; color: var(--accent); }
.titlebar .tb-dot { display: none; }
.win.busy .titlebar .tb-dot { display: inline-block; }
.win.busy .titlebar .tb-busy { display: flex; }
.titlebar .tb-busy { display: none; }

/* window controls — Yaru circular buttons */
.tb-controls { display: flex; gap: 10px; flex: none; }
.tb-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  color: var(--headerbar-fg);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--speed-fast), border-color var(--speed-fast), color var(--speed-fast);
  cursor: default;
}
.tb-btn svg { width: 12px; height: 12px; opacity: .85; }
.tb-btn:hover { background: var(--row-hover); }
.tb-btn:active { background: var(--sidebar-active); }
.tb-close { background: #3D3D3D; border-color: #3D3D3D; color: #fff; }
.tb-close:hover { background: #4f4f4f; border-color: #4f4f4f; color: #fff; }
.tb-close:active { background: #5f5f5f; border-color: #5f5f5f; }
.tb-max.restore svg { transform: scale(.8); }
[data-theme="dark"] .tb-btn:not(.tb-close) { border-color: #5a5a60; color: #fff; }
[data-theme="dark"] .tb-close { background: #3d3d42; border-color: #3d3d42; }
[data-theme="dark"] .tb-close:hover { background: #4a4a50; }

/* resize handles */
.win .resize { position: absolute; z-index: 5; }
.win .resize.n  { top: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.win .resize.s  { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.win .resize.e  { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.win .resize.w  { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.win .resize.ne { top: -5px; right: -5px; width: 14px; height: 14px; cursor: nesw-resize; }
.win .resize.nw { top: -5px; left: -5px; width: 14px; height: 14px; cursor: nwse-resize; }
.win .resize.se { bottom: -5px; right: -5px; width: 14px; height: 14px; cursor: nwse-resize; }
.win .resize.sw { bottom: -5px; left: -5px; width: 14px; height: 14px; cursor: nesw-resize; }
.win.maximized .resize { display: none; }

.win-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  position: relative;
  background: var(--app-bg);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.win.maximized .win-body { border-radius: 0; }

/* snap preview */
.snap-preview {
  position: absolute; z-index: 100; pointer-events: none;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  animation: snap-pulse 1s var(--ease-in-out) infinite alternate;
}
@keyframes snap-pulse { from { opacity: .75; } to { opacity: 1; } }

/* minimize-to-dock ghost */
.ghost-icon {
  position: fixed; z-index: 9800; pointer-events: none;
  border-radius: 14px;
  background: var(--dash-bg);
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
  box-shadow: var(--shadow-2);
  animation: ghost-in var(--speed-slow) var(--ease-spring) forwards;
}
.ghost-icon img, .ghost-icon svg { width: 36px; height: 36px; }
@keyframes ghost-in { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }

/* alt-tab switcher */
.switcher {
  position: fixed; z-index: 9300; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  background: var(--osd-bg); color: var(--osd-fg);
  border-radius: var(--radius-xl);
  padding: var(--pad-l);
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-3);
  animation: menu-in var(--speed-normal) var(--ease-spring);
}
.switcher-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px; border-radius: var(--radius-l);
  opacity: .6;
}
.switcher-item img, .switcher-item svg { width: 48px; height: 48px; }
.switcher-item.active { opacity: 1; background: rgba(255,255,255,.12); }
.switcher-item span { font-size: var(--fs-xs); }

/* workspace drag ghost */
.ws-ghost {
  position: fixed; z-index: 9200; pointer-events: none;
  width: 200px; height: 120px; border-radius: 8px;
  background: var(--ws-thumb-bg);
  box-shadow: var(--shadow-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--overview-fg); font-size: var(--fs-s);
  opacity: .9;
}
