/**
 * GRECHO Motion System V1
 * Scope: body.grecho-motion-v1-enabled only.
 * Safety: content remains visible unless JavaScript safely marks an off-screen
 * target pending and then adds html.grecho-motion-js.
 */

body.grecho-motion-v1-enabled {
    --grecho-motion-duration-instant: 80ms;
    --grecho-motion-duration-fast: 140ms;
    --grecho-motion-duration-standard: 220ms;
    --grecho-motion-duration-deliberate: 360ms;
    --grecho-motion-duration-disclosure: 240ms;
    --grecho-motion-ease-standard: cubic-bezier(.2, 0, 0, 1);
    --grecho-motion-ease-enter: cubic-bezier(.16, 1, .3, 1);
    --grecho-motion-ease-exit: cubic-bezier(.4, 0, 1, 1);
    --grecho-motion-delay-none: 0ms;
    --grecho-motion-delay-short: 40ms;
    --grecho-motion-delay-medium: 80ms;
    --grecho-motion-stagger: 55ms;
    --grecho-motion-distance-xs: 2px;
    --grecho-motion-distance-sm: 6px;
    --grecho-motion-distance-md: 12px;
    --grecho-motion-reveal-opacity: 0;
    --grecho-motion-card-scale: 1.008;
    --grecho-motion-image-scale: 1.025;
    --grecho-motion-press-scale: .985;
    --grecho-motion-hover-elevation: 0 14px 34px rgba(15, 23, 42, .12);
    --grecho-motion-focus-color: #1b4aa1;
    --grecho-motion-focus-ring: 0 0 0 3px rgba(27, 74, 161, .24);
}

body.grecho-motion-v1-enabled.grecho-motion-profile-minimal {
    --grecho-motion-duration-deliberate: 1ms;
    --grecho-motion-stagger: 0ms;
    --grecho-motion-distance-md: 0px;
    --grecho-motion-reveal-opacity: 1;
    --grecho-motion-card-scale: 1;
    --grecho-motion-image-scale: 1;
}

body.grecho-motion-v1-enabled.grecho-motion-profile-expressive {
    --grecho-motion-duration-deliberate: 420ms;
    --grecho-motion-stagger: 72ms;
    --grecho-motion-distance-md: 16px;
    --grecho-motion-card-scale: 1.012;
    --grecho-motion-image-scale: 1.035;
}

/* Progressive enhancement: attributes alone never hide content. */
html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion][data-grecho-motion-state="pending"],
html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion-item][data-grecho-motion-state="pending"] {
    opacity: var(--grecho-motion-reveal-opacity);
    transform: translate3d(0, var(--grecho-motion-distance-md), 0);
}

html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion],
html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion-item] {
    transition-property: opacity, transform;
    transition-duration: var(--grecho-motion-duration-deliberate);
    transition-timing-function: var(--grecho-motion-ease-enter);
    transition-delay: var(--grecho-motion-delay, var(--grecho-motion-delay-none));
}

html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion][data-grecho-motion-state="visible"],
html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion-item][data-grecho-motion-state="visible"] {
    opacity: 1;
    transform: none;
}

/* Existing Header scripts own state; V1 only normalizes the visual response. */
body.grecho-motion-v1-enabled :where(
    [data-grecho-global-header],
    .grecho-v1-site-header,
    .gsl-v2-nav,
    .gac-v1-nav,
    .gmw-v1-nav,
    .ggy-v1-nav,
    .pir-v1-nav,
    .grc-v2-nav,
    .gfaq-nav,
    .gcv2-nav,
    .gab-nav
) {
    transition-duration: var(--grecho-motion-duration-standard) !important;
    transition-timing-function: var(--grecho-motion-ease-standard) !important;
}

body.grecho-motion-v1-enabled :where(
    .grecho-v1-header-inner,
    .gsl-v2-nav-inner,
    .gac-v1-nav-inner,
    .gmw-v1-nav-inner,
    .ggy-v1-nav-inner,
    .pir-v1-nav-inner,
    .grc-v2-nav-inner,
    .gfaq-nav-inner,
    .gcv2-nav-inner,
    .gab-nav-inner
) {
    transition-duration: var(--grecho-motion-duration-standard) !important;
    transition-timing-function: var(--grecho-motion-ease-standard) !important;
}

/* Buttons and action links: explicit GRECHO allowlist, excluding form controls. */
body.grecho-motion-v1-enabled :where(
    .grecho-v1-btn,
    .grecho-v1-request-button,
    .gsl-v2-button,
    .gsl-v2-hero-cta,
    .gac-v1-doc-link,
    .gpl-card-action,
    .gpl-clear-button,
    .gpl-filter-clear,
    .grc-v2-button,
    .ginsights-btn,
    .gia-btn,
    .gfaq-btn,
    .gcv2-btn,
    .gcases-btn,
    .gab-btn
) {
    transition-property: color, background-color, border-color, box-shadow, transform !important;
    transition-duration: var(--grecho-motion-duration-fast) !important;
    transition-timing-function: var(--grecho-motion-ease-standard) !important;
}

