/* DexArcana Map hall — battle editor chrome restored from the live MapLibre editor.
   Tokens from theme.css. Editor controls scoped so the shared site header stays house chrome. */

html[data-theme="arcana"] {
  --bg: var(--da-bg);
  --panel: var(--da-bg-elevated);
  --chrome: var(--da-surface);
  --chrome-top: var(--da-metal-blue-lo);
  --border: var(--da-metal-blue-lo);
  --border-bright: var(--da-metal-blue);
  --text: var(--da-ink);
  --muted: var(--da-mute);
  --accent: var(--da-metal-orange);
  --accent-dim: var(--da-metal-orange-lo);
  --accent-glow: color-mix(in srgb, var(--da-metal-orange) 35%, transparent);
  --steel: var(--da-metal-blue);
  --steel-bright: var(--da-metal-blue-hi);
  --danger: var(--da-danger);
  --ok: var(--da-ok);
  --btn: var(--da-surface);
  --btn-hover: var(--da-metal-blue-lo);
  --active: var(--da-metal-blue-lo);
  --metal: linear-gradient(180deg, var(--da-metal-blue-lo) 0%, var(--da-bg-elevated) 45%, var(--da-surface) 100%);
  --metal-bar: linear-gradient(180deg, var(--da-surface) 0%, var(--da-bg-elevated) 100%);
  --ink-soft: var(--da-ink-soft);
  --focus: var(--da-focus-ring);
}

html {
  height: 100%;
}

body.map-hall {
  margin: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--da-bg);
}

body.map-hall .site-header {
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
  margin: 0;
}

#editor-view[hidden] {
  display: none !important;
}

#editor-view {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  grid-template-rows: auto minmax(240px, 1fr) auto;
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 240px;
  overflow: hidden;
  height: calc(100vh - var(--da-header-h));
  height: calc(100dvh - var(--da-header-h));
}

#editor-view button,
#editor-view input,
#editor-view select {
  font: 13px/1.4 "Segoe UI", var(--da-font-body), system-ui, sans-serif;
  color: inherit;
}

#editor-view button:focus-visible,
#editor-view input:focus-visible,
#editor-view select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#editor-view button {
  background: var(--metal);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-weight: 600;
}

#editor-view button:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: var(--steel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px var(--accent-glow);
}

#editor-view button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#editor-view button.tool.active,
#editor-view button.layer-active-btn.active,
#editor-view button.toggle[aria-pressed="true"],
#editor-view button.chip.active {
  background: linear-gradient(180deg, var(--da-metal-blue), var(--active));
  border-color: var(--accent);
  color: #fff4ec;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 8px var(--accent-glow);
}

#editor-view button.primary {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--da-metal-orange-hi), var(--da-metal-orange));
  color: #1a0e06;
  font-weight: 650;
}

#editor-view button.primary:hover:not(:disabled) {
  border-color: var(--da-metal-orange-hi);
  box-shadow: 0 0 12px var(--accent-glow);
}

#editor-view button.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 0.35rem 0.5rem;
  box-shadow: none;
}

#editor-view button.quiet:hover:not(:disabled) {
  background: var(--btn);
  border-color: var(--border);
  color: var(--text);
}

#editor-view .chrome-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  background: var(--metal-bar);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--da-metal-orange) 18%, transparent);
}

#editor-view .brand {
  font-weight: 650;
  letter-spacing: 0;
  color: var(--accent);
  text-transform: none;
  font-size: 0.82rem;
  white-space: nowrap;
  text-shadow: 0 0 12px var(--accent-glow);
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
}

#editor-view .brand .wm-cap {
  font-size: 1.42em;
  font-weight: 700;
}

#editor-view .brand .wm-rest {
  font-size: 0.76em;
  font-weight: 600;
  letter-spacing: 0.03em;
}

#editor-view .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  flex: 1;
}

#editor-view .sep {
  width: 1px;
  height: 1.4rem;
  background: var(--border);
  margin: 0 0.25rem;
}

#editor-view .zoom-readout {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 4.5rem;
  text-align: right;
}

#editor-view .side-panel {
  grid-column: 1;
  grid-row: 2;
  background: linear-gradient(180deg, var(--da-surface), var(--panel));
  border-right: 1px solid var(--border);
  overflow: auto;
  padding: 0.5rem 0.65rem 1rem;
  min-height: 0;
}

#editor-view .panel-block {
  margin-bottom: 1.1rem;
}

#editor-view .panel-block h2 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--steel-bright);
  font-weight: 600;
}

#editor-view .layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#editor-view .layer-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

