/* ── Scrollytelling: reveal, progress, chapter flow ── */
:root {
    --ease-story: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-story-soft: cubic-bezier(0.22, 1, 0.36, 1);
    --reveal-distance: 52px;
    --story-duration: 0.95s;
}

/* Scroll progress */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 200;
    pointer-events: none;
    background: transparent;
}

.scroll-progress__bar {
    height: 100%;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    background: linear-gradient(90deg, var(--primary-dark), var(--accent), #60a5fa);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.45);
    will-change: transform;
}

/* Header on scroll */
.site-header {
    transition: box-shadow 0.35s var(--ease-story), background 0.35s var(--ease-story);
}

.site-header.is-scrolled {
    box-shadow: var(--shadow-md);
    background: rgba(255, 255, 255, 0.97);
}

.site-header.is-scrolled .logo-mark {
    height: 38px;
    max-width: 50px;
    transition: height 0.35s var(--ease-story), max-width 0.35s var(--ease-story);
}

.site-header.is-scrolled .logo-name {
    font-size: 0.84rem;
}

/* Story chapters */
.story-chapter {
    position: relative;
    isolation: isolate;
}

.story-chapter::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0;
    transition: opacity 1s var(--ease-story-soft);
    pointer-events: none;
}

.story-chapter--alt::before {
    background:
        radial-gradient(ellipse 80% 50% at 100% 0%, rgba(59, 130, 246, 0.07), transparent 55%),
        radial-gradient(ellipse 60% 40% at 0% 100%, rgba(37, 99, 235, 0.05), transparent 50%);
}

.story-chapter.is-active::before {
    opacity: 1;
}

.story-chapter.is-active .section-label {
    letter-spacing: 0.12em;
}

/* Reveal base */
.reveal {
    opacity: 0;
    transition:
        opacity var(--story-duration) var(--ease-story),
        transform var(--story-duration) var(--ease-story),
        filter var(--story-duration) var(--ease-story);
    transition-delay: var(--reveal-delay, 0s);
    will-change: opacity, transform;
}

.reveal--fade-up {
    transform: translate3d(0, var(--reveal-distance), 0);
}

.reveal--fade-down {
    transform: translate3d(0, calc(var(--reveal-distance) * -0.6), 0);
}

.reveal--fade-left {
    transform: translate3d(calc(var(--reveal-distance) * -0.75), 0, 0);
}

.reveal--fade-right {
    transform: translate3d(calc(var(--reveal-distance) * 0.75), 0, 0);
}

.reveal--scale {
    transform: scale(0.9);
}

.reveal--blur-up {
    transform: translate3d(0, 36px, 0);
    filter: blur(8px);
}

.reveal.is-visible {
    opacity: 1;
    transform: none;
    filter: none;
}

/* Hero scrollytelling */
.hero-story {
    min-height: min(92vh, 900px);
    display: flex;
    align-items: center;
}

.hero-story.hero--banner {
    min-height: auto;
    display: block;
}

.hero-story .hero-grid {
    width: 100%;
}

.hero-image-wrap {
    transition: box-shadow 0.6s var(--ease-story);
}

.story-chapter.is-active .hero-image-wrap,
.hero-story .hero-image-wrap {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.hero-float-card {
    transition: transform 0.5s var(--ease-story), box-shadow 0.5s var(--ease-story);
}

.hero-story .hero-float-card.is-visible {
    animation: float-card 4s var(--ease-story-soft) infinite alternate;
}

@keyframes float-card {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

.scroll-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-soft);
    opacity: 1;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.scroll-hint.is-hidden {
    opacity: 0;
}

.scroll-hint__chevron {
    width: 22px;
    height: 22px;
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: rotate(45deg);
    animation: scroll-bounce 1.8s var(--ease-story-soft) infinite;
}

@keyframes scroll-bounce {
    0%, 100% { transform: rotate(45deg) translate(0, 0); opacity: 0.5; }
    50% { transform: rotate(45deg) translate(4px, 4px); opacity: 1; }
}

/* Cards & gallery enhanced on reveal */
.reveal.is-visible.card,
.reveal.is-visible.testimonial,
.reveal.is-visible.blog-card {
    box-shadow: var(--shadow-md);
}

.gallery-item.reveal.is-visible {
    box-shadow: var(--shadow-lg);
}

.gallery-item.reveal.is-visible .gallery-caption {
    animation: caption-rise 0.7s var(--ease-story) 0.2s both;
}

@keyframes caption-rise {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Service blocks narrative */
.service-block.reveal-pair > * {
    transition-delay: var(--reveal-delay, 0s);
}

/* Page hero */
.page-hero {
    position: relative;
    overflow: hidden;
}

.page-hero::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* CTA dramatic entrance */
.cta-band.reveal.is-visible {
    animation: cta-glow 3s ease-in-out infinite alternate;
}

@keyframes cta-glow {
    from { box-shadow: 0 12px 40px rgba(37, 99, 235, 0.25); }
    to { box-shadow: 0 20px 56px rgba(59, 130, 246, 0.38); }
}

/* Stat counter highlight */
.stat-item.reveal.is-visible strong {
    color: var(--primary-dark);
}

/* Footer reveal */
.site-footer .reveal.is-visible {
    transform: none;
}

/* Reduced motion */
html.motion-reduced .reveal {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
}

html.motion-reduced .scroll-hint,
html.motion-reduced .hero-float-card.is-visible,
html.motion-reduced .cta-band.reveal.is-visible {
    animation: none !important;
}

html.motion-reduced .scroll-progress {
    display: none;
}

@media (max-width: 960px) {
    :root {
        --reveal-distance: 36px;
    }

    .reveal--fade-left,
    .reveal--fade-right {
        transform: translate3d(0, var(--reveal-distance), 0);
    }

    .hero-story {
        min-height: auto;
    }

    .scroll-hint {
        display: none;
    }
}
