/* ─────────────────────────────────────────────────────────────────────────
   Directed scenes. Each is a sticky stage on a scroll runway; one value,
   --sp (0..1, spring-smoothed in scenes.js), scrubs every animated element:
   paused keyframes, animation-delay: calc(var(--sp) * -1s). The same
   keyframes play in every browser, and without JS or with reduced motion the
   stage simply rests on its final, fully told state (--sp: 1).
   ───────────────────────────────────────────────────────────────────────── */

.scene {
    --sp: 1;
    position: relative;
}

.js:not(.motion-reduced) .scene {
    --sp: 0;
}

.js:not(.motion-reduced) .scene__runway {
    height: var(--runway, 320svh);
}

.scene__stage {
    position: relative;
    display: grid;
    align-items: center;
    gap: clamp(28px, 5vw, 80px);
    min-height: 100svh;
    padding: calc(var(--nav-h) + 40px) var(--gutter) 48px;
    max-width: 1320px;
    margin: 0 auto;
}

.js:not(.motion-reduced) .scene__stage {
    position: sticky;
    top: 0;
    height: 100svh;
    min-height: 600px;
    overflow: clip;
}

.sx {
    animation-duration: 1s;
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-play-state: paused;
    animation-delay: calc(var(--sp) * -1s);
}

.motion-reduced .sx,
html:not(.js) .sx {
    animation: none !important;
}

/* static scenes scroll normally, so the phones size by width alone; a
   height-based size would shrink them to nothing on a phone on its side */
.motion-reduced .scene .scene__devices,
.motion-reduced .scene .app,
html:not(.js) .scene .scene__devices,
html:not(.js) .scene .app {
    --w: min(290px, 72vw);
}

/* Narration: the section's heading, then the beats; the current beat lights. */
.scene__copy {
    position: relative;
    z-index: 2;
    max-width: 460px;
}

.scene__copy .section-title {
    text-align: left;
    margin-top: 10px;
    font-size: clamp(2.2rem, 1.3rem + 2.4vw, 3.5rem);
}

.scene__copy .section-body {
    margin: 18px 0 0;
    text-align: left;
    max-width: 42ch;
}

.beats {
    list-style: none;
    margin: 30px 0 0;
    padding: 0;
    display: grid;
    gap: 2px;
    counter-reset: beat;
}

.beat {
    position: relative;
    padding: 10px 0 10px 22px;
    font-size: 1.12rem;
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: -0.01em;
    /* Steps that aren't current stay readable (5.9:1); the current one turns
       to full ink and gets the orange bar. */
    color: var(--on-paper-2);
}

/* The track every step sits on, and the orange bar of the current step. */
.beat::before,
.beat::after {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 3px;
    background: var(--on-paper-4);
    opacity: 0.5;
}

.beat::after {
    background: var(--orange);
    opacity: 0;
}

/* Each beat's window is its share of the scene (--beat, as a time); the
   animation runs over exactly that window, so 3, 4 or 5 beats all tile 0..1. */
.beat.sx,
.beat.sx::after {
    animation-name: beat-on;
    animation-duration: var(--beat, 0.2s);
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-play-state: paused;
    animation-delay: calc(var(--sp) * -1s + var(--b) * var(--beat, 0.2s));
}

.beat.sx::after {
    animation-name: bar-on;
}

.beat--last.sx {
    animation-name: beat-last;
}

.beat--last.sx::after {
    animation-name: bar-last;
}

@keyframes beat-on {
    0% { color: var(--on-paper-2); }
    10%, 92% { color: var(--on-paper); }
    100% { color: var(--on-paper-2); }
}

@keyframes beat-last {
    0% { color: var(--on-paper-2); }
    10%, 100% { color: var(--on-paper); }
}

