/* Home page only: one small leaf, a brighter shade (#1a9aa8) of the
   Order Now teal, that turns up around the page. Decoration only, so
   everything hangs off pseudo-elements placed clear of the layout: nothing
   here moves the page.
   --leaf holds the drawing; its stem is at the bottom left, so it can stand
   on an edge. --leaf-flip mirrors it for Arabic. */
:root {
    --leaf: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231a9aa8'%3E%3Cpath d='M5.2 18.2C3.6 10.5 9 3.6 21 3 15 6 9.5 11 5.2 18.2Z'/%3E%3Cpath d='M6.7 19.4C11 12 16 7 21 3.4 21.6 14.8 14.8 21.5 6.7 19.4Z'/%3E%3Cpath d='M6 18.6 3 21.6' fill='none' stroke='%231a9aa8' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    --leaf-rule: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 132 26'%3E%3Cpath d='M0 13H50M82 13H132' fill='none' stroke='%231a9aa8'/%3E%3C/svg%3E");
    --leaf-flip: 1;
}

[dir="rtl"] {
    --leaf-flip: -1;
}

.section-title::before,
.about-text p:last-child > span::after,
.footer-content::after {
    content: '';
    background: var(--leaf) center / contain no-repeat;
    transform: scaleX(var(--leaf-flip));
    pointer-events: none;
}

/* Every section title: a thin line with the leaf resting on it. It sits in
   the gap under the title, which keeps its height. The leaf and the line are
   separate pieces so that they can animate separately. */
.section-title {
    position: relative;
}

.section-title::before,
.section-title::after {
    position: absolute;
    top: 100%;
    left: 50%;
    height: 26px;
}

.section-title::before {
    width: 26px;
    margin: 10px 0 0 -13px;
}

.section-title::after {
    content: '';
    width: 132px;
    margin: 10px 0 0 -66px;
    background: var(--leaf-rule) center / contain no-repeat;
}

/* About: closes the text the way an ornament closes a chapter. */
.about-text p:last-child > span::after {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-inline-start: 7px;
    vertical-align: -3px;
}

/* Footer: the leaf rests on the line above the copyright. */
.footer-content {
    position: relative;
}

.footer-content::after {
    position: absolute;
    left: 50%;
    bottom: -51px;
    width: 22px;
    height: 22px;
    margin-left: -11px;
}

/* Phones: each leaf slowly unfurls, stem to tip, the first time it scrolls
   into view, with no bounce. js/leaves.js sets .leaf-wait, which hides it
   until then, and swaps it for .leaf-grow; so without that script the leaves
   simply stay visible. */
@media (max-width: 768px) {
    .leaf-wait::before,
    .leaf-wait::after,
    .leaf-wait > span::after {
        opacity: 0;
    }

    .leaf-grow::after,
    .leaf-grow > span::after,
    .section-title.leaf-grow::before {
        transform-origin: 50% 90%;
        animation: leafGrow 1.9s cubic-bezier(0.33, 0, 0.15, 1) both;
    }

    /* On a title the line draws out first and the leaf follows it. */
    .section-title.leaf-grow::before {
        animation-delay: 0.45s;
    }

    .section-title.leaf-grow::after {
        animation: leafRule 1.7s cubic-bezier(0.33, 0, 0.15, 1) both;
    }

    /* Reduced motion: only a fade. */
    @media (prefers-reduced-motion: reduce) {
        .leaf-grow::after,
        .leaf-grow > span::after,
        .section-title.leaf-grow::before,
        .section-title.leaf-grow::after {
            animation-name: leafFade;
        }
    }
}

/* The circle opens from the stem, drawn at 12% 88% of the box, to the tip. */
@keyframes leafGrow {
    from {
        opacity: 0;
        clip-path: circle(0% at 12% 88%);
        transform: scaleX(var(--leaf-flip)) scale(0.86) rotate(-14deg);
    }

    35% {
        opacity: 1;
    }

    to {
        opacity: 1;
        clip-path: circle(135% at 12% 88%);
        transform: scaleX(var(--leaf-flip));
    }
}

@keyframes leafRule {
    from {
        opacity: 0;
        transform: scaleX(0);
    }

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

@keyframes leafFade {
    from { opacity: 0; }
    to { opacity: 1; }
}
