/* «Наши герои» (data-story="geroi"): сцена-театр, префикс gr- */

/* волшебная картина Аквы */
.gr-fr { opacity: 0; transition: opacity .5s ease; }
.gr-fr.on { opacity: 1; }
.gr-sway { animation: gr-sway 3s ease-in-out infinite alternate; }
.gr-sway2 { animation: gr-sway 2.4s ease-in-out infinite alternate-reverse; }
.gr-spin { transform-box: fill-box; transform-origin: center; animation: tr-spin 9s linear infinite; }
.gr-rain line { animation: gr-rain .9s linear infinite; }
.gr-rain line:nth-child(2n) { animation-delay: .3s; }
.gr-rain line:nth-child(3n) { animation-delay: .6s; }
.gr-rainbow path { stroke-dasharray: 1 1; stroke-dashoffset: 1; }

/* кран */
.gr-stream { transition: opacity .3s ease; }
.trip.kran-off .gr-stream { opacity: 0; }
.gr-dr { animation: gr-drip .7s ease-in infinite; }
.gr-dr.d2 { animation-delay: .35s; }
.gr-valve { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .5s ease; }
.trip.kran-off .gr-valve { transform: rotate(90deg); }
.gr-heart { opacity: 0; transform-box: fill-box; transform-origin: center; }
.trip.g-kran .gr-heart { animation: gr-heart 2s ease both; }

/* Аква прыгает, брызги разлетаются */
.gr-jump { transform-box: fill-box; transform-origin: 50% 100%; animation: tr-bob 2.4s ease-in-out infinite; }
.trip.g-aqua .gr-jump { animation: gr-jump .9s ease both; }
.gr-splash use { opacity: 0; }
.trip.g-aqua .gr-splash use { animation: gr-splash 1s ease-out .58s forwards; }

/* Миша: книга, блик на очках, новая формула; песочные часы */
.gr-mi-hero, .gr-mi-book { transition: opacity .2s ease; }
.gr-mi-book { opacity: 0; }
.trip.g-misha .gr-mi-book { opacity: 1; }
.trip.g-misha .gr-mi-hero { opacity: 0; }
.gr-glint { opacity: 0; transform-box: fill-box; transform-origin: center; }
.trip.g-misha .gr-glint { animation: gr-glint 1.1s ease both; }
.gr-formula { transform-box: fill-box; transform-origin: center; }
.trip.g-misha .gr-formula { animation: gr-flip .6s ease both; }
.gr-motto { opacity: 0; }
.trip.g-sand .gr-motto { opacity: 1; }
.trip.g-sand .gr-formula { opacity: 0; animation: none; }
.gr-hg { transform-box: fill-box; transform-origin: center; }
.trip.g-sand .gr-hg { animation: gr-turn .7s ease both; }
.gr-sand-top, .gr-sand-bot { transform-box: fill-box; transform-origin: 50% 100%; }
.gr-sand-top { transform: scale(.3); }
.trip.sand-run .gr-sand-top { animation: gr-drain 6s linear .7s both; }
.trip.sand-run .gr-sand-bot { animation: gr-fill 6s linear .7s both; }
.gr-sand-flow { opacity: 0; }
.trip.sand-run .gr-sand-flow { animation: gr-flowline 6.7s linear both; }
.gr-snow { opacity: 0; transition: opacity .5s ease; }
.trip.cool .gr-snow { opacity: 1; }
.trip.cool .gr-snow circle { animation: gr-snow 3.2s linear infinite; }
.gr-snow circle:nth-child(2n) { animation-delay: 1.1s; }
.gr-snow circle:nth-child(3n) { animation-delay: 2.1s; }

/* Катя машет, на карте — новая отметка */
.gr-wave { transform-box: fill-box; transform-origin: 50% 100%; }
.trip.g-katya .gr-wave { animation: gr-wave .45s ease-in-out 4; }
.gr-hi { opacity: 0; transform-box: fill-box; transform-origin: 100% 50%; }
.trip.g-katya .gr-hi { animation: gr-pop 2.6s ease both; }
.gr-pin { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.gr-pin.on { opacity: 1; }
.gr-pin.new { animation: gr-pin .7s cubic-bezier(.3, 1.6, .5, 1) both; }
#gr-mapcap { transition: opacity .3s ease; }

/* мусор у речки — в рюкзак; рыбка радуется */
.gr-lit { transform-box: fill-box; transform-origin: center; }
.gr-lit.gone { animation: gr-tobag .9s ease-in forwards; pointer-events: none; }
#gr-fish { transform: translate(800px, 640px); }
.trip.g-litter #gr-fish.go { animation: gr-fish 1.4s ease-in-out both; }

/* занавес: выглядывает герой */
.gr-pk { display: none; }
.gr-pk.on { display: inline; }
.trip.g-peek .gr-pk.on .gr-pk-x { animation: gr-peek 2.8s ease both; }
.gr-pkb { opacity: 0; transform-box: fill-box; transform-origin: 100% 50%; }
.trip.g-peek .gr-pkb { animation: gr-pop 2.8s ease both; }

/* нажатый герой выходит из тени */
.trip.g-aqua #gr-aqua, .trip.g-kran #gr-aqua, .trip.g-misha #gr-misha, .trip.g-sand #gr-misha { opacity: 1 !important; }

/* конфетти-капельки в конце */
.gr-conf use { opacity: 0; }
.trip.all .gr-conf use { animation: gr-conf 3s linear infinite; }
.gr-conf use:nth-child(2n) { animation-delay: .8s; }
.gr-conf use:nth-child(3n) { animation-delay: 1.6s; }
.gr-conf use:nth-child(4n) { animation-delay: 2.3s; }

@keyframes gr-sway { from { transform: translateX(-12px); } to { transform: translateX(12px); } }
@keyframes gr-rain { from { transform: translateY(-8px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(40px); opacity: 0; } }
@keyframes gr-drip { from { transform: translateY(-12px); opacity: 1; } to { transform: translateY(18px); opacity: 0; } }
@keyframes gr-heart { 0% { opacity: 0; transform: scale(.3); } 15% { opacity: 1; transform: scale(1.35); } 25% { transform: scale(1); }
  80% { opacity: 1; transform: translateY(-26px); } 100% { opacity: 0; transform: translateY(-40px); } }
@keyframes gr-jump { 0% { transform: none; } 14% { transform: scale(1.1, .86); } 45% { transform: translateY(-110px) scale(.94, 1.08); }
  72% { transform: none; } 82% { transform: scale(1.12, .86); } 100% { transform: none; } }
@keyframes gr-splash { from { opacity: 1; transform: translate(0, 0) scale(.8); } 70% { opacity: 1; }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.7); } }
@keyframes gr-glint { 0% { opacity: 0; transform: scale(0); } 35% { opacity: 1; transform: scale(1.4) rotate(45deg); } 70% { opacity: 1; }
  100% { opacity: 0; transform: scale(.2) rotate(90deg); } }
