/* ===================================================== */
/* ============ ЭФФЕКТЫ РЕДКОСТЕЙ (5.1) ================ */
/* ===================================================== */
/*
  Мифик: «изумруд + золото» — яркий зелёный камень с подсветкой за голубем, по нему текут золотые переливы,
         изумрудная рамка с мятным бликом, изумрудное свечение, золотые искры и имя,
         надпись «Мифический» переливается мятным.
  Легендарка: по золоту течёт «жидкое золото», по рамке бежит блик, надпись «Легендарный» переливается золотом,
              вокруг голубя вспыхивают искры
              (искры — разметка из window.rarityFxHtml в state.js).

  Карточки: голуби и яйца на ферме и рынке (.farm-pigeon, .farm-egg), коллекция (.collection-card.opened), инкубатор (.incubator-slot).
  Слои в .pigeon-card-bg: ::before — перелив, ::after — рамка (обычный глянец у этих редкостей не нужен).
  Перелив бесшовный: полоса цветов повторяется с периодом 300px под углом 115°, слой сдвигается ровно на
  один период по горизонтали (300 / sin 115° ≈ 331px) — края и рывки не видны.
*/

@property --rfx-ang  { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

/* ---------- общее для обеих редкостей ---------- */
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot):is(.rarity-mythical, .rarity-legendary) > .pigeon-card-bg{
  overflow: hidden;
}
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot):is(.rarity-mythical, .rarity-legendary) > .pigeon-card-bg::before{
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(100% + 332px);
  border-radius: 0;
  opacity: 1;
  pointer-events: none;
  animation: rfx-flow 10s linear infinite;
}
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot):is(.rarity-mythical, .rarity-legendary) > .pigeon-card-bg::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 3px;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}

