/* ==========================================================================
   MOTION LAYER (client 10/7: "cool animations / transitions")
   Paired with js/motion.js. No libraries. Everything that moves sits behind
   prefers-reduced-motion: no-preference; JS adds the start-state classes, so
   with JS off nothing is hidden. Remove the two enqueues in functions.php to
   turn the whole layer off.
   ========================================================================== */

:root {
    --mx-gold: #be9141;
    --mx-gold-2: #d4af37;
    --mx-navy: #02225a;
    --mx-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --mx-top: var(--wp-admin--admin-bar--height, 0px);
}
/* WordPress's admin bar stops being fixed at 600px and below */
@media (max-width: 600px) {
    :root { --mx-top: 0px; }
}

/* --------------------------------------------------------------------------
   Page transitions: soft cross-fade between pages, and a project card's
   thumbnail grows into its case study's hero video (matching
   view-transition-name set in projects-grid.php / inner-hero.php).
   Browsers without cross-document view transitions just load the page.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.35s;
    }
    ::view-transition-group(*) {
        animation-duration: 0.55s;
        animation-timing-function: var(--mx-ease);
    }
}

/* --------------------------------------------------------------------------
   Scroll reveals (JS adds .mx-reveal only to things below the fold at load)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    /* Doubled class so it beats card hover rules while revealing; JS removes
       the classes once the reveal ends so hovers get their own timing back */
    .mx-reveal.mx-reveal {
        opacity: 0;
        translate: 0 28px;
        transition: opacity 0.8s var(--mx-ease), translate 0.8s var(--mx-ease);
        transition-delay: var(--mx-delay, 0ms);
    }
    .mx-reveal.mx-reveal.is-in {
        opacity: 1;
        translate: 0 0;
    }

    /* One-time shimmer across gold heading words */
    .mx-shine {
        background-image: linear-gradient(110deg, var(--mx-gold) 0%, var(--mx-gold-2) 38%, #fff3cf 50%, var(--mx-gold-2) 62%, var(--mx-gold) 100%) !important;
        background-size: 260% 100% !important;
        -webkit-background-clip: text !important;
        background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
        color: transparent !important;
        animation: mx-shine 1.6s var(--mx-ease) 0.25s both;
    }
    @keyframes mx-shine {
        from { background-position: 100% 0; }
        to { background-position: 0% 0; }
    }
}

/* Count-ups keep their width while the digits change */
[data-count] {
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Home hero: entrance on load, then the card pushes forward as you scroll
   (JS sets the scroll part on [data-mx] elements)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    [data-mx="hero-card"] {
        animation: mx-hero-card 1.1s var(--mx-ease) backwards;
        will-change: scale, translate;
    }
    [data-mx="hero-title"] {
        animation: mx-hero-title 1.2s var(--mx-ease) 0.25s backwards;
        will-change: translate, opacity;
    }
    [data-mx="hero-waves"] {
        will-change: translate;
    }
    @keyframes mx-hero-card {
        from { opacity: 0; scale: 0.92; translate: 0 30px; }
        to { opacity: 1; scale: 1; translate: 0 0; }
    }
    @keyframes mx-hero-title {
        from { opacity: 0; translate: 0 40px; filter: blur(10px); }
        to { opacity: 1; translate: 0 0; filter: blur(0); }
    }
}

/* --------------------------------------------------------------------------
   Header: compact, frosted, fixed once you scroll; hides going down and
   comes back going up. Thin gold reading-progress bar on top.
   -------------------------------------------------------------------------- */