@keyframes bar-on {
    0% { opacity: 0; }
    10%, 92% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes bar-last {
    0% { opacity: 0; }
    10%, 100% { opacity: 1; }
}

.motion-reduced .beat,
html:not(.js) .beat {
    color: var(--on-paper);
}

.motion-reduced .beat::after,
html:not(.js) .beat::after {
    animation: none !important;
}

.scene__note {
    margin-top: 26px;
    font-size: 0.92rem;
    color: var(--on-paper-2);
}

[data-surface="dark"] .scene__note {
    color: var(--on-dark-3);
}

/* A scene's note, after the scene, for phones in motion mode (js/boot.js
   addCodas): the sticky stage has no room for it there. */
.coda {
    display: none;
    max-width: 34ch;
    margin: 0 auto;
    padding: 4px var(--gutter) clamp(44px, 9vw, 64px);
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--on-paper-2);
}

@media (max-width: 1023px) {
    .js:not(.motion-reduced) .scene > .coda {
        display: block;
    }
}

.coda:empty {
    display: none !important;
}

/* Sunday's note in Stories is written by js/clock.js, and empty the rest of the week */
.st-sunday:empty {
    display: none;
}

/* The device stage */
.scene__devices {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
}

.scene__devices .app {
    box-shadow: 0 60px 100px -50px rgba(40, 24, 10, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.12);
}

@media (min-width: 1024px) {
    .scene__stage {
        grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    }

    .scene--flip .scene__stage {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    }

    .scene--flip .scene__copy {
        order: 2;
    }
}

/* Short desktop screens (a 1366x768 laptop, say): the beats tell the story,
   so the intro paragraph steps aside, as it does on phones. */
@media (min-width: 1024px) and (max-height: 760px) {
    .js:not(.motion-reduced) .scene__copy .section-body {
        display: none;
    }

    .beats {
        margin-top: 20px;
    }
}

/* Phones: the heading scrolls by first; the sticky stage holds the device and
   one line of narration (the current beat) under it. */
@media (max-width: 1023px) {
    /* the per-scene min-heights are for the desktop's fanned devices; on a
       phone they pushed the device past the bottom of the stage */
    .scene .scene__stage .scene__devices {
        min-height: 0;
    }

    .scene__stage {
        grid-template-rows: auto 1fr;
        justify-items: center;
        gap: 18px;
        padding-top: calc(var(--nav-h) + 28px);
        padding-bottom: 28px;
    }

    .scene__copy {
        max-width: 560px;
        text-align: center;
    }

    .scene__copy .section-title,
    .scene__copy .section-body {
        text-align: center;
        margin-inline: auto;
    }

    .js:not(.motion-reduced) .scene__copy .section-body,
    .js:not(.motion-reduced) .scene__note {
        display: none;
    }

    .js:not(.motion-reduced) .beats {
        display: grid;
        margin-top: 12px;
    }

    .js:not(.motion-reduced) .beat {
        grid-area: 1 / 1;
        padding: 0;
        font-size: 1rem;
        color: var(--on-paper);
        opacity: 0;
    }

    .js:not(.motion-reduced) .beat.sx {
        animation-name: beat-only;
    }

    .js:not(.motion-reduced) .beat--last.sx {
        animation-name: beat-only-last;
    }

    .beat::before,
    .beat::after {
        display: none;
    }

    @keyframes beat-only {
        0% { opacity: 0; }
        10%, 92% { opacity: 1; }
        100% { opacity: 0; }
    }

    @keyframes beat-only-last {
        0% { opacity: 0; }
        10%, 100% { opacity: 1; }
    }
}

/* ─────────────────────────────── AI: Ask Loonee ─────────────────────────────── */
.scene--ai .scene__devices {
    min-height: min(82svh, 760px);
}

.scene--ai .app--chat {
    --w: min(330px, calc((100svh - 200px) * 390 / 844));
    z-index: 2;
}

.scene--ai .app--reminders {
    --w: min(270px, calc((100svh - 260px) * 390 / 844));
    position: absolute;
    z-index: 3;
    left: calc(50% + min(60px, 5vw));
    top: 50%;
    translate: 0 -40%;
    animation-name: ai-r-in;
}

