/**
 * Aurora Cabinet — уместные UI-анимации (sidebar layout + auth)
 * Только opacity/transform; уважает prefers-reduced-motion.
 */

/* ===== Staggered reveal (только opacity — без translate, чтобы не налезать на header) ===== */
.cab-enter {
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--cab-enter-delay, 0ms);
}

.cab-enter.cab-enter--visible {
  opacity: 1;
}

/* ===== Section content swap ===== */
.account-sidebar-layout .account-section--active.cab-section--animating {
  animation: cab-section-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cab-section-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===== Header title crossfade ===== */
.account-sidebar-layout .account-main-header__text.cab-header--swap .account-main-title,
.account-sidebar-layout .account-main-header__text.cab-header--swap .account-main-subtitle {
  animation: cab-header-swap 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cab-header-swap {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* ===== Sidebar nav: плавный сдвиг вправо при наведении ===== */
.account-sidebar-layout .account-sidebar__link {
  position: relative;
  transform: translateX(0);
  transition:
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.22s ease,
    box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.account-sidebar-layout .account-sidebar__link:hover {
  transform: translateX(5px);
}

.account-sidebar-layout .account-sidebar__link--active:hover {
  transform: translateX(4px);
}

.account-sidebar-layout .account-sidebar__link::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #a78bfa, var(--cab-accent, #7c5cff));
  box-shadow: 0 0 12px rgba(124, 92, 255, 0.45);
  transform: translateY(-50%);
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  transition:
    height 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease;
}

.account-sidebar-layout .account-sidebar__link--active::after {
  height: 58%;
  opacity: 1;
}

.account-sidebar-layout .account-sidebar__link--active {
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.12);
}

.account-sidebar-layout .account-sidebar__badge {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}

.account-sidebar-layout .account-sidebar__link--active .account-sidebar__badge {
  transform: scale(1.04);
  background: rgba(124, 92, 255, 0.22);
}

/* Плавное появление пункта «Статистика» после загрузки профиля расширения */
@keyframes cab-sidebar-stats-in {
  0% {
    opacity: 0;
    transform: translateX(-10px) scaleY(0.9);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scaleY(1);
  }
}

.account-sidebar-layout .account-sidebar__link--stats.account-sidebar__link--stats-in {
  transform-origin: left center;
  animation: cab-sidebar-stats-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ===== Premium crown ===== */
.account-sidebar-layout .account-main-title__crown {
  animation: cab-crown-glow 3.2s ease-in-out infinite;
}

@keyframes cab-crown-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 6px rgba(245, 197, 66, 0.35));
    transform: scale(1) rotate(0deg);
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(245, 197, 66, 0.65));
    transform: scale(1.06) rotate(-4deg);
  }
}

/* ===== Cards & tiles ===== */
.account-sidebar-layout .cab-card {
  transition:
    border-color 0.25s ease,
    box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.25s ease;
}

@media (min-width: 769px) {
  .account-sidebar-layout .cab-card:hover {
    border-color: rgba(124, 92, 255, 0.22);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 14px 40px rgba(14, 14, 18, 0.14),
      0 0 0 1px rgba(124, 92, 255, 0.06);
  }

  .account-sidebar-layout .overview-action:hover {
    border-color: rgba(124, 92, 255, 0.28);
  }
}

.account-sidebar-layout .overview-stat__icon {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.account-sidebar-layout .overview-stat:hover .overview-stat__icon {
  transform: scale(1.06);
}

.account-sidebar-layout .overview-stat--premium .overview-stat__icon i {
  animation: cab-icon-float 4.5s ease-in-out infinite;
}

.account-sidebar-layout .overview-upsell {
  position: relative;
  overflow: hidden;
}

.account-sidebar-layout .overview-upsell::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    115deg,
    transparent 20%,
    rgba(124, 92, 255, 0.35) 45%,
    rgba(167, 139, 250, 0.2) 55%,
    transparent 80%
  );
  background-size: 220% 100%;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.55;
  animation: cab-border-shimmer 7s ease-in-out infinite;
  pointer-events: none;
}

@keyframes cab-icon-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -3px, 0);
  }
}

@keyframes cab-border-shimmer {
  0%,
  100% {
    background-position: 0% 50%;
    opacity: 0.35;
  }
  50% {
    background-position: 100% 50%;
    opacity: 0.75;
  }
}

/* ===== Buttons ===== */
.account-sidebar-layout .cab-btn {
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.22s ease;
}

.account-sidebar-layout .cab-btn--primary:hover {
  transform: translate3d(0, -1px, 0);
  box-shadow: 0 6px 24px var(--cab-accent-glow, rgba(124, 92, 255, 0.28));
}

.account-sidebar-layout .cab-btn:active {
  transform: translate3d(0, 0, 0) scale(0.98);
}

