html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Accessibility */
.skip-link {
    position: absolute;
    left: 1rem;
    top: -5rem;
    z-index: 100;
    padding: 0.7rem 1rem;
    border-radius: 0.75rem;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 700;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 1rem;
}

/* Custom Cursor */
.cursor-dot,
.cursor-ring {
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    z-index: 120;
}
.cursor-dot {
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    background: radial-gradient(circle, #22d3ee 0%, #6366f1 70%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55), 0 0 18px rgba(99, 102, 241, 0.35);
    transition: opacity 0.2s ease, width 0.16s ease, height 0.16s ease, box-shadow 0.16s ease;
}
.cursor-ring {
    width: 34px;
    height: 34px;
    border-radius: 9999px;
    border: 1.5px solid rgba(99, 102, 241, 0.42);
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(34, 211, 238, 0.06) 55%, transparent 75%);
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.16);
    transition: opacity 0.2s ease, width 0.2s ease, height 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.dark .cursor-dot {
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.6), 0 0 20px rgba(99, 102, 241, 0.5);
}
.dark .cursor-ring {
    border-color: rgba(129, 140, 248, 0.58);
    background: radial-gradient(circle, rgba(129, 140, 248, 0.18) 0%, rgba(34, 211, 238, 0.08) 58%, transparent 76%);
    box-shadow: 0 0 26px rgba(99, 102, 241, 0.26);
}
.cursor-dot.cursor-hover {
    width: 11px;
    height: 11px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.62), 0 0 26px rgba(99, 102, 241, 0.45);
}
.dark .cursor-dot.cursor-hover {
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.6), 0 0 26px rgba(129, 140, 248, 0.5);
}
.cursor-ring.cursor-hover {
    width: 42px;
    height: 42px;
    border-color: rgba(99, 102, 241, 0.65);
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, rgba(34, 211, 238, 0.08) 60%, transparent 78%);
}
.dark .cursor-ring.cursor-hover {
    border-color: rgba(129, 140, 248, 0.72);
    background: radial-gradient(circle, rgba(129, 140, 248, 0.24) 0%, rgba(34, 211, 238, 0.1) 60%, transparent 78%);
}
.cursor-dot.cursor-press {
    width: 9px;
    height: 9px;
}
.cursor-ring.cursor-press {
    width: 30px;
    height: 30px;
}
body.custom-cursor-active {
    cursor: none;
}
body.custom-cursor-active a,
body.custom-cursor-active button,
body.custom-cursor-active [role='button'] {
    cursor: none;
}
body.custom-cursor-active .cursor-dot,
body.custom-cursor-active .cursor-ring {
    opacity: 1;
}
body.custom-cursor-active.cursor-hidden .cursor-dot,
body.custom-cursor-active.cursor-hidden .cursor-ring {
    opacity: 0;
}

/* Bento Grid Utilities */
.bento-card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backface-visibility: hidden;
}
.bento-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.3);
    z-index: 20;
}

/* Hero Stagger-In */
.motion-ready #hero-main-card .hero-sequence-item {
    opacity: 0;
    transform: translateY(18px);
}
.motion-ready #hero-main-card .hero-sequence-item.hero-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Scroll Reveal */
.motion-ready .bento-card.reveal-card {
    opacity: 0;
    transform: translateY(18px) scale(0.995);
}
.motion-ready .bento-card.reveal-card.reveal-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--reveal-delay, 0ms);
}

/* Dynamic Avatar Expressions */
#dynamic-avatar-image {
    opacity: 1;
}

/* Hover Spotlight */
.bento-card.spotlight-card {
    position: relative;
    isolation: isolate;
}
.bento-card.spotlight-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(
        220px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%),
        rgba(255, 255, 255, 0.2),
        transparent 62%
    );
    transition: opacity 0.25s ease;
    mix-blend-mode: soft-light;
}
.dark .bento-card.spotlight-card::after {
    background: radial-gradient(
        260px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%),
        rgba(255, 255, 255, 0.14),
        transparent 62%
    );
}
.bento-card.spotlight-card:hover::after {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .bento-card,
    .hero-sequence-item,
    .marquee-content,
    .bg-orb {
        animation: none !important;
        transition: none !important;
    }
    #dynamic-avatar-image {
        opacity: 1 !important;
    }
    #orb-bg,
    .cta-spark,
    .cursor-dot,
    .cursor-ring {
        display: none !important;
    }
    .bento-card:hover {
        transform: none;
    }
    .bento-card.spotlight-card::after {
        display: none;
    }
}

