/* Homepage motion system. Values follow the landing-page-design and design-to-motion skills:
   hero appear (6px rise, 2px blur, 50-70ms stagger), card rise on scroll, story loops on visuals.
   Everything here only hides content once JS has opted in (html.ev-motion / html.ev-io), so the
   page reads fine with JS off, and reduced motion users see every final state at once. */

:root {
    --ev-e: cubic-bezier(0.16, 1, 0.3, 1);
    --ev-e2: cubic-bezier(0.33, 1, 0.68, 1);
    --ev-io: cubic-bezier(0.65, 0, 0.35, 1);
    --ev-base: cubic-bezier(0.22, 1, 0.36, 1);
}

.ev-balance { text-wrap: balance; }
.ev-pretty { text-wrap: pretty; }

/* ---------- Hero appear (page load, once) ---------- */
.ev-motion [data-appear] {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(2px);
}
.ev-motion.ev-ready [data-appear] {
    opacity: 1;
    transform: none;
    filter: none;
    transition: transform 0.8s var(--ev-e), opacity 0.6s var(--ev-e2), filter 0.6s var(--ev-e2);
    transition-delay: var(--d, 0s);
}
/* Floating hero cards use the larger card rise */
.ev-motion [data-appear="card"] {
    transform: translateY(24px) scale(0.985);
    filter: blur(6px);
}
.ev-motion.ev-ready [data-appear="card"] {
    transition: transform 0.9s var(--ev-e), opacity 0.6s var(--ev-e2), filter 0.7s var(--ev-e2);
    transition-delay: var(--d, 0s);
}
/* Hero photo resolves from blur like a photo load */
.ev-motion [data-appear="photo"] {
    transform: scale(1.015);
    filter: blur(14px) saturate(0.6);
}
.ev-motion.ev-ready [data-appear="photo"] {
    transition: transform 1.4s var(--ev-e), opacity 0.8s var(--ev-e2), filter 1.1s var(--ev-e2);
    transition-delay: var(--d, 0s);
}

/* Hand drawn underline under the headline draws on */
.ev-underline path {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
}
.ev-motion .ev-underline path { stroke-dashoffset: 1; }
.ev-motion.ev-ready .ev-underline path {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.9s var(--ev-io) 0.75s;
}

/* ---------- Hero media ---------- */
.ev-hero-media { isolation: isolate; }
.ev-hero-media video {
    opacity: 0;
    transition: opacity 1.2s var(--ev-e2);
}
.ev-hero-media video.is-playing { opacity: 1; }

/* Equalizer bars on the live call card */
.ev-eq { display: flex; align-items: center; gap: 3px; height: 24px; }
.ev-eq span {
    display: block;
    width: 3px;
    height: 24px;
    border-radius: 9999px;
    background: currentColor;
    transform-origin: center;
    transform: scaleY(var(--h, 0.4));
    will-change: transform;
}

/* Typing caret */
.ev-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -0.15em;
    background: currentColor;
    opacity: 0;
}
.ev-caret.is-on { opacity: 1; }

/* Chat bubbles and toasts that the stories bring in */
.ev-motion .ev-pop {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(4px);
    transition: transform 0.7s var(--ev-e), opacity 0.5s var(--ev-e2), filter 0.5s var(--ev-e2);
}
.ev-motion .ev-pop.is-in { opacity: 1; transform: none; filter: none; }

/* Checklist ticks */
.ev-tick {
    transition: background-color 0.4s var(--ev-e2), color 0.4s var(--ev-e2), border-color 0.4s var(--ev-e2);
}
.ev-tick i {
    opacity: 0;
    transform: scale(0.6);
    transition: transform 0.5s var(--ev-e), opacity 0.3s var(--ev-e2);
}
.ev-tick.is-done { background-color: #238277; border-color: #238277; color: #fff; }
.ev-tick.is-done i { opacity: 1; transform: none; }

/* Pulse ring for live indicators */
@keyframes ev-ring {
    0% { transform: scale(1); opacity: 0.55; }
    100% { transform: scale(2.6); opacity: 0; }
}
.ev-ring { position: relative; }
.ev-ring::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: inherit;
    animation: ev-ring 2s var(--ev-e2) infinite;
}

