/* ==========================================================================
   Ayuvani — animated category icons
   --------------------------------------------------------------------------
   Styles the icon set in web-views/partials/_category-icon.blade.php,
   which replaces the uploaded category thumbnails — small raster images
   from the catalogue import, in a style that matched nothing else here.

   TWO SPEEDS, DELIBERATELY
   Up to eight of these sit in one row on the homepage. Eight things
   looping at full energy is a fairground, so the idle motion is slow,
   small and staggered, and the livelier movement is kept for hover —
   where there is only ever one.

   Staggering matters as much as slowing: eight icons breathing in unison
   reads as a page-wide pulse and is far more distracting than eight
   drifting independently. Every idle loop below gets a different duration
   via :nth-child on the tile, further down.

   Transforms and opacity only, so the compositor does the work and a row
   of eight costs no layout.
   ========================================================================== */

.ayv-cat {
    --ayv-forest: #1b3a19;
    --ayv-leaf: #2f6b2c;
    --ayv-sun: #f7e52e;
    --ayv-sun-deep: #e3cf1c;
    --ayv-cat-size: 56px;

    display: inline-grid;
    place-items: center;
    width: var(--ayv-cat-size);
    height: var(--ayv-cat-size);
    border-radius: 50%;
    /* A soft disc behind the line art, so an icon reads as an object on
       light cards and on the white homepage card alike. */
    background: radial-gradient(circle at 32% 26%, #f2f8ec 0%, #e3efdb 70%, #d9e9ce 100%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease;
}

.ayv-cat svg {
    width: 68%;
    height: 68%;
    overflow: visible;
}

/* Strokes, shared. Every shape in every icon is one of these. */
.ayv-cat__body,
.ayv-cat__strand,
.ayv-cat__steam,
.ayv-cat__pestle,
.ayv-cat__ray,
.ayv-cat__liquid,
.ayv-cat__leaf,
.ayv-cat__sun {
    fill: none;
    stroke: var(--ayv-forest);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ayv-cat__sun { stroke: var(--ayv-sun-deep); stroke-width: 3; }
.ayv-cat__leaf,
.ayv-cat__liquid { stroke: var(--ayv-leaf); }
.ayv-cat__drop,
.ayv-cat__spark,
.ayv-cat__bubble { fill: var(--ayv-sun); stroke: none; }

/* --------------------------------------------------------------------------
   Idle motion — one small loop per icon family.
   -------------------------------------------------------------------------- */

/* Tinctures and tubes: a drop forms, falls, and is gone. The long tail of
   the keyframe is empty on purpose — a drop every few seconds reads as
   dispensing; a constant stream reads as a leak. */
.ayv-cat__drop {
    transform-box: view-box;
    animation: ayv-cat-drip 4.5s ease-in infinite;
}

@keyframes ayv-cat-drip {
    0%        { transform: translateY(0); opacity: 0; }
    8%        { opacity: 1; }
    30%       { transform: translateY(11px); opacity: 1; }
    36%       { transform: translateY(13px); opacity: 0; }
    37%, 100% { transform: translateY(0); opacity: 0; }
}

/* Tablets, skin, personal care: a slow glow. */
.ayv-cat__spark {
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: ayv-cat-glow 5s ease-in-out infinite;
}

@keyframes ayv-cat-glow {
    0%, 100% { transform: scale(0.88); opacity: 0.75; }
    50%      { transform: scale(1.1);  opacity: 1; }
}

/* Food: steam. Three strokes rising and fading out of phase. */
.ayv-cat__steam {
    transform-box: view-box;
    opacity: 0;
    animation: ayv-cat-steam 4s ease-out infinite;
}

.ayv-cat__steam--1 { animation-delay: 0s; }
.ayv-cat__steam--2 { animation-delay: 0.5s; }
.ayv-cat__steam--3 { animation-delay: 1s; }

@keyframes ayv-cat-steam {
    0%   { transform: translateY(4px); opacity: 0; }
    25%  { opacity: 0.9; }
    70%  { transform: translateY(-4px); opacity: 0; }
    100% { transform: translateY(-4px); opacity: 0; }
}

/* Hair: strands sway, each a little behind the last. */
.ayv-cat__strand {
    transform-box: view-box;
    transform-origin: 50% 0%;
    animation: ayv-cat-sway 5s ease-in-out infinite;
}

.ayv-cat__strand--2 { animation-delay: 0.35s; }
.ayv-cat__strand--3 { animation-delay: 0.7s; }

@keyframes ayv-cat-sway {
    0%, 100% { transform: skewX(0deg); }
    50%      { transform: skewX(4deg); }
}

/* Baby: bubbles rising inside the bottle. */
.ayv-cat__bubble {
    transform-box: view-box;
    opacity: 0;
    animation: ayv-cat-bubble 4.5s ease-in-out infinite;
}

.ayv-cat__bubble--2 { animation-delay: 1.4s; }

@keyframes ayv-cat-bubble {
    0%   { transform: translateY(2px);  opacity: 0; }
    25%  { opacity: 0.95; }
    75%  { transform: translateY(-10px); opacity: 0; }
    100% { transform: translateY(-10px); opacity: 0; }
}

/* Mortar: the pestle rocks. Small angle — it is grinding, not stirring. */
.ayv-cat__pestle {
    transform-box: view-box;
    transform-origin: 19px 21px;
    animation: ayv-cat-grind 4.5s ease-in-out infinite;
}

@keyframes ayv-cat-grind {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-11deg); }
}