body.grecho-motion-v1-enabled :is(
    .grecho-v1-btn,
    .grecho-v1-request-button,
    .gsl-v2-button,
    .gsl-v2-hero-cta,
    .gac-v1-doc-link,
    .gpl-card-action,
    .gpl-clear-button,
    .gpl-filter-clear,
    .grc-v2-button,
    .ginsights-btn,
    .gia-btn,
    .gfaq-btn,
    .gcv2-btn,
    .gcases-btn,
    .gab-btn
):focus-visible {
    outline: 2px solid var(--grecho-motion-focus-color) !important;
    outline-offset: 3px !important;
    box-shadow: var(--grecho-motion-focus-ring) !important;
}

/* Resolve two accepted inline-style focus resets without touching their source. */
body.grecho-motion-v1-enabled .grecho-global-page-v1 .grecho-v1-faq-intro a.grecho-v1-btn.grecho-v1-faq-cta-button:focus-visible,
body.grecho-motion-v1-enabled .gac-v1-page .gac-v1-doc-card a.gac-v1-doc-link.gac-v1-doc-cta:focus-visible {
    outline: 2px solid var(--grecho-motion-focus-color) !important;
    outline-offset: 3px !important;
    box-shadow: var(--grecho-motion-focus-ring) !important;
}

body.grecho-motion-v1-enabled :where(
    .grecho-v1-btn,
    .grecho-v1-request-button,
    .gsl-v2-button,
    .gsl-v2-hero-cta,
    .gac-v1-doc-link,
    .gpl-card-action,
    .gpl-clear-button,
    .gpl-filter-clear,
    .grc-v2-button,
    .ginsights-btn,
    .gia-btn,
    .gfaq-btn,
    .gcv2-btn,
    .gcases-btn,
    .gab-btn
):active {
    transform: translateY(0) scale(var(--grecho-motion-press-scale)) !important;
}

/* Cards are marked only after the JS allowlist confirms an interactive card. */
body.grecho-motion-v1-enabled [data-grecho-motion-card] {
    transition-property: transform, box-shadow, border-color, background-color !important;
    transition-duration: var(--grecho-motion-duration-standard) !important;
    transition-timing-function: var(--grecho-motion-ease-standard) !important;
}

body.grecho-motion-v1-enabled [data-grecho-motion-card]:focus-visible,
body.grecho-motion-v1-enabled [data-grecho-motion-card]:focus-within {
    outline: 2px solid var(--grecho-motion-focus-color) !important;
    outline-offset: 3px !important;
    box-shadow: var(--grecho-motion-focus-ring) !important;
}

body.grecho-motion-v1-enabled [data-grecho-motion-image] {
    transition: transform var(--grecho-motion-duration-deliberate) var(--grecho-motion-ease-enter) !important;
    transform-origin: center;
}

/* Navigation links, Footer links, breadcrumbs, social links. */
body.grecho-motion-v1-enabled :where(
    .grecho-v1-desktop-menu a,
    [class$="-nav-links"] a,
    [class$="-menu"] a,
    .grecho-v1-site-footer a,
    [class$="-footer"] a,
    [class*="breadcrumb"] a,
    [class*="social"] a
) {
    transition-property: color, background-color, border-color, transform !important;
    transition-duration: var(--grecho-motion-duration-fast) !important;
    transition-timing-function: var(--grecho-motion-ease-standard) !important;
}

body.grecho-motion-v1-enabled :where(
    .grecho-v1-desktop-menu a,
    [class$="-nav-links"] a,
    [class$="-menu"] a,
    .grecho-v1-site-footer a,
    [class$="-footer"] a,
    [class*="breadcrumb"] a,
    [class*="social"] a
):focus-visible {
    outline: 2px solid currentColor !important;
    outline-offset: 3px !important;
}

/* Existing disclosure logic remains authoritative; only state feedback moves. */
body.grecho-motion-v1-enabled details > summary {
    transition: color var(--grecho-motion-duration-fast) var(--grecho-motion-ease-standard),
                background-color var(--grecho-motion-duration-fast) var(--grecho-motion-ease-standard),
                border-color var(--grecho-motion-duration-fast) var(--grecho-motion-ease-standard) !important;
}

body.grecho-motion-v1-enabled details > summary:focus-visible {
    outline: 2px solid var(--grecho-motion-focus-color) !important;
    outline-offset: 3px !important;
}

