/* stylelint-disable declaration-block-single-line-max-declarations, media-feature-name-value-no-unknown -- Phase 9: multi-declaration @keyframes steps kept on one line (the canonical readable keyframe idiom); `prefers-contrast: high` is a valid media value the linter's data lags on. Keyframes kebab-renamed (D9-07c); order/empty-line cleaned; reduced-motion !important + off-scale font-size carry scoped per-line disables. */

/**
 * Animations CSS - Entrance and interaction animations
 *
 * CASCADE-LAYER DISPOSITION (D9-06): animations.css declares `array('rhuarcs-style')`
 * as a wp_enqueue dependency, so it loads AFTER style.css. Its `.animate-spin`,
 * `.animate-pulse` and `.animate-bounce` utilities exactly collide with the same
 * UNLAYERED classes in utilities.css (the after-loading pair, layered in 09).
 * Layering this sheet while those competitors stay unlayered would let utilities.css
 * win (unlayered beats @layer) — a cascade regression. The animation utilities here
 * form one cohesive cohort coupled to those collisions, so the sheet is kept
 * UNLAYERED and reconciles in the atomic Plan 09-09 (style.css/utilities.css
 * co-layer). The 4 `!important` are reduced-motion guards (base.css:306 shape),
 * documented survivors (D9-07d).
 *
 * @package RhuarcsPetSupplies
 * @since 2.1.0
 */

/* ==========================================================================
   SCROLL-TRIGGERED ENTRANCE ANIMATIONS
   ========================================================================== */

/* Base state for animated elements */
.animate-on-scroll {
    opacity: 0;
    will-change: transform, opacity;
}

/* Fade up entrance */
.animate-fade-up {
    transform: translateY(40px);
}

.animate-fade-up.visible {
    animation: animate-fade-up 0.6s ease forwards;
}

