/*
 * Short-lived marks behind gliding tokens (TokenTrailRenderer.js). They lie in the camera-moved
 * world above the objects layer and below the tokens. Each mark keeps its screen size at every
 * zoom (`--trail-scale`), points along the movement (`--trail-angle`), alternates sides
 * (`--trail-side`) and may scatter a little (`--trail-dx`/`--trail-dy`, screen px). Colours come
 * from the mover (`--trail-player-color`; rainbow cycles `--trail-color`) or the theme accent.
 */
.table-token-trail-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
}

.table-token-trail {
  --trail-mark-color: var(--trail-player-color, var(--table-accent));
  position: absolute;
  display: block;
  width: 0;
  height: 0;
  color: var(--trail-mark-color);
  transform: scale(calc(1 / var(--trail-scale, 1))) translate(var(--trail-dx, 0px), var(--trail-dy, 0px))
    rotate(var(--trail-angle, 0deg));
  pointer-events: none;
  animation-name: table-token-trail-fade;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
}

.table-token-trail::before,
.table-token-trail::after {
  position: absolute;
  display: block;
  content: "";
}

@keyframes table-token-trail-fade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  60% { opacity: 0.75; }
  100% { opacity: 0; }
}

/* A dragged token's translucent copy (TokenObject.setGhost); the token stays put until the drop. */
.table-object--ghost {
  opacity: 0.55;
  filter: drop-shadow(0 6px 10px rgba(var(--table-black-rgb, 0, 0, 0), 0.45));
  pointer-events: none;
}

.table-object--ghost * {
  pointer-events: none !important;
}

/* The JavaScript gate also clears existing marks when these preferences change. */
body.table-effect-off--token-motion .table-token-trail-layer,
.table-root.is-effects-reduced .table-token-trail-layer { display: none; }

@media (prefers-reduced-motion: reduce) {
  .table-token-trail-layer { display: none; }
}

/* The trail tiles under "Appearance": a still trail behind a small token, played once on choice. */
.table-looks__trail {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  --trail-scale: 1;
  --trail-angle: 0deg;
}

.table-looks__trail .table-token-trail {
  top: 50%;
  animation: none;
  opacity: calc(0.35 + var(--trail-index, 0) * 0.15);
}

.table-looks__trail .table-token-trail::before,
.table-looks__trail .table-token-trail::after {
  animation: none;
}

.table-looks__trail-token {
  position: absolute;
  top: calc(50% - 8px);
  left: calc(86% - 8px);
  width: 16px;
  height: 16px;
  border: 2px solid var(--trail-player-color, var(--table-accent));
  border-radius: 50%;
  background: rgb(var(--table-panel-rgb, 22, 26, 34));
}

.table-looks__trail[data-style="none"] .table-looks__trail-token {
  left: calc(50% - 8px);
}

.table-looks__trail.is-playing .table-looks__trail-token {
  animation: table-looks-trail-run 1s ease-out both;
}

.table-looks__trail.is-playing .table-token-trail {
  animation: table-token-trail-fade 1.2s ease-out both;
  animation-delay: calc(var(--trail-index, 0) * 0.16s);
}

@keyframes table-looks-trail-run {
  from { transform: translateX(-60px); }
  to { transform: translateX(0); }
}

/* The preview rests like the trails do: with the system's reduced motion or "reduce effects". */
.is-effects-reduced .table-looks__trail.is-playing .table-looks__trail-token,
.is-effects-reduced .table-looks__trail.is-playing .table-token-trail { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .table-looks__trail.is-playing .table-looks__trail-token,
  .table-looks__trail.is-playing .table-token-trail { animation: none; }
}
