:root {
  --bg: #0b0b0c;
  --ink: #f4f2ee;
  --muted: #8f8b85;
  --accent: #c9a15a;
  --paper: #fbfaf7;
  --paper-text: #262421;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  background: linear-gradient(to bottom, rgba(11,11,12,0.92), rgba(11,11,12,0));
  pointer-events: none;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.03em;
  pointer-events: auto;
  color: var(--ink);
}
.brand span { color: var(--accent); margin: 0 7px; }
.hint {
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: auto;
}
@media (max-width: 640px) {
  .hint { display: none; }
}

/* ---------- Viewport / World ---------- */
.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: var(--bg);
}
.viewport.dragging { cursor: grabbing; }

.world {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

/* ---------- Piezas (fotos tipo polaroid, esparcidas) ---------- */
.piece {
  position: absolute;
}

.frame {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #141414;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(0,0,0,0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease, z-index 0s;
}
.frame:hover {
  transform: scale(1.045) !important;
  box-shadow: 0 10px 26px rgba(0,0,0,0.55);
}
.piece:hover { z-index: 5000 !important; }

/* Pieza tomada para arrastrar: se ilumina el borde y queda sobre todas las demás */
.piece.dragging-piece { cursor: grabbing; }
.piece.dragging-piece .frame {
  transition: none;
  transform: scale(1.06) !important;
  box-shadow:
    0 0 0 3px rgba(255, 214, 140, 0.95),
    0 0 26px 6px rgba(255, 198, 110, 0.6),
    0 16px 36px rgba(0,0,0,0.6);
}

.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.frame .caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px 10px 8px;
  text-align: center;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.frame:hover .caption { opacity: 1; }

/* Piezas "trama" — cuando ya no quedan obras reales, siguen cubriendo
   la superficie (sin dejar huecos negros) pero de forma apagada/neutra. */
.frame-empty {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #17171a, #1f1f22);
  box-shadow: 0 5px 16px rgba(0,0,0,0.4);
  pointer-events: none;
}

/* ---------- Popup / modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}
.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--paper-text);
  border-radius: 4px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.6);
  position: relative;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}
.overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border-radius: 999px;
  border: none;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.modal-close:hover { background: rgba(0,0,0,0.7); }

.modal-art {
  background: #000;
  padding: 22px 22px 0;
}
.modal-art img {
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  background: #000;
}

.modal-body { padding: 22px 28px 30px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }

.modal-body h2 {
  margin: 0 0 8px;
  font-size: 23px;
  line-height: 1.3;
  font-weight: 600;
}

.modal-authorline {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--accent);
  font-style: italic;
}
.modal-dot { margin: 0 8px; color: var(--muted); }

.modal-desc {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.7;
  padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.1);
}