/* ---------- МИФИК: изумруд + золото ---------- */
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot).rarity-mythical{
  --r-border: rgba(90,255,170,.85); /* изумрудное свечение вокруг карточки */
}
/* мягкая подсветка за голубем — чтобы тёмные голуби не терялись на камне */
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot).rarity-mythical > .pigeon-card-bg{
  background:
    radial-gradient(90px 80px at 50% 60px, rgba(220,255,235,.4), transparent 70%),
    var(--rarity-info-bg);
}
/* на рынке картинка ниже — над ней лента «Яйцо» / «Голубь дня» */
.store-card.rarity-mythical > .pigeon-card-bg{
  background:
    radial-gradient(90px 80px at 50% 80px, rgba(220,255,235,.4), transparent 70%),
    var(--rarity-info-bg);
}
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot).rarity-mythical > .pigeon-card-bg::before,
.pigeon-modal.rarity-mythical .pm-stage::before{
  background: repeating-linear-gradient(115deg,
    rgba(255,210,90,.28) 0px, rgba(255,210,90,0) 60px, rgba(255,240,180,.16) 150px,
    rgba(255,210,90,0) 230px, rgba(255,210,90,.28) 300px);
  animation-duration: 9s;
}
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot).rarity-mythical > .pigeon-card-bg::after{
  padding: 3.5px;
  /* тёмный изумруд по краям + мятный блик — не сливается с зелёным фоном */
  background: conic-gradient(from var(--rfx-ang), #0b5a37 0deg, #2fd98c 40deg, #eafff3 70deg, #2fd98c 100deg, #0b5a37 160deg, #063d25 250deg, #0b5a37 360deg);
  animation: rfx-spin 4s linear infinite;
}
/* имя голубя — золотом */
.farm-pigeon.rarity-mythical h3,
.farm-egg.rarity-mythical h3,
.collection-card.opened.rarity-mythical .card-title{ color: #ffe7a3; }
/* у легендарки имя — тёмная «гравировка» на золоте: коричневый текст + светлый блик снизу */
.farm-pigeon.rarity-legendary h3,
.farm-egg.rarity-legendary h3,
.collection-card.opened.rarity-legendary .card-title{
  color: #5a3800;
  text-shadow: 0 1px 0 rgba(255,244,200,.65);
}

/* надписи редкости переливаются: «Мифический» — мятным, «Легендарный» — золотом. Везде это «таблетка»
   с тёмной подложкой: перелив обрезается по тексту, подложка остаётся (второй слой фона, --rfx-pill) */
:is(.farm-pigeon, .farm-egg, .incubator-slot) p:is(.rarity-mythical, .rarity-legendary),
.collection-card .card-rarity:is(.rarity-mythical, .rarity-legendary),
.pigeon-modal:is(.rarity-mythical, .rarity-legendary) .pm-rarity{
  background:
    var(--rfx-text-grad) 0 0 / 200% 100%,
    var(--rfx-pill, rgba(0,0,0,.35));
  -webkit-background-clip: text, padding-box;
          background-clip: text, padding-box;
  color: transparent !important;
  text-shadow: none;
  animation: rfx-text 4s linear infinite;
}
.rarity-mythical  { --rfx-text-grad: linear-gradient(90deg, #2fd98c, #9dffcf, #f0fff7, #9dffcf, #2fd98c); }
.rarity-legendary { --rfx-text-grad: linear-gradient(90deg, #b8860b, #ffe07a, #fff6d0, #ffe07a, #b8860b); }
.farm-pigeon p:is(.rarity-mythical, .rarity-legendary),
.farm-egg p:is(.rarity-mythical, .rarity-legendary){ --rfx-pill: rgba(0,0,0,.38); }
.incubator-slot p:is(.rarity-mythical, .rarity-legendary){ --rfx-pill: var(--catch-info-overlay); }
.pigeon-modal:is(.rarity-mythical, .rarity-legendary) .pm-rarity{ --rfx-pill: rgba(0,0,0,.38); }

/* окно голубя: перелив на сцене */
.pigeon-modal:is(.rarity-mythical, .rarity-legendary) .pm-stage::before{
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(100% + 332px);
  pointer-events: none;
  animation: rfx-flow 10s linear infinite;
}

/* ---------- ЛЕГЕНДАРКА ---------- */
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot).rarity-legendary > .pigeon-card-bg::before,
.pigeon-modal.rarity-legendary .pm-stage::before{
  background: repeating-linear-gradient(115deg,
    rgba(255,244,190,.55) 0px, rgba(255,200,40,0) 70px, rgba(200,120,0,.35) 150px,
    rgba(255,200,40,0) 230px, rgba(255,244,190,.55) 300px);
  animation-duration: 8s;
}
:is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot).rarity-legendary > .pigeon-card-bg::after{
  background: conic-gradient(from var(--rfx-ang), #b8860b 0deg, #ffd24a 40deg, #fffbe0 70deg, #ffd24a 100deg, #b8860b 160deg, #8a6200 250deg, #b8860b 360deg);
  animation: rfx-spin 4s linear infinite;
}

/* искры: вспыхивают и гаснут вокруг голубя (не на тексте) */
.rfx-sparks{
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
}
.rfx-sparks i{
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  opacity: 0;
  background:
    radial-gradient(circle, #fff 0 15%, rgba(255,255,255,0) 16%),
    conic-gradient(from 0deg, transparent 0 40deg, #fff 45deg, transparent 50deg 130deg, #fff 135deg, transparent 140deg 220deg, #fff 225deg, transparent 230deg 310deg, #fff 315deg, transparent 320deg);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #ff9d00) drop-shadow(0 0 1px #b36b00);
  animation: rfx-twinkle 2.8s ease-in-out infinite;
  animation-delay: calc(var(--rfx-d, 0s) + var(--i) * .47s);
}
.rfx-sparks i:nth-child(1){ left: 14%; top: 8%;  --i: 0; }
.rfx-sparks i:nth-child(2){ left: 86%; top: 12%; --i: 2; }
.rfx-sparks i:nth-child(3){ left: 22%; top: 40%; --i: 4; }
.rfx-sparks i:nth-child(4){ left: 80%; top: 38%; --i: 1; }
.rfx-sparks i:nth-child(5){ left: 50%; top: 4%;  --i: 5; }
.rfx-sparks i:nth-child(6){ left: 90%; top: 62%; --i: 3; }
/* окно голубя: искры есть в разметке всегда, видны только у легендарки и мифика; лежат под голубем и плашками */
.pigeon-modal:not(.rarity-legendary):not(.rarity-mythical) .pm-sparks{ display: none; }
.pm-sparks{ z-index: auto; border-radius: 0; }
.pm-sparks i{ width: 30px; height: 30px; margin: -15px 0 0 -15px; }
.pm-sparks i:nth-child(1){ left: 20%; top: 34%; }
.pm-sparks i:nth-child(2){ left: 80%; top: 30%; }
.pm-sparks i:nth-child(3){ left: 14%; top: 66%; }
.pm-sparks i:nth-child(4){ left: 86%; top: 62%; }
.pm-sparks i:nth-child(5){ left: 38%; top: 16%; }
.pm-sparks i:nth-child(6){ left: 66%; top: 84%; }
/* в коллекции карточки меньше — искры помельче */
.collection-card .rfx-sparks i{ width: 16px; height: 16px; margin: -8px 0 0 -8px; }

/* ---------- анимации ---------- */
@keyframes rfx-flow{ from{ transform: translateX(-331.1px); } to{ transform: translateX(0); } }
@keyframes rfx-spin{ to{ --rfx-ang: 360deg; } }
@keyframes rfx-text{ to{ background-position: 200% 0, 0 0; } }
@keyframes rfx-twinkle{
  0%, 100%{ opacity: 0; transform: scale(.3) rotate(0deg); }
  45%     { opacity: 1; transform: scale(1) rotate(45deg); }
  60%     { opacity: 0; transform: scale(.5) rotate(90deg); }
}

@media (prefers-reduced-motion: reduce){
  :is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot):is(.rarity-mythical, .rarity-legendary),
  :is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot):is(.rarity-mythical, .rarity-legendary) > .pigeon-card-bg::before,
  :is(.farm-pigeon, .farm-egg, .collection-card.opened, .incubator-slot):is(.rarity-mythical, .rarity-legendary) > .pigeon-card-bg::after,
  .pigeon-modal .pm-stage::before,
  :is(.farm-pigeon, .farm-egg, .incubator-slot) p:is(.rarity-mythical, .rarity-legendary),
  .collection-card .card-rarity:is(.rarity-mythical, .rarity-legendary),
  .pigeon-modal:is(.rarity-mythical, .rarity-legendary) .pm-rarity,
  .rfx-sparks i{ animation: none; }
  .rfx-sparks{ display: none; }
}