@media (pointer: coarse), (hover: none) {
    .cursor-dot,
    .cursor-ring {
        display: none !important;
    }
    body.custom-cursor-active {
        cursor: auto;
    }
}

/* Marquee Animation */
.marquee-container {
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}
.marquee-content {
    animation: scroll 30s linear infinite;
}
.marquee-content:hover {
    animation-play-state: paused;
}
@keyframes scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
#orb-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}
.bg-orb {
    position: absolute;
    border-radius: 9999px;
    filter: blur(80px);
    opacity: 0.24;
    will-change: transform;
    animation: orb-drift var(--orb-duration, 22s) ease-in-out infinite;
    animation-delay: var(--orb-delay, 0s);
}
.bg-orb.orb-1 {
    width: 320px;
    height: 320px;
    left: -80px;
    top: 12%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.45) 0%, rgba(56, 189, 248, 0.08) 65%, transparent 100%);
    --orb-duration: 26s;
}
.bg-orb.orb-2 {
    width: 360px;
    height: 360px;
    right: -90px;
    top: 38%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.45) 0%, rgba(99, 102, 241, 0.08) 65%, transparent 100%);
    --orb-duration: 30s;
    --orb-delay: -8s;
}
.bg-orb.orb-3 {
    width: 300px;
    height: 300px;
    left: 28%;
    bottom: -80px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.36) 0%, rgba(16, 185, 129, 0.07) 65%, transparent 100%);
    --orb-duration: 28s;
    --orb-delay: -14s;
}
@keyframes orb-drift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(24px, -22px, 0) scale(1.06); }
}
.dark .bg-orb {
    opacity: 0.34;
}

.cta-spark-target {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.cta-spark {
    position: absolute;
    left: 0;
    top: 0;
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.45) 35%, rgba(255,255,255,0) 100%);
    transform: translate(-50%, -50%) scale(0.5);
    animation: spark-pop 700ms ease-out forwards;
    mix-blend-mode: screen;
    z-index: 2;
}
@keyframes spark-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    18% {
        opacity: 0.95;
    }
    100% {
        opacity: 0;
        transform: translate(
            calc(-50% + var(--spark-x, 0px)),
            calc(-50% + var(--spark-y, -24px))
        ) scale(1.8);
    }
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Navigation Active Link */
.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.9rem;
    border-radius: 9999px;
    color: #475569;
    transition: all 0.25s ease;
}
.dark .nav-link {
    color: #9ca3af;
}
.nav-link:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #4f46e5;
}
.dark .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}
.nav-link.nav-link-active {
    background: #0f172a;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 10px 20px -12px rgba(15, 23, 42, 0.9);
}
.dark .nav-link.nav-link-active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 10px 20px -12px rgba(255, 255, 255, 0.45);
}
#mobile-menu .nav-link.nav-link-active {
    background: rgba(99, 102, 241, 0.14);
    color: #4f46e5;
    font-weight: 700;
    box-shadow: none;
}
.dark #mobile-menu .nav-link.nav-link-active {
    background: rgba(99, 102, 241, 0.22);
    color: #ffffff;
}

/* Section Wrapper for Card Groups */
.section-shell {
    background: transparent;
    backdrop-filter: none;
    border: 1px solid transparent;
    border-radius: 32px;
    padding: 0;
    box-shadow: none;
    overflow: visible;
}
.dark .section-shell {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}
@media (min-width: 768px) {
    .section-shell {
        padding: 0;
    }
}
@media (max-width: 767px) {
    .bg-orb.orb-1 {
        width: 220px;
        height: 220px;
    }
    .bg-orb.orb-2 {
        width: 250px;
        height: 250px;
    }
    .bg-orb.orb-3 {
        width: 210px;
        height: 210px;
        left: 8%;
    }
}
