/* ==========================================================================
   Rall Motion UI  (css/motion-ui.css)  v1.0
   Reusable motion WIDGETS on top of the Motion Kit (css/motion.css + js/motion.js).
   Pair with js/motion-ui.js. Load order: ..., motion.css, motion-ui.css.

   Widgets (all prefixed `mo-`, all decorative layers are aria-hidden):
     .mo-media      image frame: clip reveal + scroll parallax + hover zoom
     .mo-ring       SVG scroll-progress ring / back-to-top button
     .mo-toc        table-of-contents rail with SVG progress line + scrollspy
     .mo-faq        (in motion.css) animated accordion, built by MotionUI.faq()
     .mo-orn        SVG ornament (sun + awning) that draws itself
     .mo-divider    SVG wave divider that draws itself
     .mo-spot       pointer spotlight for cards (pair with data-tilt)
     .mo-hl         marker highlight sweep for <strong>
     [data-mo-curtain]  hero curtain wipe that never hides the LCP image

   SEO / performance contract
   --------------------------
   - Anything that hides content is gated behind `html.mo-js` AND
     `prefers-reduced-motion: no-preference`. No JS, failed JS, crawlers and
     reduced-motion users all get the finished page.
   - Only opacity / transform / translate / scale / clip-path animate: no layout
     properties, so CLS stays ~0.
   - The LCP image is never given opacity:0. Its reveal is an overlay curtain.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Media frame (images inside figures)
   -------------------------------------------------------------------------- */
.mo-media {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    border-radius: var(--radius-xl, 1.25rem);
    box-shadow: var(--shadow-lg);
    background: #e9edf4;
    cursor: zoom-in;
}

.mo-media picture {
    display: block;
}

/* beats `.blog-content img` (margin / radius / shadow / hover lift) */
.blog-content .mo-media img,
.mo-media img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    /* parallax: --p (0..1) is written by Motion.scrub; .5 = centred */
    transform: translate3d(0, calc((var(--p, 0.5) - 0.5) * -7%), 0) scale(1.09);
    transition: scale 1.1s var(--mo-ease);
}

/* layer promotion only while the frame is near the viewport (class set by motion-ui.js) */
.mo-media.is-near img {
    will-change: transform;
}

.blog-content .mo-media img:hover {
    box-shadow: none;
}

.mo-media:hover img {
    scale: 1.045;
}

/* soft sheen that follows scroll */
.mo-media::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.22) 50%, transparent 65%);
    translate: calc(-120% + var(--p, 0.5) * 240%) 0;
    opacity: 0.8;
}

