/* Captions sit in the window's column on a separate grid row, keeping the
 * window and copy aligned. Invisible words reserve their final layout space. */
.home-page-slideshow :is(.home-thoughts-slide, .home-transform-slide, .home-context-slide, .home-tts-slide, .home-launch-slide) > .grid {
    row-gap: 1.5rem !important;
}

.home-page-slideshow .home-caption-row:is(.home-thoughts-voice-indicator, .home-feature-voice-indicator) {
    grid-column: 1 / -1;
    order: 3;
    position: relative !important;
    inset: auto !important;
    width: 100%;
    min-height: 5.5rem;
    margin-top: 0;
    align-items: flex-start;
}

.home-page-slideshow .home-caption-row > .relative {
    display: grid;
    align-items: start;
    width: fit-content;
    max-width: min(26rem, 100%) !important;
    height: auto;
    min-height: 2rem;
}

.home-page-slideshow .home-caption-row .slide-window-status {
    position: relative;
    inset: auto;
    transform: none;
    grid-area: 1 / 1;
    align-self: start;
    justify-self: center;
    width: fit-content;
    max-width: 100%;
    gap: 0.625rem;
    padding: 0;
    pointer-events: none;
}

.home-page-slideshow .slide-window-status.voice-caption {
    align-items: flex-start;
    justify-content: center;
}

.home-page-slideshow .voice-caption-icon {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
}

