/* ============================================================
   Animation & 3D layer — loaded after style.css
   ============================================================ */

html {
    scroll-behavior: smooth;
    scroll-padding-top: 120px;
}

h1, h2, h3, h4, h5,
.title,
nav .logo span {
    font-family: var(--font-heading);
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* ============================================================
   WebGL canvas & fallback
   ============================================================ */

#webgl {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    display: block;
    pointer-events: none;
}

.no-webgl #webgl {
    display: none;
}

/* Without WebGL, a static version of the glow stands in for the canvas */
.no-webgl body {
    background:
        radial-gradient(ellipse 70% 60% at 15% 20%, rgba(217, 119, 59, 0.08), transparent 70%),
        var(--bg);
    background-attachment: fixed;
}

/* Film grain over everything (static, so it costs nothing per frame) */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   Smooth scroll (Lenis)
   ============================================================ */

html.lenis,
html.lenis body {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

/* ============================================================
   Custom cursor (fine pointers only, enabled from JS)
   ============================================================ */

.cursor {
    display: none;
}

.has-cursor .cursor {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 2500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.has-cursor .cursor.is-visible {
    opacity: 1;
}

.cursor__dot,
.cursor__ring {
    position: fixed;
    top: 0;
    left: 0;
    border-radius: 50%;
    will-change: transform;
}

.cursor__dot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    background: var(--accent);
}

.cursor__ring {
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 1px solid rgba(236, 230, 220, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cursor__ring::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

.cursor.is-hover .cursor__ring {
    border-color: transparent;
}

.cursor.is-hover .cursor__ring::before {
    transform: scale(1.7);
    background: rgba(217, 119, 59, 0.12);
    border: 1px solid rgba(217, 119, 59, 0.5);
}

.cursor.is-down .cursor__ring::before {
    transform: scale(0.8);
}

.has-cursor body,
.has-cursor a,
.has-cursor button,
.has-cursor .icon {
    cursor: none;
}

/* ============================================================
   Keyframes
   ============================================================ */

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-14px); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* ============================================================
   Scroll progress bar
   ============================================================ */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: 0 0;
    z-index: 2000;
}

/* ============================================================
   Navbar — fixed on scroll
   ============================================================ */

nav {
    position: fixed;
    background: rgba(17, 16, 14, 0.72);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: box-shadow 0.3s ease, background 0.3s ease;
}

nav.nav--scrolled {
    background: rgba(17, 16, 14, 0.9);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

nav .nav-links a {
    position: relative;
    padding-bottom: 2px;
}

nav .nav-links a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    height: 1px;
    width: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

nav .nav-links a:hover::after {
    transform: scaleX(1);
}

/* ============================================================
   Hero
   ============================================================ */

#profile {
    position: relative;
}

#profile .section__pic-container,
#profile .section__text {
    position: relative;
    z-index: 1;
}

.section__pic-container {
    position: relative;
    animation: float 6s ease-in-out infinite;
}

.profile-pic {
    position: relative;
    z-index: 1;
    border: 1px solid var(--border-strong);
}

/* Pause hero animations while the hero is scrolled out of view (toggled in JS) */
#profile.hero-paused .section__pic-container,
#profile.hero-paused .typing-cursor {
    animation-play-state: paused;
}

#profile .title {
    font-size: clamp(2.75rem, 6vw, 4.5rem);
    font-weight: 400;
    letter-spacing: -0.02em;
}

.typing-cursor {
    display: inline-block;
    width: 3px;
    height: 1.1em;
    margin-left: 4px;
    vertical-align: -0.15em;
    background: var(--accent);
    animation: blink 1s steps(2) infinite;
}

.about-section .title::after,
.experience-section .title::after {
    content: '';
    display: block;
    width: 64px;
    height: 3px;
    border-radius: 2px;
    background: var(--accent);
    margin: 14px auto 0;
}

/* Hero copy rises in once the background's first frame is drawn */
.has-webgl #profile .section__text,
.has-webgl #profile .section__pic-container {
    transition: opacity 1.2s ease 0.25s, translate 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.25s;
}

.is-loading #profile .section__text,
.is-loading #profile .section__pic-container {
    opacity: 0;
    translate: 0 24px;
}

/* ============================================================
   Reveal on scroll
   ============================================================ */

.js [data-reveal] {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--d, 0s);
}

.js [data-reveal="left"]  { transform: translateX(-44px); }
.js [data-reveal="right"] { transform: translateX(44px); }
.js [data-reveal="zoom"]  { transform: scale(0.9); }

.js [data-reveal].revealed {
    opacity: 1;
    transform: none;
}

/* ============================================================
   Buttons — lift (+ magnetic pull from JS via `translate`)
   ============================================================ */

.btn {
    position: relative;
}

.btn:hover {
    transform: translateY(-2px);
}

/* ============================================================
   Cards & micro-interactions
   ============================================================ */

/* Project cards: lift + image zoom (3D tilt handled in JS) */
.project-card {
    transition: transform 0.18s ease-out, box-shadow 0.35s ease, border-color 0.35s ease;
}

.project-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}

.project-card__image {
    transition: transform 0.5s ease;
}

.project-card:hover .project-card__image {
    transform: scale(1.04);
}

#socials-container .icon {
    transition: transform 0.3s ease, color 0.3s ease;
}

#socials-container .icon:hover {
    transform: translateY(-4px) scale(1.15);
    color: var(--accent);
}

.job i,
.award div i {
    transition: all 0.3s ease;
}

.job:hover i,
.award:hover > div i {
    background: var(--accent);
    color: var(--on-accent);
    transform: rotate(-6deg) scale(1.08);
}

/* Projects page (projects.html) */
.project-item {
    transition: transform 0.35s ease;
}

.project-item:hover {
    transform: translateX(6px);
}

.project-info h2 {
    transition: color 0.3s ease;
}

.project-item:hover .project-info h2 {
    color: var(--accent);
}

.project-item:hover .project-img-wrapper img {
    transform: scale(1.06);
}

/* ============================================================
   Back-to-top button
   ============================================================ */

.back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--on-accent);
    background: var(--accent);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    z-index: 1500;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-4px);
}

/* ============================================================
   Small screens — keep the pill nav inside the viewport
   ============================================================ */

@media screen and (max-width: 520px) {
    nav {
        width: calc(100% - 24px);
        justify-content: space-between;
        gap: 12px;
        padding: 10px 16px;
    }

    nav .logo span {
        display: none; /* icon-only logo, the name is right below in the hero */
    }

    nav .nav-links {
        gap: 12px;
    }
}

/* ============================================================
   Reduced motion — disable all of the above
   ============================================================ */

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

    html {
        scroll-behavior: auto;
    }

    .js [data-reveal] {
        opacity: 1;
        transform: none;
    }
}
