/* ============================================================
   SC2 bitmap editor + sprite editor (wwwroot/js/sc2Editor.js,
   spriteEditor.js). Uses the retro theme variables.
   ============================================================ */

.gfx-ed {
  --gfx-panel: rgba(0, 18, 51, 0.85);
  --gfx-line: rgba(0, 180, 255, 0.35);
  --gfx-text: var(--retro-text, #f0f8ff);
  --gfx-dim: var(--retro-ice, #a8d8ff);
  --gfx-accent: var(--retro-blue, #00b4ff);

  color: var(--gfx-text);
  font-family: "IBM Plex Sans", "Roboto", system-ui, sans-serif;
  font-size: 0.9rem;
  outline: none;
  user-select: none;
}

.gfx-ed.gfx-drop {
  box-shadow: 0 0 0 2px var(--gfx-accent) inset;
}

/* ----- toolbar ----- */
.gfx-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
  background: var(--gfx-panel);
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
  margin-bottom: 0.5rem;
}

.gfx-group {
  display: flex;
  gap: 2px;
}

.gfx-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.gfx-wrap {
  flex-wrap: wrap;
}

.gfx-btn {
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.55rem;
  background: rgba(0, 40, 85, 0.9);
  color: var(--gfx-text);
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  white-space: nowrap;
}

.gfx-btn:hover:not(:disabled) {
  border-color: var(--gfx-accent);
  box-shadow: 0 0 6px rgba(0, 180, 255, 0.5);
}

.gfx-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.gfx-btn.gfx-active {
  background: var(--gfx-accent);
  color: #001233;
  border-color: var(--gfx-accent);
}

.gfx-btn-accent {
  background: rgba(0, 180, 255, 0.25);
  border-color: var(--gfx-accent);
}

.gfx-btn-small {
  min-width: 1.8rem;
  height: 1.8rem;
  padding: 0 0.4rem;
  font-size: 0.85rem;
}

.gfx-tool {
  font-size: 1.1rem;
}

.gfx-select {
  height: 2.1rem;
  background: rgba(0, 40, 85, 0.9);
  color: var(--gfx-text);
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
  padding: 0 0.3rem;
}

.gfx-check {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--gfx-dim);
}

/* ----- layout (SC2) ----- */
.gfx-main {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.gfx-side {
  flex: 0 0 13.5rem;
  background: var(--gfx-panel);
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
  padding: 0.6rem;
}

.gfx-canvas-wrap {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  max-height: 80vh;
  background: #000;
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
}

.gfx-canvas {
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: none;
}

.gfx-label {
  font-family: "Orbitron", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gfx-dim);
  margin: 0.6rem 0 0.3rem;
}

.gfx-label:first-child {
  margin-top: 0;
}

.gfx-help {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--gfx-dim);
  line-height: 1.35;
}

.gfx-info {
  font-family: "Share Tech Mono", monospace;
  font-size: 0.8rem;
  color: var(--gfx-dim);
  min-height: 1.2rem;
}

/* ----- palette ----- */
.gfx-palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.gfx-palette-small {
  grid-template-columns: repeat(8, 1.6rem);
}

.gfx-swatch {
  aspect-ratio: 1;
  min-height: 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
  position: relative;
}

.gfx-swatch.gfx-sel-primary {
  outline: 2px solid #ffffff;
  outline-offset: 1px;
}

.gfx-swatch.gfx-sel-secondary::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px dashed #ffffff;
  mix-blend-mode: difference;
}

.gfx-swatch.gfx-off {
  opacity: 0.2;
}

