/* LITTLESITE · PARTS — frame's look: a window's chrome (frame.js makes it). */
.window {
  position: absolute;
  background: var(--window-bg);
  border: 1px solid var(--window-border);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  /* The glass is the title bar's: a window's page covers the rest of it,
     and a blur the size of every window, redrawn whenever anything under
     it moves (a demo, a game), kept a GPU busy all the time. */
  overflow: hidden;
  min-width: 300px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.window.active {
  box-shadow: 0 12px 48px var(--accent-glow), 0 0 0 1px var(--accent);
  border-color: var(--window-active-border);
}

/* A window's own colour (setWindowColor, from its title bar's menu), on
   its frame and title bar over any theme's, and its own background
   (setWindowBackground), which shows through its page. */
.window.custom-color {
  border-color: var(--window-custom-color) !important;
}

.window.custom-color .titlebar,
.window.custom-color .titlebar .window-title {
  background: var(--window-custom-color) !important;
  color: var(--window-custom-text) !important;
}

.window.custom-background .preview-pane iframe {
  background: transparent;
}

/* Maximized: the window fills the desk (windows.js sets the size), with
   square corners and no edges to resize by; the title bar's restore button
   or a drag by the title brings it back to its own size. Three classes'
   weight, over the themes' rounded corners. */
:root .window.maximized {
  border-radius: 0;
}
.window.maximized .resize-handle {
  display: none;
}
/* a maximized window dragged down to its own size: its page lets the pointer through until the press is over (windows.js, lift) */
.window.lifted .preview-pane iframe {
  pointer-events: none;
}
/* the slide between a window's own size and the desk's, as the button is pressed */
.window.zooming {
  transition: left 0.18s ease-out, top 0.18s ease-out, width 0.18s ease-out, height 0.18s ease-out, box-shadow 0.2s ease, border-color 0.2s ease;
}
@media (prefers-reduced-motion: reduce) {
  .window.zooming { transition: none; }
}

/* The title bar's glass, on a layer behind its contents: a blur on the
   title bar itself would make it a stacking context of its own, and the
   resize edges (z-index 10) would cover its buttons. Only the looks of
   glass draw it (the default, Windows 7, Sonoma), each its own blur. */
:is(.theme-modern .window, .window:not([class*="theme-"] .window), .theme-win7 .window, .theme-mac-sonoma .window) .titlebar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  backdrop-filter: blur(var(--titlebar-blur, 16px));
  -webkit-backdrop-filter: blur(var(--titlebar-blur, 16px));
  pointer-events: none;
}

/* under a maximized window: not seen, so not drawn (main.js cover) */
.window.covered { visibility: hidden; }

.window.minimized {
  transform: scale(0.1);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.window .titlebar {
  position: relative;
  height: var(--titlebar-height);
  display: flex;
  align-items: center;
  padding: 0 8px 0 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  user-select: none;
  touch-action: none;  /* a finger on it drags the window, not the page */
  flex-shrink: 0;
  gap: 8px;
}

.window .titlebar:active {
  cursor: grabbing;
}

.window .window-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the rename field, put in the title by startRename; dark enough for its
   white text on the light title bars too */
.window .window-title input {
  width: 100%;
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 2px 4px;
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border-radius: 2px;
}

.window .window-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  position: relative;
}

/* The title buttons lie above the resize edges and corners (z-index 10),
   which covered the corner buttons in part: a press on the top of 1984's
   close box resized the window. Four classes' weight, to outrank the
   themes that place the buttons themselves. */
:root .window .titlebar .window-controls {
  z-index: 11;
}

.window .window-controls button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--border-radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s ease;
}

/* The default look's coloured hovers, glows and purple buttons: scoped to
   the default theme, since every other theme draws its own and these
   showed through them (a light theme's tab labels turned white on white). */
:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .window-controls .btn-code:hover {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  color: #fff;
  transform: scale(1.1);
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .window-controls .btn-code.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 10px var(--accent-glow);
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .window-controls .btn-minimize:hover {
  background: var(--warning);
  color: #fff;
  transform: scale(1.1);
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .window-controls .btn-maximize:hover {
  background: var(--success);
  color: #fff;
  transform: scale(1.1);
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .window-controls .btn-close:hover {
  background: var(--error);
  color: #fff;
  transform: scale(1.1);
}

.window .window-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.window .preview-pane {
  width: 100%;
  height: 100%;
}

.window .preview-pane iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.window .code-pane {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.window .code-pane.active {
  display: flex;
}

.window .code-pane-editor {
  flex: 1;
  width: 100%;
  height: calc(100% - 40px);
  position: relative;
  overflow: hidden;
}

.window .preview-pane.hidden {
  display: none;
}

.window .code-toolbar {
  height: 40px;
  position: relative;
  bottom: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(10,10,20,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 10;
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .code-toolbar button.code-save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .code-toolbar button.code-save-btn:hover {
  box-shadow: 0 0 10px var(--accent-glow);
}

.window .code-tabs {
  display: flex;
  gap: 4px;
  align-items: center;
}

.window .code-tab {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.15s ease;
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .code-tab:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

:is(.theme-modern .window, .window:not([class*="theme-"] .window)) .code-tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 8px var(--accent-glow);
}

.window .code-toolbar .lang-indicator {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.resize-handle {
  position: absolute;
  z-index: 10;
  touch-action: none;
}

:is(.theme-modern .resize-handle, .resize-handle:not([class*="theme-"] .resize-handle)):hover {
  background: rgba(108, 99, 255, 0.3);
  transition: background 0.2s ease;
}

.resize-handle.n { top: 0; left: 10px; right: 10px; height: 4px; cursor: n-resize; }
.resize-handle.s { bottom: 0; left: 10px; right: 10px; height: 4px; cursor: s-resize; }
.resize-handle.e { right: 0; top: 10px; bottom: 10px; width: 4px; cursor: e-resize; }
.resize-handle.w { left: 0; top: 10px; bottom: 10px; width: 4px; cursor: w-resize; }
.resize-handle.ne { top: 0; right: 0; width: 10px; height: 10px; cursor: ne-resize; }
.resize-handle.nw { top: 0; left: 0; width: 10px; height: 10px; cursor: nw-resize; }
.resize-handle.se { bottom: 0; right: 0; width: 10px; height: 10px; cursor: se-resize; }
.resize-handle.sw { bottom: 0; left: 0; width: 10px; height: 10px; cursor: sw-resize; }

/* A game fills the desktop on a phone (concepts/desk.md, The phone); the taskbar stays. */
@media (max-width: 599px) {
  .window.kind-game { left: 0 !important; top: 0 !important; width: 100vw !important; height: calc(100vh - var(--taskbar-height)) !important; height: calc(100dvh - var(--taskbar-height) - env(safe-area-inset-bottom, 0px)) !important; border-radius: 0; }
  body.taskbar-top .window.kind-game { top: var(--taskbar-height) !important; top: calc(var(--taskbar-height) + env(safe-area-inset-top, 0px)) !important; height: calc(100dvh - var(--taskbar-height) - env(safe-area-inset-top, 0px)) !important; }
  .window.kind-game .resize-handle { display: none; }
}
