/*
 * base.css: structure shared by every window decoration.
 *
 * This file only lays things out. How windows LOOK lives in one file per
 * decoration under css/decorations/, each scoped to a class on <html>
 * (html.decor-neon, html.decor-win31, ...). theme.js sets that class.
 *
 * Every color is a CSS variable so the Appearance program can change it.
 * The defaults below are the "Neon Arcade" scheme.
 */

:root {
  /* desktop */
  --desktop: #0b0221;
  --desktop-text: #7df9ff;
  /* window frame */
  --border: #ff6ec7;
  --border-inactive: #5b1a99;
  --frame: #0b0221;
  --inner: #7df9ff;
  --inner-inactive: #3a1466;
  /* title bar / label plate */
  --title: #0ff0fc;
  --title2: #0ff0fc;
  --title-text: #0b0221;
  --title-inactive: #2a0f4d;
  --title-inactive2: #2a0f4d;
  --title-inactive-text: #ff69b4;
  /* menus and selection */
  --menu: #12062b;
  --menu-text: #7df9ff;
  --disabled-text: #6b4a8f;
  --select: #ccff00;
  --select-text: #0b0221;
  --accent: #ffff33;
  /* window contents */
  --window: #12062b;
  --window-text: #f3e8ff;
  /* buttons */
  --face: #2a0f4d;
  --hilite: #b026ff;
  --shadow: #000000;
  --button-text: #ffff33;
  --gem-min: #ffff33;
  --gem-max: #39ff14;
  --gem-close: #ff3131;
  /* icons */
  --icon-frame: #b026ff;

  /* set by theme.js from the wallpaper setting */
  --wallpaper: none;
  --wp-size: auto;
  --wp-repeat: repeat;
  --wp-pos: 0 0;

  /* minimized-icon grid cell; decorations with bigger icons override these */
  --icon-cell-w: 84px;
  --icon-cell-h: 64px;
  /* space a sliding tab must leave free on the right (tab-style decorations) */
  --tab-reserve: 0px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  font: 12px Arial, sans-serif;
  background: var(--desktop);
  -webkit-user-select: none;
  user-select: none;
}

#desktop {
  position: fixed;
  inset: 0;
  background-color: var(--desktop);
  background-image: var(--wallpaper);
  background-size: var(--wp-size);
  background-repeat: var(--wp-repeat);
  background-position: var(--wp-pos);
}

/* Touch screens: dragging these moves/resizes windows and icons
   instead of scrolling or zooming the page */
.wm-titlebar, .wm-rh, .min-icon, .wm-gems { touch-action: none; }

/* While dragging/resizing, iframes must not swallow the pointer */
body.wm-dragging iframe { pointer-events: none; }

/* ---------- windows ---------- */

.wm-window { position: absolute; display: flex; flex-direction: column; }
.wm-window.maximized {
  left: 0 !important; top: 0 !important;
  width: 100% !important; height: 100% !important;
}
.wm-window.maximized .wm-rh { display: none; }

.wm-tabrow { flex: none; display: flex; min-width: 0; }
.wm-titlebar { flex: none; display: flex; cursor: default; }
.wm-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-titlebar.back { cursor: pointer; }
.wm-titlebar.back .wm-ctlbox, .wm-titlebar.back .wm-btn { display: none; }
.wm-ctlbox, .wm-btn { flex: none; cursor: default; }

/* Parts only some decorations show */
.wm-gems, .wm-statusbar { display: none; }
.wm-gem { font: inherit; }

.wm-menubar { flex: none; display: flex; }
.wm-menubar-item { cursor: default; }

.wm-client { flex: 1; min-height: 0; position: relative; overflow: auto; }

/* resize handles: decorations position them */
.wm-rh { position: absolute; z-index: 2; }
.wm-rh-nw, .wm-rh-ne, .wm-rh-sw, .wm-rh-se { z-index: 3; }
.wm-rh-n, .wm-rh-s { cursor: ns-resize; }
.wm-rh-e, .wm-rh-w { cursor: ew-resize; }
.wm-rh-nw, .wm-rh-se { cursor: nwse-resize; }
.wm-rh-ne, .wm-rh-sw { cursor: nesw-resize; }

/* Tab mode (html.wm-tabs): the tab row sits on top of the frame, which the
   decoration draws in ::before. The top strip beside the tabs is click-through. */
html.wm-tabs .wm-window { pointer-events: none; }
html.wm-tabs .wm-window > * { pointer-events: auto; }
html.wm-tabs .wm-window::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: -1;
  pointer-events: auto;
}
/* tabs (and gem buttons) sit above the resize handles, which run under them */
html.wm-tabs .wm-tabrow { position: absolute; top: 0; max-width: 100%; z-index: 4; }
/* a maximized tab-style window covers the whole screen, so its top strip is solid */
html.wm-tabs .wm-window.maximized { background: var(--desktop); pointer-events: auto; }
.wm-gems { z-index: 4; }