.gfx-checker {
  background-color: #888 !important;
  background-image:
    linear-gradient(45deg, #555 25%, transparent 25%, transparent 75%, #555 75%),
    linear-gradient(45deg, #555 25%, transparent 25%, transparent 75%, #555 75%) !important;
  background-size: 8px 8px !important;
  background-position: 0 0, 4px 4px !important;
}

.gfx-chips {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.gfx-chip-stack {
  position: relative;
  width: 3.2rem;
  height: 2.6rem;
}

.gfx-chip {
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 1.6rem;
  border: 2px solid #ffffff;
  border-radius: 2px;
  box-shadow: 0 0 0 1px #000;
}

.gfx-chip.gfx-chip-back {
  left: 1.1rem;
  top: 0.9rem;
}

.gfx-chip.gfx-chip-small {
  position: static;
  width: 1rem;
  height: 1rem;
  border-width: 1px;
  flex: 0 0 auto;
}

.gfx-zoom-label {
  min-width: 2rem;
  text-align: center;
  font-family: "Share Tech Mono", monospace;
}

/* ----- modal (image import) ----- */
.gfx-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 8, 20, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.gfx-modal {
  background: #001233;
  border: 1px solid var(--retro-blue, #00b4ff);
  box-shadow: 0 0 24px rgba(0, 180, 255, 0.35);
  border-radius: 2px;
  color: var(--retro-text, #f0f8ff);
  font-family: "IBM Plex Sans", "Roboto", system-ui, sans-serif;
  font-size: 0.9rem;
  max-width: 1200px;
  width: 100%;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
}

.gfx-modal .gfx-btn,
.gfx-modal .gfx-select {
  background: rgba(0, 40, 85, 0.9);
  color: var(--retro-text, #f0f8ff);
  border: 1px solid rgba(0, 180, 255, 0.35);
}

.gfx-modal .gfx-btn-accent {
  background: rgba(0, 180, 255, 0.25);
  border-color: var(--retro-blue, #00b4ff);
}

.gfx-modal .gfx-label {
  color: var(--retro-ice, #a8d8ff);
}

.gfx-modal-title {
  font-family: "Orbitron", monospace;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0, 180, 255, 0.35);
}

.gfx-import-body {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  overflow: auto;
}

.gfx-import-previews {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
}

.gfx-import-canvas {
  display: block;
  width: 100%;
  max-width: 512px;
  aspect-ratio: 4 / 3;
  image-rendering: pixelated;
  background: #000;
  border: 1px solid rgba(0, 180, 255, 0.35);
}

.gfx-import-controls {
  flex: 0 0 20rem;
}

.gfx-field {
  display: grid;
  grid-template-columns: 6rem 1fr 3rem;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.gfx-field > span:first-child {
  color: var(--retro-ice, #a8d8ff);
}

.gfx-field select,
.gfx-field input[type=file] {
  grid-column: 2 / 4;
  min-width: 0;
}

.gfx-field input[type=checkbox] {
  justify-self: start;
}

.gfx-slider-val {
  font-family: "Share Tech Mono", monospace;
  font-size: 0.8rem;
  text-align: right;
}

.gfx-modal-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(0, 180, 255, 0.35);
}

.gfx-import-status {
  margin-right: auto;
  color: var(--retro-ice, #a8d8ff);
  font-family: "Share Tech Mono", monospace;
}

/* ----- sprite editor ----- */
.spr-main {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.spr-col {
  background: var(--gfx-panel);
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
  padding: 0.6rem;
}

.spr-frames-col {
  flex: 0 0 8.5rem;
}

.spr-frames {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 60vh;
  overflow-y: auto;
}

.spr-frame {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 3px;
  background: #0b0f1a;
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
  color: var(--gfx-dim);
  cursor: pointer;
}

.spr-frame canvas {
  image-rendering: pixelated;
  background: #000;
  width: 48px;
  height: 48px;
}

.spr-frame.gfx-active {
  border-color: var(--gfx-accent);
  box-shadow: 0 0 6px rgba(0, 180, 255, 0.5);
  color: var(--gfx-text);
}

.spr-center {
  flex: 0 0 auto;
}

.spr-canvas {
  max-width: 100%;
}

.spr-status {
  margin-top: 0.4rem;
}

.spr-right {
  flex: 1 1 14rem;
  min-width: 14rem;
}

.spr-layers {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.spr-layer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 3px 4px;
  border: 1px solid var(--gfx-line);
  border-radius: 2px;
  cursor: pointer;
}

.spr-layer.gfx-active {
  border-color: var(--gfx-accent);
  background: rgba(0, 180, 255, 0.15);
}

.spr-layer-name {
  flex: 1 1 auto;
  font-size: 0.82rem;
}

.spr-preview,
.spr-player {
  display: block;
  image-rendering: pixelated;
  border: 1px solid var(--gfx-line);
  margin-bottom: 0.35rem;
}

/* ----- gallery / list thumbnails ----- */
.gfx-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  image-rendering: pixelated;
  background: #000;
  border: 1px solid rgba(0, 180, 255, 0.3);
}

.gfx-thumb-sprite {
  aspect-ratio: 1;
  background-color: #0b0f1a;
  background-image:
    linear-gradient(45deg, #131a2b 25%, transparent 25%, transparent 75%, #131a2b 75%),
    linear-gradient(45deg, #131a2b 25%, transparent 25%, transparent 75%, #131a2b 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  padding: 12%;
}

.gfx-code {
  width: 100%;
  min-height: 18rem;
  max-height: 32rem;
  font-family: "Share Tech Mono", "Courier New", monospace;
  font-size: 0.8rem;
  background: #000814;
  color: #a8d8ff;
  border: 1px solid rgba(0, 180, 255, 0.35);
  padding: 0.5rem;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}

/* Narrow screens: stack the panels. */
@media (max-width: 900px) {

  .gfx-main,
  .spr-main,
  .gfx-import-body {
    flex-direction: column;
  }

  .gfx-side,
  .spr-frames-col,
  .spr-right,
  .gfx-import-controls {
    flex: 1 1 auto;
    width: 100%;
  }

  .spr-frames {
    flex-direction: row;
    overflow-x: auto;
  }
}

/* Padding inside the gallery tab panels (MudTabs has no panel class parameter in v9). */
.gfx-gallery-tabs .mud-tabs-panels {
  padding: 16px;
}