/* ---------- Scroll reveals (sections and cards, once) ---------- */
.ev-io [data-reveal] {
    opacity: 0;
    transform: translateY(32px);
}
.ev-io [data-reveal].is-in {
    opacity: 1;
    transform: none;
    transition: transform 0.8s var(--ev-base), opacity 0.7s var(--ev-base);
    /* Stagger at 60% of the marked step, so a section reached by a fast scroll settles quickly */
    transition-delay: calc(var(--d, 0s) * 0.6);
}
.ev-io [data-reveal="card"] {
    transform: translateY(24px) scale(0.985);
    filter: blur(3px);
}
.ev-io [data-reveal="card"].is-in {
    filter: none;
    transition: transform 0.9s var(--ev-e), opacity 0.6s var(--ev-e2), filter 0.45s var(--ev-e2), box-shadow 0.3s var(--ev-base), border-color 0.3s var(--ev-base);
    /* Only the entrance waits for its stagger; hover feedback stays instant */
    transition-delay: calc(var(--d, 0s) * 0.6), calc(var(--d, 0s) * 0.6), calc(var(--d, 0s) * 0.6), 0s, 0s;
}

/* The floating chat button steps aside while the pinned story fills the screen behind it */
#ev-open { transition: opacity 0.3s var(--ev-base), visibility 0s; }
.ev-story-on.ev-story-under-chat #ev-open { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s var(--ev-base), visibility 0s 0.3s; }

