/*
 * The Mandarax Web Game Editor's default layout: the editor's look, loaded after base.css. A layout or theme of your
 * own replaces this file.
 */

:root {
  --primary-color: #333333;
  --spot-background: #f1f5f9; /* Every panel's color, a light slate; the scene's spot has none (below) */
  --border-color: #666666;
  --border-width: 1px;
  --border-radius: 6px;
  --grid-gap: 0px; /* No gap between spots */
  --spot-padding: 0.75rem; /* The sides of a collapsible title bar (the scene's), by screen size below */
  --title-strip: 6px; /* What stays in view of a collapsible title bar while it is slid up */
}

/* The page is borderless: the grid area fills the window */
body {
  font-family: system-ui, -apple-system, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* The grid area */
.layout-grid {
  flex: 1;
}

/* Spots, with no padding: a panel's title bar and content start at its border, so a panel one row tall holds its title
   bar */
.spot {
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--spot-background);
  cursor: grab;
  transition: left 0.2s ease, top 0.2s ease, width 0.2s ease, height 0.2s ease;
}

/* A panel's title bar: its title, then its buttons, with 12px of room at each side (0.75rem), the size of a corner's
   resize handle (base.css), so the title and the buttons are clear of the handles along the sides */
.spot header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  padding: 0 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border-color);
}

/* A title too long for its panel ends in an ellipsis, so the buttons stay in view */
.spot-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A panel's buttons at the right of its title bar, all alike: its layer buttons (bring forward, send back), its
   minimize button and its close button */
.layer-button,
.minimize-button,
.close-button {
  flex-shrink: 0;
  padding: 0 0.3rem;
  font-size: 0.65rem;
  line-height: 1.4;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
}

.spot header > button:first-of-type {
  margin-left: auto;
}

/* A panel's content, with 12px of room at its sides and its bottom (0.75rem), as its title bar has at its sides, so
   all of it is clear of the resize handles along its edges and at its corners (base.css): the triangles in the
   Project panel's tree, the buttons at its edges and its scrollbars among it. The room is a margin, outside the
   content's box, so the size a spot tells its component (spot.js) is the room the component has, its width the
   spot's less the room. The scene's spot, which has no handles, has none. */
.spot:not(.scene-spot) > .component-container {
  width: auto;
  margin: 0 0.75rem 0.75rem;
}

/* A locked spot can't be dragged, so it shows no grab cursor */
.spot.locked {
  cursor: default;
}

/* The scene's spot fills its layer, with no border or color of its own: the page shows through it until a game
   loads */
.spot.scene-spot {
  border: none;
  border-radius: 0;
  background-color: transparent;
}

/* A collapsible title bar (the scene's), over the top of the spot's content: on the spot's own color, sliding up and
   down */
.spot.collapsible-title > header {
  margin-bottom: 0;
  padding: 0.25rem var(--spot-padding);
  background-color: inherit;
  transition: transform 0.2s ease;
}

/* The scene's title bar, see-through like the scene, has no line under it, so nothing is drawn across the game but
   its title and its buttons, white so they stand out on the game and on the page before a game loads */
.spot.scene-spot > header {
  border-bottom: none;
}

.spot.scene-spot .layer-button,
.spot.scene-spot .minimize-button,
.spot.scene-spot .close-button {
  background-color: #ffffff;
}

/* A minimized panel: its 16px icon in the middle of its one cell, on the panel color with the panel border, the
   scene's too. A click on it restores it (main.js). */
.spot.minimized {
  justify-content: center;
  align-items: center;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--spot-background);
  cursor: pointer;
}

.spot.minimized > .spot-icon,
.spot.minimized > .spot-icon svg {
  width: 16px;
  height: 16px;
}

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

/* The game's iframe in the scene, with no border */
.game-component {
  border: none;
}

/* The Project panel: its buttons, side by side and wrapping in a narrow panel, the folder's name, then its game's
   scenes as a tree, each scene's name in bold opening to where it leads, its functions and its properties, indented
   under it, an object or list among them opening in turn; then Assets, in bold like a scene, opening to the game's
   assets, one to a line, indented under it; then Add scene, in bold too, opening to a new scene's name and its
   buttons, laid out as New project's question, and what was written, wrapping */
.project-buttons {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.5rem;
}

.project-open,
.project-new {
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
}

.project-name,
.project-tree,
.project-assets,
.project-add-scene,
.project-add-asset {
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: nowrap;
}

.project-name,
.project-scene > details > summary,
.project-assets > summary,
.project-add-scene > summary,
.project-add-asset > summary {
  font-weight: bold;
}