.voice-caption-active .voice-caption-icon {
    animation: voiceActivePulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Match the caption typography instead of retaining the old tiny status label. */
.home-page-slideshow .home-caption-row .slide-window-status:not(.voice-caption) > span {
    font-size: 1.125rem;
    line-height: 1.6;
    font-weight: 500;
}

.home-page-slideshow .home-caption-row .slide-window-status:not(.voice-caption) > .animate-spin {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.home-page-slideshow .voice-caption-text {
    display: block;
    min-width: 0;
    flex: 0 1 auto;
    color: rgb(var(--vv-color-text));
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1.6;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
}

.voice-caption-word {
    display: inline-block;
    max-width: 100%;
    margin-inline-end: 0.26em;
    opacity: 0;
}

.voice-caption-active .voice-caption-word {
    animation: voiceWordReveal 180ms ease-out var(--word-delay, 0ms) forwards;
}

@keyframes voiceWordReveal {
    from {
        opacity: 0;
        filter: blur(3px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* The original steady activity pulse, independent of speech timing. */
@keyframes voiceActivePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@media (min-width: 768px) {
    .home-page-slideshow :is(.home-transform-slide, .home-tts-slide, .home-launch-slide) .home-caption-row {
        grid-column: 1;
        grid-row: 2;
    }

    .home-page-slideshow :is(.home-thoughts-slide, .home-context-slide) .home-caption-row {
        grid-column: 2;
        grid-row: 2;
    }
}

/* One compact, fluid width for every rotating demo—not a different cap per slide. */
.home-page-slideshow .home-demo-slot > .max-w-sm {
    width: 100%;
    max-width: min(26rem, 100%) !important;
    transition-property: transform, opacity !important;
}

/* Match the md column-stacking breakpoint, not the smaller phone breakpoint. */
@media (max-width: 767px) {
    .home-page-slideshow .home-mobile-feature-slide :is(.home-story-feature-heading, .home-story-feature-copy) {
        text-align: center;
        margin-inline: auto;
    }
}

@media (max-width: 767px) {
    .home-page-slideshow .voice-caption-text,
    .home-page-slideshow .home-caption-row .slide-window-status:not(.voice-caption) > span {
        font-size: 1rem;
        line-height: 1.5;
    }

    /* Center a compact envelope sized for each slide, not the largest window
     * in the entire tour. These bounds cover the authored examples at 320px+
     * and shrink fluidly as wider lines reduce their natural height. */
    .home-page-slideshow .home-thoughts-slide {
        --demo-slot-height: 15rem;
    }

    .home-page-slideshow .home-transform-slide {
        --demo-slot-height: clamp(16rem, calc(24rem - 30vw), 17.5rem);
    }

    .home-page-slideshow .home-context-slide {
        --demo-slot-height: clamp(19rem, calc(27rem - 30vw), 20.5rem);
    }

    .home-page-slideshow .home-tts-slide {
        --demo-slot-height: clamp(13.5rem, calc(21.5rem - 30vw), 15rem);
    }

    .home-page-slideshow .home-launch-slide {
        --demo-slot-height: clamp(18.25rem, calc(26rem - 30vw), 19.75rem);
    }

    .home-page-slideshow .home-caption-row:is(.home-thoughts-voice-indicator, .home-feature-voice-indicator) {
        /* Keep the layout reservation, but place visible captions 1rem below the
         * natural window bottom. Only the caption moves between examples. */
        transform: translateY(calc(var(--demo-window-height, var(--demo-slot-height)) - var(--demo-slot-height)));
        /* Captions are a footer below the centered heading/window group. Their
         * hidden sizing copies must not add blank height to that group's center. */
        height: 0;
        min-height: 0;
        margin-top: 0;
    }

    /* Preserve heading → window → caption on phones, with a scroll fallback
     * for short viewports rather than clipping the complete sentence. */
    .home-page-slideshow :is(.home-thoughts-slide, .home-transform-slide, .home-context-slide, .home-tts-slide, .home-launch-slide) {
        overflow-y: auto;
        align-items: safe center;
    }

    .home-page-slideshow :is(.home-thoughts-slide, .home-transform-slide, .home-context-slide, .home-tts-slide, .home-launch-slide) > .grid {
        width: calc(100vw - 2rem);
        flex-shrink: 0;
        height: auto;
        max-height: none;
        padding-inline: 0 !important;
        grid-template-rows: auto auto auto;
        row-gap: 1rem !important;
        margin-block: auto;
    }

    /* Reserve space OUTSIDE the visible window. Its natural height can change,
     * but must not resize/recenter the grid. The caption tracks its bottom. */
    .home-page-slideshow .home-mobile-feature-slide > .grid > .home-demo-slot {
        position: relative;
        height: var(--demo-slot-height);
        min-height: 0;
        width: 100%;
    }

    .home-page-slideshow .home-demo-slot > .max-w-sm {
        position: absolute;
        top: 0;
        left: 50%;
        translate: -50% 0;
    }

    /* Give stacked copy and demos breathing room, without increasing the
     * smaller gap between each window and its caption. */
    .home-page-slideshow .home-thoughts-slide > .grid > :first-child,
    .home-page-slideshow .home-transform-slide > .grid > :nth-child(2),
    .home-page-slideshow .home-context-slide > .grid > :first-child,
    .home-page-slideshow .home-tts-slide > .grid > :nth-child(2),
    .home-page-slideshow .home-launch-slide > .grid > :nth-child(2) {
        margin-bottom: 1.25rem;
    }

    .home-page-slideshow .home-thoughts-layout {
        max-height: none;
    }
}

/* The original page only gave the slide stage height below 640px. Keep the
 * same scrollable surface through the rest of the stacked (sm) range. */
@media (min-width: 640px) and (max-width: 767px) {
    .home-page-slideshow .home-slideshow-stage {
        padding-inline: 1rem !important;
    }

    .home-page-slideshow .home-slideshow-content {
        height: calc(100svh - var(--home-story-header-height));
        padding-inline: 0 !important;
    }
}

/* Hidden sizing copies reserve the actual tallest caption, rather than an
 * arbitrary blank block that pulls the visible stack above the midpoint. */
.voice-caption-reserve {
    visibility: hidden;
}

/* Stop the microphone pulse once recording ends, including screenshot capture. */
.home-page-slideshow .voice-caption-icon.voice-caption-idle {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    .voice-caption-active .voice-caption-word {
        animation: none;
        opacity: 1;
        filter: none;
    }

    .home-page-slideshow .voice-caption-icon {
        animation: none !important;
    }
}
