/* ==========================================================================
   Sodexus.AI Landing Page — Animations
   ========================================================================== */

/* --- Scroll-triggered fade-in-up --- */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered delays for children */
.fade-in-up[data-delay="1"] { transition-delay: 100ms; }
.fade-in-up[data-delay="2"] { transition-delay: 200ms; }
.fade-in-up[data-delay="3"] { transition-delay: 300ms; }
.fade-in-up[data-delay="4"] { transition-delay: 400ms; }
.fade-in-up[data-delay="5"] { transition-delay: 500ms; }

/* Auto-stagger children utility */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 100ms; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 200ms; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 300ms; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 400ms; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 500ms; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 600ms; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 700ms; }
.stagger-children.visible > *:nth-child(9) { transition-delay: 800ms; }
.stagger-children.visible > *:nth-child(10) { transition-delay: 900ms; }

.stagger-children.visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* --- Fade-in from left --- */
.fade-in-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.fade-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

/* --- Fade-in from right --- */
.fade-in-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.fade-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* --- Scale-in --- */
.scale-in {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.scale-in.visible {
    opacity: 1;
    transform: scale(1);
}

/* --- Reveal line animation --- */
.reveal-line {
    position: relative;
    overflow: hidden;
}

.reveal-line::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-accent, linear-gradient(135deg, #00A896, #007A6B));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-line.visible::after {
    transform: scaleX(1);
}

/* --- Counter Animation (JS-driven, CSS transition) --- */
.counter-value {
    display: inline-block;
    transition: all 0.3s ease;
}

/* Counter ring animation */
.counter-ring {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.counter-ring svg circle {
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Drill-Down Panel Animations --- */
.drill-down-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drill-down-overlay.open {
    opacity: 1;
    visibility: visible;
}

.drill-down-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(13, 27, 42, 0.7);
    backdrop-filter: blur(4px);
}

/* Desktop: slide from right */
@media (min-width: 768px) {
    .drill-down-panel {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 60%;
        max-width: 800px;
        background: white;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: -8px 0 30px rgba(0, 0, 0, 0.3);
    }

    .drill-down-overlay.open .drill-down-panel {
        transform: translateX(0);
    }
}

/* Mobile: slide from bottom */
@media (max-width: 767px) {
    .drill-down-panel {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 90vh;
        background: white;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
    }

    .drill-down-overlay.open .drill-down-panel {
        transform: translateY(0);
    }
}

.drill-down-header {
    position: sticky;
    top: 0;
    background: white;
    border-bottom: 1px solid var(--c-border);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}

.drill-down-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--c-bg-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    font-size: 1.25rem;
    color: var(--c-text);
}

.drill-down-close:hover {
    background: var(--c-border);
}

.drill-down-body {
    padding: 2rem 2.5rem 4rem;
}

@media (max-width: 767px) {
    .drill-down-body {
        padding: 1.5rem 1.25rem 3rem;
    }
}

/* --- Body scroll lock when drill-down is open --- */
body.drill-down-open {
    overflow: hidden;
}

/* --- Floating Data Flow Animation (SDF diagram) --- */
@keyframes float-data {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translateY(-8px) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 0.3;
    }
}

.data-particle {
    animation: float-data 3s ease-in-out infinite;
}

.data-particle:nth-child(2) { animation-delay: 0.5s; }
.data-particle:nth-child(3) { animation-delay: 1s; }
.data-particle:nth-child(4) { animation-delay: 1.5s; }

/* --- Pulse animation for active elements --- */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 168, 150, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(0, 168, 150, 0);
    }
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* --- Timeline week entrance --- */
.timeline-enter {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.timeline-enter.visible {
    opacity: 1;
    transform: translateX(0);
}

/* --- Hero text entrance --- */
@keyframes hero-text-in {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-animate {
    animation: hero-text-in 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.hero-animate:nth-child(1) { animation-delay: 0.1s; }
.hero-animate:nth-child(2) { animation-delay: 0.25s; }
.hero-animate:nth-child(3) { animation-delay: 0.4s; }
.hero-animate:nth-child(4) { animation-delay: 0.55s; }
.hero-animate:nth-child(5) { animation-delay: 0.7s; }

/* --- Tooltip for SDF layers --- */
.sdf-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: var(--c-primary);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    max-width: 280px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.sdf-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--c-primary);
}

.sdf-layer:hover .sdf-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* --- Button Micro-interactions --- */
.btn-glow {
    box-shadow: 0 0 20px rgba(0, 168, 150, 0.3), 0 4px 10px rgba(0, 168, 150, 0.2);
    transition: all 0.3s ease;
}

.btn-glow:hover {
    box-shadow: 0 0 30px rgba(0, 168, 150, 0.5), 0 8px 20px rgba(0, 168, 150, 0.3);
    transform: translateY(-3px);
}

.btn-glow:active {
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgba(0, 168, 150, 0.3);
}

/* --- Focus-visible styles --- */
.btn:focus-visible,
.industrie-card:focus-visible,
.vcom-dimension-card:focus-visible,
[data-drill-down]:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 2px;
}

a:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* --- CTA Pulse Glow Animation --- */
@keyframes cta-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 168, 150, 0.3), 0 4px 10px rgba(0, 168, 150, 0.2);
    }
    50% {
        box-shadow: 0 0 35px rgba(0, 168, 150, 0.5), 0 4px 20px rgba(0, 168, 150, 0.35);
    }
}

.btn-cta-pulse {
    animation: cta-pulse 2.5s ease-in-out infinite;
}

/* --- Hero mouse-follow glow --- */
.hero-mouse-glow {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 168, 150, 0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 2;
    transition: transform 0.1s ease-out, opacity 0.3s ease;
    opacity: 0;
}

.hero-mouse-glow.active {
    opacity: 1;
}

/* --- Floating accent orbs for CTA background --- */
@keyframes float-orb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(10px, -15px) scale(1.05); }
    50% { transform: translate(-5px, -25px) scale(1.1); }
    75% { transform: translate(-10px, -10px) scale(1.02); }
}

.cta-orb {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: float-orb 6s ease-in-out infinite;
    z-index: 0;
}

.cta-orb:nth-child(1) {
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(0, 168, 150, 0.08) 0%, transparent 70%);
    top: 20%;
    left: 15%;
    animation-delay: 0s;
}

.cta-orb:nth-child(2) {
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(247, 184, 1, 0.06) 0%, transparent 70%);
    top: 30%;
    right: 10%;
    animation-delay: 2s;
}

/* --- Scroll parallax helper (JS sets --scroll-y) --- */
.parallax-subtle {
    transform: translateY(calc(var(--scroll-y, 0) * -0.08px));
    will-change: transform;
}

/* --- Nav link underline animation --- */
@keyframes underline-in {
    from { width: 0; left: 50%; }
    to { width: 100%; left: 0; }
}

/* --- Comparison card animations --- */
.comparison-old {
    border-top: 4px solid #9CA3AF;
}

.comparison-new {
    border-top: 4px solid var(--c-accent);
    box-shadow: 0 0 20px rgba(0, 168, 150, 0.08);
}

/* --- Org Chart entrance animation --- */
.org-chart-animate .org-chart-connector {
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.org-chart-animate.visible .org-chart-connector {
    transform: scaleY(1);
}

.org-chart-animate .org-chart-grid > * {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.org-chart-animate.visible .org-chart-grid > *:nth-child(1) { transition-delay: 300ms; }
.org-chart-animate.visible .org-chart-grid > *:nth-child(2) { transition-delay: 400ms; }
.org-chart-animate.visible .org-chart-grid > *:nth-child(3) { transition-delay: 500ms; }
.org-chart-animate.visible .org-chart-grid > *:nth-child(4) { transition-delay: 600ms; }
.org-chart-animate.visible .org-chart-grid > *:nth-child(5) { transition-delay: 700ms; }
.org-chart-animate.visible .org-chart-grid > *:nth-child(6) { transition-delay: 800ms; }

.org-chart-animate.visible .org-chart-grid > * {
    opacity: 1;
    transform: translateY(0);
}

/* --- Comparison table row stagger --- */
.comparison-table-animate tbody tr {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.comparison-table-animate.visible tbody tr:nth-child(1) { transition-delay: 100ms; }
.comparison-table-animate.visible tbody tr:nth-child(2) { transition-delay: 200ms; }
.comparison-table-animate.visible tbody tr:nth-child(3) { transition-delay: 300ms; }
.comparison-table-animate.visible tbody tr:nth-child(4) { transition-delay: 400ms; }
.comparison-table-animate.visible tbody tr:nth-child(5) { transition-delay: 500ms; }
.comparison-table-animate.visible tbody tr:nth-child(6) { transition-delay: 600ms; }

.comparison-table-animate.visible tbody tr {
    opacity: 1;
    transform: translateX(0);
}