.project-tree summary,
.project-assets > summary,
.project-add-scene > summary,
.project-add-asset > summary {
  cursor: pointer;
}

.project-add-scene-prompt,
.project-add-asset-prompt {
  padding-left: 1rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.scene-on-screen {
  font-weight: normal;
  font-style: italic;
}

.project-tree,
.project-tree ul,
.asset-list {
  list-style: none;
}

.project-tree ul,
.scene-functions,
.asset-list {
  padding-left: 1rem;
}

/* A scene's functions wrap, all in view */
.scene-functions {
  white-space: normal;
}

/* Where a scene leads, first under its name: "Leads to", then each scene it leads to, its name a button that brings
   the tree to that scene, and under it each way there, all wrapping, as a way's conditions are long. The scene the tree
   was brought to is outlined until it is brought to another, the outline inside its name's line, as the line runs to
   the panel's edges, which would cut off an outline around it. */
.scene-links {
  padding-left: 1rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.scene-links-title {
  font-style: italic;
}

.project-tree .scene-links-list {
  padding-left: 0;
}

.project-tree .scene-link-ways {
  padding-left: 0.75rem;
}

.scene-link {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: bold;
  text-decoration: underline dotted;
  cursor: pointer;
}

.scene-link:hover {
  text-decoration-style: solid;
}

/* A scene's layers, under where it leads: "Layers", then each layer by its name and order, and under it the objects on
   it, each line opening to where its objects were made, wrapping, as a scene's functions do, then how its code writes
   each value, then "Holds" and the objects they hold */
.scene-layers {
  padding-left: 1rem;
}

.scene-layers-title,
.scene-object-held {
  font-style: italic;
}

.project-tree .scene-layer-list {
  padding-left: 0;
}

.scene-object > p {
  padding-left: 1rem;
  white-space: normal;
}

/* The sounds a scene's code plays, under its layers: "Sounds", then each sound and when it plays, and under it its
   options' values and each way it stops, all wrapping, as where a scene leads does */
.scene-sounds {
  padding-left: 1rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.scene-sounds-title {
  font-style: italic;
}

.project-tree .scene-sound-list {
  padding-left: 0;
}

.project-tree details.is-focused > summary {
  outline: 1px solid var(--primary-color);
  outline-offset: -1px;
  border-radius: 3px;
}

/* A value that can be edited now (while paused), underlined under the mouse, and its input while edited */
.project-tree.is-editable .scene-property-value[data-key] {
  cursor: text;
}

.project-tree.is-editable .scene-property-value[data-key]:hover {
  text-decoration: underline dotted;
}

.scene-property-input {
  font: inherit;
  padding: 0 2px;
}

/* The questions under a folder's name: a folder without a mandaraxConfig.json asks for one, with its Yes and No, and a
   new project asks for its first scene's name, with Make project */
.project-config-prompt,
.project-new-prompt {
  font-size: 0.85rem;
  line-height: 1.5;
}

.project-config-prompt p,
.project-new-prompt p,
.project-add-scene-prompt p,
.project-add-asset-prompt p {
  margin-bottom: 0.5rem;
}

.project-config-prompt button,
.project-new-prompt button,
.project-add-scene-prompt button,
.project-add-asset-prompt button {
  margin-right: 0.5rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
}

/* Add scene's two buttons, and Add asset's, wrap under each other in a narrow panel, with room between their rows */
.project-add-scene-prompt button,
.project-add-asset-prompt button {
  margin-bottom: 0.5rem;
}

.project-new-prompt input,
.project-add-scene-prompt input,
.project-add-asset-prompt input {
  max-width: 100%;
  margin: 0 0.5rem 0.5rem 0;
  font: inherit;
  padding: 0 2px;
}

/* The Engine config panel: the file's name and Save, what the panel has to say, then the options, one per row, each
   object of options under its name and indented; true-or-false options side by side */
.engine-config-component {
  font-size: 0.85rem;
  line-height: 1.5;
}

.engine-config-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.engine-config-file {
  font-weight: bold;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.engine-config-save {
  margin-left: auto;
  padding: 0.1rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
}

.engine-config-save:disabled {
  cursor: default;
}

.engine-config-status {
  margin: 0.25rem 0;
  color: #444444;
}

.engine-config-status:empty {
  display: none;
}

.engine-config-option {
  display: grid;
  grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr);
  align-items: center;
  column-gap: 0.4rem;
  margin: 0.1rem 0;
}

.engine-config-option[data-kind="checkbox"] {
  display: inline-flex;
  gap: 0.2rem;
  margin-right: 0.6rem;
}

/* The name's background is the mark of a missing or needed option, as wide as the name */
.engine-config-name {
  justify-self: start;
  padding: 0 0.2rem;
  border-radius: 3px;
}

.engine-config-option input:not([type="checkbox"]),
.engine-config-option select {
  min-width: 0;
  font: inherit;
  padding: 0 2px;
}

.engine-config-group {
  padding-left: 0.75rem;
}

.engine-config-group-name {
  margin: 0.25rem 0 0 -0.75rem;
  padding: 0 0.2rem;
  font-weight: bold;
}

/* An option the file lacks, shown at the engine's default (yellow); the first scene while the file names none (red);
   a value changed and not saved; a value that is not of its option's kind */
.engine-config-option.is-missing .engine-config-name {
  background-color: #fde68a;
}

.engine-config-option.is-needed .engine-config-name {
  background-color: #fca5a5;
}

.engine-config-option.is-changed .engine-config-name {
  font-style: italic;
}

.engine-config-option.is-changed .engine-config-name::after {
  content: " *";
}

.engine-config-option.is-invalid input,
.engine-config-option.is-invalid select {
  outline: 2px solid #ef4444;
}

/* The Frame panel: the frame's scene and number, then its events, one line each, the event's name in bold */
.frame-component {
  font-size: 0.85rem;
  line-height: 1.5;
}

.frame-events {
  list-style: none;
}

.frame-events li {
  white-space: nowrap;
}

.frame-event-name {
  font-weight: bold;
}

/* The bar showing how far a build of a scene's frames is */
.frame-progress {
  width: 100%;
}

/* The Next update line: the next update's input, its fields side by side, wrapping in a narrow panel */
.frame-next-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  margin: 0.25rem 0;
}

.frame-next-input input,
.frame-next-input button {
  font: inherit;
}

/* A button panel, such as the Controls panel: small buttons, 4px apart and from its edges, each its 16px icon, with
   its word beside it when every button fits with its word. Launch's green and Stop's red are their own (main.js). A
   disabled button keeps the browser's gray, its icon with it. */
.button-panel-component {
  gap: 4px;
  padding: 4px;
}

.button-panel-button {
  gap: 4px;
  min-width: 28px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid #cccccc;
  border-radius: 4px;
  background-color: #f0f0f0;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.button-panel-button:disabled {
  cursor: default;
}

.button-panel-icon,
.button-panel-icon svg {
  display: block;
  width: 16px;
  height: 16px;
}

.button-panel-icon svg {
  fill: currentColor;
}

/* The master panel: a line for each panel, its 16px icon then its name, the whole line a button, its name underlined
   under the mouse */
.master-panel-component {
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.5;
}

.master-panel-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.master-panel-line:hover .master-panel-name {
  text-decoration: underline;
}

.master-panel-icon,
.master-panel-icon svg {
  display: block;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.master-panel-icon svg {
  fill: currentColor;
}

.master-panel-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A closed panel's line, faded */
.master-panel-line.is-closed {
  opacity: 0.5;
}

/* The panel the master panel made the one in use, outlined inside its edge until the keys leave it (main.js
   focusPanel) */
.spot.is-focused {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

/* A spot being resized */
.spot.resizing {
  opacity: 0.8;
  outline: 2px dashed #007bff;
}

/* Drag and drop */
.dragging {
  opacity: 0.6;
  transform: scale(0.95);
  border: 2px dashed #666 !important;
}

.drop-target {
  border: 2px dashed #007bff !important;
  background-color: rgba(0, 123, 255, 0.1);
}

.drop-indicator {
  opacity: 0.6;
  transition: all 0.1s ease;
}

.drop-indicator-valid {
  border: 2px dashed #007bff;
  background-color: rgba(0, 123, 255, 0.1);
}

.drop-indicator-invalid {
  border: 2px dashed #ff0000;
  background-color: rgba(255, 0, 0, 0.1);
}

/* Corner radius, and the sides of a collapsible title bar, by screen size */

/* Mobile Portrait (up to 480px) */
@media only screen and (max-width: 480px) and (orientation: portrait) {
  :root {
    --border-radius: 4px;
    --spot-padding: 0.5rem;
  }
}

/* Tablet (481px-768px) */
@media only screen and (min-width: 481px) and (max-width: 768px) and (orientation: portrait) {
  :root {
    --border-radius: 6px;
  }
}

/* Desktop (1025px-1440px) */
@media only screen and (min-width: 1025px) and (max-width: 1440px) {
  :root {
    --border-radius: 8px;
    --spot-padding: 1rem;
  }
}

/* Large screens (1441px+) */
@media only screen and (min-width: 1441px) {
  :root {
    --border-radius: 10px;
    --spot-padding: 1.25rem;
  }
}
