/*
 * Bee flight animation.
 *
 * The flight overlay is injected by assets/js/bee-flight.js. These styles
 * position it, draw the dotted trail, and provide ambient drifting bees.
 * Everything here degrades gracefully: with JS off, nothing appears; with
 * reduced motion, the bee rests and the trail is shown static.
 */

/* ---- Flight overlay -------------------------------------------------- */

.apiary-flight {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1; /* above section backgrounds, below content and header */
}

/* The dotted flight trail that draws in as the bee passes. */
.apiary-flight__trail {
  fill: none;
  stroke: var(--wp--preset--color--honey, #e9a500);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 12; /* dot / gap -> reads as a plotted flight path */
  opacity: 0.55;
}

/* A faint full-length ghost of the path, so the route is hinted ahead. */
.apiary-flight__ghost {
  fill: none;
  stroke: var(--wp--preset--color--honey, #e9a500);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 12;
  opacity: 0.1;
}

/* The travelling bee. */
.apiary-flight__bee {
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform;
}

.apiary-flight__bee-wing {
  transform-box: fill-box;
  transform-origin: 90% 80%;
  animation: apiary-wing 0.16s ease-in-out infinite alternate;
}

.apiary-flight__bee-wing--back {
  animation-delay: -0.08s;
  opacity: 0.55;
}

@keyframes apiary-wing {
  from { transform: rotate(-14deg) scaleY(1); }
  to   { transform: rotate(16deg) scaleY(0.82); }
}

/* ---- Ambient bees (hero atmosphere) ---------------------------------- */

.apiary-ambient {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.apiary-ambient__bee {
  position: absolute;
  width: 26px;
  height: 26px;
  opacity: 0.9;
  animation: apiary-drift var(--dur, 22s) ease-in-out infinite;
}

.apiary-ambient__bee .apiary-flight__bee-wing {
  animation-duration: 0.14s;
}

@keyframes apiary-drift {
  0%   { transform: translate(0, 0) rotate(6deg); }
  25%  { transform: translate(6vw, -3vh) rotate(-8deg); }
  50%  { transform: translate(2vw, 4vh) rotate(10deg); }
  75%  { transform: translate(-5vw, 1vh) rotate(-4deg); }
  100% { transform: translate(0, 0) rotate(6deg); }
}

/* ---- Reduced motion -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .apiary-flight__bee-wing,
  .apiary-ambient__bee {
    animation: none;
  }
  /* Show the full trail statically instead of drawing it on scroll. */
  .apiary-flight__trail {
    stroke-dashoffset: 0 !important;
    opacity: 0.4;
  }
  .apiary-flight__ghost {
    display: none;
  }
}

/* Hide the whole thing inside the block editor canvas, where absolute
   document-height positioning is meaningless. */
.block-editor-writing-flow .apiary-flight,
.block-editor-writing-flow .apiary-ambient {
  display: none;
}