/* ---------- Tagline: words light up one at a time ---------- */
.ev-home-tagline .w {
    color: rgba(38, 70, 83, 0.28);
    transition: color 0.6s var(--ev-base);
}
.ev-home-tagline .w.is-on { color: #264653; }
.ev-home-tagline .w.accent.is-on { color: #238277; }

/* ---------- Story: a day with ElderVoice, one chapter per screen ----------
   Resting layout (no JS, reduced motion): chapters stack, every card visible.
   html.ev-story-on (set by home-motion.js): one sticky stage below the 80px nav, chapters
   cross over each other as the section scrolls, and the rail tracks progress. */
.ev-ch {
    display: grid;
    gap: 32px;
    align-items: center;
    padding: 48px 0;
}
.ev-ch-eyebrow { color: #238277; font-weight: 700; font-size: 0.875rem; line-height: 1.25rem; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 12px; }
.ev-ch-title { color: #264653; font-weight: 600; font-size: 1.875rem; line-height: 2.25rem; margin-bottom: 16px; }
.ev-ch-body { color: #4b5563; font-size: 1.125rem; line-height: 1.75rem; max-width: 30rem; }
.ev-ch-note { color: #6b7280; font-size: 0.875rem; line-height: 1.25rem; margin-top: 16px; }
.ev-ch-media {
    position: relative;
    margin: 0;
    width: 100%;
    max-width: 460px;
    aspect-ratio: 4 / 5;
    border-radius: 2rem;
    overflow: hidden;
    background: #E9E2D6;
    box-shadow: 0 25px 50px -12px rgba(38, 70, 83, 0.25);
    justify-self: center;
    isolation: isolate;
}
.ev-ch-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(calc(1.08 - var(--cp, 1) * 0.08));
}
.ev-story-on .ev-ch.is-active .ev-ch-media img { will-change: transform; }
.ev-ch-card {
    position: absolute;
    z-index: 1;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #fff;
    box-shadow: 0 20px 25px -5px rgba(38, 70, 83, 0.15);
    padding: 16px;
}
.ev-ch-tick { width: 24px; height: 24px; border-radius: 9999px; background: #238277; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; flex-shrink: 0; }
.ev-ch-bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 64px; }
.ev-ch-bars span {
    flex: 1;
    height: 100%;
    border-radius: 6px;
    background: #238277;
    transform-origin: bottom center;
    transform: scaleY(var(--h));
}
.ev-ch-bars span.is-low { background: #F4A261; }
.ev-story-rail { display: none; }

@media (min-width: 1024px) {
    .ev-ch { grid-template-columns: 5fr 6fr; gap: 64px; padding: 64px 0; }
    .ev-ch-title { font-size: 3rem; line-height: 1.1; }
    .ev-ch-body { font-size: 1.25rem; line-height: 1.75rem; }
}

/* Pinned, scroll driven version */
/* Scroll length per chapter: about three mouse-wheel clicks on a laptop screen */
.ev-story-on .ev-story { position: relative; height: calc(var(--n) * 50vh + 15vh); }
.ev-story-on .ev-story-stage {
    position: sticky;
    top: 5rem;
    height: calc(100vh - 5rem);
    height: calc(100svh - 5rem);
    overflow: hidden;
}
.ev-story-on .ev-story-inner { position: relative; height: 100%; }
.ev-story-on .ev-ch {
    position: absolute;
    inset: 0 16px 72px;
    padding: 0;
    pointer-events: none;
}
.ev-story-on .ev-ch.is-active { pointer-events: auto; }

.ev-story-on .ev-ch-copy > * {
    opacity: 0;
    transform: translateY(24px);
    transition: transform 0.5s var(--ev-base), opacity 0.3s var(--ev-base);
}
.ev-story-on .ev-ch.is-past .ev-ch-copy > * { transform: translateY(-24px); }
.ev-story-on .ev-ch.is-active .ev-ch-copy > * {
    opacity: 1;
    transform: none;
    transition: transform 0.8s var(--ev-base), opacity 0.7s var(--ev-base);
}
.ev-story-on .ev-ch.is-active .ev-ch-copy > :nth-child(2) { transition-delay: 0.06s; }
.ev-story-on .ev-ch.is-active .ev-ch-copy > :nth-child(3) { transition-delay: 0.12s; }
.ev-story-on .ev-ch.is-active .ev-ch-copy > :nth-child(n+4) { transition-delay: 0.18s; }

.ev-story-on .ev-ch-media {
    opacity: 0;
    transform: translateY(48px) scale(0.96);
    transition: transform 0.6s var(--ev-base), opacity 0.4s var(--ev-base);
}
.ev-story-on .ev-ch.is-past .ev-ch-media { transform: translateY(-48px) scale(0.96); }
.ev-story-on .ev-ch.is-active .ev-ch-media {
    opacity: 1;
    transform: none;
    transition: transform 1s var(--ev-e), opacity 0.7s var(--ev-base);
}

/* The card on each photo arrives after the photo, and its pieces after the card */
.ev-story-on .ev-ch-card {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.4s var(--ev-base), opacity 0.3s var(--ev-base);
}
.ev-story-on .ev-ch.is-active .ev-ch-card {
    opacity: 1;
    transform: none;
    transition: transform 0.8s var(--ev-e) 0.35s, opacity 0.6s var(--ev-base) 0.35s;
}
.ev-story-on .ev-ch-item,
.ev-story-on .ev-ch-bars span { transition: transform 0.3s var(--ev-base), opacity 0.3s var(--ev-base); }
.ev-story-on .ev-ch-item { opacity: 0; transform: translateY(8px); }
.ev-story-on .ev-ch-bars span { transform: scaleY(0); }
.ev-story-on .ev-ch.is-active .ev-ch-item {
    opacity: 1;
    transform: none;
    transition: transform 0.7s var(--ev-e), opacity 0.5s var(--ev-base);
    transition-delay: calc(0.75s + var(--i, 0) * 0.45s);
}
.ev-story-on .ev-ch.is-active .ev-ch-bars span {
    transform: scaleY(var(--h));
    transition: transform 0.9s var(--ev-e);
    transition-delay: calc(0.6s + var(--i, 0) * 0.08s);
}

.ev-story-on .ev-story-rail {
    display: flex;
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 24px;
    gap: 8px;
}
.ev-story-rail button {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    text-align: left;
    background: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 600;
    transition: color 0.3s var(--ev-base);
}
.ev-story-rail button:hover,
.ev-story-rail button[aria-current] { color: #264653; }
.ev-story-rail button:focus-visible { outline: 3px solid #E9C46A; outline-offset: 2px; border-radius: 4px; }
/* Labels show on desktop; on phones they stay for screen readers only */
.ev-rail-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.ev-rail-track { display: block; height: 4px; border-radius: 9999px; background: #e5e7eb; overflow: hidden; }
.ev-rail-fill { display: block; height: 100%; background: #238277; transform: scaleX(0); transform-origin: left center; }

/* Phones: photo on top, words underneath, inside the same pinned screen */
@media (max-width: 1023px) {
    .ev-story-on .ev-ch { grid-template-rows: minmax(0, 1fr) auto; align-content: center; gap: 24px; padding-top: 16px; }
    .ev-story-on .ev-ch-media { order: -1; height: 100%; max-height: 52svh; width: auto; max-width: 100%; }
    .ev-story-on .ev-ch-title { font-size: 1.5rem; line-height: 2rem; margin-bottom: 8px; }
    .ev-story-on .ev-ch-body { font-size: 1rem; line-height: 1.5rem; }
    .ev-story-on .ev-ch-eyebrow { margin-bottom: 4px; }
    .ev-story-on .ev-ch-cta { margin-top: 16px; }
}
/* Short phones: the photo gets too small to carry a card on top of it */
@media (max-width: 1023px) and (max-height: 700px) {
    .ev-story-on .ev-ch-card { display: none; }
}
@media (min-width: 1024px) {
    .ev-story-on .ev-ch { inset: 0 32px 96px; grid-template-rows: minmax(0, 1fr); }
    .ev-story-on .ev-ch-media { max-width: 100%; height: min(100%, 640px); width: auto; }
    .ev-story-on .ev-story-rail { left: 32px; right: 32px; bottom: 32px; gap: 16px; }
    .ev-rail-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}

/* ---------- Feature card visuals ---------- */
.ev-chip {
    transition: background-color 0.5s var(--ev-e2), border-color 0.5s var(--ev-e2), color 0.5s var(--ev-e2), transform 0.6s var(--ev-e), box-shadow 0.5s var(--ev-e2);
}
.ev-chip.is-lit {
    background-color: #238277;
    border-color: #238277;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -8px rgba(35, 130, 119, 0.6);
}

.ev-day {
    transition: background-color 0.45s var(--ev-e2), border-color 0.45s var(--ev-e2), color 0.45s var(--ev-e2), transform 0.6s var(--ev-e);
}
.ev-day.is-done { background-color: #F4A261; border-color: #F4A261; color: #fff; }
.ev-day.is-missed { background-color: #fff; border-color: #F4A261; color: #F4A261; }
.ev-day.is-now { transform: scale(1.12); }

.ev-node {
    transition: background-color 0.5s var(--ev-e2), color 0.5s var(--ev-e2), box-shadow 0.6s var(--ev-e2), transform 0.6s var(--ev-e);
}
.ev-node.is-lit {
    background-color: #E76F51;
    color: #fff;
    transform: scale(1.06);
    box-shadow: 0 0 0 8px rgba(231, 111, 81, 0.16);
}
.ev-node.is-calm {
    background-color: #238277;
    color: #fff;
}

/* ---------- How it works track ---------- */
.ev-track-fill {
    transform: scaleX(0);
    transform-origin: left center;
}
.ev-io [data-reveal].is-in .ev-track-fill,
.ev-track-fill.is-drawn {
    transform: scaleX(1);
    transition: transform 1.4s var(--ev-io) 0.2s;
}
.ev-step-badge {
    transition: transform 0.6s var(--ev-e), box-shadow 0.6s var(--ev-e2), background-color 0.5s var(--ev-e2);
}
.ev-step-badge.is-lit {
    transform: scale(1.12);
    background-color: #238277;
    box-shadow: 0 0 0 8px rgba(35, 130, 119, 0.16);
}

/* Buttons: physical feedback */
.ev-btn { transition: transform 0.3s var(--ev-base), background-color 0.3s var(--ev-base), box-shadow 0.3s var(--ev-base), border-color 0.3s var(--ev-base); }
.ev-btn:hover { transform: translateY(-1px); }
.ev-btn:active { transform: scale(0.98); }
.ev-btn:focus-visible { outline: 3px solid #E9C46A; outline-offset: 3px; }

/* ---------- FAQ: tap a question to open its answer ---------- */
.ev-faq > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.ev-faq > summary::-webkit-details-marker { display: none; }
.ev-faq > summary i { margin-top: 4px; font-size: 0.75rem; color: #238277; transition: transform 0.3s var(--ev-base); }
.ev-faq[open] > summary i { transform: rotate(180deg); }
.ev-faq > summary:focus-visible { outline: 3px solid #E9C46A; outline-offset: 2px; border-radius: 4px; }
/* Larger screens keep the answers always open, as before: no arrow, no tap target */
@media (min-width: 768px) {
    .ev-faq > summary { cursor: default; }
    .ev-faq > summary i { display: none; }
}

/* ---------- Phones: tighter sections, swipe rows instead of tall stacks ---------- */
@media (max-width: 1023px) {
    /* Shorter scroll per story chapter, so the five chapters take about two screens */
    .ev-story-on .ev-story { height: calc(var(--n) * 40vh + 15vh); }
}
@media (max-width: 767px) {
    section.ev-sec { padding-top: 64px; padding-bottom: 64px; }
    section .ev-story-intro { padding-top: 64px; }
    .ev-sec .ev-sec-head { margin-bottom: 32px; }

    .ev-swipe {
        position: relative;
        display: flex;
        align-items: stretch;
        gap: 16px;
        margin: -16px -16px 0;
        padding: 16px 16px 24px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 16px;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
    }
    .ev-swipe::-webkit-scrollbar { display: none; }
    .ev-swipe:focus-visible { outline: 3px solid #E9C46A; outline-offset: -3px; }
    .ev-swipe > * { flex: 0 0 85%; height: auto; scroll-snap-align: start; }
    /* Cards waiting off to the side would stay hidden until swiped in, so they show at once */
    .ev-io .ev-swipe > [data-reveal] { opacity: 1; transform: none; filter: none; }
    .ev-swipe-center > * { scroll-snap-align: center; }
    /* Room for the Most popular badge; the card no longer grows past its neighbours */
    .ev-swipe-center { padding-top: 24px; }
    .ev-swipe [data-swipe-start] { --tw-scale-x: 1; --tw-scale-y: 1; }
    .ev-swipe .h-72 { height: 15rem; }
    .ev-swipe > .p-8 { padding: 24px; }
    .ev-swipe .ml-auto.text-accent { white-space: nowrap; font-size: 0.75rem; }
    section.ev-sec .gap-16 { gap: 40px; }

    .ev-steps { margin-bottom: 32px; }
    .ev-steps > .grid { gap: 12px; }
    .ev-steps .ev-step { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; padding: 20px; text-align: left; }
    .ev-steps .ev-step-n { grid-row: span 2; width: 44px; height: 44px; margin: 0; font-size: 1.125rem; }
    .ev-steps .ev-step h3 { margin-bottom: 4px; font-size: 1.125rem; line-height: 1.75rem; }
    .ev-sec .ev-faq-box { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .ev-motion [data-appear],
    .ev-io [data-reveal],
    .ev-pop,
    .ev-track-fill { opacity: 1 !important; transform: none !important; filter: none !important; transition: none !important; }
    .ev-motion .ev-underline path { stroke-dashoffset: 0; }
    .ev-ring::after { animation: none; }
    .ev-home-tagline .w { color: #264653; }
    .ev-home-tagline .w.accent { color: #238277; }
    .ev-hero-media video { display: none; }
    .ev-ch-media img { transform: none; }
}