body.grecho-motion-v1-enabled details > summary :where(span, i, svg) {
    transition-property: transform, opacity, color !important;
    transition-duration: var(--grecho-motion-duration-disclosure) !important;
    transition-timing-function: var(--grecho-motion-ease-standard) !important;
}

body.grecho-motion-v1-enabled details[open] > :where(
    .grecho-v1-mobile-panel,
    [class$="-mobile-panel"],
    [class*="answer"]
) {
    opacity: 1;
    transform: none;
    transition: opacity var(--grecho-motion-duration-disclosure) var(--grecho-motion-ease-enter),
                transform var(--grecho-motion-duration-disclosure) var(--grecho-motion-ease-enter);
    @starting-style {
        opacity: 0;
        transform: translate3d(0, calc(-1 * var(--grecho-motion-distance-sm)), 0);
    }
}

/* Filter results change discretely; only controls receive state feedback. */
body.grecho-motion-v1-enabled :where(
    [data-series-filter],
    .gfaq-tab,
    .gcases-filter-btn,
    .ginsights-filter button,
    .grc-v2-filter button
) {
    transition-property: color, background-color, border-color, box-shadow, transform !important;
    transition-duration: var(--grecho-motion-duration-fast) !important;
    transition-timing-function: var(--grecho-motion-ease-standard) !important;
}

body.grecho-motion-v1-enabled :where(
    [data-series-filter],
    .gfaq-tab,
    .gcases-filter-btn,
    .ginsights-filter button,
    .grc-v2-filter button
):focus-visible {
    outline: 2px solid var(--grecho-motion-focus-color) !important;
    outline-offset: 3px !important;
    box-shadow: var(--grecho-motion-focus-ring) !important;
}

@media (hover: hover) and (pointer: fine) {
    body.grecho-motion-v1-enabled :where(
        .grecho-v1-btn,
        .grecho-v1-request-button,
        .gsl-v2-button,
        .gsl-v2-hero-cta,
        .gac-v1-doc-link,
        .gpl-card-action,
        .grc-v2-button,
        .ginsights-btn,
        .gia-btn,
        .gfaq-btn,
        .gcv2-btn,
        .gcases-btn,
        .gab-btn
    ):hover {
        transform: translate3d(0, calc(-1 * var(--grecho-motion-distance-xs)), 0);
    }

    body.grecho-motion-v1-enabled [data-grecho-motion-card]:hover {
        transform: translate3d(0, calc(-1 * var(--grecho-motion-distance-sm)), 0) scale(var(--grecho-motion-card-scale)) !important;
        box-shadow: var(--grecho-motion-hover-elevation) !important;
    }

    body.grecho-motion-v1-enabled [data-grecho-motion-card]:hover [data-grecho-motion-image] {
        transform: scale(var(--grecho-motion-image-scale)) !important;
    }
}

@media (max-width: 768px) {
    body.grecho-motion-v1-enabled {
        --grecho-motion-duration-deliberate: 260ms;
        --grecho-motion-stagger: 38ms;
        --grecho-motion-distance-md: 8px;
        --grecho-motion-image-scale: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    html.grecho-motion-js body.grecho-motion-v1-enabled,
    html.grecho-motion-js body.grecho-motion-v1-enabled * {
        scroll-behavior: auto !important;
    }

    html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion],
    html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion-item],
    body.grecho-motion-v1-enabled [data-grecho-motion-card],
    body.grecho-motion-v1-enabled [data-grecho-motion-image],
    body.grecho-motion-v1-enabled details > summary,
    body.grecho-motion-v1-enabled details > summary :where(span, i, svg),
    body.grecho-motion-v1-enabled :where(
        .grecho-v1-btn,
        .grecho-v1-request-button,
        .gsl-v2-button,
        .gsl-v2-hero-cta,
        .gac-v1-doc-link,
        .gpl-card-action,
        .grc-v2-button,
        .ginsights-btn,
        .gia-btn,
        .gfaq-btn,
        .gcv2-btn,
        .gcases-btn,
        .gab-btn,
        [data-series-filter],
        .gfaq-tab,
        .gcases-filter-btn
    ) {
        animation: none !important;
        transition-duration: .01ms !important;
        transition-delay: 0ms !important;
    }

    html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion],
    html.grecho-motion-js body.grecho-motion-v1-enabled [data-grecho-motion-item] {
        opacity: 1 !important;
        transform: none !important;
    }

    body.grecho-motion-v1-enabled [data-grecho-motion-card],
    body.grecho-motion-v1-enabled [data-grecho-motion-card]:hover,
    body.grecho-motion-v1-enabled [data-grecho-motion-image],
    body.grecho-motion-v1-enabled [data-grecho-motion-card]:hover [data-grecho-motion-image] {
        transform: none !important;
    }
}
