/* editor/editor.css — estilos específicos del editor */

body {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  flex-wrap: wrap;
}
.toolbar .brand {
  font-weight: 700;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.toolbar .brand .mascot {
  width: 24px;
  height: 24px;
}
.toolbar .spacer { flex: 1; }
.toolbar .file-name {
  font-size: 0.85rem;
  opacity: 0.7;
}

.tabs {
  display: flex;
  gap: 0.5rem;
}
.tab {
  background: transparent;
  border: 1.5px solid transparent;
  border-bottom: 1.5px solid var(--ink);
  padding: 0.3em 0.8em;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.85rem;
  text-transform: lowercase;
}
.tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Focus visible: outline ámbar consistente en todo el editor.
 * Solo afecta navegación por teclado (no por mouse) gracias a :focus-visible. */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
button:focus-visible { outline-offset: 1px; }
.tab:focus-visible { outline-offset: -3px; }
.list-item:focus-visible,
.frame:focus-visible,
.color-swatch:focus-visible {
  outline-offset: 1px;
}
.room-cell:focus-visible { outline-offset: -2px; z-index: 1; }

.workspace {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 0;
  overflow: hidden;
}
.panel {
  overflow: auto;
  padding: 1rem;
  border-right: 1px solid var(--ink);
}
.panel:last-child { border-right: none; }
.panel.center {
  background: var(--paper-2);
  display: grid;
  place-items: center;
}

.panel h2 { margin-bottom: 0.5rem; }
.panel h3 { margin-top: 1rem; margin-bottom: 0.4rem; }

.list {
  display: grid;
  gap: 2px;
  margin-bottom: 1rem;
}
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35em 0.5em;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
}
.list-item:hover { background: var(--paper-2); }
.list-item.active {
  border-color: var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--amber);
}
.list-item .preview {
  width: 24px; height: 24px;
  background: var(--ink);
  image-rendering: pixelated;
}

.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

/* Pixel paint editor */
.paint {
  display: grid;
  gap: 0.5rem;
  width: 100%;
}
.paint canvas {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border: 2px solid var(--ink);
  cursor: crosshair;
  touch-action: none;
}
.paint .frames {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.paint .frame {
  width: 40px; height: 40px;
  border: 1.5px solid var(--ink);
  image-rendering: pixelated;
  cursor: pointer;
}
.paint .frame.active {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.tool-indicator {
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.3rem;
  text-align: center;
}

.color-row {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 0.4rem;
}

/* Sprite editor: selector de paleta para preview (no muta el sprite) */
.preview-palette {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  align-items: center;
  margin-top: 0.6rem;
  padding: 0.4rem 0;
  border-top: 1px dashed var(--ink-soft);
}
.preview-palette .label {
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.65rem;
}
.palette-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2em 0.4em;
  border: 1.5px solid transparent;
  background: var(--paper);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.7rem;
}
.palette-btn:hover { border-color: var(--ink-soft); }
.palette-btn.active {
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--amber);
  background: var(--paper);
}
.palette-mini {
  display: flex;
  border: 1px solid var(--ink-soft);
}
.palette-mini-color {
  width: 8px; height: 14px;
}
.palette-name {
  font-size: 0.72rem;
}
.color-swatch {
  width: 28px; height: 28px;
  border: 1.5px solid var(--ink);
  cursor: pointer;
  position: relative;
}
.color-swatch.active::after {
  content: "▮";
  position: absolute; bottom: -2px; left: 50%;
  transform: translate(-50%, 0);
  color: var(--amber);
  font-size: 0.6rem;
  text-shadow: 0 0 2px var(--ink);
}

/* Room editor (grid) */
.room-grid {
  display: grid;
  gap: 0;
  border: 2px solid var(--ink);
  background: var(--ink);
  width: min(80vh, 100%);
  aspect-ratio: 1;
  user-select: none;
  touch-action: none;
}
.room-cell {
  background: var(--paper);
  cursor: pointer;
  position: relative;
}
.room-cell canvas {
  width: 100%; height: 100%;
  image-rendering: pixelated;
}
.room-cell.avatar-here::after {
  content: "@";
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  color: var(--amber);
  font-size: 0.8rem;
  pointer-events: none;
}

/* Field rows */
.field {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.6rem;
}
.field label {
  font-size: 0.7rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.field input, .field select, .field textarea {
  width: 100%;
}
.field textarea {
  font-size: 0.8rem;
  min-height: 80px;
  resize: vertical;
}

/* Toggle buttons */
.toggle {
  display: inline-flex; gap: 4px;
}
.toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* Empty state */
.empty {
  opacity: 0.5;
  font-style: italic;
  text-align: center;
  padding: 2rem 0;
  font-size: 0.85rem;
}

/* Empty con CTA: en vez de un mensaje pasivo, invita a una acción concreta. */
.empty-cta {
  display: grid;
  place-items: center;
  gap: 0.8rem;
  padding: 3rem 1rem;
  border: 1.5px dashed var(--ink-soft);
  background: var(--paper);
  margin: 1rem 0;
  text-align: center;
}
.empty-cta p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.7;
}
.empty-cta button {
  font-size: 0.95rem;
  padding: 0.5em 1em;
}

/* Status bar */
.statusbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  padding: 0.3em 1rem;
  font-family: var(--mono);
  display: flex; gap: 0.6rem;
  align-items: baseline;
}
#status-info {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-sep {
  opacity: 0.4;
}
#status-msg {
  opacity: 0.85;
}
#status-dirty:not(:empty) {
  color: var(--amber);
}

/* Responsive — tablet y móvil */
@media (max-width: 900px) {
  body { height: auto; overflow: auto; }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow: visible;
  }
  .panel {
    border-right: none;
    border-bottom: 2px solid var(--ink);
    max-height: none;
    overflow: visible;
    padding: 0.8rem;
  }
  .panel:last-child { border-bottom: none; }
  /* Center primero: paint/grid es lo principal en móvil */
  .panel.center { order: -1; place-items: stretch; }
  .paint { justify-self: center; max-width: 100%; }
  .paint canvas { max-width: 100%; }
  .room-grid { width: min(92vw, 480px); }
  /* tira de tabs scrolleable si caben muchos */
  .tabs { overflow-x: auto; flex-shrink: 0; }
  /* status bar más compacto y NO fixed (rompe scroll en móvil con teclado abierto) */
  .statusbar { position: static; font-size: 0.7rem; padding: 0.3em 0.6rem; }
  body { padding-bottom: 0; }
}

@media (max-width: 480px) {
  .toolbar {
    padding: 0.5rem;
    gap: 0.4rem;
    flex-wrap: wrap;
  }
  .toolbar .file-name { display: none; }
  .toolbar .spacer { display: none; }
  .toolbar button { font-size: 0.75rem; padding: 0.3em 0.5em; }
  .tab { font-size: 0.78rem; padding: 0.25em 0.6em; }
  .panel { padding: 0.6rem; }
  .panel.center { padding: 0.6rem 0.3rem; }
  .paint canvas { width: 100%; max-width: 100%; }
  /* Listas y items más altos para tocar con dedo */
  .list-item { padding: 0.5em 0.6em; min-height: 36px; }
  .frame { width: 48px !important; height: 48px !important; }
  .color-swatch { width: 36px !important; height: 36px !important; }
  /* Brand sin texto largo */
  .toolbar .brand .brand-text { display: none; }
}