@keyframes ai-r-in {
    0%, 82% { opacity: 0; translate: 40px -36%; scale: 0.94; animation-timing-function: var(--ease-out-cubic); }
    90%, 100% { opacity: 1; translate: 0 -40%; scale: 1; }
}

.scene--ai .a-row--new {
    animation-name: ai-new-row;
}

@keyframes ai-new-row {
    0%, 88% { box-shadow: 0 0 0 0 rgba(244, 123, 37, 0); }
    93% { box-shadow: 0 0 0 calc(8 * var(--u)) rgba(244, 123, 37, 0.18); }
    100% { box-shadow: 0 0 0 calc(3 * var(--u)) rgba(244, 123, 37, 0.18); }
}

/* each step is placed on the 0..1 track by its own keyframes */
.ai-user { animation-name: ai-user; }
.ai-cap { animation-name: ai-cap; }
.ai-row { animation-name: ai-row; }
.ai-chip-1 { animation-name: ai-chip-1; }
.ai-chip-2 { animation-name: ai-chip-2; }
.ai-prop { animation-name: ai-prop; }
.ai-out { animation-name: ai-out; }

@keyframes ai-user {
    0%, 2% { max-height: 0; opacity: 0; translate: 0 calc(12 * var(--u)); }
    7%, 100% { max-height: calc(160 * var(--u)); opacity: 1; translate: 0 0; }
}

@keyframes ai-cap {
    0%, 19% { max-height: 0; opacity: 0; }
    22%, 25% { max-height: calc(60 * var(--u)); opacity: 1; }
    28%, 100% { max-height: 0; opacity: 0; margin-top: calc(-10 * var(--u)); }
}

@keyframes ai-row {
    0%, 26% { max-height: 0; opacity: 0; translate: 0 calc(12 * var(--u)); }
    30%, 100% { max-height: calc(520 * var(--u)); opacity: 1; translate: 0 0; }
}

@keyframes ai-chip-1 {
    0%, 30% { max-height: 0; opacity: 0; }
    32%, 100% { max-height: calc(40 * var(--u)); opacity: 1; }
}

@keyframes ai-chip-2 {
    0%, 33% { max-height: 0; opacity: 0; }
    35%, 100% { max-height: calc(40 * var(--u)); opacity: 1; }
}

@keyframes ai-prop {
    0%, 59% { max-height: 0; opacity: 0; translate: 0 calc(12 * var(--u)); }
    65%, 100% { max-height: calc(260 * var(--u)); opacity: 1; translate: 0 0; }
}

@keyframes ai-out {
    0%, 80% { max-height: 0; opacity: 0; }
    83%, 100% { max-height: calc(30 * var(--u)); opacity: 1; }
}

/* chip label: running → done */
.ai-run-1 { animation-name: ai-run-1; }
.ai-done-1 { animation-name: ai-done-1; }
.ai-run-2 { animation-name: ai-run-2; }
.ai-done-2 { animation-name: ai-done-2; }

@keyframes ai-run-1 { 0%, 35% { opacity: 1; } 37%, 100% { opacity: 0; } }
@keyframes ai-done-1 { 0%, 35% { opacity: 0; } 37%, 100% { opacity: 1; } }
@keyframes ai-run-2 { 0%, 38% { opacity: 1; } 40%, 100% { opacity: 0; } }
@keyframes ai-done-2 { 0%, 38% { opacity: 0; } 40%, 100% { opacity: 1; } }

/* capsule phrases cross-fade (chat_typing_indicator.dart) */
.ai-ph-1 { animation-name: ai-ph-1; }
.ai-ph-2 { animation-name: ai-ph-2; }
@keyframes ai-ph-1 { 0%, 23% { opacity: 1; } 24%, 100% { opacity: 0; } }
@keyframes ai-ph-2 { 0%, 23% { opacity: 0; } 24%, 100% { opacity: 1; } }

/* the bubble: shimmer while tools run, then the reply streams in line by line */
.ai-shimmer { animation-name: ai-shimmer; }
.ai-text { animation-name: ai-text; }

