/**
 * Decorative motion, same style as the lp-obuz theme (obuz_theme/assets/css/style.css "Hero động").
 * Set with data-motion="…" in the components (classes stay as in template_html):
 *   media / media-2  hero picture or picture group: floats (floaty)
 *   chip / chip-2    small card over the hero picture: bobs (chip-2 out of step)
 *   glow             orange radial glow behind the hero picture: drifts
 *   pulse            orange dot of the label pill: pulses like a "live" dot
 *   streak … streak-4  soft horizontal bars behind the hero picture: float up and down, out of step
 *   bg               section with a background picture: the picture slowly drifts behind the content
 *   dash             dashed border that runs around the box (drawn by assets/js/motion.js)
 *   orbit            diagram whose [data-orbit] items turn around its centre (assets/js/motion.js)
 *   sunrise          CTA sea scene (components/zotek/<screen>/cta.php): the sun (sun-halo + sun-core)
 *                    rises from behind the waves the first time the scene scrolls into view
 *                    (assets/js/motion.js sets data-motion-ready / data-motion-in), then the halo
 *                    breathes, the core floats and the waves (wave-1…3, back to front) sway
 *   arrow / page     hover states of list rows and pagination links (see "Hover states" below)
 * Keyframes use `transform`; the scroll reveal and the sunrise use the separate `translate` property,
 * so both add up.
 */

@keyframes zk-floaty {
  50% { transform: translateY(-10px); }
}

@keyframes zk-bob {
  50% { transform: translateY(-8px); }
}

@keyframes zk-drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-40px, 30px) scale(1.08); }
  100% { transform: translate(30px, -20px) scale(0.95); }
}

@keyframes zk-pulse {
  0% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(243, 156, 18, 0); }
  100% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0); }
}

@keyframes zk-bg-drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-4%, -3%) scale(1.08); }
}

[data-motion="media"] { animation: zk-floaty 7s ease-in-out infinite; }
[data-motion="media-2"] { animation: zk-floaty 8s ease-in-out -4s infinite; }
[data-motion="chip"] { animation: zk-bob 6s ease-in-out infinite; }
[data-motion="chip-2"] { animation: zk-bob 7s ease-in-out -3s infinite; }
[data-motion="glow"] { animation: zk-drift 18s ease-in-out infinite alternate; }
[data-motion="pulse"] { animation: zk-pulse 1.8s infinite; }

/* Hero streaks (home/hero.php): the soft horizontal bars behind the hero picture float up and down,
   each with its own distance / speed / phase. The two upper bars rise and the two lower bars sink,
   so neighbouring bars only move apart and never overlap. */
@keyframes zk-streak {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(var(--zk-streak, -10px)); }
}

[data-motion="streak"] { --zk-streak: -10px; animation: zk-streak 6s ease-in-out infinite; }
[data-motion="streak-2"] { --zk-streak: 8px; animation: zk-streak 7.5s ease-in-out -2s infinite; }
[data-motion="streak-3"] { --zk-streak: 12px; animation: zk-streak 8.5s ease-in-out -5s infinite; }
[data-motion="streak-4"] { --zk-streak: -8px; animation: zk-streak 6.8s ease-in-out -3.5s infinite; }

/* The section's own background (classes + inline background-image) is copied to a layer behind the
   content that is a bit larger than the section, so it can move without showing its edges. */
[data-motion="bg"] {
  position: relative;
  isolation: isolate;
}

[data-motion="bg"]::before {
  content: "";
  position: absolute;
  inset: -8%;
  z-index: -1;
  pointer-events: none;
  background: inherit;
  animation: zk-bg-drift 20s ease-in-out infinite alternate;
}

/* CTA sunrise */
@keyframes zk-sun-glow {
  50% { transform: scale(1.14); }
}

@keyframes zk-sun-float {
  50% { transform: translateY(-6px); }
}

/* Slightly wider than the scene, so the sway never shows the wave ends. */
@keyframes zk-wave {
  from { transform: translateX(-2%) scaleX(1.06); }
  to { transform: translateX(2%) scaleX(1.06); }
}

[data-motion="sun-halo"] { animation: zk-sun-glow 5s ease-in-out infinite; }
[data-motion="sun-core"] { animation: zk-sun-float 7s ease-in-out infinite; }
[data-motion="wave-1"] { animation: zk-wave 14s ease-in-out infinite alternate; }
[data-motion="wave-2"] { animation: zk-wave 11s ease-in-out -4s infinite alternate-reverse; }
[data-motion="wave-3"] { animation: zk-wave 8s ease-in-out -2s infinite alternate; }

/* Transitions only for the rise: going below the horizon at load is instant. */
[data-motion="sunrise"][data-motion-in] [data-motion="sun-core"] {
  transition: translate 2.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 1.6s ease;
}

[data-motion="sunrise"][data-motion-in] [data-motion="sun-halo"] {
  transition: translate 2.4s cubic-bezier(0.22, 1, 0.36, 1) 0.2s, opacity 1.8s ease 0.2s;
}

[data-motion="sunrise"][data-motion-ready]:not([data-motion-in]) :is([data-motion="sun-halo"], [data-motion="sun-core"]) {
  opacity: 0;
  translate: 0 110px;
}

/* Hover states (opt-in with data-motion, the template classes stay unchanged):
   arrow  round arrow button of a list row (.group, e.g. components/zotek/news/list.php): fills blue,
          the arrow turns white and nudges right while the row is hovered / focused
   page   page link of a pagination: blue border on hover */
[data-motion="arrow"] { transition: background-color 0.25s ease, border-color 0.25s ease; }
[data-motion="arrow"] img { transition: transform 0.25s ease, filter 0.25s ease; }

.group:hover [data-motion="arrow"],
.group:focus-visible [data-motion="arrow"] {
  border-color: #0b75d5;
  background-color: #0b75d5;
}

.group:hover [data-motion="arrow"] img,
.group:focus-visible [data-motion="arrow"] img {
  filter: brightness(0) invert(1);
  transform: translateX(2px);
}

[data-motion="page"] { transition: border-color 0.2s ease; }
[data-motion="page"]:hover,
[data-motion="page"]:focus-visible { border-color: #0b75d5; }

/* Listing pages (inc/zotek/listing.php): tab / page links end with #<list id>; the jump stops
   below the sticky header. */
[data-listing] { scroll-margin-top: 100px; }

/* While a tab / page loads in place (assets/js/listing-nav.js) the list below the tabs fades a little;
   the delay keeps quick loads from flashing. */
[data-listing-loading] [data-listing] ~ * { opacity: 0.45; transition: opacity 0.2s ease 0.15s; }

/* Category icon of the active tab (blue pill) turns white. */
[aria-current="page"] > [data-tab-icon] img { filter: brightness(0) invert(1); }

/* Keyword search box of a listing (form[data-listing-search]). */
[data-listing-search] { transition: border-color 0.2s ease; }
[data-listing-search]:focus-within { border-color: #0b75d5; }
[data-listing-search] input::placeholder { color: #757575; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  [data-motion],
  [data-motion]::before { animation: none; }
  [data-motion="arrow"],
  [data-motion="arrow"] img,
  [data-motion="page"] { transition: none; }
}
