/* Windows, snap preview, context menus, toasts, palette and boot. */

.windows { position: fixed; inset: 0 0 var(--taskbar-h) 0; pointer-events: none; z-index: 20; }

.win {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column;
  min-width: 280px; min-height: 180px;
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(145%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(145%);
  border: 1px solid var(--line-2);
  border-radius: var(--r-win);
  box-shadow: var(--shadow-win-idle), var(--highlight);
  pointer-events: auto;
  overflow: hidden;
  overflow: clip;
  contain: layout paint;
  transform-origin: 50% 60%;
  will-change: transform;
}
.win.is-focused { box-shadow: var(--shadow-win), var(--highlight); border-color: rgb(255 255 255 / 0.17); }
.win.is-max { border-radius: 0; border-width: 0 0 1px 0; }
.win.is-min { visibility: hidden; pointer-events: none; }

.win.is-opening { animation: win-in var(--dur-2) var(--ease-out); }
.win.is-closing { animation: win-out 160ms var(--ease-in) forwards; pointer-events: none; }
.win.is-minimizing { animation: win-min 200ms var(--ease-in) forwards; }
@keyframes win-in { from { opacity: 0; scale: 0.96; } to { opacity: 1; scale: 1; } }
@keyframes win-out { to { opacity: 0; scale: 0.97; } }
@keyframes win-min { to { opacity: 0; scale: 0.88; translate: 0 36px; } }

.win-bar {
  display: flex; align-items: center; gap: 8px;
  height: var(--titlebar-h); flex: none;
  padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--line);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  cursor: default;
}
.win-bar .glyph { width: 16px; height: 16px; color: var(--text-2); }
.win-title {
  flex: 1; min-width: 0;
  font-weight: 500; font-size: var(--fs-2); color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win.is-focused .win-title { color: var(--text); }
.win.is-focused .win-bar .glyph { color: var(--text); }
.win-busy { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface-4); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.win-ctl { display: flex; gap: 2px; }
.win-ctl button {
  display: grid; place-items: center;
  width: 30px; height: 28px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2);
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.win-ctl button:hover { background: var(--surface-3); color: var(--text); }
.win-ctl button.close:hover { background: var(--red); color: #fff; }
.win-ctl .glyph { width: 15px; height: 15px; }
@media (pointer: coarse) { .win-ctl button { width: 40px; height: 36px; } }

.win-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; overflow: clip; }
.win-body > [class^="app-"], .win-body > [class*=" app-"] { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Resize handles */
.win-rz { position: absolute; z-index: 2; touch-action: none; }
.win-rz[data-d="n"]  { top: -3px; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.win-rz[data-d="s"]  { bottom: -3px; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.win-rz[data-d="e"]  { right: -3px; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.win-rz[data-d="w"]  { left: -3px; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.win-rz[data-d="ne"] { right: -3px; top: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.win-rz[data-d="nw"] { left: -3px; top: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.win-rz[data-d="se"] { right: -3px; bottom: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.win-rz[data-d="sw"] { left: -3px; bottom: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.win.is-max .win-rz, .win.is-sheet .win-rz { display: none; }

/* While dragging, iframes must not swallow the pointer. */
html.wm-dragging iframe { pointer-events: none; }
html.wm-dragging, html.wm-dragging * { user-select: none !important; -webkit-user-select: none !important; }

/* Phone: windows become sheets */
.win.is-sheet { border-radius: 14px 14px 0 0; border-width: 1px 0 0 0; }

.snap-preview {
  position: fixed; z-index: 19; pointer-events: none;
  border-radius: var(--r-win);
  background: rgb(0 172 193 / 0.12);
  border: 1px solid rgb(0 172 193 / 0.5);
  backdrop-filter: blur(6px);
  transition: all var(--dur-1) var(--ease-out);
}

/* Context menu */
.menu {
  position: fixed; z-index: 90; min-width: 212px; padding: 5px;
  background: var(--surface); backdrop-filter: blur(var(--blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line-2); border-radius: 11px;
  box-shadow: var(--shadow-pop), var(--highlight);
  animation: pop-in var(--dur-1) var(--ease-out);
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text); text-align: left; font-size: var(--fs-2);
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-3); box-shadow: none; }
.menu button .glyph { width: 16px; height: 16px; color: var(--text-2); }
.menu button .hint { margin-left: auto; color: var(--text-3); font-size: var(--fs-1); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(0.98); } }

/* Toasts */
.toasts {
  position: fixed; z-index: 95; right: 14px; bottom: calc(var(--taskbar-h) + 14px);
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; gap: 12px; align-items: flex-start;
  width: min(360px, calc(100vw - 28px)); padding: 12px 14px;
  background: var(--surface); backdrop-filter: blur(var(--blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow-pop), var(--highlight);
  pointer-events: auto;
  animation: toast-in var(--dur-2) var(--ease-out);
}
.toast.is-leaving { animation: toast-out 180ms var(--ease-in) forwards; }
.toast .glyph { color: var(--accent); margin-top: 1px; }
.toast b { display: block; font-weight: 600; }
.toast p { margin: 2px 0 0; color: var(--text-2); }
.toast .os-btn { margin-top: 8px; min-height: 28px; padding: 0 10px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* Command palette */
.palette-scrim { position: fixed; inset: 0; z-index: 100; background: var(--scrim); animation: fade-in var(--dur-1) linear; }
.palette {
  position: fixed; z-index: 101; left: 50%; top: 16vh; translate: -50% 0;
  width: min(620px, calc(100vw - 24px));
  background: var(--surface); backdrop-filter: blur(var(--blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line-2); border-radius: var(--r-pop);
  box-shadow: var(--shadow-pop), var(--highlight);
  overflow: hidden;
  animation: pop-in var(--dur-2) var(--ease-out);
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input .glyph { color: var(--text-3); }
.palette-input input { flex: 1; height: 52px; border: 0; background: transparent; font-size: var(--fs-3); }
.palette-input input:focus-visible { box-shadow: none; }
.palette-list { max-height: min(420px, 56vh); padding: 6px; }
.palette-group { padding: 8px 10px 4px; color: var(--text-3); font-size: var(--fs-1); font-weight: 500; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.palette-item[aria-selected="true"] { background: var(--surface-3); }
.palette-item .tile-sm { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--line); }
.palette-item .tile-sm .glyph { width: 16px; height: 16px; }
.palette-item .sub { color: var(--text-3); font-size: var(--fs-1); }
.palette-item .hint { margin-left: auto; color: var(--text-3); font-size: var(--fs-1); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--text-3); font-size: var(--fs-1); }
@keyframes fade-in { from { opacity: 0; } }

/* Boot */
.boot {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity 500ms var(--ease-out);
}
.boot.is-done { opacity: 0; pointer-events: none; }
.boot svg { width: min(420px, 72vw); height: auto; overflow: visible; }
.boot .river { fill: none; stroke-width: 3; stroke-linecap: round; }
.boot .word { font: 400 22px var(--font-display); fill: var(--text); letter-spacing: 0.02em; }
.boot .skip { position: absolute; bottom: 28px; color: var(--text-3); font-size: var(--fs-1); }