@keyframes ai-shimmer {
    0%, 41% { max-height: calc(60 * var(--u)); opacity: 1; }
    43%, 100% { max-height: 0; opacity: 0; }
}

@keyframes ai-text {
    0%, 42% { max-height: 0; -webkit-mask-position: 0 100%; mask-position: 0 100%; }
    58%, 100% { max-height: calc(400 * var(--u)); -webkit-mask-position: 0 0; mask-position: 0 0; }
}

.ai-text {
    overflow: hidden;
    -webkit-mask: linear-gradient(#000 45%, transparent 55%) 0 100% / 100% 300% no-repeat;
    mask: linear-gradient(#000 45%, transparent 55%) 0 100% / 100% 300% no-repeat;
}

/* Confirm: pressed, then the actions give way to the outcome */
.ai-confirm { animation-name: ai-confirm; }
.ai-actions { animation-name: ai-actions; }

@keyframes ai-confirm {
    0%, 75% { scale: 1; background-color: transparent; }
    77% { scale: 0.95; background-color: rgba(244, 123, 37, 0.28); }
    80%, 100% { scale: 1; background-color: rgba(244, 123, 37, 0.18); }
}

@keyframes ai-actions {
    0%, 80% { max-height: calc(50 * var(--u)); opacity: 1; }
    83%, 100% { max-height: 0; opacity: 0; margin-top: calc(-10 * var(--u)); }
}

/* Static (no JS / reduced motion): the finished conversation, both screens. */
.motion-reduced .scene--ai .app--reminders,
html:not(.js) .scene--ai .app--reminders {
    position: relative;
    left: auto;
    top: auto;
    translate: none;
}

.motion-reduced .scene--ai .scene__devices,
html:not(.js) .scene--ai .scene__devices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
}

.motion-reduced .ai-cap,
html:not(.js) .ai-cap,
.motion-reduced .ai-shimmer,
html:not(.js) .ai-shimmer,
.motion-reduced .ai-actions,
html:not(.js) .ai-actions,
.motion-reduced .ai-run-1,
html:not(.js) .ai-run-1,
.motion-reduced .ai-run-2,
html:not(.js) .ai-run-2 {
    display: none;
}

.motion-reduced .ai-text,
html:not(.js) .ai-text {
    -webkit-mask: none;
    mask: none;
}

@media (max-width: 1023px) {
    .scene--ai .scene__devices {
        min-height: 0;
    }

    .scene--ai .app--chat {
        --w: min(300px, calc((100svh - 250px) * 390 / 844), 78vw);
    }

    .scene--ai .app--reminders {
        --w: min(200px, calc((100svh - 330px) * 390 / 844), 52vw);
        left: auto;
        right: max(-12px, calc(50% - 260px));
        top: auto;
        bottom: 6%;
        translate: 0 0;
    }

    @keyframes ai-r-in {
        0%, 82% { opacity: 0; translate: 30px 0; scale: 0.94; animation-timing-function: var(--ease-out-cubic); }
        90%, 100% { opacity: 1; translate: 0 0; scale: 1; }
    }
}

/* ──────────────────────────────── Scan ──────────────────────────────── */
/* mode content: only the picked mode shows (no JS: food). data-m can name
   several modes ("food plant"), so match words, not the whole attribute. */
.scene--scan [data-m] {
    display: none;
}

.scene--scan[data-mode="food"] [data-m~="food"],
.scene--scan[data-mode="plant"] [data-m~="plant"],
.scene--scan[data-mode="body"] [data-m~="body"] {
    display: block;
}

.scene--scan .s-mode[data-m-on] {
    transition: background-color var(--dur-2) var(--ease-out-cubic), box-shadow var(--dur-2) var(--ease-out-cubic);
}

.scene--scan[data-mode="food"] .s-mode[data-m-on="food"],
.scene--scan[data-mode="plant"] .s-mode[data-m-on="plant"],
.scene--scan[data-mode="body"] .s-mode[data-m-on="body"] {
    background: color-mix(in srgb, var(--c) 16%, rgba(0, 0, 0, 0.35));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 50%, transparent);
}