#editor-view .layer-active-btn {
  flex: 1;
  text-align: left;
}

#editor-view .vis {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

#editor-view .vis input {
  width: auto;
}

#editor-view .field-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.55rem;
}

#editor-view .field-row label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

#editor-view .field-row input[type="number"],
#editor-view .field-row input[type="text"],
#editor-view .field-row input[type="range"],
#editor-view .field-row select,
#editor-view .field-row input[type="color"],
#editor-view .field-row input[type="file"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
}

#editor-view .field-row input[type="color"] {
  height: 2rem;
  padding: 0.15rem;
}

#editor-view #map-wrap {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  min-width: 0;
  min-height: 240px;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

#editor-view #map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 240px;
  background: #080c12;
}

#editor-view #map .maplibregl-map,
#editor-view #map .maplibregl-canvas-container,
#editor-view #map canvas.maplibregl-canvas {
  width: 100% !important;
  height: 100% !important;
}

#editor-view #map img {
  max-width: none;
}

#editor-view .stamp-tray {
  min-height: 4rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  max-height: 36vh;
  overflow: auto;
}

#editor-view .texture-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}

#editor-view .texture-cats button {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  text-transform: capitalize;
}

#editor-view .empty-hint {
  margin: 0.4rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

#editor-view .stamp-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin-bottom: 0.35rem;
  text-align: left;
  padding: 0.3rem 0.45rem;
}

#editor-view .stamp-item.selected {
  outline: 1px solid var(--accent);
  background: var(--active);
  box-shadow: 0 0 6px var(--accent-glow);
}

#editor-view .stamp-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: #0a1018;
  border-radius: 3px;
  border: 1px solid var(--border);
}

#editor-view .stamp-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editor-view .stamp-item .kind {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: auto;
  flex-shrink: 0;
}

#editor-view .status-bar {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem 0.75rem;
  background: var(--chrome);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

#editor-view .status-bar #status.error {
  color: var(--danger);
}

#editor-view .maplibregl-ctrl-group {
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
}

#editor-view .maplibregl-ctrl-group button {
  background-color: var(--btn) !important;
}

#editor-view .stamp-marker {
  width: 48px;
  height: 48px;
  cursor: grab;
  user-select: none;
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
}

#editor-view .stamp-art {
  width: 100%;
  height: 100%;
  transform-origin: center center;
  pointer-events: none;
}

#editor-view .stamp-marker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

#editor-view .stamp-marker.selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
  box-shadow: 0 0 10px var(--accent-glow);
}

#editor-view .stamp-marker.dragging {
  cursor: grabbing;
  opacity: 0.9;
}

#editor-view .stamp-handle {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: var(--da-metal-orange-hi);
  border: 1px solid var(--accent-dim);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  z-index: 2;
  pointer-events: auto;
}

#editor-view .stamp-handle-nw {
  left: -5px;
  top: -5px;
  cursor: nwse-resize;
}

#editor-view .stamp-handle-ne {
  right: -5px;
  top: -5px;
  cursor: nesw-resize;
}

#editor-view .stamp-handle-sw {
  left: -5px;
  bottom: -5px;
  cursor: nesw-resize;
}

#editor-view .stamp-handle-se {
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}

#editor-view .stamp-marker:not(.selected) .stamp-handle {
  display: none;
}

#editor-view #selection-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#editor-view .stamp-rotate-btn {
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--text);
}

#editor-view .coming-soon-banner {
  margin: 0.5rem 0;
  padding: 0.5rem 0.65rem;
  background: color-mix(in srgb, var(--da-metal-orange) 15%, transparent);
  border: 1px solid var(--da-metal-orange-lo);
  border-radius: 6px;
  color: var(--da-metal-orange-hi);
  font-size: 0.82rem;
}

#editor-view button.chip {
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  background: var(--da-surface);
  border-color: var(--border);
  color: var(--ink-soft);
  text-transform: capitalize;
}

body.tool-paint #map,
body.tool-erase #map {
  cursor: crosshair;
}

body.tool-stamp #map {
  cursor: copy;
}

body.tool-wall #map {
  cursor: crosshair;
}

body.tool-select #map {
  cursor: default;
}

body.tool-pan #map {
  cursor: grab;
}

@media (max-width: 820px) {
  #editor-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(240px, 1fr) auto;
  }

  #editor-view .side-panel {
    grid-column: 1;
    grid-row: 2;
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  #editor-view #map-wrap {
    grid-column: 1;
    grid-row: 3;
  }

  #editor-view .status-bar {
    grid-row: 4;
  }
}
