/* ==========================================================================
   EFFECTS.CSS – Khem IT motion layer
   Loaded on every page (after base.css). Works together with js/effects.js.

   1. Scroll reveals for the existing data-aos="…" attributes
   2. Cursor spotlight on cards
   3. Work-process "power-on" sequence
   4. Stats rings fill-in
   5. Reduced-motion: everything static and visible
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. SCROLL REVEALS
   Elements are only hidden when JS is running (html.js) and not yet revealed.
   The animation uses fill-mode "backwards" so it never overrides the cards'
   own hover transforms once it has finished.
   -------------------------------------------------------------------------- */

.js [data-aos]:not(.is-in) {
    opacity: 0;
}

.js [data-aos].is-in {
    animation: kx-rise 0.8s var(--kx-ease) var(--kx-delay, 0ms) backwards;
}

.js [data-aos="fade-down"].is-in {
    animation-name: kx-drop;
}

.js [data-aos="zoom-in"].is-in {
    animation-name: kx-zoom;
}

@keyframes kx-rise {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: none; }
}

@keyframes kx-drop {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: none; }
}

@keyframes kx-zoom {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   2. CURSOR SPOTLIGHT ON CARDS
   js/effects.js sets --mx / --my (cursor position inside the card).
   -------------------------------------------------------------------------- */

.feature-card,
.service-card,
.offer-card,
.step,
.stat-card,
.blog-card,
.wki-card,
.mv-card,
.tech-category,
.contact-card,
.benefit-card,
.team-card,
.future-category,
.hire-card {
    position: relative;
    isolation: isolate;
}

.feature-card::before,
.service-card::before,
.offer-card::before,
.step::before,
.stat-card::before,
.blog-card::before,
.wki-card::before,
.mv-card::before,
.tech-category::before,
.contact-card::before,
.benefit-card::before,
.team-card::before,
.future-category::before,
.hire-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        280px circle at var(--mx, 50%) var(--my, 0%),
        rgba(74, 222, 128, 0.16),
        rgba(192, 132, 252, 0.06) 45%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: -1;
}

.feature-card:hover::before,
.service-card:hover::before,
.offer-card:hover::before,
.step:hover::before,
.stat-card:hover::before,
.blog-card:hover::before,
.wki-card:hover::before,
.mv-card:hover::before,
.tech-category:hover::before,
.contact-card:hover::before,
.benefit-card:hover::before,
.team-card:hover::before,
.future-category:hover::before,
.hire-card:hover::before {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   3. WORK PROCESS – steps "power on" in order, like a circuit coming alive.
   js/effects.js adds .is-live to .process-steps and --i (0,1,2…) to each step.
   -------------------------------------------------------------------------- */

.process-steps .step::after {
    content: "";
    position: absolute;
    top: -1px;
    left: 24px;
    right: 24px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--kx-signal), var(--kx-volt), transparent);
    transform: scaleX(0);
    transform-origin: left center;
    pointer-events: none;
}

.js .process-steps:not(.is-live) .step-number {
    filter: grayscale(1) brightness(0.55);
}

.process-steps.is-live .step::after {
    animation: kx-trace 1.1s var(--kx-ease) calc(var(--i, 0) * 220ms + 250ms) forwards;
}

.process-steps.is-live .step-number {
    animation: kx-power 1s ease-out calc(var(--i, 0) * 220ms + 550ms) backwards;
}

@keyframes kx-trace {
    0%   { transform: scaleX(0); opacity: 1; }
    70%  { transform: scaleX(1); opacity: 1; }
    100% { transform: scaleX(1); opacity: 0.5; }
}

@keyframes kx-power {
    0%   { filter: grayscale(1) brightness(0.55); box-shadow: none; }
    45%  { filter: none; box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.22), 0 0 30px rgba(74, 222, 128, 0.6); }
    100% { filter: none; }
}

/* --------------------------------------------------------------------------
   4. STATS RINGS – js/effects.js starts them empty and sets the real value
   when the card scrolls into view; this transition does the fill.
   -------------------------------------------------------------------------- */

.progress-ring-fill {
    transition: stroke-dashoffset 1.6s var(--kx-ease);
}

