* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
    scroll-behavior: smooth;
}

h1,
h2,
h3,
h4,
h5,
h6,
.logo {
    font-family: var(--font-en);
    letter-spacing: 2px;
}

body {
    cursor: none;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-color);
}

#cursor {
    width: 20px;
    height: 20px;
    border: 1px solid var(--primary);
    border-radius: 50%;
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 9999;
    /* Moved with transform (set from js/main.js) so following the mouse never triggers layout */
    transform: translate3d(var(--x, -100px), var(--y, -100px), 0) translate(-50%, -50%) scale(var(--s, 1));
    will-change: transform;
    transition: width 0.3s, height 0.3s, background 0.3s;
    mix-blend-mode: difference;
}

#cursor-blur {
    /* A soft radial gradient looks like the old blur(80px) disc without re-blurring on every move */
    width: 580px;
    height: 580px;
    background: radial-gradient(circle closest-side, rgba(0, 243, 255, 0.82) 0%, rgba(0, 243, 255, 0.62) 30%, rgba(0, 243, 255, 0.25) 60%, rgba(0, 243, 255, 0.06) 82%, rgba(0, 243, 255, 0) 100%);
    opacity: 0.15;
    border-radius: 50%;
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: -1;
    transform: translate3d(var(--x, -1000px), var(--y, -1000px), 0) translate(-50%, -50%);
    will-change: transform;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

/* The custom circle replaces the system cursor everywhere, including buttons and links */
@media (hover: hover) {
    body * {
        cursor: none !important;
    }
}

/* Touch screens: the circle follows the finger, hidden until the first touch */
@media (hover: none) {
    #cursor,
    #cursor-blur {
        opacity: 0;
    }

    body.touch-active #cursor {
        opacity: 1;
    }

    body.touch-active #cursor-blur {
        opacity: 0.15;
    }

    /* Blurring the animated particles behind each card every frame is too heavy for phones */
    body .project-card {
        backdrop-filter: none;
    }
}

/* Off-screen slide-in animations must not widen the page on phones */
.section {
    overflow-x: clip;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
    border: 2px solid var(--bg-color);
    /* Adds a gap around the thumb */
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* With a mouse, the page scrollbar is drawn in the page (js/main.js) so the
   custom cursor stays visible over it; the browser's own one is hidden */
.page-scrollbar {
    display: none;
}

@media (hover: hover) {
    html {
        scrollbar-width: none;
    }

    html::-webkit-scrollbar {
        display: none;
    }

    .page-scrollbar {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        width: 10px;
        height: 100vh;
        background: var(--bg-color);
        z-index: 9998;
    }

    .page-scrollbar-thumb {
        position: absolute;
        left: 2px;
        right: 2px;
        min-height: 40px;
        background: var(--primary);
        border-radius: 5px;
    }

    .page-scrollbar-thumb:hover,
    .page-scrollbar.dragging .page-scrollbar-thumb {
        background: var(--secondary);
    }
}

/* RTL Typography enhancement */
body[dir="rtl"] {
    font-family: var(--font-ar), var(--font-body);
}

body[dir="rtl"] *:not(i):not([class*="fa-"]) {
    font-family: inherit;
}

body[dir="rtl"] h1,
body[dir="rtl"] h2,
body[dir="rtl"] h3,
body[dir="rtl"] h4,
body[dir="rtl"] h5,
body[dir="rtl"] h6,
body[dir="rtl"] .logo,
body[dir="rtl"] .project-title,
body[dir="rtl"] .btn {
    font-family: var(--font-ar), var(--font-en);
    letter-spacing: normal;
}

/* Guard Font Awesome Icons from font inheritance in RTL */
body[dir="rtl"] i,
body[dir="rtl"] [class*="fa-"],
body[dir="rtl"] .fa-solid,
body[dir="rtl"] .fa-regular {
    font-family: "Font Awesome 6 Free" !important;
}

body[dir="rtl"] .fa-brands,
body[dir="rtl"] .fab {
    font-family: "Font Awesome 6 Brands" !important;
}