/* =========================================================
   Kinetic enhancements — Vila Blue Harmony
   Added by Hermes. Self-contained, progressive enhancement:
   if this file/JS fails to load, the site stays fully usable.
   ========================================================= */

html {
    scroll-behavior: smooth;
}

/* Anchor the hero so the scroll indicator can sit at its bottom */
header {
    position: relative;
}

/* ---------- Top scroll progress bar ---------- */
#kb-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--whatsapp));
    background-size: 300% 100%;
    animation: kb-gradient-shift 4s linear infinite;
    z-index: 3000;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* ---------- Scroll-reveal base ---------- */
.kb-reveal,
.kb-reveal-left,
.kb-reveal-right,
.kb-reveal-scale {
    opacity: 0;
    will-change: opacity, transform;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.kb-reveal        { transform: translateY(42px); }
.kb-reveal-left   { transform: translateX(-55px); }
.kb-reveal-right  { transform: translateX(55px); }
.kb-reveal-scale  { transform: scale(0.9); }

.kb-reveal.kb-visible,
.kb-reveal-left.kb-visible,
.kb-reveal-right.kb-visible,
.kb-reveal-scale.kb-visible {
    opacity: 1;
    transform: none;
}

/* ---------- Hero kinetic typography ---------- */
/* Gradient shimmer on the main hero title */
header h1 {
    background: linear-gradient(90deg,
        #ffffff 0%,
        #5bb0e0 25%,
        #ffffff 50%,
        var(--primary) 75%,
        #ffffff 100%);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: kb-shimmer 6s linear infinite;
}

@keyframes kb-shimmer {
    to { background-position: 220% center; }
}

/* Fallback for engines without background-clip:text support */
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
    header h1 {
        color: #ffffff;
        background: none;
        -webkit-text-fill-color: #ffffff;
        animation: none;
    }
}

/* Staggered entrance for hero contents (class added by JS) */
.kb-hero-in header .container > * {
    animation: kb-rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.kb-hero-in header .container > *:nth-child(1) { animation-delay: 0.10s; }
.kb-hero-in header .container > *:nth-child(2) { animation-delay: 0.30s; }
.kb-hero-in header .container > *:nth-child(3) { animation-delay: 0.50s; }

@keyframes kb-rise {
    from { opacity: 0; transform: translateY(45px); }
    to   { opacity: 1; transform: none; }
}

/* Gentle floating CTA in the hero */
header .btn {
    animation: kb-float 3.4s ease-in-out infinite;
}
@keyframes kb-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-9px); }
}

/* ---------- Button shine sweep on hover ---------- */
.btn {
    position: relative;
    overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -130%;
    width: 75%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
    pointer-events: none;
}
.btn:hover::after {
    left: 140%;
}

/* ---------- Kinetic underline on section headings ---------- */
section h2 {
    position: relative;
    display: inline-block;
    padding-bottom: 12px;
}
section h2::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.2s;
}
section h2.kb-visible::after {
    width: 100%;
}

/* ---------- Feature card icon flourish ---------- */
.feature-card i {
    transition: transform 0.4s ease, color 0.3s ease;
}
.feature-card:hover i {
    transform: scale(1.22) rotate(-6deg);
    color: var(--secondary);
}

/* ---------- Scroll-down indicator ---------- */
#kb-scroll-ind {
    position: absolute;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    color: #fff;
    font-size: 30px;
    z-index: 5;
    opacity: 0.9;
    animation: kb-bounce 2.2s infinite;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
#kb-scroll-ind:hover { opacity: 1; }
@keyframes kb-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translate(-50%, 0); }
    40% { transform: translate(-50%, -13px); }
    60% { transform: translate(-50%, -6px); }
}

/* ---------- Back-to-top button ---------- */
#kb-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    opacity: 0;
    transform: translateY(22px) scale(0.8);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease, background 0.3s ease;
}
#kb-top.kb-show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
#kb-top:hover {
    background: var(--secondary);
}

/* ---------- Shared keyframes ---------- */
@keyframes kb-gradient-shift {
    to { background-position: 300% 0; }
}

/* ---------- Parallax hero (desktop only) ---------- */
@media (min-width: 768px) {
    header {
        background-attachment: fixed;
    }
}

/* ---------- Accessibility: honor reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
    .kb-reveal, .kb-reveal-left, .kb-reveal-right, .kb-reveal-scale {
        opacity: 1 !important;
        transform: none !important;
    }
    header { background-attachment: scroll !important; }
    #kb-scroll-ind { display: none; }
}
