/*
 * Site-wide motion on the tokens in base.css :root (entrances are in
 * reveal.css):
 *   page transitions  cross-document View Transitions: the header stays put,
 *                     the old page lifts away and the new one rises in through
 *                     a rounded reveal (reversed on back/forward), the current
 *                     nav underline slides to the new item, and a thin line
 *                     under the header shows a page still loading. Every page
 *                     is still a full server page; browsers without support
 *                     navigate as before
 *   button press      every .rm-btn and .rm-fbtn scales to .97 while pressed
 *   arrow             a button's arrow (parts/button.php 'arrow') moves 3px
 *                     forward on hover and keyboard focus
 *   card lift         link cards rise 2px with a blurple-tinted shadow, only
 *                     on devices that hover
 *   hero titles       words rise one after another on load (rm_theme_words)
 *   scroll            media drift, the header settling and a reading line
 *                     (scroll-driven animations, see below)
 * Reduced motion turns all of it off.
 */

@view-transition {
    navigation: auto;
}

.rm-header {
    view-transition-name: rm-header;
}

.rm-header__link.is-current {
    position: relative;
}

.rm-header__link.is-current::after {
    content: "";
    position: absolute;
    right: 15px;
    bottom: 9px;
    left: 15px;
    height: 2px;
    border-radius: 2px;
    background: var(--rm-blurple);
    view-transition-name: rm-nav-current;
}

::view-transition-group(rm-header) {
    animation-duration: 0s;
}

::view-transition-group(rm-nav-current) {
    animation-duration: 520ms;
    animation-timing-function: var(--rm-ease);
}

::view-transition-old(root) {
    animation: rm-vt-leave 320ms cubic-bezier(.4, 0, 1, 1) both;
}

::view-transition-new(root) {
    animation: rm-vt-enter 760ms var(--rm-ease) 90ms both;
}

html:active-view-transition-type(back)::view-transition-old(root) {
    animation-name: rm-vt-leave-back;
}

html:active-view-transition-type(back)::view-transition-new(root) {
    animation-name: rm-vt-enter-back;
}

@keyframes rm-vt-leave {
    to { opacity: 0; transform: translateY(-32px) scale(.97); }
}

@keyframes rm-vt-enter {
    from { opacity: 0; transform: translateY(56px); clip-path: inset(10% 2% 0 2% round 40px); }
    to { clip-path: inset(0 0 0 0 round 0); }
}

@keyframes rm-vt-leave-back {
    to { opacity: 0; transform: translateY(32px) scale(.97); }
}

@keyframes rm-vt-enter-back {
    from { opacity: 0; transform: translateY(-40px); clip-path: inset(0 2% 10% 2% round 40px); }
    to { clip-path: inset(0 0 0 0 round 0); }
}

/* While the next page loads (assets/js/page-transition.js sets html.rm-leaving), a
   thin blurple line runs under the header, so a slow page still answers the click. */
.rm-header::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--rm-blurple);
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    pointer-events: none;
}

.rm-leaving .rm-header::after {
    opacity: 1;
    animation: rm-vt-progress 2400ms cubic-bezier(.1, .7, .2, 1) both;
}

@keyframes rm-vt-progress {
    from { transform: scaleX(0); }
    to { transform: scaleX(.85); }
}

.rm-btn,
.rm-fbtn {
    transition: background-color var(--rm-dur-base) var(--rm-ease), color var(--rm-dur-base) var(--rm-ease), border-color var(--rm-dur-base) var(--rm-ease), transform var(--rm-dur-fast) var(--rm-ease);
}

.rm-btn:active,
.rm-fbtn:active {
    transform: scale(.97);
    transition-duration: 60ms;
}

.rm-btn__arrow {
    display: inline-block;
    width: .8em;
    height: .8em;
    margin-left: .45em;
    transition: transform var(--rm-dur-base) var(--rm-ease);
}

.rm-btn:hover .rm-btn__arrow,
.rm-btn:focus-visible .rm-btn__arrow,
.rm-fbtn--2:hover .rm-fbtn__icon,
.rm-fbtn--2:focus-visible .rm-fbtn__icon {
    transform: translateX(3px);
}

.rm-fbtn__icon {
    transition: transform var(--rm-dur-base) var(--rm-ease);
}

.rm-job-card__link,
.rm-pub-card,
.rm-team-card,
.rm-episode-more__card img,
.rm-insight-card__art {
    transition: transform var(--rm-dur-base) var(--rm-ease), box-shadow var(--rm-dur-base) var(--rm-ease), border-color var(--rm-dur-base) var(--rm-ease), background-color var(--rm-dur-base) var(--rm-ease);
}

@media (hover: hover) {
    .rm-job-card__link:hover,
    .rm-pub-card:hover,
    .rm-team-card:hover,
    .rm-episode-more__card:hover img,
    .rm-insight-card:has(.rm-insight-card__link:hover) .rm-insight-card__art {
        box-shadow: 0 14px 36px rgba(94, 85, 252, .16);
        transform: translateY(-2px);
    }
}