.stat-number {
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   CIRCUIT BOARDS ON PAGE HEROES
   <section class="… kx-board"><canvas class="kx-circuit" aria-hidden="true">
   Drawn by js/hero-circuit.js; the canvas bleeds to the full window width.
   -------------------------------------------------------------------------- */

.kx-board {
    position: relative;
    isolation: isolate;
}

.kx-circuit {
    position: absolute;
    top: calc(-5vh - 2px);       /* tuck under main's top padding */
    left: 50%;
    width: 100vw;
    max-width: none;
    height: calc(100% + 5vh + 2px);
    transform: translateX(-50%);
    z-index: -1;
    pointer-events: none;
    /* fade-out at the bottom is drawn by js/hero-circuit.js */
}

/* Board only behind the top of a section (e.g. the Contact heading) */
.kx-circuit--top {
    height: calc(min(460px, 70%) + 5vh);
}

.js .kx-circuit {
    opacity: 0;
    transition: opacity 1.4s ease;
}

.js .kx-circuit.is-on {
    opacity: 1;
}

/* Page heroes sit on the board, so let it show through */
.kx-board.about-hero,
.kx-board.services-hero,
.kx-board.careers-hero {
    background: transparent;
}

/* --------------------------------------------------------------------------
   CALL-TO-ACTION BOXES – a signal pulse travels round the border
   -------------------------------------------------------------------------- */

@property --kx-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

.cta-box {
    position: relative;
    isolation: isolate;
}

.cta-box::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 2px;
    background: conic-gradient(
        from var(--kx-angle),
        transparent 0deg 250deg,
        rgba(74, 222, 128, 0.18) 295deg,
        rgba(74, 222, 128, 0.95) 345deg,
        var(--kx-volt) 357deg,
        transparent 360deg
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    animation: kx-orbit 7s linear infinite;
    pointer-events: none;
}

@keyframes kx-orbit {
    to { --kx-angle: 360deg; }
}

/* --------------------------------------------------------------------------
   DECODE EFFECT (data-decode): each letter keeps its real width while random
   glyphs flicker on top of it (spans are created by js/hero-circuit.js).
   -------------------------------------------------------------------------- */
.kx-ch {
    display: inline-block;
    position: relative;
}

.kx-ch.is-scrambling {
    color: transparent;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

.kx-ch.is-scrambling::after {
    content: attr(data-g);
    position: absolute;
    inset: 0;
    text-align: center;
    color: var(--kx-signal);
    -webkit-text-fill-color: var(--kx-signal);
    opacity: 0.75;
}

/* --------------------------------------------------------------------------
   FOUNDER PHOTO PLACEHOLDER (About + Careers) – until the photoshoot
   -------------------------------------------------------------------------- */

.founder-photo-placeholder.kx-photo-soon {
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1 / 1.2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 28px;
    border-radius: 24px;
    border: 2px dashed rgba(212, 184, 120, 0.4);
    background-color: rgba(10, 31, 26, 0.6);
    background-image: radial-gradient(rgba(212, 184, 120, 0.12) 1px, transparent 1.4px);
    background-size: 22px 22px;
    text-align: center;
    transition: border-color 0.3s ease, transform 0.3s ease;
}

.founder-photo-placeholder.kx-photo-soon:hover {
    border-color: rgba(74, 222, 128, 0.5);
    transform: translateY(-5px);
}

/* the emblem must not pick up the page's photo-frame styles */
.founder-photo-placeholder.kx-photo-soon img,
.founder-photo-placeholder.kx-photo-soon img:hover {
    width: 50%;
    max-width: 200px;
    height: auto;
    aspect-ratio: auto;
    object-fit: contain;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    transform: none;
    opacity: 0.9;
    filter: drop-shadow(0 12px 26px rgba(0, 0, 0, 0.45));
}

.founder-photo-placeholder.kx-photo-soon span {
    font-family: var(--kx-font-display);
    font-weight: 500;
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--kx-mist);
    max-width: 240px;
    line-height: 1.6;
}

@media (max-width: 900px) {
    .founder-photo-placeholder.kx-photo-soon {
        max-width: 380px;
    }
}

/* Text that is read by screen readers but not shown */
.kx-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   5. REDUCED MOTION – respect the visitor's system setting
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .js [data-aos]:not(.is-in) {
        opacity: 1;
    }

    .js .process-steps:not(.is-live) .step-number {
        filter: none;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
