/* =========================================================
   VoltDev — Home page only (index.html)
   Loaded after redesign.css: scroll cue, circuit canvas,
   services carousel, Telegram demo, glass & glow polish.
   ========================================================= */

/* ---- Hero circuit canvas: calm centre via radial mask ---- */
.hero-v2__circuit-bg {
    -webkit-mask-image: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0.35) 0%, #000 75%);
    mask-image: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0.35) 0%, #000 75%);
}

.hero-v2__circuit-bg canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

/* ---- Always-visible scroll cue (created by home-ui.js) ---- */
.scroll-next {
    position: fixed;
    left: 50%;
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
    z-index: 9000; /* below the chat widget's 9999 */
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(0, 163, 255, 0.45);
    background: rgba(10, 15, 30, 0.6);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--accent-primary, #00a3ff);
    box-shadow: 0 0 18px rgba(0, 163, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transform: translateX(-50%);
    transition: opacity 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.scroll-next:hover,
.scroll-next:focus-visible {
    border-color: var(--accent-secondary, #00e5ff);
    box-shadow: 0 0 24px rgba(0, 163, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.scroll-next__chev {
    display: flex;
    transition: transform 0.3s ease;
}

.scroll-next--up .scroll-next__chev {
    transform: rotate(180deg);
}

/* bob the chevron, not the button, so the button itself stays a stable
   click target */
.scroll-next--bob .scroll-next__chev {
    animation: scroll-next-bob 1.8s ease-in-out infinite;
}

.scroll-next--settled {
    opacity: 0.8;
}

.scroll-next--hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes scroll-next-bob {
    0%, 100% { transform: translateY(-4px); }
    50% { transform: translateY(3px); }
}

@media (prefers-reduced-motion: reduce) {
    .scroll-next--bob .scroll-next__chev { animation: none; }
    .scroll-next__chev { transition: none; }
}

/* ---- Services: swipeable carousel on phones ---- */
.svc-dots {
    display: none;
}

/* the carousel bleeds to the viewport edges; the horizontal inset matches
   .container's real padding (var(--space-lg) at 481..768, var(--space-md)
   at <=480) so card 1 still lines up with the section text column */
@media (max-width: 720px) {
    #services {
        overflow-x: clip;
    }

    #services .grid.grid-3 {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        overscroll-behavior-x: contain;
        gap: 14px;
        --vd-ctr-x: var(--space-lg);
        margin-inline: calc(-1 * var(--vd-ctr-x));
        padding-inline: var(--vd-ctr-x);
        scroll-padding-inline: var(--vd-ctr-x);
        padding-block: 6px 12px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    #services .grid.grid-3::-webkit-scrollbar {
        display: none;
    }

    #services .grid.grid-3 > .card--service {
        flex: 0 0 82%;
        scroll-snap-align: center;
        min-width: 0;
    }

    .svc-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-top: var(--space-lg);
    }

    .svc-dots__dot {
        width: 8px;
        height: 8px;
        border-radius: 9999px;
        background: rgba(255, 255, 255, 0.18);
        transition: width 0.25s ease, background 0.25s ease;
    }

    .svc-dots__dot--active {
        width: 22px;
        background: var(--accent-primary, #00a3ff);
    }
}

@media (max-width: 480px) {
    #services .grid.grid-3 {
        --vd-ctr-x: var(--space-md);
    }
}

/* ---- Live Telegram demo ---- */
.tg-demo__inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
    align-items: center;
}

.tg-demo__copy {
    max-width: 560px;
}

.tg-demo__side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    width: 100%;
    max-width: 380px;
}

@media (min-width: 900px) {
    .tg-demo__inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3xl);
    }

    .tg-demo__copy {
        flex: 1;
        max-width: 520px;
    }

    .tg-demo__side {
        flex-shrink: 0;
    }
}

.tg-demo__frame {
    width: 100%;
    max-width: 340px;
    height: 430px;
    border-radius: 28px;
    padding: 14px;
    display: flex;
    flex-direction: column;
}

@media (min-width: 900px) {
    .tg-demo__frame {
        height: 480px;
    }
}

.tg-demo__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 6px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.tg-demo__logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.tg-demo__title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
}

.tg-demo__status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--accent-success);
}

.tg-demo__status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-success);
    box-shadow: 0 0 6px var(--accent-success);
}

.tg-demo__msgs {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 2px;
    scrollbar-width: thin;
    overscroll-behavior: contain;
    /* soft top/bottom edge fade so scrolled bubbles are not hard-clipped */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 calc(100% - 14px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 calc(100% - 14px), transparent 100%);
}

.tg-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.tg-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2aabee, #1d96d8);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tg-msg--bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 163, 255, 0.15);
    border-left: 2px solid var(--accent-primary, #00a3ff);
    color: var(--text-body);
    border-bottom-left-radius: 4px;
}

/* Messages hidden only while JS is going to animate them in */
html.vd-js .tg-demo--armed .tg-msg:not(.tg-msg--typing) {
    opacity: 0;
    transform: translateY(8px);
}

html.vd-js .tg-demo--armed .tg-msg--user:not(.tg-msg--typing) {
    transform: translate(10px, 8px);
}

html.vd-js .tg-demo--armed .tg-msg--bot:not(.tg-msg--typing) {
    transform: translate(-10px, 8px);
}

html.vd-js .tg-demo--armed .tg-msg.tg-msg--in {
    opacity: 1;
    transform: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.tg-msg--typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 14px;
}

.tg-msg--typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-primary, #00a3ff);
    opacity: 0.4;
    animation: tg-typing 1s ease-in-out infinite;
}

.tg-msg--typing i:nth-child(2) { animation-delay: 0.15s; }
.tg-msg--typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes tg-typing {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
}

.tg-demo__input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-faint);
    font-size: 0.85rem;
}

.tg-demo__replay {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.8rem;
    color: var(--accent-primary, #00a3ff);
    padding: 6px 16px;
    border-radius: 9999px;
    border: 1px solid rgba(0, 163, 255, 0.3);
    transition: border-color 0.2s ease, color 0.2s ease;
}

.tg-demo__replay:hover,
.tg-demo__replay:focus-visible {
    color: var(--accent-secondary, #00e5ff);
    border-color: var(--accent-secondary, #00e5ff);
}

.tg-demo__replay[hidden] {
    display: none;
}

.tg-demo__caption {
    font-size: 0.78rem;
    color: var(--text-muted);
    max-width: 340px;
    text-align: center;
}

/* ---- Glass & glow polish ---- */
.card--service,
.tg-demo__frame {
    background: rgba(255, 255, 255, 0.04);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(0, 163, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .card--service,
    .tg-demo__frame {
        background: var(--bg-tertiary, #111936);
    }
}

/* keep the interaction transition smooth even when other scripts set an
   inline transform transition on .card */
.card--service {
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
                box-shadow 0.3s ease, border-color 0.3s ease,
                background 0.3s ease !important;
}

.card--service:hover,
.card--service:focus-visible,
.card--service:active {
    border-color: rgba(0, 229, 255, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.55),
                0 0 24px rgba(0, 163, 255, 0.35),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-v2:active {
    transform: scale(0.97);
}

/* ---- One-time rise reveal (JS-gated; GSAP already covers titles/cards) ---- */
html.vd-js .vd-rise {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

html.vd-js .vd-rise.vd-rise--in {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html.vd-js .tg-demo--armed .tg-msg:not(.tg-msg--typing) {
        opacity: 1;
        transform: none;
    }

    html.vd-js .vd-rise {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .tg-msg--typing i { animation: none; }
}
