/*
 * Decoration: Neon Arcade (html.decor-neon)
 *
 * 8/16-bit RPG dialog frames: a neon outer line, a dark gap and a thin inner
 * line, with pixel staircase corners. The title is a "label plate" sitting on
 * the top border (a tab, so Shift+drag slides it and stacked windows line up
 * their plates). Gem buttons on the right of the active window; the control
 * menu becomes a PAUSE menu. A LOAD meter shows page loading.
 *
 * Fonts: Press Start 2P (plates, menus), VT323 (text), Silkscreen (labels).
 */

html.decor-neon {
  --icon-cell-w: 96px;
  --icon-cell-h: 104px;
  --tab-reserve: 150px;
  /* pixel staircase corners. --ps keeps the 4px neon line unbroken round the
     corner; --px is a deeper step for elements without a border line. */
  --px: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px), 0 8px, 4px 8px, 4px 4px, 8px 4px);
  --ps: polygon(4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px), 0 4px, 2px 4px, 2px 2px, 4px 2px);
}

html.decor-neon body { font: 20px 'VT323', monospace; }

/* ---------- frame ---------- */

html.decor-neon .wm-window { padding: 40px 12px 12px; }
html.decor-neon .wm-window::before {
  top: 14px;
  background: var(--window);
  clip-path: var(--ps);
  box-shadow:
    inset 0 0 0 4px var(--border-inactive),
    inset 0 0 0 8px var(--frame),
    inset 0 0 0 10px var(--inner-inactive);
}
html.decor-neon .wm-window.active::before {
  box-shadow:
    inset 0 0 0 4px var(--border),
    inset 0 0 0 8px var(--frame),
    inset 0 0 0 10px var(--inner);
}
html.decor-neon .wm-window.active:not(.maximized) {
  filter: drop-shadow(0 0 5px var(--border)) drop-shadow(0 0 14px color-mix(in srgb, var(--border) 45%, transparent));
}
html.decor-neon .wm-window.maximized { padding: 40px 10px 10px; }
html.decor-neon .wm-window.maximized::before { clip-path: none; }

/* ---------- label plates (title bars) ---------- */

html.decor-neon .wm-tabrow {
  height: 32px;
  margin-left: 20px;
  max-width: calc(100% - var(--tab-reserve));
  gap: 4px;
  align-items: flex-start;
}
html.decor-neon .wm-titlebar {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 300px;
  height: 32px;
  padding: 0 12px 0 8px;
  gap: 8px;
  align-items: center;
  border: 3px solid var(--frame);
  clip-path: var(--ps);
  background: linear-gradient(to right, var(--title-inactive), var(--title-inactive2));
  color: var(--title-inactive-text);
  font: 10px 'Press Start 2P', monospace;
  text-transform: uppercase;
}
html.decor-neon .wm-titlebar.active {
  background: linear-gradient(to right, var(--title), var(--title2));
  color: var(--title-text);
  font-size: 11px;
}
html.decor-neon .wm-titlebar.back {
  height: 26px;
  margin-top: 4px;
  padding: 0 10px;
  font-size: 8px;
}
html.decor-neon .wm-title { line-height: 1; padding-top: 1px; }

/* the pixel arrow on the plate opens the pause menu */
html.decor-neon .wm-ctlbox {
  width: 12px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
html.decor-neon .wm-ctlbox::after {
  content: "";
  width: 8px;
  height: 10px;
  background: currentColor;
  clip-path: polygon(0 0, 2px 0, 2px 2px, 4px 2px, 4px 4px, 6px 4px, 6px 6px, 4px 6px, 4px 8px, 2px 8px, 2px 10px, 0 10px);
}
html.decor-neon .wm-titlebar .wm-btn { display: none; }

/* ---------- gem buttons (active window only) ---------- */

html.decor-neon .wm-gems {
  display: flex;
  position: absolute;
  top: 1px;
  right: 24px;
  gap: 6px;
}
html.decor-neon .wm-window:not(.active) > .wm-gems { display: none; }
html.decor-neon .wm-gem {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--frame);
  clip-path: var(--ps);
  color: var(--frame);
  cursor: pointer;
}
html.decor-neon .wm-gem svg { width: 12px; height: 12px; display: block; shape-rendering: crispEdges; }
html.decor-neon .wm-gem:active { transform: translateY(2px); }
html.decor-neon .wm-gem-min { background: var(--gem-min); }
html.decor-neon .wm-gem-max { background: var(--gem-max); }
html.decor-neon .wm-gem-close { background: var(--gem-close); }

/* ---------- menu bar, client, status ---------- */

html.decor-neon .wm-menubar {
  gap: 4px;
  padding: 0 0 6px;
  margin-bottom: 4px;
  color: var(--menu-text);
  font: 12px 'Silkscreen', monospace;
  border-bottom: 2px dashed var(--inner-inactive);
}
html.decor-neon .wm-menubar-item { padding: 2px 8px; }
html.decor-neon .wm-menubar-item.open { background: var(--select); color: var(--select-text); }
html.decor-neon .wm-client { background: var(--window); color: var(--window-text); }