.site-header.mx-stuck {
    position: fixed;
    top: var(--mx-top);
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    box-shadow: 0 6px 24px rgba(2, 34, 90, 0.08);
    transition: translate 0.45s var(--mx-ease), box-shadow 0.3s ease;
}
.site-header.mx-stuck > .container > div {
    padding-top: 10px;
    padding-bottom: 10px;
}
.site-header.mx-stuck img {
    height: 44px;
    max-width: 210px;
}
.site-header.mx-stuck.mx-hide {
    translate: 0 calc(-100% - var(--mx-top) - 8px);
    box-shadow: none;
}
.mx-progress {
    position: fixed;
    top: var(--mx-top);
    left: 0;
    right: 0;
    z-index: 55;
    height: 3px;
    background: linear-gradient(90deg, var(--mx-gold), var(--mx-gold-2));
    transform-origin: 0 50%;
    scale: 0 1;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Flight route (home, wide screens): a dashed gold route down the right
   edge that draws itself as you scroll, a drone riding it, and a waypoint
   per section you can click.
   -------------------------------------------------------------------------- */
.mx-route {
    position: fixed;
    right: 26px;
    top: 50%;
    z-index: 40;
    height: min(52vh, 460px);
    width: 26px;
    translate: 0 -50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
.mx-route.is-on {
    opacity: 1;
    pointer-events: auto;
}
.mx-route__track,
.mx-route__fill {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    margin-left: -1px;
    height: 100%;
}
.mx-route__track {
    background: repeating-linear-gradient(to bottom, rgba(2, 34, 90, 0.22) 0 6px, transparent 6px 12px);
}
.mx-route__fill {
    background: repeating-linear-gradient(to bottom, var(--mx-gold) 0 6px, transparent 6px 12px);
    transform-origin: 50% 0;
    scale: 1 0;
}
.mx-route__dot {
    position: absolute;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    padding: 0;
    border: 2px solid rgba(2, 34, 90, 0.35);
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.3s ease, background 0.3s ease, scale 0.3s ease;
}
.mx-route__dot.is-reached {
    border-color: var(--mx-gold);
    background: var(--mx-gold);
}
.mx-route__dot:hover,
.mx-route__dot:focus-visible {
    scale: 1.35;
    outline: none;
}
.mx-route__label {
    position: absolute;
    right: 22px;
    top: 50%;
    translate: 6px -50%;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--mx-navy);
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, translate 0.2s ease;
}
.mx-route__dot:hover .mx-route__label,
.mx-route__dot:focus-visible .mx-route__label {
    opacity: 1;
    translate: 0 -50%;
}
.mx-route__drone {
    position: absolute;
    left: 50%;
    top: 0;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    pointer-events: none;
    filter: drop-shadow(0 3px 6px rgba(2, 34, 90, 0.25));
}
.mx-route__drone .mx-rotor {
    transform-box: fill-box;
    transform-origin: center;
}
@media (prefers-reduced-motion: no-preference) {
    .mx-route__drone .mx-rotor {
        animation: mx-rotor 0.18s linear infinite;
    }
    .mx-route__drone {
        animation: mx-hover 2.4s ease-in-out infinite;
    }
}
@keyframes mx-rotor {
    to { rotate: 360deg; }
}
@keyframes mx-hover {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -3px; }
}
@media (max-width: 1399px) {
    .mx-route { display: none; }
}

/* --------------------------------------------------------------------------
   Home process: a gold line fills across the steps as they line up, and
   each reached step's number turns gold
   -------------------------------------------------------------------------- */
