/**
 * LNDM reusable drag-and-drop iframe styles.
 * Use with #app.dd-plate or #app.dd-layered (see README).
 */

:root {
  --dd-ink: #0b0b0b;
  /* Tool thumbnails + drag ghost: fixed box so bitmaps scale to fill it */
  --dd-tool-display: 180px;
  --dd-ghost-size: var(--dd-tool-display);
}

/* -------------------------------------------------------------------------- */
/* Shared                                                                     */
/* -------------------------------------------------------------------------- */

html.dd-root,
html.dd-root body {
  height: 100%;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--dd-ink);
}

.dd-tool {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  justify-self: center;
  align-self: start;
}

.dd-tool:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.3);
}

.dd-tool-img {
  width: var(--dd-tool-display);
  height: var(--dd-tool-display);
  min-width: var(--dd-tool-display);
  min-height: var(--dd-tool-display);
  box-sizing: border-box;
  object-fit: contain;
  object-position: center;
  display: block;
  transform: translateZ(0);
}

.dd-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  width: var(--dd-ghost-size);
  height: var(--dd-ghost-size);
  object-fit: contain;
  transform: translate(-50%, -50%);
  opacity: 0.95;
}

.dd-tray-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.8vmin, 18px);
  align-content: start;
  justify-content: center;
  padding: 0;
  min-height: 0;
}

.dd-plate-shake {
  animation: dd-plateShake 240ms ease-in-out 1;
}

@keyframes dd-plateShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

/* -------------------------------------------------------------------------- */
/* Layout: plate (single main video, drop on full panel)                      */
/* -------------------------------------------------------------------------- */

html.dd-root-plate,
html.dd-root-plate body {
  background: #ffffff;
  overflow: auto;
}

#app.dd-plate {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#app.dd-plate .dd-top {
  padding: 14px 18px;
  padding-right: 100px !important;
  border-bottom: 1px solid #000000;
}

#app.dd-plate .dd-step-title {
  font-weight: 800;
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.05;
  letter-spacing: 0.2px;
  margin-bottom: 8px;
}

#app.dd-plate .dd-step-instruction {
  font-size: clamp(13px, 1.55vw, 18px);
  line-height: 1.25;
  max-width: 980px;
}

#app.dd-plate .dd-main {
  flex: 1;
  display: flex;
  gap: 18px;
  padding: 18px;
  background: #f6f2f2;
  min-height: 0;
}

#app.dd-plate .dd-panel {
  border: 1.37px solid #000000;
  background: #ffffff;
  min-width: 0;
}

#app.dd-plate .dd-plate-panel {
  flex: 1.1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 18px;
  box-sizing: border-box;
  background: #f6f2f2;
}

#app.dd-plate .dd-plate-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  display: block;
}

#app.dd-plate .dd-tray-panel {
  flex: 0.9;
  display: flex;
  flex-direction: column;
  padding: 18px;
  box-sizing: border-box;
  gap: 0;
  background: #f6f2f2;
  min-height: 0;
}

/* Tray grid fills panel height; tools scale down inside cells (mobile landscape). */
#app.dd-plate .dd-tray-grid {
  flex: 1;
  height: 100%;
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
}

#app.dd-plate .dd-tool {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#app.dd-plate .dd-tool:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  filter: none;
}

#app.dd-plate .dd-tool-img {
  margin: 0 auto;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: min(100%, var(--dd-tool-display));
  max-height: min(100%, var(--dd-tool-display));
}

/* -------------------------------------------------------------------------- */
/* Layout: layered (full-page bg video + fg clip + ring drop)                 */
/* -------------------------------------------------------------------------- */

html.dd-root-layered,
html.dd-root-layered body {
  background: #000;
  overflow: hidden;
}

#app.dd-layered {
  position: relative;
  height: 100%;
  isolation: isolate;
  overflow: hidden;
}

#app.dd-layered .dd-app-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#app.dd-layered .dd-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  background: #000;
  pointer-events: none;
  transform: translateZ(0);
}

