/* ============================================================
   NanoTech-kw | Icon & button animations (index + TechGuide)
   CSS only. Everything here is disabled for visitors who ask
   their device for reduced motion (see the bottom of the file).
   ============================================================ */

/* ---------- Keyframes ---------- */
@keyframes nt-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
@keyframes nt-pop {
    0% { transform: scale(1) rotate(0); }
    35% { transform: scale(1.28) rotate(-10deg); }
    65% { transform: scale(0.94) rotate(6deg); }
    100% { transform: scale(1) rotate(0); }
}
@keyframes nt-wiggle {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(-14deg); }
    40% { transform: rotate(12deg); }
    60% { transform: rotate(-8deg); }
    80% { transform: rotate(4deg); }
}
@keyframes nt-shine {
    from { transform: translateX(-120%) skewX(-20deg); }
    to { transform: translateX(220%) skewX(-20deg); }
}
@keyframes nt-glow {
    0%, 100% { box-shadow: 0 10px 25px -5px rgba(56, 189, 248, 0.30); }
    50% { box-shadow: 0 10px 34px 2px rgba(56, 189, 248, 0.55); }
}
@keyframes nt-ring {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
    80%, 100% { box-shadow: 0 0 0 12px rgba(37, 211, 102, 0); }
}
@keyframes nt-heartbeat {
    0%, 60%, 100% { transform: scale(1); }
    15% { transform: scale(1.18); }
    30% { transform: scale(1); }
    45% { transform: scale(1.12); }
}
@keyframes nt-spin-once {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

/* ============================================================
   Home page (Tailwind markup; matched by its utility classes)
   ============================================================ */

/* Primary buttons: light sweep on hover, press-down on click. */
a[class*="bg-accentBlue"][class*="rounded-"],
button[class*="bg-accentBlue"][class*="rounded-"] {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
a[class*="bg-accentBlue"][class*="rounded-"]::after,
button[class*="bg-accentBlue"][class*="rounded-"]::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 45%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transform: translateX(-120%) skewX(-20deg);
    pointer-events: none;
    z-index: 1;
}
a[class*="bg-accentBlue"][class*="rounded-"]:hover::after,
button[class*="bg-accentBlue"][class*="rounded-"]:hover::after {
    animation: nt-shine 0.75s ease;
}
a[class*="bg-accentBlue"][class*="rounded-"]:active,
button[class*="bg-accentBlue"][class*="rounded-"]:active,
a[class*="rounded-lg"][class*="bg-slate-800"]:active,
button[class*="rounded-lg"][class*="bg-slate-800"]:active {
    transform: scale(0.96) !important;
    transition-duration: 0.08s !important;
}

/* The hero's main call-to-action (the large one) breathes softly. */
section a[class*="bg-accentBlue"][class*="py-4"][class*="shadow-xl"] {
    animation: nt-glow 3s ease-in-out infinite;
}

/* Service card icons: gentle idle float, staggered so they don't move in
   lockstep; a full spin when the card is hovered. */
.group div[class*="w-14"][class*="h-14"][class*="rounded-xl"] > i {
    display: inline-block;
    animation: nt-float 3.6s ease-in-out infinite;
}
.group:nth-child(2n) div[class*="w-14"][class*="h-14"][class*="rounded-xl"] > i { animation-delay: -1.2s; }
.group:nth-child(3n) div[class*="w-14"][class*="h-14"][class*="rounded-xl"] > i { animation-delay: -2.4s; }
.group:hover div[class*="w-14"][class*="h-14"][class*="rounded-xl"] > i {
    animation: nt-spin-once 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Social / footer round icon buttons: icon pops on hover. */
a[class*="w-11"][class*="h-11"][class*="rounded-full"] > i,
a[class*="w-11"][class*="h-11"][class*="rounded-full"] > svg {
    display: inline-block;
    transition: transform 0.2s ease;
}
a[class*="w-11"][class*="h-11"][class*="rounded-full"]:hover > i,
a[class*="w-11"][class*="h-11"][class*="rounded-full"]:hover > svg {
    animation: nt-pop 0.55s ease;
}
a[class*="w-11"][class*="h-11"][class*="rounded-full"]:active {
    transform: scale(0.9) !important;
}
/* WhatsApp: a soft "call me" ring every few seconds. */
a[href*="wa.me"][class*="rounded-full"] {
    animation: nt-ring 2.6s ease-out infinite;
}

/* Feature check-marks tick in when their list is hovered. */
li:hover > i.fa-check {
    display: inline-block;
    animation: nt-pop 0.5s ease;
}

/* Hero badge icon and the language globe. */
section .rounded-full > i.fa-circle-check {
    display: inline-block;
    animation: nt-heartbeat 2.8s ease-in-out infinite;
}
button:hover > i.fa-globe {
    display: inline-block;
    animation: nt-spin-once 0.8s ease;
}

/* Contact details icons (phone, envelope, location). */
a:hover > i.fa-phone,
a:hover > i.fa-envelope,
div:hover > i.fa-location-dot {
    display: inline-block;
    animation: nt-wiggle 0.6s ease;
}

/* Mobile menu toggle. */
#mobileMenuBtn:active { transform: scale(0.9); }
#mobileMenuBtn > i { transition: transform 0.3s ease; }
#mobileMenuBtn:hover > i { transform: rotate(90deg); }

/* ============================================================
   Tech Guide (its own class names)
   ============================================================ */
.tabs button,
.ht-cat,
.share-btn,
.ht-page-btn,
.searchbar button,
.ai-actions button,
.examples code {
    transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.tabs button:active,
.ht-cat:active,
.share-btn:active,
.ht-page-btn:active:not(:disabled),
.searchbar button:active,
.ai-actions button:active:not(:disabled),
.examples code:active {
    transform: scale(0.95);
}
.share-btn:hover,
.ht-cat:hover:not(.active) {
    transform: translateY(-2px);
}
.share-btn:hover svg {
    animation: nt-pop 0.55s ease;
}
.searchbar button {
    position: relative;
    overflow: hidden;
}
.searchbar button::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 45%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: translateX(-120%) skewX(-20deg);
    pointer-events: none;
}
.searchbar button:hover::after {
    animation: nt-shine 0.75s ease;
}
.wa-btn {
    animation: nt-ring 2.6s ease-out infinite;
}
.wa-btn:hover > i {
    display: inline-block;
    animation: nt-wiggle 0.6s ease;
}

/* ---------- Keyboard focus (both pages) ---------- */
a:focus-visible,
button:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: 3px;
}

/* ============================================================
   Scroll effects (js/scroll-fx.js)
   Entrance animations use the individual translate/scale/filter
   properties, so they never fight the cards' hover `transform`.
   ============================================================ */
:root { --sfx-dir: 1; }
[dir="rtl"] { --sfx-dir: -1; }

/* Reading progress bar */
.sfx-progress {
    position: fixed;
    inset: 0 0 auto 0;
    height: 3px;
    z-index: 60;
    pointer-events: none;
    background: linear-gradient(90deg, #0ea5e9, #38bdf8, #7dd3fc);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
    transform-origin: 0 50%;
    transform: scaleX(var(--sfx-progress, 0));
}
[dir="rtl"] .sfx-progress { transform-origin: 100% 50%; }

/* Back-to-top button with a progress ring */
.sfx-top {
    position: fixed;
    bottom: 22px;
    inset-inline-end: 22px;
    z-index: 55;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    background: rgba(19, 31, 59, 0.92);
    color: #38bdf8;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
    display: grid;
    place-items: center;
    opacity: 0;
    translate: 0 16px;
    scale: 0.8;
    pointer-events: none;
    transition: opacity 0.3s ease, translate 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), scale 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
}
.sfx-top.is-visible { opacity: 1; translate: 0 0; scale: 1; pointer-events: auto; }
.sfx-top:hover { background: #38bdf8; color: #0b1329; }
.sfx-top:active { scale: 0.92; }
.sfx-top svg { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; }
.sfx-top .sfx-ring-bg { stroke: rgba(56, 189, 248, 0.18); }
.sfx-top .sfx-ring { stroke: #38bdf8; stroke-dasharray: 138.2; stroke-dashoffset: calc(138.2 * (1 - var(--sfx-progress, 0))); }
.sfx-top:hover .sfx-ring { stroke: #0b1329; }
.sfx-top .sfx-arrow { position: relative; font-size: 18px; line-height: 1; }

/* Entrance animations (only after JS marks the page, so no-JS still shows everything) */
.sfx-on .sfx-item {
    opacity: 0;
    transition:
        opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        translate 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        scale 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.8s ease;
    transition-delay: calc(var(--sfx-i, 0) * 90ms);
}
.sfx-on .sfx-item[data-sfx="card"] { translate: 0 40px; scale: 0.94; }
.sfx-on .sfx-item[data-sfx="start"] { translate: calc(-60px * var(--sfx-dir)) 0; }
.sfx-on .sfx-item[data-sfx="end"] { translate: calc(60px * var(--sfx-dir)) 0; }
@media (max-width: 768px) {
    .sfx-on .sfx-item[data-sfx="start"],
    .sfx-on .sfx-item[data-sfx="end"] { translate: 0 30px; }
}
.sfx-on .sfx-item[data-sfx="heading"] { translate: 0 18px; filter: blur(8px); }
.sfx-on .sfx-item.sfx-in { opacity: 1; translate: 0 0; scale: 1; filter: none; }
.sfx-prep .sfx-item,
.sfx-prep h2.sfx-underline { transition: none !important; }

/* Section heading underline that draws itself */
.sfx-on h2.sfx-underline {
    background-image: linear-gradient(90deg, #0ea5e9, #38bdf8);
    background-repeat: no-repeat;
    background-position: var(--sfx-ul-pos, left) bottom;
    background-size: 0 3px;
    padding-bottom: 10px;
    transition: background-size 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.25s;
}
[dir="rtl"].sfx-on h2.sfx-underline { --sfx-ul-pos: right; }
.sfx-on h2.sfx-underline[data-align="center"] { --sfx-ul-pos: center; }
.sfx-on h2.sfx-underline.sfx-drawn { background-size: 64px 3px; }

/* Hero drifts and fades as you scroll away */
.sfx-hero { will-change: translate, opacity; }

/* Nothing may widen the page on phones (off-screen slide-in starts, marquee),
   otherwise mobile browsers zoom out on load. `clip` keeps position:sticky working. */
html, body { overflow-x: clip; max-width: 100%; }

/* In-page links (#contact etc.) land below the home page's fixed 96px header. */
html:has(header.fixed) { scroll-padding-top: 104px; }

/* ============================================================
   Animated network background (home hero + Tech Guide .net-bg)
   Data flows along the lines, nodes drift while they pulse, and the
   whole network sways slowly. Individual `translate` is used so it
   combines with the pulse's `transform: scale()`.
   ============================================================ */
@keyframes net-flow { to { stroke-dashoffset: -240; } }
@keyframes net-drift-a { 0%, 100% { translate: 0 0; } 50% { translate: 14px -10px; } }
@keyframes net-drift-b { 0%, 100% { translate: 0 0; } 50% { translate: -12px 12px; } }
@keyframes net-drift-c { 0%, 100% { translate: 0 0; } 50% { translate: 10px 14px; } }
@keyframes net-sway { 0%, 100% { translate: 0 0; } 50% { translate: -18px 10px; } }

svg:has(#lineGrad) { animation: net-sway 40s ease-in-out infinite; }
svg:has(#lineGrad) path {
    stroke-dasharray: 14 10;
    animation: net-flow 9s linear infinite;
}
svg:has(#lineGrad) path:nth-of-type(2) { animation-duration: 12s; animation-direction: reverse; }
svg:has(#lineGrad) path:nth-of-type(3),
svg:has(#lineGrad) path:nth-of-type(4) { stroke-dasharray: 5 5; animation-duration: 6s; }
svg:has(#lineGrad) .node-pulse {
    transform-box: fill-box;
    transform-origin: center;
    animation: pulseNode 4s ease-in-out infinite, net-drift-a 11s ease-in-out infinite;
}
svg:has(#lineGrad) .node-pulse:nth-of-type(3n + 2) { animation: pulseNode 4s ease-in-out infinite, net-drift-b 13s ease-in-out infinite; }
svg:has(#lineGrad) .node-pulse:nth-of-type(3n) { animation: pulseNode 4s ease-in-out infinite, net-drift-c 9s ease-in-out infinite; }

/* ---------- Respect "reduce motion" ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