.mx-process-line {
    display: none;
}
@media (min-width: 1024px) {
    #process .process-stage {
        padding-top: 22px;
        padding-bottom: 48px;
        height: auto;
        min-height: 322px;
        /* Steps rising in fade at the bottom edge; a mask, so nothing paints over the page's flight lines */
        -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
        mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
    }
    .mx-process-line {
        display: block;
        position: absolute;
        top: 6px;
        left: 40px;
        right: 40px;
        height: 2px;
        background: repeating-linear-gradient(90deg, rgba(2, 34, 90, 0.18) 0 6px, transparent 6px 12px);
    }
    .mx-process-line > span {
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg, var(--mx-gold), var(--mx-gold-2));
        transform-origin: 0 50%;
        scale: 0 1;
    }
    #process .process-step.is-reached > span:first-child {
        --tw-gradient-from: #be9141 var(--tw-gradient-from-position);
        --tw-gradient-to: #d4af37 var(--tw-gradient-to-position);
        --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   Map: gold states light up one by one, then pulse to invite a click
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    #map-locations.homepage-state-map.mx-armed .state.is-completed {
        fill: #1b3358;
    }
    #map-locations.homepage-state-map.mx-lit .state.is-completed {
        animation:
            mx-state-in 0.7s var(--mx-ease) calc(var(--mx-i, 0) * 180ms) both,
            mx-state-pulse 3.2s ease-in-out calc(1.2s + var(--mx-i, 0) * 400ms) infinite;
    }
    /* Animations beat normal rules, so hover drops them to show its color */
    #map-locations.homepage-state-map.mx-lit .state.is-completed:hover,
    #map-locations.homepage-state-map.mx-lit .state.is-completed:focus {
        animation: none;
        fill: #c49a4e;
    }
    @keyframes mx-state-in {
        from { fill: #1b3358; }
        60% { fill: #e2bf5c; }
        to { fill: #be9141; }
    }
    @keyframes mx-state-pulse {
        0%, 100% { fill: #be9141; filter: drop-shadow(0 0 0 rgba(212, 175, 55, 0)); }
        50% { fill: #cfa54d; filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.75)); }
    }
}

/* --------------------------------------------------------------------------
   Hover touches
   -------------------------------------------------------------------------- */

/* Client logos: gray until hovered */
#clients .swiper-slide img {
    filter: grayscale(1);
    opacity: 0.7;
    transition: filter 0.4s ease, opacity 0.4s ease;
}
#clients .swiper-slide:hover img {
    filter: none;
    opacity: 1;
}

/* Project cards (Our Work, Contact, case study strips): lift, slow zoom,
   pulsing play button. Only cards that go somewhere get these. */
.site-projects-grid article,
.site-case-study-videos article,
.site-case-study-more article {
    transition: translate 0.45s var(--mx-ease), box-shadow 0.45s var(--mx-ease);
}
.site-projects-grid article:hover,
.site-case-study-videos article:hover,
.site-case-study-more article:hover {
    translate: 0 -6px;
    box-shadow: 0 18px 40px rgba(2, 34, 90, 0.14);
}
.site-projects-grid article > .relative,
.site-case-study-videos article > .relative,
.site-case-study-more article > .relative {
    overflow: hidden;
}
.site-projects-grid article > .relative > img,
.site-case-study-videos article > .relative > img,
.site-case-study-more article > .relative > img {
    transition: scale 1.4s var(--mx-ease);
}
.site-projects-grid article:hover > .relative > img,
.site-case-study-videos article:hover > .relative > img,
.site-case-study-more article:hover > .relative > img {
    scale: 1.07;
}
@media (prefers-reduced-motion: no-preference) {
    .site-projects-grid article > .relative .rounded-full,
    .site-case-study-videos article > .relative .rounded-full,
    .site-case-study-more article > .relative .rounded-full {
        position: relative;
    }
    .site-projects-grid article:hover > .relative .rounded-full::after,
    .site-case-study-videos article:hover > .relative .rounded-full::after,
    .site-case-study-more article:hover > .relative .rounded-full::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.9);
        animation: mx-ping 1.4s var(--mx-ease) infinite;
    }
}
@keyframes mx-ping {
    from { scale: 1; opacity: 0.9; }
    to { scale: 1.8; opacity: 0; }
}

/* Customize Your Tour: small "preview" badge on cards that have a hover clip
   (desktop only; the clip itself only loads on hover) */
@media (hover: hover) {
    .customize-card .relative:has(.customize-card-video)::after {
        content: "";
        position: absolute;
        right: 8px;
        bottom: 8px;
        z-index: 2;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: rgba(2, 34, 90, 0.78) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='12' viewBox='0 0 10 12'%3E%3Cpath d='M0 0v12l10-6z' fill='%23ffffff'/%3E%3C/svg%3E") 55% 50% no-repeat;
        transition: opacity 0.3s ease;
    }
    .customize-card:hover .relative:has(.customize-card-video)::after {
        opacity: 0;
    }
}
@media (hover: none) {
    .customize-card-video {
        display: none;
    }
}

/* Case study hero: the video's thumbnail sits behind the player so the
   card-to-hero transition (and a slow embed) shows a picture, not a box */
.mx-hero-thumb {
    background-color: #0f172a;
    background-position: center;
    background-size: cover;
}

/* ==========================================================================
   BACKGROUND MOTION (client 10/7). Everything pauses off-screen (.mx-off,
   set by motion.js) and nothing here runs for reduced-motion visitors.
   ========================================================================== */
.mx-off,
.mx-off * {
    animation-play-state: paused !important;
}

/* Home hero "air currents": live SVG redraw of the hero-waves ribbon
   (js/motion.js), with gold pulses traveling along two of the lines */
