/*
 * The Mandarax Web Game Editor's base stylesheet: what any editor layout needs to work. The look (colors, borders,
 * sizes, the page around the grid) comes from the stylesheet loaded after it: defaultLayout.css, or a layout or theme
 * of your own.
 */

/* Base reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* The grid's size in cells, the only place it is written: the same at any window size, the cells stretching with the
   window. domGrid.js reads it when it makes a grid (createDOMGrid). It also sizes a spot until domGrid.js places it. */
:root {
  --grid-cols: 32;
  --grid-rows: 24;
}

/* The grid area: the container the layers are stacked in */
.layout-grid {
  position: relative;
}

/* A layer: a container for a grid, stacked over the same area as the other layers (main.js createLayer).
   The mouse goes through a layer's empty cells to the layers below; its spots take it. */
.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.layer .spot {
  pointer-events: auto;
}

/* While a spot is dragged, its layer is the drag's source (dragDrop.js): it takes the pointer, and the other layers'
   spots let it through, so the drag reaches any cell of its layer, also one under a spot of a higher layer */
.layer.drag-source {
  pointer-events: auto;
}

.layout-grid:has(.layer.drag-source) .layer:not(.drag-source) .spot {
  pointer-events: none;
}

/* A spot, placed by domGrid.js, which sets its left, top, width and height; its spot-col-N and spot-row-N classes
   record its span. The gap between spots is the layout's --grid-gap, none if it sets none. */
.spot {
  position: absolute;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: calc(100% / var(--grid-cols) - var(--grid-gap, 0px));
  height: calc(100% / var(--grid-rows) - var(--grid-gap, 0px));
}

.spot .component-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* A closed spot, out of its grid (main.js closePanel), is hidden and lets the mouse through. What it holds keeps its
   size, so nothing in it is resized, such as the scene's game. */
.spot.closed {
  visibility: hidden;
}

/* A spot's icon (spot.js), which the master panel shows beside its name, is drawn on the spot only while it is
   minimized */
.spot > .spot-icon {
  display: none;
}

/* A minimized spot, one cell of its grid (main.js minimizePanel), shows its icon alone: its title bar and its resize
   handles are hidden, and what it holds keeps the size it had (spot.js setMinimized), hidden and out of the icon's
   way, so nothing in it is resized, such as the scene's game */
.spot.minimized > header,
.spot.minimized > .resize-handle {
  display: none;
}

.spot.minimized > .component-container {
  position: absolute;
  visibility: hidden;
}

.spot.minimized > .spot-icon {
  display: block;
}

/* The master panel's lines scroll when they are longer or wider than the panel */
.master-panel-component {
  height: 100%;
  overflow: auto;
}

/* The Project panel's scene tree scrolls when it is longer or wider than the panel */
.project-component {
  height: 100%;
  overflow: auto;
}

/* The Frame panel's events scroll when they are longer or wider than the panel */
.frame-component {
  height: 100%;
  overflow: auto;
}

/* Its Next update line hides when it is hidden, whatever display a layout gives it */
.frame-next-input[hidden] {
  display: none;
}

/* The Engine config panel's options scroll when they are longer or wider than the panel, and hide when hidden (no
   project, or a file that can't be read), whatever display a layout gives them */
.engine-config-component {
  height: 100%;
  overflow: auto;
}

.engine-config-options[hidden] {
  display: none;
}

/* A button panel, such as the Controls panel: its buttons in rows from the top left, wrapping, or in columns when it
   is vertical, and what runs past the panel cut off. A button is its icon and its word side by side, the word hidden
   while the buttons don't all fit with their words (buttonPanelComponent.js measures it), but on a button with no
   icon. */
.button-panel-component {
  width: 100%;
  height: 100%;
  display: flex;
  flex-flow: row wrap;
  align-content: flex-start;
  align-items: flex-start;
  overflow: hidden;
}

.button-panel-component.is-vertical {
  flex-direction: column;
}

.button-panel-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.button-panel-component:not(.with-words) .button-panel-button.has-icon .button-panel-word {
  display: none;
}

/* The game's iframe fills the scene's spot */
.game-component {
  display: block;
  width: 100%;
  height: 100%;
}

/* While a spot is resized, the game's iframe lets the mouse through to the editor's page, where the resize follows it
   (resize.js); the iframe would keep the mouse's moves and its release for the game's page */
.layout-grid:has(.spot.resizing) .game-component {
  pointer-events: none;
}

/* A locked spot, such as the scene's, stays at its size: its resize handles are hidden (it can't be dragged either,
   spot.js) */
.spot.locked > .resize-handle {
  display: none;
}

/* A collapsible title bar, such as the scene's: it lies over the top of the spot's content, so the content keeps its
   size, and is slid up out of sight but for a strip at the spot's top edge, the layout's --title-strip. It slides down
   while the mouse is on it, or a key's focus is on one of its buttons. */
.spot.collapsible-title > header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  transform: translateY(calc(-100% + var(--title-strip, 6px)));
}

.spot.collapsible-title > header:hover,
.spot.collapsible-title > header:has(:focus-visible) {
  transform: none;
}

/* Resize handles on every edge and corner of a spot (the spot template, index.html), on top of its content so they
   take the click before a drag starts: 8px along an edge, and 12px square at a corner, over the ends of its two
   edges' handles, as it comes after them in the template. None is drawn: the cursor shows the resize over each
   (resize.js). */
.resize-handle {
  position: absolute;
  pointer-events: auto;
  z-index: 30;
}

.resize-top {
  top: 0;
  left: 0;
  width: 100%;
  height: 8px;
  cursor: n-resize;
}

.resize-right {
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: e-resize;
}

.resize-bottom {
  bottom: 0;
  left: 0;
  height: 8px;
  width: 100%;
  cursor: s-resize;
}

.resize-left {
  top: 0;
  left: 0;
  width: 8px;
  height: 100%;
  cursor: w-resize;
}

.resize-top-left {
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  cursor: nw-resize;
}

.resize-top-right {
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  cursor: ne-resize;
}

.resize-bottom-left {
  bottom: 0;
  left: 0;
  width: 12px;
  height: 12px;
  cursor: sw-resize;
}

.resize-bottom-right {
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  cursor: se-resize;
}

/* A spot being resized stays on top and follows the mouse without sliding */
.spot.resizing {
  z-index: 20;
  transition: none;
}

/* Where a dragged spot would land */
.drop-indicator {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}