/* ===== Subscription ring ===== */
.account-sidebar-layout .sub-progress-ring__fill {
  transition: stroke-dashoffset 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.account-sidebar-layout .sub-hero__ring.cab-ring--animate .sub-progress-ring__fill {
  animation: cab-ring-draw 1.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.account-sidebar-layout .sub-progress-ring__label {
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.account-sidebar-layout .sub-hero__ring.cab-ring--animate .sub-progress-ring__label {
  animation: cab-ring-label 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.35s both;
}

@keyframes cab-ring-draw {
  from {
    stroke-dashoffset: 283;
    opacity: 0.4;
  }
}

@keyframes cab-ring-label {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== Modals & overlays ===== */
/* buy-overlay: стабильная ширина с первого кадра, без transform на боксе/карточках */
.buy-overlay__box {
  width: min(calc(100vw - 40px), 880px);
  max-width: min(calc(100vw - 40px), 880px);
  flex: 0 1 auto;
  min-width: 0;
  box-sizing: border-box;
}

.buy-overlay__grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .buy-overlay__box {
    width: min(calc(100vw - 20px), 880px);
    max-width: min(calc(100vw - 20px), 880px);
  }

  .buy-overlay__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .buy-overlay__box {
    width: min(calc(100vw - 12px), 880px);
    max-width: min(calc(100vw - 12px), 880px);
  }

  .buy-overlay__grid {
    grid-template-columns: 1fr;
  }
}

/* Только лёгкий fade — без transform, чтобы не ломать раскладку */
.buy-overlay[aria-hidden="false"] .buy-overlay__backdrop {
  animation: cab-overlay-fade-in 0.22s ease both;
}

.buy-overlay[aria-hidden="false"] .buy-overlay__box {
  animation: cab-buy-box-fade 0.22s ease both;
}

@keyframes cab-overlay-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cab-buy-box-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.review-modal-overlay[aria-hidden="false"] .review-modal,
.review-modal-overlay[aria-hidden="false"] .license-prompt {
  animation: cab-buy-box-fade 0.28s ease both;
}

/* Tip bar: анимация через .cab-enter в script.js */

/* ===== Auth pages (login / register) ===== */
body.account-chamber-bg .login-card {
  animation: cab-auth-in 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

body.account-chamber-bg .modal {
  animation: cab-auth-in 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cab-auth-in {
  from {
    opacity: 0;
    transform: translate3d(0, 22px, 0) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* ===== Avatar shimmer ===== */
.account-sidebar-layout .account-sidebar__user-avatar {
  position: relative;
  overflow: hidden;
}

.account-sidebar-layout .account-sidebar__user-avatar::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    120deg,
    transparent 35%,
    rgba(255, 255, 255, 0.22) 50%,
    transparent 65%
  );
  transform: translateX(-120%) rotate(8deg);
  animation: cab-avatar-shine 6s ease-in-out infinite;
}

@keyframes cab-avatar-shine {
  0%,
  72%,
  100% {
    transform: translateX(-120%) rotate(8deg);
  }
  82% {
    transform: translateX(120%) rotate(8deg);
  }
}

/* ===== Mobile: короче и легче ===== */
@media (max-width: 768px) {
  .cab-enter {
    transition-duration: 0.4s;
  }

  .account-sidebar-layout .account-section--active.cab-section--animating {
    animation-duration: 0.32s;
  }

  .account-sidebar-layout .overview-stat--premium .overview-stat__icon i {
    animation: none;
  }

  .account-sidebar-layout .overview-upsell::before {
    animation: none;
    opacity: 0.35;
  }

  .account-sidebar-layout .account-sidebar__user-avatar::after {
    animation: none;
  }

@media (prefers-reduced-motion: reduce) {
  .cab-enter,
  .cab-enter.cab-enter--visible,
  .account-sidebar-layout .account-section--active.cab-section--animating,
  body.account-on-home .overview-tip,
  body.account-chamber-bg .login-card,
  body.account-chamber-bg .modal,
  .account-sidebar-layout .account-main-title__crown,
  .account-sidebar-layout .overview-stat--premium .overview-stat__icon i,
  .account-sidebar-layout .overview-upsell::before,
  .account-sidebar-layout .account-sidebar__user-avatar::after {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .account-sidebar-layout .account-sidebar__link:hover {
    transform: none !important;
  }

  .account-sidebar-layout .account-sidebar__link--stats.account-sidebar__link--stats-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .account-sidebar-layout .account-main-subtitle--home-cycle .account-main-subtitle__phrase {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .buy-overlay[aria-hidden="false"] .buy-overlay__box,
  .buy-overlay[aria-hidden="false"] .buy-overlay__backdrop,
  .review-modal-overlay,
  .review-modal-overlay .review-modal,
  .review-modal-overlay .license-prompt {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
} /* close @media (max-width: 768px) — was missing (pre-existing bug fix) */

/* ═══════════════════════════════════════════════════════════════
   Page preloader: sidebar-layout context
   (primary styles are inline in <head> for instant render;
    this block adds context-specific overrides)
   ═══════════════════════════════════════════════════════════════ */

/* Prevent content from being visible through the preloader overlay */
html.cab-loading body > *:not(#cab-preloader) {
  pointer-events: none;
}

/* Reduced-motion: disable activity-indicator bars, use instant hide */
@media (prefers-reduced-motion: reduce) {
  .cab-tick::before {
    animation: none !important;
    opacity: 0.25 !important;
  }
  #cab-preloader,
  #cab-preloader.cab-preloader--out {
    transition: none !important;
  }
}
