/* =====================================================================
   AGROALEM — анимации и «живость» интерфейса.
   Подключается последним. Дизайн (цвета, сетка, шрифты) не меняет — только движение.
   Всё отключается при prefers-reduced-motion.
   ===================================================================== */
:root { --ease: cubic-bezier(.2, .7, .2, 1); --ease-out: cubic-bezier(.16, 1, .3, 1); }
html { scroll-behavior: smooth; }

/* ---------- плавные переходы между страницами (Chrome/Edge/Safari — прогрессивно) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; animation-timing-function: var(--ease); }
.tabbar { view-transition-name: tabbar; }

/* ---------- появление страницы ---------- */
main { animation: pageIn .6s var(--ease) backwards; }
.page-head h1 { animation: pageIn .7s var(--ease) .05s both; }
.crumbs { animation: fadeIn .6s ease .1s both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- появление блоков при прокрутке ---------- */
.js .reveal { opacity: 0; transform: translateY(32px); transition: opacity .8s var(--ease), transform .8s var(--ease); will-change: opacity, transform; }
.js .reveal.in { opacity: 1; transform: none; will-change: auto; }

/* поэлементное появление внутри секций (задержка через --i) */
.js .reveal.in .cat, .js .reveal.in .feat, .js .reveal.in .stats > div { animation: itemIn .7s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 55ms + 120ms); }
@keyframes itemIn { from { opacity: 0; transform: translateY(26px) scale(.97); } to { opacity: 1; transform: none; } }
.cat:nth-child(1), .feat:nth-child(1), .stats > div:nth-child(1) { --i: 0; } .cat:nth-child(2), .feat:nth-child(2), .stats > div:nth-child(2) { --i: 1; }
.cat:nth-child(3), .feat:nth-child(3), .stats > div:nth-child(3) { --i: 2; } .cat:nth-child(4), .feat:nth-child(4) { --i: 3; }
.cat:nth-child(5) { --i: 4; } .cat:nth-child(6) { --i: 5; } .cat:nth-child(7) { --i: 6; } .cat:nth-child(8) { --i: 7; }
.cat:nth-child(9) { --i: 8; } .cat:nth-child(10) { --i: 9; } .cat:nth-child(11) { --i: 10; } .cat:nth-child(12) { --i: 11; }
.cat:nth-child(13) { --i: 12; } .cat:nth-child(14) { --i: 13; }

