/* ================================================================
   Site animations — scroll reveals + micro-motion
   Honors html.a11y-reduce-motion and prefers-reduced-motion
   ================================================================ */

[data-animate] {
    opacity: 0;
    transform: translateY(28px);
    transition:
        opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}

[data-animate="fade"] {
    transform: none;
}

[data-animate="left"] {
    transform: translateX(-32px);
}

[data-animate="right"] {
    transform: translateX(32px);
}

[data-animate="scale"] {
    transform: scale(0.94);
}

[data-animate].is-in {
    opacity: 1;
    transform: none;
}

[data-animate-delay="1"] { transition-delay: 0.08s; }
[data-animate-delay="2"] { transition-delay: 0.16s; }
[data-animate-delay="3"] { transition-delay: 0.24s; }
[data-animate-delay="4"] { transition-delay: 0.32s; }
[data-animate-delay="5"] { transition-delay: 0.4s; }
[data-animate-delay="6"] { transition-delay: 0.48s; }

/* Soft float on key cards */
.ts-bento__card,
.ts-why-card,
.ts-product,
.ts-brand,
.card.product-item,
.blog-item.card {
    transition:
        transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.35s ease,
        border-color 0.25s ease,
        background 0.25s ease;
}

.ts-btn,
.ts-nav__cta,
.ts-nav__icon-btn,
.ts-nav__link,
.ts-hot__item {
    transition:
        transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.25s ease,
        background 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease,
        gap 0.2s ease,
        opacity 0.2s ease;
}

.ts-btn:active,
.ts-nav__cta:active {
    transform: translateY(1px) scale(0.98);
}