/* the chips scroll in the app; picking Body brings it into view */
.scene--scan[data-mode="body"] .s-modes {
    justify-content: flex-end;
}

/* body mode: the side view is already staged, the hint asks for the top view,
   and both clear away once the photo is taken and the beam starts */
.scene--scan[data-mode="body"] .s-stage[data-m] {
    display: grid;
}

.scene--scan .s-stage.sx {
    animation: s-stage 1s linear both paused;
    animation-delay: calc(var(--sp) * -1s);
}

@keyframes s-stage {
    0%, 5% { opacity: 1; }
    8%, 100% { opacity: 0; }
}

.motion-reduced .scene--scan .s-stage,
html:not(.js) .scene--scan .s-stage {
    display: none;
}

/* the switcher on the page (a glass segmented control) */
.scan-switch {
    display: inline-flex;
    gap: 4px;
    margin-top: 26px;
    padding: 4px;
    border-radius: var(--r-pill);
}

.scan-switch button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    font: 600 0.95rem/1 var(--font);
    color: var(--on-paper-2);
    cursor: pointer;
    transition: background-color var(--dur-2) var(--ease-out-cubic), color var(--dur-2) var(--ease-out-cubic);
}

.scan-switch button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.scan-switch button[aria-checked="true"] {
    background: #fff;
    color: var(--on-paper);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 16px -8px rgba(60, 40, 20, 0.3);
}

html:not(.js) .scan-switch {
    display: none;
}

.scene--scan .scene__devices {
    grid-template-columns: auto auto;
    gap: clamp(20px, 3vw, 44px);
    min-height: min(80svh, 720px);
}

.scene--scan .app {
    --w: min(300px, calc((100svh - 200px) * 390 / 844), 24vw);
}

/* the camera: the beam sweeps and the capsule says "Looking at it…" */
.s-beam {
    animation: s-beam 2200ms var(--ease-in-out) infinite alternate;
}

@keyframes s-beam {
    from { translate: 0 -10%; }
    to { translate: 0 300%; }
}

.scene--scan .s-beam.sx,
.scene--scan .s-status.sx {
    animation: s-beam 2200ms var(--ease-in-out) infinite alternate, s-busy 1s linear both paused;
    animation-delay: 0s, calc(var(--sp) * -1s);
}

.scene--scan .s-status.sx {
    animation: s-busy 1s linear both paused;
    animation-delay: calc(var(--sp) * -1s);
}