@media (prefers-reduced-motion: reduce) {

    .blog-content .mo-media img,
    .mo-media img {
        transform: none;
        will-change: auto;
    }

    .mo-media::after {
        display: none;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .mo-js .mo-media[data-reveal] img {
        scale: 1.28;
        transition: scale 1.8s var(--mo-ease) var(--mo-delay, 0ms);
    }

    .mo-js .mo-media[data-reveal].is-in img {
        scale: 1;
    }
}

/* --------------------------------------------------------------------------
   2. Hero curtain (LCP-safe) + hero image motion
   -------------------------------------------------------------------------- */
[data-mo-curtain] {
    position: relative;
    overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {

    /* The image underneath is painted from the first frame (LCP is unaffected);
       a navy curtain slides off it. Pure CSS: it needs no JS to finish. */
    .mo-js [data-mo-curtain]::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 3;
        pointer-events: none;
        background:
            linear-gradient(115deg, rgba(230, 209, 77, 0.22), transparent 40%),
            linear-gradient(160deg, var(--mo-navy-2, #1a2744), var(--mo-navy, #0f1829));
        transform-origin: 50% 0;
        animation: mo-curtain 1.35s var(--mo-ease-io, cubic-bezier(.65, 0, .35, 1)) 0.25s both;
    }

    .mo-js [data-mo-curtain] img {
        animation: mo-hero-zoom 2.6s var(--mo-ease) 0.25s both;
    }
}

@keyframes mo-curtain {
    to {
        transform: scaleY(0);
    }
}

@keyframes mo-hero-zoom {
    from {
        scale: 1.22;
    }

    to {
        scale: 1;
    }
}

/* scroll-out parallax + damped pointer drift (--p, --mx, --my set by JS) */
@media (prefers-reduced-motion: no-preference) {
    .mo-js [data-mo-curtain] img {
        transform: translate3d(0, calc(var(--p, 0) * 9%), 0) scale(calc(1.06 + var(--p, 0) * 0.1));
        translate: calc(var(--mx, 0) * -14px) calc(var(--my, 0) * -10px);
        transition: none;
        will-change: transform;
    }

    .mo-js .blog-header__hero:hover img {
        transform: translate3d(0, calc(var(--p, 0) * 9%), 0) scale(calc(1.06 + var(--p, 0) * 0.1));
    }
}

/* --------------------------------------------------------------------------
   3. Scroll-progress ring / back-to-top
   -------------------------------------------------------------------------- */
.mo-ring {
    position: fixed;
    left: clamp(0.75rem, 2vw, 1.5rem);
    bottom: clamp(0.75rem, 2vw, 1.5rem);
    z-index: calc(var(--z-sticky, 200) - 10);
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    /* solid, no backdrop-filter: a blurred backdrop forces an extra render surface
       over the whole page for every frame, which costs more than it adds */
    background: rgba(15, 24, 41, 0.94);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 14px 34px -12px rgba(15, 24, 41, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    opacity: 0;
    /* --mo-lift (px) is set by motion-ui.js while the cookie banner is showing */
    translate: 0 calc(var(--mo-lift, 0px) * -1 + 18px);
    scale: 0.8;
    pointer-events: none;
    transition: opacity 0.5s var(--mo-ease), translate 0.7s var(--mo-ease), scale 0.7s var(--mo-ease-back), box-shadow 0.4s;
}

.mo-ring.is-on {
    opacity: 1;
    translate: 0 calc(var(--mo-lift, 0px) * -1);
    scale: 1;
    pointer-events: auto;
}

.mo-ring:hover {
    box-shadow: 0 18px 40px -10px rgba(230, 209, 77, 0.55), inset 0 0 0 1px rgba(230, 209, 77, 0.5);
}

.mo-ring:focus-visible {
    outline: 3px solid var(--mo-gold, #e6d14d);
    outline-offset: 3px;
}

.mo-ring>svg:first-child {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    rotate: -90deg;
}

.mo-ring__track,
.mo-ring__bar {
    fill: none;
    stroke-width: 3;
}

.mo-ring__track {
    stroke: rgba(255, 255, 255, 0.14);
}

.mo-ring__bar {
    stroke: var(--mo-gold, #e6d14d);
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.mo-ring__num,
.mo-ring__arrow {
    grid-area: 1 / 1;
    transition: opacity 0.35s, translate 0.5s var(--mo-ease);
}

.mo-ring__num {
    font-size: 0.8rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.mo-ring__arrow {
    width: 1.35rem;
    height: 1.35rem;
    opacity: 0;
    translate: 0 10px;
    fill: none;
    stroke: var(--mo-gold, #e6d14d);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mo-ring:hover .mo-ring__num,
.mo-ring:focus-visible .mo-ring__num {
    opacity: 0;
    translate: 0 -10px;
}

.mo-ring:hover .mo-ring__arrow,
.mo-ring:focus-visible .mo-ring__arrow {
    opacity: 1;
    translate: 0 0;
}

@media (prefers-reduced-motion: reduce) {
    .mo-ring {
        transition: opacity 0.2s;
        translate: 0 calc(var(--mo-lift, 0px) * -1);
        scale: 1;
    }
}

/* The site sidebar ships its own back-to-top button (components.js, inline
   styles). The ring replaces it, so never show two. */
body:has(.mo-ring) .scroll-top-item {
    display: none !important;
}

/* --------------------------------------------------------------------------
   4. Table-of-contents rail (wide screens only: it needs side gutters)
   -------------------------------------------------------------------------- */
.mo-toc {
    display: none;
}

@media (min-width: 1380px) {
    .mo-toc {
        position: fixed;
        top: 50%;
        left: max(1.25rem, calc((100vw - 760px) / 2 - 17.5rem));
        z-index: calc(var(--z-sticky, 200) - 20);
        display: block;
        width: 15.5rem;
        max-height: 70vh;
        overflow: hidden;
        opacity: 0;
        translate: -18px -50%;
        pointer-events: none;
        transition: opacity 0.6s var(--mo-ease), translate 0.9s var(--mo-ease);
    }

    .mo-toc.is-on {
        opacity: 1;
        translate: 0 -50%;
        pointer-events: auto;
    }
}

.mo-toc__title {
    margin: 0 0 0.9rem 1.6rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-muted, #6b7488);
}

.mo-toc__list {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mo-toc__rail {
    position: absolute;
    left: 0.35rem;
    top: 0;
    width: 0.7rem;
    height: 100%;
    overflow: visible;
}

.mo-toc__rail path {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.mo-toc__rail .t {
    stroke: rgba(15, 24, 41, 0.14);
}

.mo-toc__rail .f {
    stroke: var(--mo-gold-deep, #8a7a12);
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.mo-toc__item {
    position: relative;
    margin: 0;
}

.mo-toc__item a {
    display: block;
    padding: 0.42rem 0 0.42rem 1.6rem;
    font-size: 0.84rem;
    line-height: 1.35;
    font-weight: 500;
    color: var(--text-muted, #6b7488);
    text-decoration: none;
    transition: color 0.35s, translate 0.5s var(--mo-ease);
}

.mo-toc__item a::before {
    content: "";
    position: absolute;
    left: 0.35rem;
    top: 50%;
    width: 0.62rem;
    height: 0.62rem;
    margin: -0.31rem 0 0 -0.31rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 0 0 2px rgba(15, 24, 41, 0.22);
    transition: background-color 0.4s, box-shadow 0.4s, scale 0.6s var(--mo-ease-back);
}

.mo-toc__item a:hover {
    color: var(--primary, #1a2744);
    translate: 3px 0;
}

.mo-toc__item.is-past a::before {
    background: var(--mo-gold-deep, #8a7a12);
    box-shadow: none;
}

.mo-toc__item.is-active a {
    color: var(--primary, #1a2744);
    font-weight: 700;
}

.mo-toc__item.is-active a::before {
    background: var(--mo-gold, #e6d14d);
    box-shadow: 0 0 0 4px rgba(230, 209, 77, 0.3);
    scale: 1.35;
}

/* --------------------------------------------------------------------------
   5. SVG ornaments
   -------------------------------------------------------------------------- */
.blog-header {
    position: relative;
}

.blog-header>*:not(.mo-orn) {
    position: relative;
    z-index: 1;
}

.mo-orn {
    position: absolute;
    top: -1.2rem;
    right: -0.4rem;
    z-index: 0;
    width: clamp(7rem, 15vw, 11rem);
    height: auto;
    overflow: visible;
    pointer-events: none;
    color: var(--accent-dark, #b89d1c);
    /* stroke is inherited by every shape, so group colours below still apply */
    stroke: currentColor;
}

.mo-orn * {
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mo-orn__sun {
    stroke: var(--mo-gold-deep, #8a7a12);
}

.mo-orn__rays {
    transform-origin: 120px 62px;
    animation: mo-spin 56s linear infinite;
}

.mo-orn__awning {
    stroke: var(--primary, #1a2744);
    opacity: 0.85;
}

@keyframes mo-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 639px) {
    .mo-orn {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mo-orn__rays {
        animation: none;
    }
}

.mo-divider {
    display: block;
    width: 100%;
    height: 0.9rem;
    margin: var(--space-12, 3rem) 0 0;
    overflow: visible;
    color: var(--accent, #e6d14d);
    pointer-events: none;
}

.mo-divider path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    opacity: 0.9;
}

.blog-content .mo-divider+h2 {
    margin-top: var(--space-4, 1rem);
}

/* --------------------------------------------------------------------------
   6. Pointer spotlight (cards)
   -------------------------------------------------------------------------- */
.mo-spot {
    position: relative;
    isolation: isolate;
}

.mo-spot::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(420px circle at var(--sx, 50%) var(--sy, 50%), rgba(230, 209, 77, 0.2), transparent 46%);
    transition: opacity 0.5s;
}

.mo-spot:hover::after {
    opacity: 1;
}

/* Blog index: tilt owns `transform`, so the hover lift moves to `translate`. */
.mo-js .blog-card.mo-spot {
    transition: translate 0.55s var(--mo-ease), box-shadow var(--transition-normal);
}

.mo-js .blog-card.mo-spot:hover {
    transform: none;
    translate: 0 -6px;
}

/* featured image: headroom so the parallax never exposes an edge */
.mo-js .blog-featured__image img {
    scale: 1.14;
}

@media (prefers-reduced-motion: reduce) {
    .mo-js .blog-featured__image img {
        scale: 1;
    }
}

/* --------------------------------------------------------------------------
   7. Article choreography (preset "article" adds the hooks; every hidden
      start state lives in the no-preference block below)
   -------------------------------------------------------------------------- */
.blog-article {
    --mo-y: 26px;
    --mo-dur: 0.95s;
}

.blog-content h2,
.blog-content h3 {
    scroll-margin-top: calc(var(--mo-header, 92px) + 1.5rem);
}

/* FAQ block inside articles (built by MotionUI.faq) */
.blog-content .mo-faq {
    margin-top: var(--space-6, 1.5rem);
}

.blog-content .mo-faq summary {
    padding: 1.1rem 1.25rem;
}

.blog-content .mo-faq .mo-faq__q {
    margin: 0;
    font-size: clamp(1rem, 1.4vw, 1.1rem);
    line-height: 1.35;
}

.blog-content .mo-faq__a-inner {
    padding: 0 1.25rem 1.2rem;
}

.blog-content .mo-faq__a-inner p {
    margin: 0;
    font-size: 1rem;
}

.blog-content .mo-faq__a-inner p+p {
    margin-top: 0.8rem;
}

/* footer CTA extras */
.blog-footer-cta {
    isolation: isolate;
}

.blog-footer-cta .mo-aurora {
    z-index: -1;
    opacity: 0.55;
}

.blog-footer-cta .btn {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.blog-footer-cta .btn::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.5) 50%, transparent 70%);
    translate: -130% 0;
    transition: translate 0.9s var(--mo-ease);
}

.blog-footer-cta .btn:hover::before,
.blog-footer-cta .btn:focus-visible::before {
    translate: 130% 0;
}

@media (prefers-reduced-motion: no-preference) {

    /* h2 accent bar grows after the words land */
    .mo-js .blog-content h2::before {
        transform: scaleY(0);
        transform-origin: 50% 0;
        transition: transform 0.9s var(--mo-ease) 0.25s;
    }

    .mo-js .blog-content h2.is-in::before {
        transform: scaleY(1);
    }

    /* marker highlight sweep on <strong> once its block is revealed */
    .mo-js .blog-content p strong,
    .mo-js .blog-content li strong {
        background-image: linear-gradient(transparent 58%, rgba(230, 209, 77, 0.55) 58%, rgba(230, 209, 77, 0.55) 92%, transparent 92%);
        background-repeat: no-repeat;
        background-size: 0% 100%;
        transition: background-size 1.1s var(--mo-ease) calc(var(--mo-delay, 0ms) + 0.45s);
        -webkit-box-decoration-break: clone;
        box-decoration-break: clone;
    }

    .mo-js .blog-content .is-in strong,
    .mo-js .blog-content strong.is-in {
        background-size: 100% 100%;
    }

    /* list marks pop in with their item */
    .mo-js .blog-content ul>li::before,
    .mo-js .blog-content ul>li::after,
    .mo-js .blog-content ol>li::before {
        scale: 0;
        transition: scale 0.7s var(--mo-ease-back) calc(var(--mo-delay, 0ms) + 0.25s);
    }

    .mo-js .blog-content ul>li.is-in::before,
    .mo-js .blog-content ul>li.is-in::after,
    .mo-js .blog-content ol>li.is-in::before {
        scale: 1;
    }

    /* callout icon + blockquote glyph pop */
    .mo-js .blog-callout:not(.is-in)::before,
    .mo-js .blog-content blockquote:not(.is-in)::before {
        scale: 0;
        rotate: -28deg;
    }

    .blog-callout::before,
    .blog-content blockquote::before {
        transition: scale 0.9s var(--mo-ease-back) 0.4s, rotate 0.9s var(--mo-ease-back) 0.4s;
    }

    /* table rows cascade after the table frame is revealed */
    .mo-js .blog-content table tbody tr {
        opacity: 0;
        translate: 0 14px;
        transition: opacity 0.7s var(--mo-ease) calc(0.25s + var(--r, 0) * 70ms), translate 0.8s var(--mo-ease) calc(0.25s + var(--r, 0) * 70ms), background 0.2s;
    }

    .mo-js .blog-content table.is-in tbody tr {
        opacity: 1;
        translate: 0 0;
    }

    /* caption trails the image */
    .mo-js .blog-content figcaption {
        opacity: 0;
        translate: 0 8px;
        transition: opacity 0.8s var(--mo-ease) 0.7s, translate 0.8s var(--mo-ease) 0.7s;
    }

    .mo-js .blog-content figure.is-seen figcaption {
        opacity: 1;
        translate: 0 0;
    }

    /* related-article links + faq entrance */
    .mo-js .blog-related li {
        opacity: 0;
        translate: 0 12px;
        transition: opacity 0.7s var(--mo-ease) calc(var(--r, 0) * 90ms), translate 0.8s var(--mo-ease) calc(var(--r, 0) * 90ms);
    }

    .mo-js .blog-related.is-in li {
        opacity: 1;
        translate: 0 0;
    }
}