#app.dd-layered .dd-app-foreground {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#app.dd-layered .dd-top {
  padding: 14px 18px;
  padding-right: 100px !important;
  border-bottom: 1px solid var(--dd-ink);
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#app.dd-layered .dd-page-title {
  font-weight: 800;
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.05;
  margin: 0 0 8px 0;
}

#app.dd-layered .dd-instruction {
  font-size: clamp(13px, 1.55vw, 18px);
  line-height: 1.25;
  max-width: 980px;
  margin: 0;
}

#app.dd-layered .dd-main {
  flex: 1;
  display: flex;
  gap: 18px;
  padding: 18px;
  min-height: 0;
  background: transparent;
}

#app.dd-layered .dd-stage {
  position: relative;
  flex: 1.25;
  overflow: hidden;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  isolation: isolate;
}

#app.dd-layered .dd-drop-zone {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1;
  transform: translateZ(0);
}

#app.dd-layered .dd-drop-ring {
  width: min(52vh, 64%);
  aspect-ratio: 1 / 1;
  border: none;
  background: transparent;
  box-shadow: none;
  display: grid;
  place-items: center;
  padding: 0;
  box-sizing: border-box;
}

#app.dd-layered .dd-drop-ring-label {
  background: rgba(0, 0, 0, 0.72);
  padding: 14px 18px;
  border-radius: 10px;
  text-align: center;
  max-width: 92%;
  box-sizing: border-box;
}

#app.dd-layered .dd-drop-ring-label strong {
  color: #fff;
  font-size: clamp(14px, 1.5vw, 18px);
  letter-spacing: 0.2px;
  text-align: center;
  line-height: 1.25;
  font-weight: 800;
}

#app.dd-layered .dd-drop-ring-label small {
  display: block;
  margin-top: 8px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
}

#app.dd-layered .dd-fg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
  transform: translateZ(0);
}

#app.dd-layered .dd-fg-video {
  width: min(980px, 92%);
  height: min(72vh, 92%);
  object-fit: contain;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  pointer-events: none;
  display: none;
}

#app.dd-layered .dd-fg-video.is-visible {
  display: block;
}

#app.dd-layered .dd-tray {
  flex: 0.75;
  display: flex;
  flex-direction: column;
  padding: 18px;
  box-sizing: border-box;
  border: none;
  background: rgba(255, 255, 255, 0.5);
  min-height: 0;
}

#app.dd-layered .dd-tray-grid {
  flex: 1;
  height: 100%;
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
}

#app.dd-layered .dd-tool {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#app.dd-layered .dd-tool-img {
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: min(100%, var(--dd-tool-display));
  max-height: min(100%, var(--dd-tool-display));
}

#app.dd-layered .dd-stage.dd-plate-shake {
  animation: dd-plateShake 240ms ease-in-out 1;
}

@media (max-width: 900px) {
  #app.dd-layered .dd-main {
    flex-direction: column;
  }

  #app.dd-layered .dd-stage {
    flex: 1 1 0;
    min-height: 0;
  }

  #app.dd-layered .dd-tray {
    flex: 0 0 auto;
    min-height: 0;
    height: min(40vh, 300px);
    max-height: min(40vh, 300px);
  }
}

/* Short landscape: tighter chrome + smaller tool cap so the tray fits without scrolling */
@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --dd-tool-display: min(180px, 22vmin);
    --dd-ghost-size: var(--dd-tool-display);
  }

  #app.dd-plate .dd-top {
    padding: 8px 12px;
  }

  #app.dd-plate .dd-step-title {
    margin-bottom: 4px;
  }

  #app.dd-plate .dd-main {
    gap: clamp(8px, 1.5vmin, 18px);
    padding: clamp(8px, 1.5vmin, 18px);
  }

  #app.dd-plate .dd-plate-panel,
  #app.dd-plate .dd-tray-panel {
    padding: clamp(8px, 1.5vmin, 18px);
  }

  #app.dd-layered .dd-top {
    padding: 8px 12px;
  }

  #app.dd-layered .dd-main {
    gap: clamp(8px, 1.5vmin, 18px);
    padding: clamp(8px, 1.5vmin, 18px);
  }

  #app.dd-layered .dd-tray {
    padding: clamp(8px, 1.5vmin, 18px);
  }
}