@keyframes s-busy {
    0%, 4% { opacity: 0; }
    8%, 44% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* the result: the second phone arrives, then the sheet rises over the photo */
.s-res {
    animation-name: s-res-in;
}

@keyframes s-res-in {
    0%, 28% { opacity: 0; translate: 0 24px; animation-timing-function: var(--ease-out-cubic); }
    38%, 100% { opacity: 1; translate: 0 0; }
}

.s-sheet {
    animation-name: s-sheet-up;
}

@keyframes s-sheet-up {
    0%, 40% { translate: 0 100%; animation-timing-function: cubic-bezier(0.2, 0.9, 0.25, 1.06); }
    52%, 100% { translate: 0 0; }
}

.s-card > * {
    animation: s-card-in 1s linear both paused;
    animation-delay: calc(var(--sp) * -1s);
}

@keyframes s-card-in {
    0%, 48% { opacity: 0; translate: 0 8px; }
    58%, 100% { opacity: 1; translate: 0 0; }
}

.motion-reduced .s-card > *,
html:not(.js) .s-card > * {
    animation: none;
}

.motion-reduced .s-beam,
html:not(.js) .s-beam,
.motion-reduced .s-status,
html:not(.js) .s-status {
    display: none;
}

/* phones: one screen; the result settles over the camera, as in the app */
@media (max-width: 1023px) {
    .scene--scan .scene__devices {
        grid-template-columns: auto;
        min-height: 0;
    }

    .scene--scan .app {
        --w: min(290px, calc((100svh - 300px) * 390 / 844), 74vw);
        grid-area: 1 / 1;
    }

    .scan-switch {
        margin-top: 14px;
    }

    .js:not(.motion-reduced) .scene--scan .scene__copy .scan-switch {
        display: inline-flex;
    }

    @keyframes s-res-in {
        0%, 32% { opacity: 0; }
        36%, 100% { opacity: 1; }
    }
}

.motion-reduced .scene--scan .s-cam,
html:not(.js) .scene--scan .s-cam {
    display: none;
}

/* ─────────────────────────────── Stories ─────────────────────────────── */
.scene--stories .scene__devices {
    min-height: min(80svh, 720px);
}

.scene--stories .app {
    --w: min(290px, calc((100svh - 200px) * 390 / 844), 22vw);
    grid-area: 1 / 1;
}

.scene--stories .st-week {
    z-index: 3;
    animation-name: st-week;
}

.scene--stories .st-month {
    z-index: 2;
    animation-name: st-month;
}

.scene--stories .st-share {
    z-index: 2;
    animation-name: st-share;
}

@keyframes st-week {
    0%, 2% { opacity: 0; translate: 0 30px; animation-timing-function: var(--ease-out-cubic); }
    10%, 100% { opacity: 1; translate: 0 0; }
}

@keyframes st-month {
    0%, 30% { opacity: 0; translate: 0 0; scale: 0.92; animation-timing-function: var(--ease-out-cubic); }
    44%, 100% { opacity: 1; translate: calc(var(--w) * -0.86) 26px; scale: 0.94; }
}

@keyframes st-share {
    0%, 63% { opacity: 0; translate: 0 0; scale: 0.92; animation-timing-function: var(--ease-out-cubic); }
    77%, 100% { opacity: 1; translate: calc(var(--w) * 0.86) 26px; scale: 0.94; }
}

/* static: three screens side by side */
.motion-reduced .scene--stories .scene__devices,
html:not(.js) .scene--stories .scene__devices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

@media (max-width: 1023px) {
    .scene--stories .app {
        --w: min(280px, calc((100svh - 320px) * 390 / 844), 72vw);
    }

    /* phones: one screen at a time */
    @keyframes st-week {
        0%, 2% { opacity: 0; translate: 0 24px; }
        8%, 30% { opacity: 1; translate: 0 0; }
        36%, 100% { opacity: 0; translate: -40px 0; }
    }

    @keyframes st-month {
        0%, 30% { opacity: 0; translate: 40px 0; scale: 1; }
        36%, 63% { opacity: 1; translate: 0 0; scale: 1; }
        69%, 100% { opacity: 0; translate: -40px 0; scale: 1; }
    }

    @keyframes st-share {
        0%, 63% { opacity: 0; translate: 40px 0; scale: 1; }
        69%, 100% { opacity: 1; translate: 0 0; scale: 1; }
    }

}

/* ─────────────────────────── Reminders and health ─────────────────────────── */
.scene--health .scene__devices {
    min-height: min(80svh, 720px);
}

/* on the container too, so the wrappers (.h-rem) can move by phone widths */
.scene--health .scene__devices,
.scene--health .app {
    --w: min(290px, calc((100svh - 200px) * 390 / 844), 22vw);
}

.scene--health .h-rem,
.scene--health .h-vacc,
.scene--health .h-pdf {
    grid-area: 1 / 1;
}

.h-rem {
    position: relative;
    z-index: 2;
    animation-name: h-rem;
}

.h-pushes {
    position: absolute;
    z-index: 3;
    left: -34%;
    right: 18%;
    top: 12%;
    display: grid;
    gap: 10px;
}

.h-push {
    position: relative;
    width: 300px;
    background: rgba(38, 30, 24, 0.86);
    border-color: rgba(255, 255, 255, 0.12);
    animation-name: h-push;
    animation-delay: calc(var(--sp) * -1s + var(--i, 0) * 0.06s) !important;
}

.h-vacc {
    z-index: 3;
    animation-name: h-vacc;
}

.h-pdf {
    --w: min(300px, 23vw);
    z-index: 4;
    animation-name: h-pdf;
}

@keyframes h-rem {
    0%, 2% { opacity: 0; translate: 0 30px; animation-timing-function: var(--ease-out-cubic); }
    10%, 33% { opacity: 1; translate: 0 0; animation-timing-function: var(--ease-in-out); }
    44%, 100% { opacity: 1; translate: calc(var(--w) * -0.62) 0; scale: 0.92; }
}

@keyframes h-push {
    0%, 8% { opacity: 0; translate: 0 -18px; animation-timing-function: var(--ease-out-cubic); }
    16%, 30% { opacity: 1; translate: 0 0; }
    38%, 100% { opacity: 0; translate: 0 -10px; }
}

@keyframes h-vacc {
    0%, 33% { opacity: 0; translate: 40% 0; animation-timing-function: var(--ease-out-cubic); }
    46%, 66% { opacity: 1; translate: calc(var(--w) * 0.34) 0; animation-timing-function: var(--ease-in-out); }
    78%, 100% { opacity: 1; translate: calc(var(--w) * 0.1) 0; }
}

@keyframes h-pdf {
    0%, 66% { opacity: 0; translate: 40% 40px; rotate: 6deg; animation-timing-function: cubic-bezier(0.2, 0.9, 0.25, 1.04); }
    80%, 100% { opacity: 1; translate: calc(var(--w) * 0.72) 30px; rotate: 3deg; }
}

.motion-reduced .scene--health .scene__devices,
html:not(.js) .scene--health .scene__devices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
}