html.decor-neon .wm-statusbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 22px;
  padding-top: 6px;
  color: var(--inner);
  font: 10px 'Silkscreen', monospace;
}
html.decor-neon .wm-load {
  position: relative;
  width: 100px;
  height: 12px;
  background: repeating-linear-gradient(90deg, var(--inner-inactive) 0 8px, transparent 8px 10px);
}
html.decor-neon .wm-load-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 100%;
  background: repeating-linear-gradient(90deg, var(--select) 0 8px, transparent 8px 10px);
}
html.decor-neon .wm-window.loading .wm-load-fill { animation: wm-neon-load 1.2s steps(10) infinite; }
@keyframes wm-neon-load { from { width: 0; } to { width: 100%; } }
html.decor-neon .wm-load-state { color: var(--select); }
html.decor-neon .wm-window.loading .wm-load-state { color: var(--accent); }
html.decor-neon .wm-grip {
  margin-left: auto;
  width: 18px;
  height: 18px;
  background: var(--border);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath d='M7 1h2v2H7zM4 4h2v2H4zM7 4h2v2H7zM1 7h2v2H1zM4 7h2v2H4zM7 7h2v2H7z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath d='M7 1h2v2H7zM4 4h2v2H4zM7 4h2v2H7zM1 7h2v2H1zM4 7h2v2H4zM7 7h2v2H7z'/%3E%3C/svg%3E") center / contain no-repeat;
}
html.decor-neon .wm-window:not(.active) .wm-grip { background: var(--border-inactive); }

/* resize handles: over the frame, which starts 14px down */
html.decor-neon .wm-rh-n  { top: 14px;  left: 16px; right: 16px; height: 6px; }
html.decor-neon .wm-rh-s  { bottom: 0;  left: 16px; right: 16px; height: 6px; }
html.decor-neon .wm-rh-e  { right: 0;   top: 30px;  bottom: 16px; width: 6px; }
html.decor-neon .wm-rh-w  { left: 0;    top: 30px;  bottom: 16px; width: 6px; }
html.decor-neon .wm-rh-nw { top: 14px;  left: 0;  width: 16px; height: 16px; }
html.decor-neon .wm-rh-ne { top: 14px;  right: 0; width: 16px; height: 16px; }
html.decor-neon .wm-rh-sw { bottom: 0;  left: 0;  width: 16px; height: 16px; }
html.decor-neon .wm-rh-se { bottom: 0;  right: 0; width: 20px; height: 20px; }

/* ---------- icons: minimized windows become item boxes ---------- */

/* icons are drawn at 48px: exactly 3x the 16px pixel grid, so they stay crisp */
html.decor-neon .wm-icon { width: 92px; }
html.decor-neon .icon-img { width: 48px; height: 48px; line-height: 48px; font-size: 38px; }
html.decor-neon .icon-img img { width: 48px; height: 48px; }
html.decor-neon .icon-label { margin-top: 6px; font: 11px 'Silkscreen', monospace; line-height: 13px; }
html.decor-neon .icon-grid { gap: 14px 6px; padding: 10px 6px; }
html.decor-neon .min-icon .icon-img {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  border: 3px solid var(--icon-frame);
  background: var(--window);
  clip-path: var(--ps);
}
html.decor-neon .min-icon.selected .icon-img { border-color: var(--select); }

/* ---------- menus: RPG boxes; the control menu is the PAUSE menu ---------- */

html.decor-neon .wm-menu {
  min-width: 210px;
  padding: 16px 14px;
  clip-path: var(--ps);
  background: var(--menu);
  color: var(--window-text);
  box-shadow:
    inset 0 0 0 4px var(--accent),
    inset 0 0 0 8px var(--frame),
    inset 0 0 0 10px var(--border);
  font: 10px 'Press Start 2P', monospace;
  text-transform: uppercase;
}
html.decor-neon .wm-menu-item { padding: 6px 8px 6px 0; line-height: 1.3; }
html.decor-neon .wm-menu-item .shortcut { display: none; }
html.decor-neon .wm-menu-sep { border-top: 2px dashed var(--inner-inactive); margin: 6px 0; }
html.decor-neon .wm-menu.wm-ctlmenu::before {
  content: "- PAUSE -";
  display: block;
  margin: 2px 0 10px;
  text-align: center;
  letter-spacing: 2px;
  color: var(--accent);
}
html.decor-neon .wm-item-close:not(:hover) .label { color: var(--gem-close); }

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

html.decor-neon .dialog { background: var(--window); color: var(--window-text); font: 20px 'VT323', monospace; }
html.decor-neon .about-icon { width: 48px; height: 48px; }
html.decor-neon .wm-window.fixed .wm-client { background: var(--window); color: var(--window-text); }
html.decor-neon .dialog input[type=text] {
  padding: 2px 6px;
  font: 20px 'VT323', monospace;
  background: var(--frame);
  color: var(--window-text);
  border: 2px solid var(--inner);
  outline: none;
}
html.decor-neon .dialog button {
  padding: 8px 12px;
  font: 10px 'Press Start 2P', monospace;
  text-transform: uppercase;
  background: var(--face);
  color: var(--button-text);
  border: 3px solid var(--frame);
  border-radius: 0;
  clip-path: var(--ps);
  box-shadow: inset 0 0 0 2px var(--hilite);
}
html.decor-neon .dialog button:active { transform: translateY(2px); }