.rm-job-card__link:focus-visible,
.rm-pub-card:focus-visible,
.rm-episode-more__card:focus-visible img,
.rm-insight-card:has(.rm-insight-card__link:focus-visible) .rm-insight-card__art {
    box-shadow: 0 14px 36px rgba(94, 85, 252, .16);
    transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }

    .rm-leaving .rm-header::after {
        animation: none;
        transform: scaleX(.85);
    }

    .rm-btn,
    .rm-fbtn,
    .rm-btn__arrow,
    .rm-fbtn__icon,
    .rm-job-card__link,
    .rm-pub-card,
    .rm-team-card,
    .rm-episode-more__card img,
    .rm-insight-card__art {
        transition: none;
    }

    .rm-btn:active,
    .rm-fbtn:active,
    .rm-btn .rm-btn__arrow,
    .rm-fbtn .rm-fbtn__icon,
    .rm-job-card__link,
    .rm-pub-card,
    .rm-team-card,
    .rm-episode-more__card img,
    .rm-insight-card__art {
        transform: none !important;
    }
}

/* Hero titles (rm_theme_words() in the hero blocks): the words rise out of a mask on load,
   one after another, highlighted words last. CSS only, so it starts with the first paint, and
   no word is ever fully hidden (it starts 70% down its mask at 20% opacity), so the title still
   paints at once for LCP. */
.rm-hero-words .rm-word {
    display: inline-block;
    overflow: clip;
    padding-bottom: .14em;
    margin-bottom: -.14em;
    vertical-align: top;
}

.rm-hero-words .rm-word > span {
    display: inline-block;
    animation: rm-hero-word 1300ms var(--rm-ease) both;
    animation-delay: calc(250ms + var(--rm-w, 0) * 90ms);
}

.rm-hero-words .rm-accent .rm-word > span {
    animation-delay: calc(450ms + var(--rm-w, 0) * 90ms);
}

@keyframes rm-hero-word {
    from { opacity: .2; transform: translateY(70%); }
}

@media (prefers-reduced-motion: reduce) {
    .rm-hero-words .rm-word > span {
        animation: none;
    }
}

/* Scroll-linked motion (CSS scroll-driven animations; browsers without them, and reduced
   motion, get none of it). Transform, opacity and paint only, so nothing moves in the layout:
   - section media (images, videos, motifs beside text) drift 28px against the scroll, so the
     panels gain a little depth as they pass;
   - the header bar gains a soft shadow and a frosted background over the first 160px;
   - on episodes and insights a thin blurple line under the header shows how far you have read. */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .rm-home-feature__media > *,
        .rm-feature-row__media > *,
        .rm-practice__media > *,
        .rm-careers-digs__media > *,
        .rm-showcase__img {
            animation: rm-scroll-drift linear both;
            animation-timeline: view();
            animation-range: entry 0% exit 100%;
        }

        .rm-header__bar {
            animation: rm-scroll-header linear both;
            animation-timeline: scroll(root);
            animation-range: 0 160px;
        }

        body:has(.rm-episode, .rm-insight) .rm-header::before {
            content: "";
            position: absolute;
            right: 10px;
            bottom: 2px;
            left: 10px;
            height: 2px;
            border-radius: 2px;
            background: var(--rm-blurple);
            transform-origin: left;
            pointer-events: none;
            animation: rm-scroll-progress linear both;
            animation-timeline: scroll(root);
        }
    }
}

@keyframes rm-scroll-drift {
    from { transform: translateY(28px); }
    to { transform: translateY(-28px); }
}

@keyframes rm-scroll-header {
    to {
        background: rgba(255, 255, 255, .86);
        box-shadow: 0 10px 30px rgba(41, 41, 41, .08);
        backdrop-filter: blur(12px);
    }
}

@keyframes rm-scroll-progress {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* Pause buttons (parts/pause-button.php): a small round button in a corner of
   the moving band; the icon shows what a press does. */
.rm-pause {
    position: absolute;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(41, 41, 41, .2);
    border-radius: 50%;
    background: var(--rm-white);
    color: var(--rm-black);
    cursor: pointer;
    transition: background-color var(--rm-dur-base) var(--rm-ease), color var(--rm-dur-base) var(--rm-ease), transform var(--rm-dur-fast) var(--rm-ease);
}

.rm-pause[hidden] {
    display: none;
}

.rm-pause svg {
    width: 16px;
    height: 16px;
}

.rm-pause:hover,
.rm-pause:focus-visible {
    background: var(--rm-black);
    color: var(--rm-white);
}

.rm-pause:focus-visible {
    outline: 2px solid var(--rm-blurple);
    outline-offset: 2px;
}

.rm-pause:active {
    transform: scale(.94);
}

.rm-pause[aria-pressed="false"] .rm-pause__icon-play,
.rm-pause[aria-pressed="true"] .rm-pause__icon-pause {
    display: none;
}

.rm-logo-strip__pause {
    right: 16px;
    bottom: 12px;
}

.rm-logo-strip:not(.is-paused):has(.rm-pause:hover, .rm-pause:focus-visible) .rm-logo-strip__track {
    animation-play-state: running;
}

.rm-logo-strip.is-paused .rm-logo-strip__track {
    animation-play-state: paused;
}

.rm-home-testimonials__pause {
    right: 0;
    bottom: 0;
}

.rm-compatible__pause {
    right: 24px;
    bottom: 36px;
    border-color: rgba(255, 255, 255, .3);
    background: transparent;
    color: var(--rm-white);
}

.rm-compatible__pause:hover,
.rm-compatible__pause:focus-visible {
    background: var(--rm-white);
    color: var(--rm-black);
}