/* Syrup: the liquid level tilts, as if the bottle were just set down. */
.ayv-cat__liquid {
    transform-box: view-box;
    transform-origin: 24px 35px;
    animation: ayv-cat-tilt 6s ease-in-out infinite;
}

@keyframes ayv-cat-tilt {
    0%, 100% { transform: rotate(-1.5deg); }
    50%      { transform: rotate(1.5deg); }
}

/* Supplements: the leaf lifts. */
.ayv-cat__leaf {
    transform-box: view-box;
    transform-origin: 24px 36px;
    animation: ayv-cat-lift 5.5s ease-in-out infinite;
}

@keyframes ayv-cat-lift {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-7deg); }
}

/* The fallback sun: rays breathe. */
.ayv-cat__ray {
    transform-box: view-box;
    transform-origin: 24px 32px;
    animation: ayv-cat-rays 5s ease-in-out infinite;
}

@keyframes ayv-cat-rays {
    0%, 100% { transform: scale(0.94); opacity: 0.8; }
    50%      { transform: scale(1.04); opacity: 1; }
}

/* Capsule halves, barely parting. */
.ayv-cat__cap-a,
.ayv-cat__cap-b {
    transform-box: view-box;
    animation: ayv-cat-split 5s ease-in-out infinite;
}

.ayv-cat__cap-b { animation-name: ayv-cat-split-b; }

@keyframes ayv-cat-split {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(-1px, -1px); }
}

@keyframes ayv-cat-split-b {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(1px, 1px); }
}

/* Flower petals, opening a little. */
.ayv-cat__petals {
    transform-box: view-box;
    transform-origin: 24px 21px;
    animation: ayv-cat-bloom 6s ease-in-out infinite;
}

@keyframes ayv-cat-bloom {
    0%, 100% { transform: scale(0.95) rotate(0deg); }
    50%      { transform: scale(1.03) rotate(4deg); }
}

/* --------------------------------------------------------------------------
   Stagger.
   Eight icons on one loop pulse together and read as the page breathing.
   Nudging each one's duration breaks them apart without anyone being able
   to say why it looks calmer.
   -------------------------------------------------------------------------- */
.ayv-cat:nth-child(2n) svg * { animation-duration: 5.4s; }
.ayv-cat:nth-child(3n) svg * { animation-duration: 6.1s; }
.ayv-cat:nth-child(5n) svg * { animation-duration: 4.7s; }

/* --------------------------------------------------------------------------
   Hover.
   The livelier half of the design. Only ever one at a time, so it can
   afford to be more than the idle loop.
   -------------------------------------------------------------------------- */
a:hover > .ayv-cat,
a:focus-visible > .ayv-cat,
.ayv-cat:hover,
a:hover .ayv-cat,
a:focus-visible .ayv-cat {
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 14px 24px -14px rgba(27, 58, 25, 0.75);
}

a:hover .ayv-cat .ayv-cat__drop,
a:hover .ayv-cat .ayv-cat__bubble,
a:hover .ayv-cat .ayv-cat__steam {
    animation-duration: 1.6s;
}

a:hover .ayv-cat .ayv-cat__spark,
a:hover .ayv-cat .ayv-cat__ray,
a:hover .ayv-cat .ayv-cat__leaf,
a:hover .ayv-cat .ayv-cat__pestle,
a:hover .ayv-cat .ayv-cat__petals,
a:hover .ayv-cat .ayv-cat__strand {
    animation-duration: 1.8s;
}

/* --------------------------------------------------------------------------
   Reduced motion.
   None. Every loop here is decoration on a navigation tile — the icon
   says exactly as much standing still. The hover lift stays: that is
   feedback, and it is a transition rather than an animation.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .ayv-cat svg * {
        animation: none !important;
    }

    /* Things whose idle keyframe starts invisible need putting back. */
    .ayv-cat__drop,
    .ayv-cat__bubble,
    .ayv-cat__steam {
        opacity: 1;
    }
}


