/*
 * drag-drop.css
 * Level 2 drag/drop challenge.
 *
 * Critical UX rules:
 * - The drag zone should remain visible at once whenever possible.
 * - Items and slots resize instead of causing horizontal scroll.
 * - Supports both pointer dragging and tap item -> tap slot fallback.
 */

.drag-challenge-screen .screen-inner {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  align-content: start;
  gap: clamp(8px, 2.6dvh, 16px);
  padding-top: calc(clamp(12px, 2.6dvh, 24px) + var(--safe-top));
  padding-bottom: calc(clamp(12px, 2.6dvh, 24px) + var(--safe-bottom));
}

.drag-challenge-screen .screen-title {
  font-size: clamp(1.32rem, 6vw, 2.05rem);
  line-height: 1.05;
}

.drag-challenge-screen .text-box {
  padding: clamp(9px, 2.6vw, 13px);
  font-size: clamp(0.92rem, 3.4vw, 1.05rem);
  line-height: 1.2;
}

.drag-challenge {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(8px, 2.4dvh, 14px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.drag-game-area {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(8px, 2.2dvh, 14px);
  width: 100%;
  max-width: 100%;
  height: min(58dvh, 350px);
  min-height: 340px;
  overflow: hidden;
  border: var(--border-soft);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 218, 155, 0.1), transparent 34%),
    rgba(5, 2, 2, 0.46);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  touch-action: none;
}

.drag-items,
.drag-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: clamp(5px, 2vw, 12px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: clamp(8px, 2.5vw, 14px);
}

.drag-items {
  align-self: start;
}

.drag-slots {
  align-self: end;
}

.drag-playfield {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 86px;
  overflow: visible;
  pointer-events: none;
}

.drag-item,
.drag-slot {
  width: var(--drag-item-size);
  height: var(--drag-item-size);
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: clamp(12px, 4vw, 20px);
}

.drag-slot {
  position: relative;
  width: var(--drag-slot-size);
  height: var(--drag-slot-size);
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 218, 155, 0.42);
  background: rgba(255, 244, 226, 0.07);
  box-shadow: inset 0 0 20px rgba(255, 218, 155, 0.07), 0 10px 24px rgba(0, 0, 0, 0.2);
  transition:
    transform var(--duration-base) var(--ease-standard),
    border-color var(--duration-base) var(--ease-standard),
    background var(--duration-base) var(--ease-standard),
    box-shadow var(--duration-base) var(--ease-standard);
}

.drag-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.8;
  pointer-events: none;
}

.drag-slot.is-targeted,
.drag-slot:hover {
  transform: scale(1.035);
  border-color: rgba(255, 218, 155, 0.86);
  background: rgba(255, 218, 155, 0.14);
  box-shadow: inset 0 0 22px rgba(255, 218, 155, 0.12), 0 0 28px rgba(255, 174, 83, 0.16);
}

.drag-slot.is-correct {
  border-style: solid;
  border-color: rgba(201, 255, 196, 0.72);
  background: rgba(96, 160, 78, 0.16);
  box-shadow: inset 0 0 24px rgba(201, 255, 196, 0.12), 0 0 26px rgba(201, 255, 196, 0.12);
}

.drag-slot.is-wrong-pulse {
  animation: slotWrongPulse 360ms var(--ease-standard);
}

.drag-item {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 218, 155, 0.36);
  background:
    radial-gradient(circle at 34% 22%, rgba(255, 255, 255, 0.2), transparent 28%),
    rgba(255, 244, 226, 0.08);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.34), 0 0 22px rgba(255, 174, 83, 0.1);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition:
    transform var(--duration-base) var(--ease-standard),
    border-color var(--duration-base) var(--ease-standard),
    box-shadow var(--duration-base) var(--ease-standard),
    opacity var(--duration-base) var(--ease-standard),
    filter var(--duration-base) var(--ease-standard);
}

.drag-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.drag-item:hover,
.drag-item:focus-visible {
  transform: scale(1.04);
  border-color: rgba(255, 218, 155, 0.78);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.38), 0 0 28px rgba(255, 174, 83, 0.18);
}

.drag-item:active,
.drag-item.is-dragging {
  cursor: grabbing;
  transform: scale(1.08);
  z-index: 10;
  filter: brightness(1.08) saturate(1.08);
  box-shadow: 0 22px 42px rgba(0, 0, 0, 0.46), 0 0 36px rgba(255, 174, 83, 0.24);
}

.drag-item.is-floating {
  position: fixed;
  left: 0;
  top: 0;
  z-index: calc(var(--z-modal) - 1);
  pointer-events: none;
  will-change: transform;
}

.drag-item.is-selected-for-tap {
  border-color: rgba(255, 238, 204, 0.94);
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.38),
    0 0 0 4px rgba(255, 218, 155, 0.14),
    0 0 34px rgba(255, 174, 83, 0.28);
  animation: selectedGemPulse 900ms var(--ease-standard) infinite alternate;
}

.drag-item.is-locked {
  cursor: default;
  pointer-events: none;
  opacity: 0.96;
  filter: saturate(1.1) brightness(1.04);
}

.drag-item.is-returning {
  transition: transform var(--duration-base) var(--ease-standard);
}

.drag-item.is-hidden-source {
  opacity: 0;
  pointer-events: none;
}

.drag-status-row {
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-height: 34px;
  text-align: center;
}

.drag-attempts,
.drag-item-errors {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.15;
}

.drag-item-errors {
  /*display: flex;*/
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 9px;
  max-width: 100%;
}

.drag-error-chip {
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid rgba(255, 218, 155, 0.18);
  border-radius: var(--radius-round);
  background: rgba(0, 0, 0, 0.24);
  overflow-wrap: anywhere;
}

@keyframes selectedGemPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.045);
  }
}

@keyframes slotWrongPulse {
  0%, 100% {
    transform: translate3d(0, 0, 0);
    border-color: rgba(255, 183, 168, 0.42);
  }

  25% {
    transform: translate3d(-3px, 0, 0);
    border-color: rgba(255, 183, 168, 0.9);
  }

  50% {
    transform: translate3d(3px, 0, 0);
  }

  75% {
    transform: translate3d(-2px, 0, 0);
  }
}

@media (max-width: 360px) {
  .drag-challenge-screen .screen-inner {
    gap: 8px;
    padding-top: calc(10px + var(--safe-top));
    padding-bottom: calc(10px + var(--safe-bottom));
  }

  .drag-game-area {
    height: min(60dvh, 440px);
    min-height: 300px;
    gap: 6px;
    border-radius: var(--radius-lg);
  }

  .drag-items,
  .drag-slots {
    gap: 4px;
    padding: 7px;
  }

  .drag-playfield {
    min-height: 70px;
  }
}

@media (max-height: 640px) and (orientation: portrait) {
  .drag-challenge-screen .screen-inner {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 7px;
  }

  .drag-challenge-screen .screen-title {
    font-size: clamp(1.18rem, 5.6vw, 1.72rem);
  }

  .drag-challenge-screen .text-box {
    padding: 8px 10px;
    font-size: 0.95rem;
  }

  .drag-game-area {
    height: min(62dvh, 400px);
    min-height: 284px;
  }

  .drag-status-row {
    min-height: 24px;
  }
}