.motion-reduced .h-pushes,
html:not(.js) .h-pushes {
    display: none;
}

@media (max-width: 1023px) {
    .scene--health .scene__devices,
    .scene--health .app {
        --w: min(280px, calc((100svh - 320px) * 390 / 844), 72vw);
    }

    .h-pdf {
        --w: min(300px, 78vw);
    }

    .h-pushes {
        left: -6%;
        right: -6%;
        top: 9%;
    }

    .h-push {
        width: auto;
    }

    @keyframes h-rem {
        0%, 2% { opacity: 0; translate: 0 24px; }
        8%, 30% { opacity: 1; translate: 0 0; }
        36%, 100% { opacity: 0; translate: -40px 0; scale: 1; }
    }

    @keyframes h-vacc {
        0%, 30% { opacity: 0; translate: 40px 0; }
        36%, 63% { opacity: 1; translate: 0 0; }
        69%, 100% { opacity: 0; translate: -40px 0; }
    }

    @keyframes h-pdf {
        0%, 63% { opacity: 0; translate: 40px 20px; rotate: 4deg; }
        70%, 100% { opacity: 1; translate: 0 0; rotate: 1.5deg; }
    }
}

/* ─────────────────────────────── Day care ─────────────────────────────── */
/* The owner's stay fills in as the venue logs it: checked in (push), a walk,
   lunch and a nap (one rolled-up push), Apoquel and a photo (instant pushes),
   then "Visit complete", the report-card banner, and the card itself. */
.scene--care .scene__devices {
    min-height: min(80svh, 720px);
}

.scene--care .scene__devices,
.scene--care .app {
    --w: min(290px, calc((100svh - 200px) * 390 / 844), 22vw);
}

.scene--care .k-stay,
.scene--care .k-card {
    grid-area: 1 / 1;
}

.k-stay {
    position: relative;
    z-index: 2;
    animation-name: k-stay;
}

.k-card {
    z-index: 3;
    animation-name: k-card;
}

.k-pushes {
    position: absolute;
    z-index: 3;
    left: -34%;
    right: 18%;
    top: 12%;
    display: grid;
}

.k-push {
    grid-area: 1 / 1;
    position: relative;
    width: 300px;
    background: rgba(38, 30, 24, 0.86);
    border-color: rgba(255, 255, 255, 0.12);
    animation-name: k-push;
    animation-delay: calc(var(--sp) * -1s + var(--at) * 1s) !important;
}