/* --------------------------------------------------------------------------
   Theme hook: the all-categories page (/categories).

   Its tiles style `.brand_div img` directly — 50px square, a border, and
   `margin: 0 auto 15px`. The icon here is a <span>, not an <img>, so none
   of that lands and the label ends up jammed against the artwork. This
   restores the spacing the tile was designed around.

   Scoped to .brand_div rather than written into .ayv-cat itself, because
   the margin belongs to that layout, not to the icon.
   -------------------------------------------------------------------------- */
.brand_div .ayv-cat {
    margin: 0 auto 15px;
}

/* The tile's own hover already scales the image; match it for the icon so
   the two pages behave the same. The lift comes from the shared rule. */
.brand_div:hover .ayv-cat {
    transform: translateY(-3px) scale(1.08);
}

/* --------------------------------------------------------------------------
   Mini variant — the 20px slots beside a text label.
   Header mega-menu, homepage category sidebar, product filters.

   Same drawing, three changes:

   1. NO IDLE ANIMATION. At 20px a drip or a sway is not read as motion,
      only as flicker, and a mega-menu can show dozens at once. The
      homepage tiles keep the motion because they have the room.
   2. HEAVIER STROKE. 2.4 units in a 48-unit viewBox scaled to 20px lands
      near half a device pixel, which renders as a grey smudge. 3.4 holds
      the shape.
   3. NO DISC. A filled circle behind a 20px glyph beside 13px text reads
      as a bullet, and the theme already puts these in a round frame.
   -------------------------------------------------------------------------- */
.ayv-cat--mini {
    background: none;
    border-radius: 0;
    flex: none;
}

.ayv-cat--mini svg {
    width: 100%;
    height: 100%;
}

.ayv-cat--mini svg * {
    animation: none !important;
}

.ayv-cat--mini .ayv-cat__body,
.ayv-cat--mini .ayv-cat__strand,
.ayv-cat--mini .ayv-cat__steam,
.ayv-cat--mini .ayv-cat__pestle,
.ayv-cat--mini .ayv-cat__ray,
.ayv-cat--mini .ayv-cat__liquid,
.ayv-cat--mini .ayv-cat__leaf {
    stroke-width: 3.4;
}

.ayv-cat--mini .ayv-cat__sun {
    stroke-width: 4;
}

/* The keyframes these belong to start at opacity 0; with the animation
   off they would simply never appear. */
.ayv-cat--mini .ayv-cat__drop,
.ayv-cat--mini .ayv-cat__bubble,
.ayv-cat--mini .ayv-cat__steam {
    opacity: 1;
}

/* The shared hover lift is wrong here — these sit in menu rows, not on
   tiles, and a glyph jumping as the row highlights is distracting. */
a:hover .ayv-cat--mini,
a:focus-visible .ayv-cat--mini,
label:hover .ayv-cat--mini {
    transform: none;
    box-shadow: none;
}

/* --------------------------------------------------------------------------
   Two icons added 2026-11-07 for the categories created with the product
   import. Without these both would fall through to the Ayuvani sun, which
   is a fine fallback but says nothing about what is in the category.
   -------------------------------------------------------------------------- */

/* Eye drops. The iris drifts rather than blinks: a blink at 20px reads as
   a flicker, and these icons appear at 20px in the menu. */
.ayv-cat__iris {
    fill: none;
    stroke: var(--ayv-leaf);
    stroke-width: 2.4;
    transform-box: view-box;
    transform-origin: 24px 24px;
    animation: ayv-cat-look 6s ease-in-out infinite;
}

@keyframes ayv-cat-look {
    0%, 100% { transform: translateX(-2.5px); }
    50%      { transform: translateX(2.5px); }
}

/* Globules settling in the vial. Staggered so they do not bob in unison,
   which would read as one object rather than three pellets. */
.ayv-cat__pellet {
    fill: var(--ayv-sun);
    stroke: var(--ayv-forest);
    stroke-width: 1.8;
    transform-box: view-box;
    animation: ayv-cat-settle 4.5s ease-in-out infinite;
}

.ayv-cat__pellet--2 { animation-delay: .5s; }
.ayv-cat__pellet--3 { animation-delay: 1s; }

@keyframes ayv-cat-settle {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2.5px); }
}

/* Mini variant: same treatment as every other icon, no idle motion. */
.ayv-cat--mini .ayv-cat__iris { stroke-width: 3.4; }
.ayv-cat--mini .ayv-cat__pellet { stroke-width: 2.4; }
