/* slotInteraction.css
 * Tampilan interaksi slot Container Editor (E1): seret, hantu item, menu
 * slot, dan mode Sebar.
 *
 * Selektor status memakai `.slot-host .slot.slot--…` (spesifisitas 0,3,0)
 * karena tema workbench dimuat SETELAH berkas ini dan menimpa `.slot`,
 * `.slot--filled`, dan `:hover` dengan spesifisitas 0,1,0–0,2,0.
 */

/* ── Host & slot ───────────────────────────────────────────────────────── */
.slot-host {
  position: relative;
  /* Kisi bisa lebih lebar dari layar HP → gulir horizontal di sini,
     bukan seluruh halaman. */
  max-width: 100%;
}

.slot-host .slot {
  -webkit-user-select: none;
  user-select: none;
  /* iOS: jangan munculkan gelembung "Simpan gambar" saat tekan lama. */
  -webkit-touch-callout: none;
}

.slot-host .slot img {
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Tekan lama sedang berjalan / berhasil (HP). */
.slot-host .slot.slot--pressed {
  transform: scale(0.94);
  transition: transform 120ms var(--ease-standard, ease);
}

/* Asal seretan: tampak "kosong sementara" supaya jelas item sedang diangkat. */
.slot-host .slot.slot--lifted > * {
  opacity: 0.28;
}

.slot-host .slot.slot--drop-target {
  border-color: var(--wb-signal, #72c95f);
  background: color-mix(in srgb, var(--wb-signal, #72c95f) 18%, var(--wb-panel-raised, #191d22));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--wb-signal, #72c95f) 55%, transparent);
  z-index: 2;
}

.slot-host .slot.slot--drop-copy {
  border-color: var(--wb-field, #5cc4b4);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--wb-field, #5cc4b4) 60%, transparent);
}

/* Sentuh: slot tujuan diperbesar — jari menutupi slot kecil di HP,
   jadi sorotan harus terlihat di sekeliling jari. */
@media (pointer: coarse) {
  .slot-host .slot.slot--drop-target {
    transform: scale(1.18);
  }
}

body.is-slot-dragging,
body.is-slot-dragging * {
  cursor: grabbing !important;
}

/* ── Hantu item ────────────────────────────────────────────────────────── */
.slot-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  pointer-events: none;
  /* Titik tengah hantu = titik pointer (translate diberikan JS). */
  margin: -22px 0 0 -22px;
  will-change: transform;
}

.slot-ghost__box {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--wb-signal, #72c95f);
  border-radius: var(--radius-sm, 6px);
  background: var(--wb-panel-raised, #191d22);
  box-shadow: 0 10px 24px var(--wb-shadow, rgba(0, 0, 0, 0.45));
  transform: rotate(-4deg);
}

.slot-ghost--touch .slot-ghost__box {
  width: 56px;
  height: 56px;
  margin: -6px 0 0 -6px;
}

.slot-ghost--copy .slot-ghost__box {
  border-color: var(--wb-field, #5cc4b4);
}

.slot-ghost--copy .slot-ghost__box::after {
  content: "+";
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--wb-field, #5cc4b4);
  color: var(--wb-canvas, #0c0e11);
  font: 700 14px/18px var(--font-mono, monospace);
  text-align: center;
}

/* ── Menu slot ─────────────────────────────────────────────────────────── */
.slot-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: transparent;
}

.slot-menu {
  position: fixed;
  z-index: 1101;
  min-width: 220px;
  max-width: 280px;
  padding: 6px;
  border: 1px solid var(--wb-rule, #2a3038);
  border-radius: var(--radius-md, 8px);
  background: var(--wb-panel-raised, #191d22);
  color: var(--wb-ink, #eef0f3);
  box-shadow: 0 16px 34px var(--wb-shadow, rgba(0, 0, 0, 0.45));
  animation: slot-menu-in 120ms var(--ease-standard, ease);
}

@keyframes slot-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.slot-menu__title {
  padding: 6px 10px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--wb-ink-soft, #b3bac3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--wb-rule-soft, #1f242a);
  margin-bottom: 4px;
}

.slot-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.slot-menu__item:hover:not(:disabled),
.slot-menu__item:focus-visible {
  background: color-mix(in srgb, var(--wb-signal, #72c95f) 14%, transparent);
  outline: none;
}

.slot-menu__item:disabled {
  opacity: 0.4;
  cursor: default;
}

.slot-menu__item--danger {
  color: var(--wb-danger, #f08a78);
}

.slot-menu__icon {
  flex: none;
  opacity: 0.85;
}

.slot-menu__label {
  flex: 1;
}

.slot-menu__hint {
  font: 11px var(--font-mono, monospace);
  color: var(--wb-ink-muted, #8d96a1);
  background: none;
  border: 0;
  padding: 0;
}

.slot-menu__sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--wb-rule-soft, #1f242a);
}

/* Layar sempit: panel bawah selebar layar, baris 48px, latar redup. */
@media (max-width: 560px) {
  .slot-menu-backdrop {
    background: rgba(0, 0, 0, 0.45);
  }

  .slot-menu {
    left: 0 !important;
    right: 0;
    top: auto !important;
    bottom: 0;
    min-width: 0;
    max-width: none;
    max-height: 78vh;
    overflow-y: auto;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    animation-name: slot-sheet-in;
    animation-duration: 180ms;
  }

  .slot-menu__title {
    font-size: 13px;
    padding: 8px 8px 10px;
  }

  .slot-menu__item {
    min-height: 48px;
    font-size: 15px;
  }

  /* Pintasan keyboard tidak berarti di HP. */
  .slot-menu__hint {
    display: none;
  }
}

@keyframes slot-sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

/* ── Mode Sebar ────────────────────────────────────────────────────────── */
.spread-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--wb-field, #5cc4b4) 55%, var(--wb-rule, #2a3038));
  border-radius: var(--radius-sm, 6px);
  background: color-mix(in srgb, var(--wb-field, #5cc4b4) 10%, var(--wb-panel, #13161a));
  font-size: 13px;
}

.spread-banner[hidden] {
  display: none;
}

.spread-banner__text {
  flex: 1 1 220px;
}

.spread-banner__btn {
  min-height: 32px;
  padding: 4px 14px;
}

/* touch-action dipasang SEBELUM sentuhan dimulai → sapuan tidak menggulir. */
.slot-host.slot-host--spreading {
  touch-action: none;
}

.slot-host.slot-host--spreading .slot {
  cursor: crosshair;
}

.slot-host .slot.slot--spread-source {
  border-color: var(--wb-field, #5cc4b4);
  box-shadow: inset 0 0 0 2px var(--wb-field, #5cc4b4);
}

.slot-host .slot.slot--spread-target {
  border-color: var(--wb-field, #5cc4b4);
  background: color-mix(in srgb, var(--wb-field, #5cc4b4) 16%, var(--wb-panel-raised, #191d22));
}

/* Selama pratinjau, jumlah LAMA disembunyikan dan jumlah HASIL tampil di
   tempat yang sama (warna berbeda). Dua angka dalam satu slot membuat
   pengguna menebak mana yang berlaku. */
.slot-host .slot.slot--spread-source .slot__count,
.slot-host .slot.slot--spread-target .slot__count {
  display: none;
}

.slot__preview {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font: 700 10px var(--font-mono, monospace);
  color: var(--wb-field-strong, #86dccf);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .slot-menu,
  .slot-host .slot.slot--pressed {
    animation: none;
    transition: none;
  }
}
