/* embed.css — panel de controles integrado en el modal del catálogo (SOLO staging).
   Se carga DESPUÉS del CSS del shell, así que gana por orden en empates de especificidad.
   Dos trabajos: (1) compactar el header del modal — fuera título y categoría, todo en una
   fila — y (2) el drawer de ajustes: bottom-sheet en móvil, columna derecha en escritorio. */

/* ---------- 1 · header compacto ---------- */

/* El nombre del componente solo le sirve al admin (allí se conserva); la categoría ya
   filtra en la rejilla. En el modal solo queda el "?" con la descripción. */
.modal-title h2,
#modal-cat {
  display: none;
}

@media (max-width: 860px) {
  /* una sola fila: [?] [prompt────────] [ajustes] [↗] [✕] */
  .modal-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }
  .modal-title {
    padding-right: 0;
    flex-wrap: nowrap;
  }
  .modal-actions {
    margin-top: 0;
    flex: 1;
    min-width: 0;
  }
  .modal-actions .btn-prompt {
    min-width: 0;
    overflow: hidden;
  }
  #modal-close {
    position: static;
    width: 34px;
    height: 34px;
    flex: none;
  }
}

/* ---------- 2 · drawer de ajustes ---------- */

.modal-frame {
  position: relative;
}

/* .btn del shell impone display:inline-flex, que le gana al atributo [hidden] del UA */
#mpk-btn[hidden] {
  display: none;
}
#mpk-btn.on {
  background: var(--fg-strong, #000);
  color: #fff;
}
@media (max-width: 860px) {
  /* la regla móvil del shell mete padding 8px 14px a todo .btn de la fila y aplastaría el icono */
  #mpk-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    flex: none;
  }
}

.mpk {
  position: absolute;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: #fff;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.35s;
  visibility: hidden;
}
.mpk.open {
  visibility: visible;
}

/* escritorio: columna derecha que se desliza sobre el lienzo */
.mpk {
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.08);
  transform: translateX(105%);
}
.mpk.open {
  transform: translateX(0);
}

/* móvil: bottom-sheet sobre el lienzo */
@media (max-width: 860px) {
  .mpk {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62%;
    border-left: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(105%);
  }
  .mpk.open {
    transform: translateY(0);
  }
}

/* barra del drawer: título + restablecer + cerrar en UNA fila de 40px */
.mpk-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex: none;
}
.mpk-bar b {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: auto;
}
.mpk-ico {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted, #858585);
  transition: background 0.15s, color 0.15s;
}
.mpk-ico:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--fg-strong, #000);
}
.mpk-ico svg {
  width: 15px;
  height: 15px;
  display: block;
}
@keyframes mpk-spin {
  to { transform: rotate(-360deg); }
}
.mpk-ico.spin svg {
  animation: mpk-spin 0.5s ease;
}
/* en escritorio el panel sale por la derecha → el chevron de cerrar apunta a la derecha */
@media (min-width: 861px) {
  #mpk-close svg {
    transform: rotate(-90deg);
  }
}

.mpk-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 14px calc(14px + env(safe-area-inset-bottom));
}

.mpk-group {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b3b3b3;
  margin: 14px 2px 8px;
}

/* ---------- filas de control: pastillas de una sola fila ---------- */

/* Cada knob es UNA pastilla de 38px con la etiqueta dentro (mitad de alto que
   etiqueta + control en filas separadas). */
.k {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  margin: 6px 0;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.045);
  font-size: 12.5px;
}
.k-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #202020;
}
.k-val {
  font-size: 12px;
  color: #6f6f6f;
  font-variant-numeric: tabular-nums;
}

/* punto de "modificado": tocarlo revierte SOLO ese knob */
.k-dot {
  width: 16px;
  height: 16px;
  flex: none;
  display: grid;
  place-items: center;
  visibility: hidden;
}
.k-dot::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e0489a;
}
.k.changed .k-dot {
  visibility: visible;
}

/* deslizador: la pastilla entera es la pista; relleno por gradiente + asa fina */
.k-range {
  padding-right: 12px;
}
.k-range .k-fill {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  pointer-events: none;
}
.k-range .k-thumb {
  position: absolute;
  top: 50%;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: #7a7a7a;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: background 0.15s;
}
.k-range:active .k-thumb {
  background: #000;
}
.k-range input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  -webkit-appearance: none;
  touch-action: pan-y;
}
.k-range .k-label,
.k-range .k-val,
.k-range .k-dot {
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.k-range .k-dot {
  pointer-events: auto;
}

/* color: hex editable + círculo */
.k-swatch {
  position: relative;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.k-swatch input[type="color"] {
  position: absolute;
  inset: -8px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.k-hex {
  width: 70px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: #6f6f6f;
  text-align: right;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  border-radius: 6px;
  padding: 2px 4px;
}
.k-hex:focus {
  background: #fff;
  color: #202020;
  outline: none;
}

/* desplegable, sin cromo del sistema */
.k-select {
  appearance: none;
  max-width: 55%;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: #6f6f6f;
  text-align: right;
  cursor: pointer;
  padding: 2px 16px 2px 6px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 7px center, right 3px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

/* interruptor */
.k-toggle {
  width: 32px;
  height: 19px;
  flex: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  position: relative;
  transition: background 0.15s;
}
.k-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}
.k-toggle.on {
  background: #000;
}
.k-toggle.on::after {
  transform: translateX(13px);
}

.mpk-empty {
  color: #858585;
  font-size: 12.5px;
  padding: 18px 2px;
}

@media (prefers-reduced-motion: reduce) {
  .mpk,
  .mpk-ico.spin svg {
    transition: none;
    animation: none;
  }
}