/* entries, the banner and the pushes run from their own --at on the track */
.k-ent.sx {
    animation-name: k-ent;
    animation-delay: calc(var(--sp) * -1s + var(--at) * 1s);
}

.k-st1.sx { animation-name: k-st1; }
.k-st2.sx { animation-name: k-st2; }
.k-st3.sx { animation-name: k-st3; }
.k-count.sx { animation-name: k-count; }
.k-empty.sx { animation-name: k-empty; }

@keyframes k-stay {
    0%, 2% { opacity: 0; translate: 0 30px; animation-timing-function: var(--ease-out-cubic); }
    8%, 80% { opacity: 1; translate: 0 0; animation-timing-function: var(--ease-in-out); }
    92%, 100% { opacity: 1; translate: calc(var(--w) * -0.56) 0; scale: 0.92; }
}

@keyframes k-card {
    0%, 82% { opacity: 0; translate: 40% 0; animation-timing-function: var(--ease-out-cubic); }
    94%, 100% { opacity: 1; translate: calc(var(--w) * 0.46) 0; }
}

@keyframes k-push {
    0% { opacity: 0; translate: 0 -18px; animation-timing-function: var(--ease-out-cubic); }
    3%, 12% { opacity: 1; translate: 0 0; }
    15%, 100% { opacity: 0; translate: 0 -10px; }
}

/* fold open, then the app's _Appear: fade in while dropping 12 pt into place */
@keyframes k-ent {
    0% { grid-template-rows: 0fr; opacity: 0; translate: 0 calc(-12 * var(--u)); animation-timing-function: var(--ease-out-cubic); }
    3% { grid-template-rows: 1fr; opacity: 0; translate: 0 calc(-12 * var(--u)); animation-timing-function: var(--ease-out-cubic); }
    6%, 100% { grid-template-rows: 1fr; opacity: 1; translate: 0 0; }
}

@keyframes k-st1 {
    0%, 9% { opacity: 1; }
    11%, 100% { opacity: 0; }
}

@keyframes k-st2 {
    0%, 9% { opacity: 0; }
    11%, 71% { opacity: 1; }
    73%, 100% { opacity: 0; }
}

@keyframes k-st3 {
    0%, 71% { opacity: 0; }
    73%, 100% { opacity: 1; }
}

/* counters.logs: one per entry (check-in writes no log) */
@keyframes k-count {
    0%, 28% { --k-n: 0; opacity: 0; }
    29%, 35% { --k-n: 1; opacity: 1; }
    36%, 42% { --k-n: 2; opacity: 1; }
    43%, 59% { --k-n: 3; opacity: 1; }
    60%, 69% { --k-n: 4; opacity: 1; }
    70%, 100% { --k-n: 5; opacity: 1; }
}

@keyframes k-empty {
    0%, 26% { opacity: 1; }
    28%, 100% { opacity: 0; }
}

/* static: both screens side by side, the stay complete */
.motion-reduced .scene--care .scene__devices,
html:not(.js) .scene--care .scene__devices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
}

.motion-reduced .k-pushes,
html:not(.js) .k-pushes {
    display: none;
}

@media (max-width: 1023px) {
    .scene--care .scene__devices,
    .scene--care .app {
        --w: min(280px, calc((100svh - 320px) * 390 / 844), 72vw);
    }

    /* where iOS banners sit: over the status and app bars, clear of the stay's status */
    .k-pushes {
        left: -6%;
        right: -6%;
        top: 0.5%;
    }

    .k-push {
        width: auto;
    }

    /* phones: one screen at a time; the stay leaves before the card arrives,
       as if the "report card is ready" push had been tapped */
    @keyframes k-stay {
        0%, 2% { opacity: 0; translate: 0 24px; }
        8%, 84% { opacity: 1; translate: 0 0; scale: 1; }
        87%, 100% { opacity: 0; translate: -40px 0; scale: 1; }
    }

    @keyframes k-card {
        0%, 87% { opacity: 0; translate: 40px 0; }
        91%, 100% { opacity: 1; translate: 0 0; }
    }
}