.mx-currents path {
    fill: none;
    stroke: #b9bbd6;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}
.mx-currents .mx-current-pulse {
    stroke: #d4af37;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-dasharray: 70 930;
    filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.85));
}
@media (prefers-reduced-motion: no-preference) {
    .mx-currents .mx-current-pulse {
        animation: mx-pulse-run 7.5s linear infinite;
    }
    .mx-currents .mx-current-pulse + .mx-current-pulse {
        animation-duration: 10.5s;
        animation-delay: -4s;
    }
}
@keyframes mx-pulse-run {
    from { stroke-dashoffset: 1000; }
    to { stroke-dashoffset: 0; }
}

/* Soft glows that breathe and drift */
@media (prefers-reduced-motion: no-preference) {
    .mx-glow-breathe {
        transform-origin: 50% 0;
        animation: mx-breathe 9s ease-in-out infinite alternate;
    }
    .mx-glow-drift {
        animation: mx-drift 16s ease-in-out infinite alternate;
        will-change: translate, scale;
    }
    .mx-glow-drift.mx-glow-slow {
        animation-duration: 21s;
        animation-delay: -7s;
    }
}
@keyframes mx-breathe {
    from { opacity: 0.75; scale: 1; }
    to { opacity: 1; scale: 1.06; }
}
@keyframes mx-drift {
    0% { translate: -6% -4%; scale: 1; }
    50% { translate: 5% 3%; scale: 1.12; }
    100% { translate: -2% 6%; scale: 0.95; }
}

/* Night flight: dark FAQ + quote section. Faint flight grid that slowly
   pans, gold light trails like long-exposure drone lights, blinking beacons */
.mx-night {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.mx-night__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 64px 64px;
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 65% 45%, #000 0%, transparent 100%);
    mask-image: radial-gradient(ellipse 70% 60% at 65% 45%, #000 0%, transparent 100%);
}
.mx-trail {
    position: absolute;
    left: 0;
    top: var(--y);
    width: var(--w);
    height: 1.5px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.15) 35%, rgba(212, 175, 55, 0.9) 85%, #fff6d8);
    opacity: var(--o);
    transform-origin: 0 50%;
    transform: rotate(var(--a)) translateX(-40vw);
}
.mx-trail::after {
    content: "";
    position: absolute;
    right: -2px;
    top: 50%;
    width: 4px;
    height: 4px;
    margin-top: -2px;
    border-radius: 50%;
    background: #fff6d8;
    box-shadow: 0 0 8px 2px rgba(212, 175, 55, 0.8);
}
.mx-beacon {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--c, #ffffff);
    box-shadow: 0 0 6px 2px var(--g, rgba(255, 255, 255, 0.6));
    opacity: 0.15;
}
@media (prefers-reduced-motion: no-preference) {
    /* 10/22: the grid's lines sit on a ::before that slides one 64px cell (GPU), the mask stays
       put on the parent - the same pan without repainting the section every frame. */
    .mx-night__grid {
        background-image: none;
    }
    .mx-night__grid::before {
        content: "";
        position: absolute;
        inset: -64px 0 0 -64px;
        background-image:
            linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
        background-size: 64px 64px;
        animation: mx-grid-slide 36s linear infinite;
        will-change: translate;
    }
    .mx-trail {
        animation: mx-trail var(--d) linear var(--delay) infinite;
    }
    .mx-beacon {
        animation:
            mx-blink var(--b, 2.6s) steps(1, end) var(--bd, 0s) infinite,
            mx-float 24s ease-in-out var(--bd, 0s) infinite alternate;
    }
}
@keyframes mx-grid-pan {
    to { background-position: 64px 64px; }
}
@keyframes mx-trail {
    from { transform: rotate(var(--a)) translateX(-40vw); }
    to { transform: rotate(var(--a)) translateX(140vw); }
}
@keyframes mx-blink {
    0%, 86% { opacity: 0.15; }
    88%, 94% { opacity: 1; }
}
@keyframes mx-float {
    from { translate: 0 0; }
    to { translate: 60px -24px; }
}

@keyframes mx-grid-slide {
    to { translate: 64px 64px; }
}
/* 10/22: glows animate on their own GPU layers (no repaint of the blur each frame) */
.mx-glow-breathe {
    will-change: opacity, scale;
}
