/* ==========================================================================
   HERO.CSS – Khem IT home hero
   A live circuit board (canvas, js/hero-circuit.js) behind the logo emblem:
   the circuit pyramid, golden-ratio construction lines that draw themselves,
   the KHEM IT wordmark revealed by a scan line, and the tagline decoding.
   ========================================================================== */

:root {
    --kx-gold: #d4b878;
}

.hero {
    min-height: calc(100vh - 80px - 5vh);
    display: flex;
    align-items: center;
    position: relative;
    isolation: isolate;
    background: transparent;
    overflow: visible;           /* the canvas bleeds full-width; body clips it */
    margin-top: 0;
}

/* ----- Circuit canvas: full viewport width, fades out at top/bottom ----- */
.hero-circuit {
    position: absolute;
    top: calc(-5vh - 2px);
    bottom: 0;
    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 */
}

.js .hero-circuit {
    opacity: 0;
    transition: opacity 1.4s ease;
}

.js .hero-circuit.is-on {
    opacity: 1;
}

/* Container */
.hero .container {
    max-width: 1300px;
    margin: 0 auto;
    padding: clamp(24px, 4vh, 48px) clamp(20px, 5vw, 40px);
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.hero-content {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ----- Emblem: pyramid + construction geometry ----- */
.hero-emblem {
    position: relative;
    width: clamp(170px, min(24vw, 30vh), 290px);
    aspect-ratio: 891 / 750;
    margin-bottom: clamp(18px, 3vh, 32px);
    perspective: 900px;
}

.hero-geometry {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 205%;
    height: auto;
    max-width: none;
    transform: translate(-50%, -52%);
    fill: none;
    stroke: var(--kx-gold);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    opacity: 0.28;
    pointer-events: none;
}

.hero-geometry * {
    vector-effect: non-scaling-stroke;
}

.hero-pyramid {
    position: relative;
    width: 100%;
    height: auto;
    /* The soft shadow + gold glow are a pre-drawn image in the padding
       around the pyramid (a CSS drop-shadow filter here had to be redrawn on
       every frame of the moving board behind it). Padding and the negative
       margin cancel out, so the pyramid's size and position are unchanged. */
    box-sizing: content-box;
    padding: 32.772%;
    margin: -32.772%;
    background: url("../images/logo/emblem-shadow.14328d6a2504.webp") center / 100% 100% no-repeat;
    transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
    transition: transform 0.6s var(--kx-ease);
    will-change: transform;
}

/* ----- Wordmark ----- */
.hero-title {
    margin: 0 0 clamp(10px, 2vh, 18px);
    line-height: 0;
    display: flex;
    justify-content: center;   /* keeps the wordmark centred on tiny screens */
}

.hero-wordmark {
    width: min(520px, 78vw);
    height: auto;
    /* green glow: pre-drawn image in the padding (see .hero-pyramid) */
    box-sizing: content-box;
    padding: calc(min(520px, 78vw) * 0.07717);
    margin: calc(min(520px, 78vw) * -0.07717) auto;
    background: url("../images/logo/wordmark-glow.47863b640452.webp") center / 100% 100% no-repeat;
}

/* ----- Tagline (from the logo lock-up) ----- */
.hero-tagline {
    font-family: var(--kx-font-display);
    font-weight: 500;
    font-size: clamp(0.72rem, 1.8vw, 1rem);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--kx-mist);
    margin: 0 0 clamp(14px, 2.5vh, 22px);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 0.9em;
}

.hero-tagline-sep {
    color: var(--kx-gold);
}

.hero-slogan {
    font-size: clamp(1rem, 2.4vw, 1.25rem);
    color: #b8c4bc;
    max-width: 640px;
    margin: 0 auto clamp(22px, 4vh, 34px);
    line-height: 1.5;
}

/* ----- Buttons ----- */
.hero-buttons {
    display: flex;
    gap: clamp(15px, 3vw, 25px);
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: clamp(10px, 2vh, 14px) clamp(20px, 4vw, 32px);
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    font-weight: 600;
    text-decoration: none;
    border-radius: 40px;
    transition: all 0.3s ease;
    letter-spacing: 0.04em;
}

.btn-primary {
    background: #c084fc;
    color: #0a1f1a;
    border: 2px solid #c084fc;
    box-shadow: 0 0 8px rgba(192, 132, 252, 0.3);
}

.btn-primary:hover {
    background: #a855f7;
    border-color: #a855f7;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.3);
}

.btn-secondary {
    background: rgba(10, 31, 26, 0.6);
    color: #4ade80;
    border: 2px solid #4ade80;
}

.btn-secondary:hover {
    background: rgba(74, 222, 128, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(74, 222, 128, 0.2);
}

/* ----- Social icons ----- */
.hero-social {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(20px, 5vw, 30px);
    margin-top: clamp(28px, 5vh, 48px);
    width: 100%;
}

.hero-social a {
    color: #4ade80;
    font-size: clamp(1.25rem, 4vw, 1.6rem);
    transition: all 0.3s ease;
    display: inline-block;
}

.hero-social a:hover {
    color: #c084fc;
    transform: translateY(-3px) scale(1.1);
}

/* ==========================================================================
   ENTRANCE SEQUENCE (runs once on load, only when JS is running)
   board powers up → geometry draws → pyramid lands → wordmark scans in
   → tagline decodes → slogan, buttons, socials
   ========================================================================== */

.js .hero-geometry > * {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: kx-draw 2.2s var(--kx-ease) calc(200ms + var(--g, 0) * 70ms) forwards;
}

.js .hero-pyramid {
    animation: kx-land 1.1s var(--kx-ease) 350ms backwards;
}

.js .hero-wordmark {
    animation: kx-scan 1s cubic-bezier(0.6, 0, 0.2, 1) 900ms backwards;
}

.js .hero-title {
    position: relative;
}

/* the glowing scan line that sweeps across the wordmark */
.js .hero-title::after {
    content: "";
    position: absolute;
    top: -6%;
    bottom: -6%;
    left: 50%;
    width: 3px;
    border-radius: 3px;
    background: var(--kx-signal);
    box-shadow: 0 0 18px 4px rgba(74, 222, 128, 0.7);
    opacity: 0;
    pointer-events: none;
    animation: kx-scanline 1s cubic-bezier(0.6, 0, 0.2, 1) 900ms;
}

.js .hero-tagline {
    animation: kx-fade 0.6s ease 1500ms backwards;
}

.js .hero-slogan {
    animation: kx-rise 0.8s var(--kx-ease) 1750ms backwards;
}

.js .hero-buttons {
    animation: kx-rise 0.8s var(--kx-ease) 1900ms backwards;
}

.js .hero-social {
    animation: kx-rise 0.8s var(--kx-ease) 2050ms backwards;
}

@keyframes kx-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes kx-land {
    from { opacity: 0; transform: translateY(26px) scale(0.92); filter: brightness(0.4); }
    to   { opacity: 1; }
}

@keyframes kx-scan {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 0 0 0); }
}

@keyframes kx-scanline {
    0%   { opacity: 1; left: calc(50% - min(260px, 39vw)); }
    90%  { opacity: 1; }
    100% { opacity: 0; left: calc(50% + min(260px, 39vw)); }
}

@keyframes kx-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ========== RESPONSIVE ========== */

@media (max-width: 560px) {
    .hero-tagline {
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }
    .hero-tagline-sep {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero {
        min-height: auto;
    }
    .hero .container {
        padding-top: 20px;
        padding-bottom: 28px;
    }
    .hero-tagline {
        letter-spacing: 0.16em;
    }
    .hero-social {
        margin-top: 26px;
    }
}

@media (max-height: 700px) and (min-width: 481px) {
    .hero-emblem {
        width: clamp(150px, 26vh, 220px);
    }
}

/* Reduced motion: no entrance, no geometry drawing – everything in place */
@media (prefers-reduced-motion: reduce) {
    .js .hero-geometry > * {
        stroke-dashoffset: 0;
    }
    .js .hero-title::after {
        display: none;
    }
    .js .hero-circuit {
        opacity: 1;
    }
}