/* Page hero gentle entrance */
.ts-page-hero__content {
    animation: tsPageHeroIn 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tsPageHeroIn {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stagger hot strip on load */
.ts-hot__item {
    opacity: 0;
    animation: tsHotIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.ts-hot__item:nth-child(1) { animation-delay: 0.35s; }
.ts-hot__item:nth-child(2) { animation-delay: 0.45s; }
.ts-hot__item:nth-child(3) { animation-delay: 0.55s; }

@keyframes tsHotIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Image zoom on hover for media cards */
.ts-services__media img,
.ts-product__media img,
.blog-item .card-img-top {
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.ts-services__panel:hover .ts-services__media img,
.ts-product:hover .ts-product__media img,
.blog-item:hover .card-img-top {
    transform: scale(1.05);
}

/* Brand logo — soft pulse after intro */
.ts-logo {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.ts-logo__img {
    position: relative;
    z-index: 1;
    transition: filter 0.35s ease, transform 0.35s ease, opacity 0.35s ease;
}

.ts-logo.is-alive .ts-logo__img {
    animation: ts-logo-float 4.5s ease-in-out infinite;
}

.ts-logo::after {
    content: "";
    position: absolute;
    inset: 12% 8% 18% 4%;
    border-radius: 999px;
    background: radial-gradient(ellipse at 70% 50%, rgba(211, 55, 51, 0.35), transparent 70%);
    opacity: 0;
    z-index: 0;
    pointer-events: none;
}

.ts-logo.is-alive::after {
    opacity: 0.55;
    animation: ts-logo-glow 3.2s ease-in-out infinite;
}

.ts-logo:hover .ts-logo__img {
    animation-play-state: paused;
    transform: scale(1.04);
    filter: drop-shadow(0 0 10px rgba(211, 55, 51, 0.45));
}

.ts-logo:hover::after {
    opacity: 0.85;
}

/* Hide nav logo until homepage splash finishes */
.ts-logo--await-intro {
    opacity: 0;
    pointer-events: none;
}

.ts-logo--await-intro.is-ready {
    opacity: 1;
    pointer-events: auto;
    animation: ts-logo-nav-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Homepage landing splash — fast, GPU-friendly draw */
.ts-logo-splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 50% 45%, rgba(211, 55, 51, 0.2), transparent 55%),
        rgba(8, 10, 14, 0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ts-logo-splash.is-on {
    visibility: visible;
    pointer-events: auto;
    animation: ts-logo-splash-bg 2.5s ease forwards;
}

.ts-logo-splash__stage {
    position: relative;
    width: min(82vw, 440px);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateZ(0);
}

.ts-logo-splash__glow {
    position: absolute;
    width: 70%;
    height: 50%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(211, 55, 51, 0.45), transparent 70%);
    opacity: 0;
    transform: translateZ(0);
}

.ts-logo-splash.is-on .ts-logo-splash__glow {
    animation: ts-logo-splash-glow 2.5s ease forwards;
}

.ts-logo-splash__mark {
    position: relative;
    width: 100%;
    z-index: 1;
    transform: translateZ(0);
}

.ts-logo-splash__img {
    display: block;
    width: 100%;
    height: auto;
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    will-change: clip-path, opacity;
}

.ts-logo-splash.is-on .ts-logo-splash__img {
    animation: ts-logo-splash-draw 1.35s cubic-bezier(0.22, 1, 0.36, 1) 0.05s forwards;
}

.ts-logo-splash__bits {
    position: absolute;
    right: 2%;
    top: 10%;
    bottom: 12%;
    width: 40%;
    display: flex;
    justify-content: flex-start;
    gap: 6px;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
}

.ts-logo-splash.is-on .ts-logo-splash__bits {
    animation: ts-logo-bits-fade 2.5s ease forwards;
}

@keyframes ts-logo-bits-fade {
    0% { opacity: 0; }
    12% { opacity: 1; }
    70% { opacity: 1; }
    88%, 100% { opacity: 0; }
}

.ts-logo-splash__col {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-family: "Sora", "Consolas", monospace;
    font-weight: 700;
    font-size: clamp(0.5rem, 1.3vw, 0.75rem);
    line-height: 1.2;
    color: #ff5a54;
}

.ts-logo-splash__bit {
    opacity: 0;
    transform: translate3d(0, 4px, 0);
}

.ts-logo-splash.is-on .ts-logo-splash__bit {
    animation: ts-logo-bit-draw 0.22s ease forwards;
    animation-delay: calc(var(--d, 0) * 1ms);
}

.ts-logo-splash__circuits {
    position: absolute;
    right: 0;
    top: 14%;
    width: 46%;
    height: 72%;
    overflow: visible;
    pointer-events: none;
    opacity: 0.9;
}

.ts-logo-splash__trace {
    fill: none;
    stroke: #ff3b36;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
}

.ts-logo-splash.is-on .ts-logo-splash__trace {
    animation: ts-logo-trace-draw 0.9s ease forwards;
}

.ts-logo-splash.is-on .ts-logo-splash__trace:nth-child(1) { animation-delay: 0.25s; }
.ts-logo-splash.is-on .ts-logo-splash__trace:nth-child(2) { animation-delay: 0.38s; }
.ts-logo-splash.is-on .ts-logo-splash__trace:nth-child(3) { animation-delay: 0.5s; }

.ts-logo-splash__node {
    fill: #ff6b66;
    opacity: 0;
}

.ts-logo-splash.is-on .ts-logo-splash__node {
    animation: ts-logo-node-in 0.25s ease forwards;
}

.ts-logo-splash.is-on .ts-logo-splash__node:nth-child(4) { animation-delay: 0.7s; }
.ts-logo-splash.is-on .ts-logo-splash__node:nth-child(5) { animation-delay: 0.8s; }
.ts-logo-splash.is-on .ts-logo-splash__node:nth-child(6) { animation-delay: 0.9s; }
.ts-logo-splash.is-on .ts-logo-splash__node:nth-child(7) { animation-delay: 1s; }
.ts-logo-splash.is-on .ts-logo-splash__node:nth-child(8) { animation-delay: 1.05s; }

.ts-logo-splash.is-leaving .ts-logo-splash__mark {
    animation: ts-logo-splash-exit 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes ts-logo-splash-bg {
    0% { opacity: 0; }
    10% { opacity: 1; }
    78% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

@keyframes ts-logo-splash-glow {
    0% { opacity: 0; transform: scale(0.85); }
    25% { opacity: 0.75; transform: scale(1); }
    70% { opacity: 0.45; }
    100% { opacity: 0; transform: scale(1.08); }
}

@keyframes ts-logo-splash-draw {
    0% {
        opacity: 0;
        clip-path: inset(0 100% 0 0);
    }
    12% {
        opacity: 1;
        clip-path: inset(0 70% 0 0);
    }
    100% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

@keyframes ts-logo-splash-exit {
    to {
        opacity: 0;
        transform: translate3d(0, -28vh, 0) scale(0.4);
    }
}

@keyframes ts-logo-bit-draw {
    from {
        opacity: 0;
        transform: translate3d(0, 4px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes ts-logo-trace-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes ts-logo-node-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ts-logo-nav-in {
    from {
        opacity: 0;
        transform: translate3d(0, -6px, 0) scale(0.9);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes ts-logo-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes ts-logo-glow {
    0%, 100% {
        opacity: 0.4;
        transform: scale(0.96);
    }
    50% {
        opacity: 0.75;
        transform: scale(1.04);
    }
}

/* Respect reduced motion */
html.a11y-reduce-motion [data-animate],
html.a11y-reduce-motion .ts-page-hero__content,
html.a11y-reduce-motion .ts-hot__item,
html.a11y-reduce-motion .ts-reveal,
html.a11y-reduce-motion .ts-logo__img,
html.a11y-reduce-motion .ts-logo::after,
html.a11y-reduce-motion .ts-logo-splash,
html.a11y-reduce-motion .ts-logo-splash__img,
html.a11y-reduce-motion .ts-logo-splash__glow {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    visibility: visible !important;
    clip-path: none !important;
}

html.a11y-reduce-motion .ts-logo-splash {
    display: none !important;
}

html.a11y-reduce-motion .ts-logo--await-intro {
    opacity: 1 !important;
    pointer-events: auto !important;
}

@media (prefers-reduced-motion: reduce) {
    [data-animate],
    .ts-page-hero__content,
    .ts-hot__item,
    .ts-reveal,
    .ts-marquee__track,
    .ts-logo__img,
    .ts-logo::after,
    .ts-logo-splash,
    .ts-logo-splash__img,
    .ts-logo-splash__glow,
    .ts-logo--await-intro {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
        transition: none !important;
        visibility: visible !important;
        clip-path: none !important;
    }

    .ts-logo-splash {
        display: none !important;
    }
}