@keyframes gr-flip { from { transform: scaleX(0); } to { transform: none; } }
@keyframes gr-turn { from { transform: rotate(-180deg); } to { transform: none; } }
@keyframes gr-drain { from { transform: none; } to { transform: scale(.3); } }
@keyframes gr-fill { from { transform: scale(.3); } to { transform: none; } }
@keyframes gr-flowline { 0%, 10% { opacity: 0; } 11%, 98% { opacity: 1; } 100% { opacity: 0; } }
@keyframes gr-snow { from { transform: translateY(-20px); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(160px); opacity: 0; } }
@keyframes gr-wave { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes gr-pop { 0% { opacity: 0; transform: scale(.3); } 14% { opacity: 1; transform: scale(1.12); } 24% { transform: none; }
  85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes gr-pin { from { opacity: 0; transform: translateY(-60px) scale(.4); } to { opacity: 1; transform: none; } }
@keyframes gr-tobag { 0% { transform: none; opacity: 1; } 55% { transform: translate(calc(var(--tx) * .55), calc(var(--ty) - 50px)) scale(.8); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(.3); opacity: 0; } }
@keyframes gr-fish { 0% { transform: translate(730px, 640px) rotate(-50deg); } 50% { transform: translate(800px, 500px) rotate(0); }
  100% { transform: translate(870px, 640px) rotate(50deg); } }
@keyframes gr-peek { 0% { transform: none; } 18%, 78% { transform: translateX(-104px); } 100% { transform: none; } }
@keyframes gr-conf { from { transform: translateY(0); opacity: 0; } 10% { opacity: 1; } 85% { opacity: 1; } to { transform: translateY(380px); opacity: 0; } }

/* без анимаций — нужное состояние видно сразу */
@media (prefers-reduced-motion: reduce) {
  .trip.g-kran .gr-heart, .trip.g-misha .gr-glint, .trip.g-katya .gr-hi, .trip.g-peek .gr-pkb, .trip.all .gr-conf use { opacity: 1; }
  .trip.g-aqua .gr-splash use { opacity: 1; transform: translate(var(--dx), var(--dy)) scale(1.4); }
  .trip.g-aqua .gr-jump { transform: translateY(-40px); }
  .trip.g-peek .gr-pk.on .gr-pk-x { transform: translateX(-104px); }
  .trip.sand-up .gr-sand-top { transform: none; }
  .trip.sand-up .gr-sand-bot { transform: scale(.3); }
  .gr-lit.gone { opacity: 0; }
  .trip.g-litter #gr-fish.go { transform: translate(800px, 520px); }
}

/* карточки */
.gr-face { float: right; width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: -2px -2px 8px 12px;
  background: #fff; box-shadow: 0 0 0 5px var(--sky); }
.trip-card .tag + h2 { margin-top: 8px; }
.gr-likes { margin: 0 0 12px; padding-left: 20px; color: var(--ink-soft); }
.gr-likes li { margin-bottom: 6px; }
.gr-likes b, .gr-team b { color: var(--ink); }
.gr-links a { display: inline-block; margin: 0 6px 8px 0; padding: 6px 14px; border-radius: 999px; background: var(--sky);
  font-weight: 800; text-decoration: none; }
.gr-links a:hover { background: #c5e4f8; }
.trip-card .say { margin: 6px 0 14px; }
.gr-team { list-style: none; margin: 0 0 14px; padding: 0; }
.gr-team li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-weight: 700; }
.gr-team li:last-child { border-bottom: 0; }
.gr-team b { display: inline-block; min-width: 56px; }
.gr-team .gr-c-a { color: var(--water-deep); }
.gr-team .gr-c-m { color: #5b6f86; }
.gr-team .gr-c-k { color: #c0614f; }
.gr-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.gr-anchor { scroll-margin-top: 13vh; }
@media (max-width: 860px) {
  .gr-face { width: 72px; height: 72px; }
  .gr-anchor { scroll-margin-top: calc(var(--hdr, 68px) + 58vw + 40px); }
}