@keyframes animate-fade-up {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade down entrance */
.animate-fade-down {
    transform: translateY(-40px);
}

.animate-fade-down.visible {
    animation: animate-fade-down 0.6s ease forwards;
}

@keyframes animate-fade-down {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade left entrance */
.animate-fade-left {
    transform: translateX(-40px);
}

.animate-fade-left.visible {
    animation: animate-fade-left 0.6s ease forwards;
}

@keyframes animate-fade-left {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade right entrance */
.animate-fade-right {
    transform: translateX(40px);
}

.animate-fade-right.visible {
    animation: animate-fade-right 0.6s ease forwards;
}

@keyframes animate-fade-right {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale up entrance */
.animate-scale-up {
    transform: scale(0.9);
}

.animate-scale-up.visible {
    animation: animate-scale-up 0.5s ease forwards;
}

@keyframes animate-scale-up {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Simple fade entrance */
.animate-fade {
    opacity: 0;
}

.animate-fade.visible {
    animation: animate-fade 0.5s ease forwards;
}

@keyframes animate-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ==========================================================================
   STAGGER DELAYS (for card grids)
   ========================================================================== */

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }
.stagger-9 { animation-delay: 0.45s; }
.stagger-10 { animation-delay: 0.5s; }
.stagger-11 { animation-delay: 0.55s; }
.stagger-12 { animation-delay: 0.6s; }

/* ==========================================================================
   HOVER ANIMATIONS
   ========================================================================== */

/* Lift on hover */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-6px);
}

/* Grow on hover */
.hover-grow {
    transition: transform var(--transition-base);
}

.hover-grow:hover {
    transform: scale(1.05);
}

/* Subtle grow */
.hover-grow-sm {
    transition: transform var(--transition-fast);
}

.hover-grow-sm:hover {
    transform: scale(1.02);
}

/* Bounce on hover */
.hover-bounce {
    transition: transform var(--transition-bounce);
}

.hover-bounce:hover {
    transform: translateY(-8px);
}

/* Shadow grow on hover */
.hover-shadow {
    transition: box-shadow var(--transition-base);
}

.hover-shadow:hover {
    box-shadow: var(--shadow-purple-md);
}

/* ==========================================================================
   LOADING ANIMATIONS
   ========================================================================== */

/* Pulse animation */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Spin animation */
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Bounce animation */
.animate-bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(-5%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }

    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* ==========================================================================
   ATTENTION GRABBING ANIMATIONS
   ========================================================================== */

/* Shake animation (for errors) */
.animate-shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Wiggle animation (for attention) */
.animate-wiggle {
    animation: wiggle 1s ease-in-out infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

/* Pop animation (for success) */
.animate-pop {
    animation: pop 0.3s ease-out;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ==========================================================================
   PAGE TRANSITION ANIMATIONS
   ========================================================================== */

/* Page enter */
.page-enter {
    animation: page-enter 0.4s ease-out;
}

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Page exit */
.page-exit {
    animation: page-exit 0.3s ease-in forwards;
}

@keyframes page-exit {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ==========================================================================
   HERO SECTION ANIMATIONS
   ========================================================================== */

/* Hero content entrance */
.hero-animate {
    opacity: 0;
}

.hero-animate.loaded {
    animation: hero-entrance 0.8s ease-out forwards;
}

@keyframes hero-entrance {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero title special animation */
.hero-title-animate.loaded {
    animation: hero-title-entrance 0.8s ease-out forwards;
}

@keyframes hero-title-entrance {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Hero subtitle with delay */
.hero-subtitle-animate.loaded {
    opacity: 0;
    animation: hero-subtitle-entrance 0.6s ease-out 0.2s forwards;
}

@keyframes hero-subtitle-entrance {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero CTA with delay */
.hero-cta-animate.loaded {
    opacity: 0;
    animation: hero-cta-entrance 0.5s ease-out 0.4s forwards;
}

@keyframes hero-cta-entrance {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   CARD ENTRANCE ANIMATIONS
   ========================================================================== */

/* Card grid entrance */
.card-entrance {
    opacity: 0;
    transform: translateY(30px);
}

.card-entrance.visible {
    animation: card-entrance 0.5s ease-out forwards;
}

@keyframes card-entrance {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Product card special entrance */
.product-card-entrance {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
}

.product-card-entrance.visible {
    animation: product-card-entrance 0.6s ease-out forwards;
}

@keyframes product-card-entrance {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   COUNTER/NUMBER ANIMATIONS
   ========================================================================== */

/* Number count up container */
.count-up {
    font-variant-numeric: tabular-nums;
}

/* Stats number pop */
.stat-value-animate {
    opacity: 0;
}

.stat-value-animate.visible {
    animation: stat-pop 0.6s ease-out forwards;
}

@keyframes stat-pop {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }

    70% {
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   ICON ANIMATIONS
   ========================================================================== */

/* Heart beat (for favorites) */
.icon-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14% { transform: scale(1.15); }
    28% { transform: scale(1); }
    42% { transform: scale(1.15); }
    70% { transform: scale(1); }
}

/* Icon rotate on hover parent */
.icon-rotate-on-hover:hover .icon {
    transform: rotate(15deg);
    transition: transform var(--transition-fast);
}

/* ==========================================================================
   SKELETON LOADING ANIMATIONS
   ========================================================================== */

.skeleton-shimmer,
.skeleton {
    background: linear-gradient(
        90deg,
        var(--sand-100) 25%,
        var(--cream-200) 50%,
        var(--sand-100) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ==========================================================================
   NOTIFICATION ANIMATIONS
   ========================================================================== */

/* Toast slide in */
.toast-enter {
    animation: toast-enter 0.3s ease-out;
}

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Toast slide out */
.toast-exit {
    animation: toast-exit 0.2s ease-in forwards;
}

@keyframes toast-exit {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ==========================================================================
   FLOATING ELEMENTS
   ========================================================================== */

/* Gentle float */
.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Slower float for backgrounds */
.float-slow {
    animation: float 6s ease-in-out infinite;
}

/* ==========================================================================
   WHIMSY MICRO-INTERACTIONS
   ========================================================================== */

/* Cursor paw trail — follows mouse inside .featured-products-section */
.whimsy-paw-trail {
    position: absolute;
    z-index: var(--z-toast);
    /* stylelint-disable-next-line scale-unlimited/declaration-strict-value -- decorative paw-emoji glyph size; no byte-exact token, kept literal for zero visual delta (D9-05) */
    font-size: 1rem;
    animation: whimsy-paw-fade 0.9s ease-out forwards;
    pointer-events: none;
    user-select: none;
    will-change: opacity, transform;
}

@keyframes whimsy-paw-fade {
    0%   { opacity: 0.75; transform: scale(0.8) rotate(-15deg); }
    50%  { opacity: 0.45; transform: scale(1.05) rotate(-5deg); }
    100% { opacity: 0;    transform: scale(0.6) translateY(-18px) rotate(8deg); }
}

/* Filter celebration — paw prints burst from grid centre */
.whimsy-burst-paw {
    position: absolute;
    z-index: var(--z-toast);
    /* stylelint-disable-next-line scale-unlimited/declaration-strict-value -- decorative paw-emoji glyph size; no byte-exact token, kept literal for zero visual delta (D9-05) */
    font-size: 1.4rem;
    animation: whimsy-burst 0.75s ease-out forwards;
    pointer-events: none;
    user-select: none;
    will-change: opacity, transform;
}

@keyframes whimsy-burst {
    0%   { opacity: 1;   transform: scale(0.3) rotate(0deg); }
    60%  { opacity: 0.6; }
    100% { opacity: 0;   transform: scale(2.2) rotate(40deg) translateY(-35px); }
}

/* ==========================================================================
   VIEW TRANSITIONS (cross-document MPA, Chrome 126+ / progressive enhancement)
   ========================================================================== */

/* Enable same-origin cross-document view transitions automatically */
@view-transition {
    navigation: auto;
}

/* Default root cross-fade — short so it feels snappy, not sluggish */
::view-transition-old(root) {
    animation: 180ms ease-out both vt-root-out;
}

::view-transition-new(root) {
    animation: 280ms ease-out both vt-root-in;
}

@keyframes vt-root-out {
    from { opacity: 1; }
    to   { opacity: 0; transform: scale(0.99); }
}

@keyframes vt-root-in {
    from { opacity: 0; transform: scale(1.01); }
    to   { opacity: 1; transform: scale(1); }
}

/* Product image hero cross-fade — the named transition from archive → single */
::view-transition-old(product-hero) {
    animation: 380ms ease-in-out both vt-product-out;
}

::view-transition-new(product-hero) {
    animation: 420ms ease-in-out both vt-product-in;
}

@keyframes vt-product-out {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.95); }
}

@keyframes vt-product-in {
    from { opacity: 0; transform: scale(1.05); }
    to   { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   SCROLL-DRIVEN ANIMATION ENHANCEMENT
   Progressive enhancement: in supporting browsers (Chrome 115+, Firefox 114+)
   the IntersectionObserver-based .visible class becomes redundant — the CSS
   animation plays automatically as elements enter the viewport. Browsers
   without support still get the JS-driven approach.
   ========================================================================== */

@supports (animation-timeline: view()) {
    .animate-on-scroll.animate-fade-up {
        animation: animate-fade-up auto linear both;
        animation-timeline: view();
        animation-range: entry 5% entry 65%;
    }

    .animate-on-scroll.animate-fade-down {
        animation: animate-fade-down auto linear both;
        animation-timeline: view();
        animation-range: entry 5% entry 65%;
    }

    .animate-on-scroll.animate-fade-left {
        animation: animate-fade-left auto linear both;
        animation-timeline: view();
        animation-range: entry 5% entry 65%;
    }

    .animate-on-scroll.animate-fade-right {
        animation: animate-fade-right auto linear both;
        animation-timeline: view();
        animation-range: entry 5% entry 65%;
    }

    .animate-on-scroll.animate-scale-up {
        animation: animate-scale-up auto linear both;
        animation-timeline: view();
        animation-range: entry 5% entry 60%;
    }

    .animate-on-scroll.animate-fade {
        animation: animate-fade auto linear both;
        animation-timeline: view();
        animation-range: entry 5% entry 55%;
    }

    .animate-on-scroll.card-entrance {
        animation: card-entrance auto linear both;
        animation-timeline: view();
        animation-range: entry 5% entry 60%;
    }
}

/* ==========================================================================
   REDUCED MOTION SUPPORT
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    /* stylelint-disable declaration-no-important -- reduced-motion accessibility guard: must override every animation/transition regardless of source order/specificity (base.css:306 shape, D9-07d) */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    /* stylelint-enable declaration-no-important */

    .animate-on-scroll,
    .animate-fade-up,
    .animate-fade-down,
    .animate-fade-left,
    .animate-fade-right,
    .animate-scale-up,
    .animate-fade,
    .hero-animate,
    .card-entrance,
    .product-card-entrance,
    .stat-value-animate {
        opacity: 1;
        transform: none;
    }

    .hover-lift:hover,
    .hover-grow:hover,
    .hover-grow-sm:hover,
    .hover-bounce:hover {
        transform: none;
    }

    .animate-pulse,
    .animate-spin,
    .animate-bounce,
    .animate-wiggle,
    .float,
    .float-slow,
    .icon-heartbeat {
        animation: none;
    }

    /* Suppress cross-document view transitions for motion-sensitive users */
    ::view-transition-group(*),
    ::view-transition-image-pair(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        /* stylelint-disable-next-line declaration-no-important -- reduced-motion accessibility guard: must suppress view transitions regardless of source order (D9-07d) */
        animation: none !important;
    }
}

/* ==========================================================================
   HIGH CONTRAST MODE
   ========================================================================== */

@media (prefers-contrast: high) {
    .skeleton-shimmer,
    .skeleton {
        background: var(--sand-200);
        animation: none;
    }
}
