/* ── Desktop mode: floating windows inside <main> ─────────────────────────────
   See core/desktopWindow.ts and issue #19 §10-11. Windows live in
   #lfDesktop, a child of <main> (not of <body>) per the explicit "inside a div
   inside main" requirement — so the mount needs a positioning context for them.

   The mount, not `main.container-fluid`: in the classic shell they are the same element
   (_LiveLayout marks <main>), and in Embedded the desktop lives in whatever container the
   host mounted — issue #118. */

.lf-mount:has(> #lfDesktop) {
  position: relative;
  overflow: hidden;
}

.lf-desktop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* Let clicks reach the page underneath except where a window/preview actually is. */
  pointer-events: none;
}

.lf-desktop-snap-preview {
  position: absolute;
  background: rgba(13, 110, 253, 0.18);
  border: 2px solid rgba(13, 110, 253, 0.65);
  border-radius: 0.35rem;
  pointer-events: none;
  z-index: 1;
}

.lf-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.175);
  border-radius: 0.4rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
  overflow: hidden;
  pointer-events: auto;
  min-width: 200px;
  min-height: 140px;
}

.lf-window.is-focused {
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.35);
  border-color: rgba(13, 110, 253, 0.4);
}

.lf-window.is-minimized {
  display: none;
}

.lf-window.is-maximized {
  border-radius: 0;
}

.lf-window.is-dragging,
.lf-window.is-dragging .lf-window-body {
  user-select: none;
}

.lf-window-titlebar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  height: 2.2rem;
  padding: 0 0.4rem 0 0.6rem;
  background: #212529;
  color: #f8f9fa;
  cursor: move;
  touch-action: none;
}

.lf-window-icon {
  flex: 0 0 auto;
  opacity: 0.85;
}

.lf-window-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.lf-window-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 0 0 auto;
}

.lf-window-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.lf-window-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.lf-window-btn.lf-window-close:hover {
  background: #dc3545;
}

.lf-window-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.lf-window-surface {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

/* A surface is a <div>, so it needs the two things a document used to provide for itself: a
   scrolling box of its own, and a containing block so a `position: absolute` inside the page
   cannot escape into the shell. There used to be a `.lf-window-resize-veil` here too, laid over
   the content while dragging so an iframe from another document could not swallow the
   pointermove — with the content in this document the drag's own pointer capture handles that. */
.lf-surface-inline {
  overflow: auto;
  position: relative;
}

.lf-window-resize {
  position: absolute;
  z-index: 2;
}

.lf-window-resize-n, .lf-window-resize-s {
  left: 6px;
  right: 6px;
  height: 6px;
  cursor: ns-resize;
}
.lf-window-resize-n { top: -3px; }
.lf-window-resize-s { bottom: -3px; }

.lf-window-resize-e, .lf-window-resize-w {
  top: 6px;
  bottom: 6px;
  width: 6px;
  cursor: ew-resize;
}
.lf-window-resize-e { right: -3px; }
.lf-window-resize-w { left: -3px; }

.lf-window-resize-ne, .lf-window-resize-nw, .lf-window-resize-se, .lf-window-resize-sw {
  width: 12px;
  height: 12px;
}
.lf-window-resize-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.lf-window-resize-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.lf-window-resize-se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.lf-window-resize-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }

.lf-window.is-maximized .lf-window-resize {
  display: none;
}

/* Taskbar affordance: a pinned function with an open window reads as "active",
   like the header bar's function pins already do for other states. */
.lf-menu-bar-pin.lf-window-open {
  box-shadow: inset 0 0 0 2px rgba(13, 110, 253, 0.6);
}
