/* Base and Reset Styles */
html {
    width: 100%;
}

body,
html {
    margin: 0;
    padding: 0;
    background-color: var(--bg-body) !important;
    color: var(--text-main) !important;
    font-family: "Google Sans Code", "Roboto", sans-serif !important;
    line-height: 1.6;
    display: flow;

    scroll-behavior: smooth;
    transition: all .7s var(--animation-curve);
}

main {
    margin-top: -3rem;
}

main section {
    min-height: 100vh !important;
}


a {
    color: var(--text-main);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

a.link {
    transition: var(--transition-speed) var(--animation-curve);
}

a.link:hover {
    text-decoration: none !important;
    color: var(--primary-dark);
    transform: translateY(-2px);
}

[data-theme="dark"] .link,
.link:hover {
    color: var(--text-main);
}

a.link.text-muted:hover {
    color: var(--text-main) !important;
}

#glowGrid {
    --mouse-x: 50%;
    --mouse-y: 50%;

    background-color: var(--bg-body) !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh !important;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;

    background-image:
        linear-gradient(90deg, var(--grid-color-faint) 1px, transparent 1px),
        linear-gradient(180deg, var(--grid-color-faint) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
}

[data-theme="dark"] #glowGrid {
    --mouse-x: 50%;
    --mouse-y: 50%;

    background-image:
        radial-gradient(circle at var(--mouse-x) var(--mouse-y),
            rgba(255, 255, 255, .02) 0%,
            transparent 250px),

        linear-gradient(90deg, rgba(245, 247, 249, 0.1) 1px, transparent 1px),
        linear-gradient(180deg, rgba(245, 247, 249, 0.1) 1px, transparent 1px);
}



/* "highlight" Layer */
#glowGrid::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to buttons below */
    z-index: 2;

    /* The Bright Blue Grid (Must match base layer size exactly) */
    background-image:
        linear-gradient(90deg, var(--grid-color-bright) 1px, transparent 1px),
        linear-gradient(180deg, var(--grid-color-bright) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);

    /* The Magic Mask: Hides everything except the circle around the mouse */
    mask-image: radial-gradient(circle at var(--mouse-x) var(--mouse-y),
            black 0%,
            transparent 150px
            /* Adjust size of the glow radius here */
        );
    -webkit-mask-image: radial-gradient(circle at var(--mouse-x) var(--mouse-y),
            black 0%,
            transparent 150px);

    animation: gridTakeOver 2s var(--animation-curve) forwards;
}


#glowGrid::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;

    background-image:
        linear-gradient(90deg, var(--grid-color-bright) 1px, transparent 1px),
        linear-gradient(180deg, var(--grid-color-bright) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);

    /* Run the animation once on load */
    animation: gridFlash 2s var(--animation-curve) forwards;
}


/* Animation: Initial "power on" flash of the grid */
@keyframes gridFlash {
    0% {
        opacity: 0;
        /* Start dark */
        transform: scale(1.02);
        /* Slight zoom out effect */
    }

    20% {
        opacity: .4;
        /* Flash to full brightness quickly */
        transform: scale(1);
        /* Back to normal size */
    }

    100% {
        opacity: 0;
        /* Fade out slowly to reveal the mouse layer underneath */
        transform: scale(1);
    }
}

@keyframes gridTakeOver {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.filter-to-theme {
    filter: var(--filter-light-to-theme);
}

.filter-to-white {
    filter: none;
}

[data-theme="dark"] .filter-to-white {
    filter: brightness(0) invert(1);
}




/* Disable grid on smaller screens for performance */
@media (max-width: 768px) {
    main {
        margin-top: -2rem;
    }
    
    #glowGrid {
        --mouse-x: 50% !important;
        --mouse-y: 50% !important;

        background-image:
            linear-gradient(90deg, rgba(245, 247, 249, 0.1) 1px, transparent 1px),
            linear-gradient(180deg, rgba(245, 247, 249, 0.1) 1px, transparent 1px) !important;
    }
}