/* карточки товаров: каскадное появление при каждой загрузке */
.card { animation: cardIn .6s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.grid .card:nth-child(1), .hits .card:nth-child(1) { --i: 0; } .grid .card:nth-child(2), .hits .card:nth-child(2) { --i: 1; }
.grid .card:nth-child(3), .hits .card:nth-child(3) { --i: 2; } .grid .card:nth-child(4), .hits .card:nth-child(4) { --i: 3; }
.grid .card:nth-child(5), .hits .card:nth-child(5) { --i: 4; } .grid .card:nth-child(6), .hits .card:nth-child(6) { --i: 5; }
.grid .card:nth-child(7) { --i: 6; } .grid .card:nth-child(8) { --i: 7; } .grid .card:nth-child(9) { --i: 8; }
.hits .card:nth-child(n+7) { --i: 6; } .grid .card:nth-child(n+10) { --i: 3; }
.crow { animation: cardIn .45s var(--ease) backwards; }
.empty, .done { animation: pageIn .6s var(--ease) both; }

/* ---------- карточки: подъём, тень, zoom картинки ---------- */
.card, .cat { transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s; }
.card__pic, .cat__pic { position: absolute; inset: 0; display: block; background: #f1f3f1 center / cover no-repeat; transition: transform .8s var(--ease); transform-origin: center; }
.cat__img { position: relative; overflow: hidden; }
.card__media .card__pic { z-index: 0; }
.cat__sub { z-index: 1; }
.hits { padding: 10px 2px 26px; margin: -10px -2px -22px; }
@media (hover: hover) {
  .card:hover { transform: translateY(-6px); box-shadow: 0 20px 44px rgba(26, 26, 37, .14); border-color: rgba(0, 128, 0, .25); }
  .card:hover .card__pic { transform: scale(1.08); }
  .cat:hover { transform: translateY(-6px); box-shadow: 0 20px 44px rgba(26, 26, 37, .14); border-color: rgba(0, 128, 0, .25); }
  .cat:hover .cat__pic { transform: scale(1.1); }
  .cat:hover .cat__name { color: var(--green); }
  .hero__promo { transition: transform .5s var(--ease), box-shadow .5s var(--ease); }
  .hero__promo:hover { transform: translateY(-4px); box-shadow: 0 22px 48px rgba(0, 0, 0, .22); }
  .feat { transition: transform .35s var(--ease), box-shadow .35s var(--ease), background .3s; }
  .feat:not(.feat--active):hover { transform: translateY(-6px); box-shadow: 0 18px 40px rgba(26, 26, 37, .1); }
}
.cat__name { transition: color .25s; }
.card__title { transition: color .25s; }
.card:active, .cat:active { transform: scale(.985); }

/* ---------- кнопки ---------- */
.btn { transition: background .25s, box-shadow .3s, transform .25s var(--ease), color .2s, border-color .2s; }
.btn:active { transform: translateY(0) scale(.97); }
.btn img { transition: transform .3s var(--ease); }
@media (hover: hover) {
  .btn:hover { transform: translateY(-2px); }
  .btn--green:hover { box-shadow: 0 12px 26px rgba(0, 128, 0, .32); }
  .btn--white:hover { box-shadow: 0 12px 26px rgba(0, 0, 0, .22); }
  .btn--outline-green:hover, .btn--outline-white:hover { box-shadow: 0 10px 22px rgba(0, 0, 0, .12); }
  .btn:hover img[src*="arrow"] { transform: translateX(5px); }
}
.btn.is-in { animation: popIn .45s var(--ease); }
@keyframes popIn { 0% { transform: scale(.94); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* ---------- шапка и меню ---------- */
.header__phone, .header__callback, .header__login { transition: color .2s; }
.socials a, .footer__soc a { display: inline-flex; transition: transform .3s var(--ease); }
.hico__img { transition: transform .3s var(--ease); }
@media (hover: hover) {
  .socials a:hover, .footer__soc a:hover { transform: translateY(-3px) scale(1.12); }
  .hico:hover .hico__img { transform: scale(1.14); }
}
@media (min-width: 1101px) {
  .nav a { position: relative; }
  .nav a::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 5px; height: 2px; border-radius: 2px; background: var(--green); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
  .nav a:hover::after { transform: scaleX(1); }
}
@media (max-width: 1100px) {
  .header__nav { transition: box-shadow .3s; }
  body.is-scrolled .header__nav { box-shadow: 0 8px 22px rgba(26, 26, 37, .1); }
  body.menu-open .nav { animation: dropIn .3s var(--ease); }
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.search__drop:not([hidden]) { animation: dropIn .22s var(--ease); }

/* счётчики и иконки: «подпрыгивание» */
.is-bump { animation: bump .7s var(--ease); }
@keyframes bump { 0% { transform: scale(1); } 25% { transform: scale(1.28) rotate(-8deg); } 55% { transform: scale(.92) rotate(4deg); } 100% { transform: scale(1); } }
.count.is-pop { animation: countPop .5s var(--ease); }
@keyframes countPop { 0% { transform: scale(.4); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
.js-fav.is-pop img { animation: heartPop .55s var(--ease); }
@keyframes heartPop { 0% { transform: scale(1); } 35% { transform: scale(1.5); } 65% { transform: scale(.9); } 100% { transform: scale(1); } }
.icon-btn { transition: transform .25s var(--ease), opacity .2s; }

/* ---------- герой: смена слайдов, лёгкий «Ken Burns» ---------- */
.hero__main { isolation: isolate; }
.hero__bg { transition: opacity .4s ease; animation: kenburns 16s ease-in-out infinite alternate; transform-origin: 60% 50%; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.09); } }
.hero__body, .hero__foot { transition: opacity .4s ease, transform .5s var(--ease); }
#hero.is-swap .hero__bg { opacity: 0; }
#hero.is-swap .hero__body { opacity: 0; transform: translateY(16px); }
.hero__body h1 { animation: pageIn .9s var(--ease) .15s backwards; }
.hero__body p { animation: pageIn .9s var(--ease) .3s backwards; }
.hero__btns { animation: pageIn .9s var(--ease) .45s backwards; }
.dots button { width: 8px; transition: width .35s var(--ease), opacity .3s; }
.dots button.is-active { width: 26px; }

/* вкладки «Хит товары / Акции…» */
.tabs .tab, .tabs .tabs__title { position: relative; }
.tabs .tab::after, .tabs .tabs__title::after { content: ''; position: absolute; left: 0; right: 0; bottom: -6px; height: 3px; border-radius: 3px; background: var(--green); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease); }
.tabs .tab.is-active::after, .tabs .tabs__title.is-active::after, .tabs .tab:hover::after { transform: scaleX(1); }
.tabs .tabs__title::after { transform: scaleX(1); }
.tabs:has(.tab.is-active) .tabs__title::after { transform: scaleX(0); }
.arrow { transition: background .25s, transform .25s var(--ease), box-shadow .25s; }
@media (hover: hover) { .arrow:hover { transform: scale(1.1); box-shadow: 0 8px 20px rgba(0, 128, 0, .25); } }
.arrow:active { transform: scale(.94); }

/* ---------- скелетоны ---------- */
.card--sk { pointer-events: none; animation: none; }
.card--sk .card__media, .sk-l { background: linear-gradient(90deg, #eceeec 25%, #f6f8f6 37%, #eceeec 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.sk-l { height: 14px; margin: 16px 20px 0; border-radius: 7px; }
.sk-l--s { width: 55%; }
.sk-l--p { height: 42px; margin-top: 30px; margin-bottom: 20px; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.hits.is-loading, .grid.is-loading { transition: opacity .25s; }

/* ---------- страница товара ---------- */
.p-gallery__main { overflow: hidden; }
.p-gallery__main img { transition: transform .6s var(--ease), opacity .25s ease; transform-origin: var(--ox, 50%) var(--oy, 50%); }
.p-gallery__main img.is-fade { opacity: 0; }
@media (hover: hover) {
  .p-gallery__main { cursor: zoom-in; }
  .p-gallery__main:hover img { transform: scale(1.8); transition: transform .35s var(--ease); }
}
.thumb { transition: border-color .25s, transform .25s var(--ease), box-shadow .25s; }
@media (hover: hover) { .thumb:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(26, 26, 37, .14); } }
.thumb.is-active { box-shadow: 0 0 0 2px rgba(0, 128, 0, .2); }
.acc { transition: box-shadow .3s, border-color .3s; }
.acc__head { cursor: pointer; }
@media (hover: hover) { .acc:hover { box-shadow: 0 8px 26px rgba(26, 26, 37, .07); } }
.acc.is-open { border-color: rgba(0, 128, 0, .3); }
.acc.is-open .acc__body { animation: accIn .45s var(--ease); }
@keyframes accIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.acc__toggle { transition: transform .3s var(--ease), background .2s; }
.acc__toggle:hover { transform: scale(1.1); }
.p-kaspi { animation: pageIn .7s var(--ease) .2s backwards; }

/* ---------- модальные окна ---------- */
.modal:not([hidden]) { animation: fadeIn .25s ease; }
.modal:not([hidden]) .modal__box { animation: modalIn .4s var(--ease-out); }
@keyframes modalIn { from { opacity: 0; transform: translateY(28px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) { .modal:not([hidden]) .modal__box { animation: sheet-up .38s var(--ease-out); } }
.modal__close { transition: transform .3s var(--ease), background .2s; }
.modal__close:hover { transform: rotate(90deg); }
.sub__card { animation: cardIn .5s var(--ease) backwards; }
.sub__item:nth-child(2) .sub__card { animation-delay: .06s; } .sub__item:nth-child(3) .sub__card { animation-delay: .12s; } .sub__item:nth-child(n+4) .sub__card { animation-delay: .18s; }

/* ---------- подвал ---------- */
.footer__col a { display: inline-block; transition: color .2s, transform .25s var(--ease); }
@media (hover: hover) { .footer__col a:hover { transform: translateX(5px); } }

/* ---------- нижнее меню на телефоне ---------- */
.tb { transition: color .2s, transform .2s var(--ease); }
.tb:active { transform: scale(.9); }
.tb__ico { transition: transform .3s var(--ease); }
.page-home .tb--home .tb__ico, .page-catalog .tb--catalog .tb__ico, .page-product .tb--catalog .tb__ico, .page-favorites .tb--favorites .tb__ico, .page-cart .tb--cart .tb__ico, .page-checkout .tb--cart .tb__ico { transform: translateY(-2px) scale(1.1); }

/* ---------- индикатор прокрутки и «наверх» ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; z-index: 400; height: 3px; background: linear-gradient(90deg, var(--green), var(--lime)); transform: scaleX(var(--p, 0)); transform-origin: left; pointer-events: none; opacity: 0; transition: opacity .3s; }
body.is-scrolled #progress { opacity: 1; }
#toTop { position: fixed; right: 22px; bottom: 26px; z-index: 130; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--green); color: #fff; box-shadow: 0 10px 26px rgba(0, 128, 0, .38); opacity: 0; transform: translateY(16px) scale(.9); pointer-events: none; transition: opacity .3s, transform .35s var(--ease), background .2s; }
#toTop.is-show { opacity: 1; transform: none; pointer-events: auto; }
@media (hover: hover) { #toTop:hover { background: #006a00; transform: translateY(-3px); } }
@media (max-width: 760px) { #toTop { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 44px; height: 44px; } .page-product #toTop { bottom: calc(142px + env(safe-area-inset-bottom)); } }

/* ---------- полёт товара в корзину ---------- */
.fly { position: fixed; z-index: 500; width: 68px; height: 68px; border-radius: 16px; background: #fff center / cover no-repeat; border: 2px solid #fff; box-shadow: 0 14px 34px rgba(0, 0, 0, .3); pointer-events: none; }

/* ---------- уважение к настройкам «уменьшить движение» ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
  .hero__bg { animation: none !important; }
}