/* ---------- icons ---------- */

.wm-icon {
  width: 84px;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
  outline: none;
}
.min-icon { position: absolute; z-index: 1; }
.icon-img {
  width: 32px; height: 32px;
  font-size: 26px;
  line-height: 32px;
  text-align: center;
}
.icon-img img { width: 32px; height: 32px; image-rendering: pixelated; vertical-align: middle; }
.icon-label {
  margin-top: 3px;
  padding: 0 2px;
  text-align: center;
  line-height: 13px;
  overflow-wrap: break-word;
  color: var(--window-text);
}
#desktop > .min-icon .icon-label { color: var(--desktop-text); }
.wm-icon.selected .icon-label,
#desktop > .min-icon.selected .icon-label { background: var(--select); color: var(--select-text); }

.icon-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px 4px;
  padding: 8px 4px;
}

/* Program Manager's inside, where group windows and group icons live */
.pm-mdi { position: absolute; inset: 0; overflow: hidden; background: var(--window); }

/* program windows */
.app-frame {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  border: 0;
  background: var(--window);
}

/* ---------- menus ---------- */

.wm-menu {
  position: fixed;
  z-index: 100000;
  min-width: 150px;
  background: var(--menu);
  color: var(--menu-text);
}
.wm-menu-item { display: flex; white-space: nowrap; cursor: default; }
.wm-menu-item .check { width: 18px; text-align: center; flex: none; }
.wm-menu-item .label { flex: 1; }
.wm-menu-item .shortcut { margin-left: 24px; }
.wm-menu-item:hover:not(.disabled) { background: var(--select); color: var(--select-text); }
.wm-menu-item.disabled { color: var(--disabled-text); }

/* ---------- stacking feedback ---------- */

.wm-tab-ghost { position: fixed; z-index: 100001; pointer-events: none; opacity: 0.85; }
.wm-window.wm-drop-target { outline: 2px dashed var(--select); outline-offset: 2px; }

/* ---------- dialogs ---------- */

.dialog { padding: 10px 14px; height: 100%; background: var(--face); color: var(--button-text); }
.dialog p { margin: 0 0 8px; }
.dialog input[type=text] { width: 100%; margin-top: 4px; }
.dialog-buttons { margin-top: 12px; text-align: center; }
.dialog button { min-width: 72px; cursor: pointer; }
.about { display: flex; gap: 14px; }
.about-icon { width: 32px; height: 32px; flex: none; image-rendering: pixelated; }

/* ---------- Webamp (js/actions.js) ---------- */

/* zero-size anchor Webamp positions its windows around */
#webamp-layer { position: fixed; left: 50%; top: 40%; width: 0; height: 0; z-index: 99990; }
/* Webamp's own root element: keep its windows above the desktop's windows */
#webamp { z-index: 99990 !important; }

/* ---------- Task List ---------- */

.tasklist { display: flex; flex-direction: column; height: 100%; }
.tl-items {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--window);
  color: var(--window-text);
  border: 1px solid var(--frame);
}
.tl-item { display: flex; align-items: center; gap: 8px; padding: 3px 6px; cursor: default; }
.tl-item.sel { background: var(--select); color: var(--select-text); }
.tl-item .icon-img { width: 16px; height: 16px; font-size: 14px; line-height: 16px; flex: none; }
.tl-item .icon-img img { width: 16px; height: 16px; }
.tasklist .dialog-buttons { margin-top: 8px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.tasklist button:disabled { opacity: 0.5; }

/* the phone Task List button is only shown in phone mode (css/phone.css) */
#tasklist-btn { display: none; }

/* ---------- window switcher (Alt+Q, set in js/settings.js) ---------- */

.wm-coolswitch {
  position: fixed;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
  max-width: calc(100vw - 24px);
  padding: 14px 20px;
  background: var(--face);
  color: var(--button-text);
  border: 2px solid var(--frame);
  box-shadow: inset -2px -2px var(--shadow), inset 2px 2px var(--hilite), 4px 4px 0 rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.wm-coolswitch .icon-img { width: 32px; height: 32px; flex: none; font-size: 28px; line-height: 32px; text-align: center; }
.wm-coolswitch .icon-img img { width: 32px; height: 32px; image-rendering: pixelated; }
.wm-coolswitch .cs-text { min-width: 0; }
.wm-coolswitch .cs-title { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-coolswitch .cs-count { opacity: 0.7; margin-top: 3px; font-size: 0.85em; }
html.decor-neon .wm-coolswitch {
  border: 3px solid var(--border);
  box-shadow: 0 0 14px color-mix(in srgb, var(--border) 60%, transparent), 4px 4px 0 rgba(0, 0, 0, 0.5);
  font: 10px 'Press Start 2P', monospace;
  color: var(--title);
}
html.decor-neon .wm-coolswitch .cs-count { font: 9px 'Silkscreen', monospace; color: var(--window-text); }
