/* Noise Texture Overlay */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Gradient Mesh Background */
.gradient-mesh {
    background:
        radial-gradient(at 18% 18%, rgba(34, 34, 34, 0.08) 0px, transparent 42%),
        radial-gradient(at 82% 12%, rgba(84, 84, 84, 0.1) 0px, transparent 46%),
        radial-gradient(at 26% 82%, rgba(34, 34, 34, 0.05) 0px, transparent 40%),
        radial-gradient(at 88% 78%, rgba(123, 123, 123, 0.07) 0px, transparent 42%),
        linear-gradient(180deg, #ffffff 0%, var(--brand-cloud) 100%);
}

/* Smooth Transitions */
.transition-smooth {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.transition-fast {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Text Gradient */
.text-gradient {
    background: var(--brand-gradient-strong);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-accent {
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Magnetic Button Effect */
.magnetic-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.magnetic-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--brand-gradient);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.magnetic-btn:hover::before {
    opacity: 1;
}

.magnetic-btn span {
    position: relative;
    z-index: 1;
}

/* Hover Lift Effect */
.hover-lift {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.15);
}

/* Card Shine Effect */
.card-shine {
    position: relative;
    overflow: hidden;
}

.card-shine::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 40%,
        rgba(255, 255, 255, 0.8) 50%,
        transparent 60%
    );
    transform: translateX(-100%) rotate(45deg);
    transition: transform 0.6s ease;
}

.card-shine:hover::before {
    transform: translateX(100%) rotate(45deg);
}

/* Project Card */
.project-card {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    min-height: 300px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.project-card-image {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card:hover .project-card-image {
    transform: translateY(-4px);
}

.project-card-overlay {
    display: none;
}

.project-card-content {
    position: static;
    padding: 0;
    transform: none;
    opacity: 1;
    margin-top: auto;
}

.project-card:hover .project-card-content {
    transform: none;
    opacity: 1;
}

/* Section Number */
.section-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #6b7280;
}

/* Mobile Menu */
.mobile-menu {
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-menu.active {
    transform: translateX(0);
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Reveal Animation */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.72s cubic-bezier(0.16, 1, 0.3, 1), transform 0.72s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-stagger {
    opacity: 0;
    transform: translateY(24px);
}

.reveal-stagger.visible {
    animation: revealStagger 0.72s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes revealStagger {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero Text Animation */
.hero-title {
    overflow: hidden;
}

.hero-title-line {
    display: block;
    transform: translateY(100%);
    animation: slideUp 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        filter: blur(12px);
    }
    to {
        transform: translateY(0);
        filter: blur(0);
    }
}

/* Hero Badge Entrance */
.hero-badge-reveal {
    animation: heroBadgeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

@keyframes heroBadgeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.96);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Hero Visual Entrance — combined scale-fade entrance then float */
.hero-visual-entrance {
    animation: heroVisualIn 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both, heroFloat 7s ease-in-out 1.4s infinite;
}

@keyframes heroVisualIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(16px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

/* Hero Callout Entrances */
.hero-callout-status {
    min-width: 220px;
    animation: calloutSlideRight 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.85s both;
}

.hero-callout-live {
    min-width: 180px;
    animation: calloutSlideLeft 0.65s cubic-bezier(0.16, 1, 0.3, 1) 1.05s both;
}

@keyframes calloutSlideRight {
    from {
        opacity: 0;
        transform: translateX(14px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes calloutSlideLeft {
    from {
        opacity: 0;
        transform: translateX(-14px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Code Window Cursor */
.code-cursor {
    display: inline-block;
    width: 2px;
    height: 0.85em;
    background: #60a5fa;
    margin-left: 3px;
    vertical-align: text-bottom;
    border-radius: 1px;
    animation: cursorBlink 1.1s step-end infinite;
}

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

/* Badge */
.badge-glow {
    position: relative;
}

.badge-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--brand-ink), var(--brand-graphite), var(--brand-silver), var(--brand-ink));
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.4s ease;
    background-size: 300% 300%;
    animation: gradientShift 3s ease infinite;
}

.badge-glow:hover::before {
    opacity: 0.6;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Floating Animation */
.float {
    animation: float 6s ease-in-out infinite;
}

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

/* Marquee */
.marquee {
    display: flex;
    overflow: hidden;
    user-select: none;
    mask-image: linear-gradient(90deg, transparent 0%, black 8%, black 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 8%, black 92%, transparent 100%);
}

.marquee-content {
    display: flex;
    gap: 12px;
    padding-right: 12px;
    animation: marquee 28s linear infinite;
    flex-shrink: 0;
}

.marquee:hover .marquee-content {
    animation-play-state: paused;
}

@keyframes marquee {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* Blur Circle Decoration */
.blur-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    pointer-events: none;
}

/* Service Card Hover */
.service-card {
    position: relative;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,0,0,0.05);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.service-card:hover {
    background: rgba(255,255,255,0.95);
    border-color: rgba(0,0,0,0.1);
    transform: translateY(-4px);
}

.service-card-number {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 72px;
    font-weight: 700;
    line-height: 1;
    -webkit-text-stroke: 1px #e5e7eb;
    -webkit-text-fill-color: transparent;
    transition: all 0.4s ease;
}

.service-card:hover .service-card-number {
    -webkit-text-stroke-color: #9ca3af;
}

/* Process Step */
.process-step {
    position: relative;
}

.process-step::after {
    content: '';
    position: absolute;
    top: 28px;
    left: 100%;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, #e5e7eb 0%, transparent 100%);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.35s;
}

.process-step:last-child::after {
    display: none;
}

.process-step.active::after,
.process-step.visible::after {
    transform: scaleX(1);
}

/* Tech Stack Item */
.tech-item {
    padding: 16px 28px;
    background: white;
    border: 1px solid #f3f4f6;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tech-item:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
    transform: translateY(-2px);
}

/* Split Text Effect */
.split-text {
    display: inline-block;
    overflow: hidden;
}

.split-text span {
    display: inline-block;
    transform: translateY(100%);
    opacity: 0;
}

.split-text.visible span {
    animation: splitReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes splitReveal {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Interactive Grid */
.interactive-grid {
    display: grid;
    gap: 1px;
    background: #f3f4f6;
}

.interactive-grid > * {
    background: white;
}

/* Underline Animation */
.underline-hover {
    position: relative;
}

.underline-hover::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.underline-hover:hover::after {
    width: 100%;
}

/* Glass Card */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Dot Pattern */
.dot-pattern {
    background-image: radial-gradient(#d1d5db 1px, transparent 1px);
    background-size: 24px 24px;
}

.hero-callout {
    z-index: 2;
}

main > section:nth-of-type(n + 2) {
    content-visibility: auto;
    contain-intrinsic-size: 1px 960px;
}

@media (max-width: 767px) {
    .noise-overlay {
        display: none;
    }

    .blur-circle {
        filter: blur(56px);
        opacity: 0.22;
    }

    .float {
        animation: none;
    }

    .hero-visual-card {
        display: flex;
        flex-direction: column;
        gap: 14px;
        padding: 20px;
        aspect-ratio: auto;
        min-height: 0;
    }

    .hero-code-window {
        margin-bottom: 0;
    }

    .hero-callout {
        position: static;
        width: 100%;
        max-width: 100%;
        transform: none;
    }

    .hero-callout-status {
        align-self: center;
        max-width: min(280px, 100%);
    }

    .hero-callout-live {
        display: none;
    }
}

@media (hover: none), (prefers-reduced-motion: reduce) {
    .badge-glow::before,
    .card-shine::before,
    .marquee-content,
    .float,
    .code-cursor {
        animation: none;
        transition: none;
    }

    .hero-title-line {
        animation: none;
        transform: none;
        filter: none;
        transition: none;
    }

    .reveal,
    .reveal-stagger,
    .scroll-reveal-view {
        opacity: 1;
        transform: none;
        transition: none;
        animation: none;
    }

    .hero-visual-entrance {
        animation: none;
        opacity: 1;
    }

    .hero-badge-reveal {
        animation: none;
        opacity: 1;
    }

    .hero-callout-status,
    .hero-callout-live {
        animation: none;
        opacity: 1;
    }

    .process-step::after,
    .process-connector-scroll::after {
        transform: scaleX(1);
        transition: none;
        animation: none;
    }

    .hero-parallax-content {
        animation: none;
        transform: none;
    }

    .tech-grid-parallax {
        animation: none;
        transform: none;
    }

    /* New animation reduced-motion overrides */
    .hero-spotlight::before {
        display: none;
    }

    .hero-visual-card::after {
        display: none;
    }

    .hero-code-line {
        opacity: 1;
        transform: none;
        animation: none;
    }

    .hero-code-window.code-revealed .hero-code-line {
        animation: none;
    }
}

/* ── PROJECT CARDS: ACHROMATIC DARK TREATMENT ─────────────────────── */

.project-card-dark {
    color: #f1f5f9;
}

.project-card-dark-1 {
    background:
        radial-gradient(ellipse 65% 42% at 12% 12%, rgba(255, 255, 255, 0.045) 0%, transparent 70%),
        #111827;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.project-card-dark-2 {
    background:
        radial-gradient(ellipse 65% 42% at 88% 12%, rgba(255, 255, 255, 0.045) 0%, transparent 70%),
        #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.project-card-dark-3 {
    background:
        radial-gradient(ellipse 65% 42% at 12% 88%, rgba(255, 255, 255, 0.045) 0%, transparent 70%),
        #111827;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.project-card-dark-4 {
    background:
        radial-gradient(ellipse 65% 42% at 88% 88%, rgba(255, 255, 255, 0.045) 0%, transparent 70%),
        #0d1520;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.project-card-dark:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.project-card-numeral {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 64px;
    font-weight: 700;
    line-height: 1;
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.10);
    -webkit-text-fill-color: transparent;
    position: absolute;
    top: 18px;
    right: 22px;
    user-select: none;
    pointer-events: none;
    transition: -webkit-text-stroke-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card-dark:hover .project-card-numeral {
    -webkit-text-stroke-color: rgba(255, 255, 255, 0.24);
}

.project-card-dark .section-label {
    color: rgba(255, 255, 255, 0.38);
}

.project-card-dark-body {
    color: rgba(255, 255, 255, 0.58);
}

.project-card-tag {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.52);
    font-size: 0.75rem;
    line-height: 1.5;
    border-radius: 999px;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.project-card-dark:hover .project-card-tag {
    border-color: rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.72);
}

/* ── HERO SPOTLIGHT — cursor-tracked radial glow ───────────────────── */
.hero-spotlight {
    --hero-mx: 50%;
    --hero-my: 30%;
}

.hero-spotlight::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        700px circle at var(--hero-mx) var(--hero-my),
        var(--brand-glow) 0%,
        transparent 60%
    );
    pointer-events: none;
    z-index: 1;
}

/* ── HERO VISUAL CARD — scan line + 3D tilt ─────────────────────────── */
.hero-visual-card {
    overflow: visible;
}

.hero-visual-card::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.06) 20%,
        rgba(255, 255, 255, 0.32) 50%,
        rgba(255, 255, 255, 0.06) 80%,
        transparent 100%
    );
    top: 0;
    animation: scanDown 6s linear 2.2s infinite;
    z-index: 5;
    pointer-events: none;
}

@keyframes scanDown {
    0%   { top: 0;    opacity: 0; }
    4%   { opacity: 1; }
    92%  { opacity: 0.7; }
    100% { top: 100%; opacity: 0; }
}

/* ── CODE WINDOW LINE-BY-LINE REVEAL ─────────────────────────────────── */
.hero-code-line {
    opacity: 0;
    transform: translateX(-6px);
}

.hero-code-window.code-revealed .hero-code-line {
    animation: codeLineIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--line-i, 0) * 160ms + 800ms);
}

@keyframes codeLineIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ── SERVICE CARD 3D PERSPECTIVE ENTRANCE ────────────────────────────── */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .service-card.scroll-reveal-view {
            animation: serviceCardReveal linear both;
            animation-timeline: view();
            animation-range: entry 0% entry 34%;
            transform-origin: top center;
        }

        @keyframes serviceCardReveal {
            from {
                opacity: 0;
                transform: perspective(900px) rotateX(9deg) translateY(20px);
            }
            to {
                opacity: 1;
                transform: none;
            }
        }
    }
}

/* ── PROJECT CARD CURSOR LABEL ───────────────────────────────────────── */
.project-card-label {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10000;
    background: #ffffff;
    color: #222222;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 7px 14px;
    border-radius: 999px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
    opacity: 0;
    will-change: transform, opacity;
    transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card-label.visible {
    opacity: 1;
}

/* ── SCROLL-DRIVEN ANIMATIONS: DIRECTION B — PRECISION ────────────── */

/* 1. Hero content depth parallax — tied to root scroll position */
@supports (animation-timeline: scroll()) {
    @media (prefers-reduced-motion: no-preference) {
        .hero-parallax-content {
            animation: heroParallaxUp linear;
            animation-timeline: scroll(root);
            animation-range: 0px 640px;
        }

        @keyframes heroParallaxUp {
            from { transform: translateY(0px); }
            to   { transform: translateY(-52px); }
        }
    }
}

/* 2. View-linked reveal — each element animates on its own viewport entry */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .scroll-reveal-view {
            transition: none !important;
            animation: viewRevealUp linear both;
            animation-timeline: view();
            animation-range: entry 0% entry 28%;
        }

        @keyframes viewRevealUp {
            from { opacity: 0; transform: translateY(16px); }
            to   { opacity: 1; transform: none; }
        }
    }
}

/* 3. Process connectors draw exactly with scroll position */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .process-connector-scroll::after {
            transition: none !important;
            animation: connectorLineDraw linear both;
            animation-timeline: view();
            animation-range: entry 15% contain 60%;
        }

        .process-connector-scroll.active::after,
        .process-connector-scroll.visible::after {
            transform: initial;
        }

        @keyframes connectorLineDraw {
            from { transform: scaleX(0); }
            to   { transform: scaleX(1); }
        }
    }
}

/* 4. Tech section grid — subtle perspective depth as section scrolls */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .tech-grid-parallax {
            will-change: transform;
            animation: techGridDepth linear;
            animation-timeline: view(block);
            animation-range: entry 0% exit 100%;
        }

        @keyframes techGridDepth {
            0%   { transform: perspective(700px) translateY(-10px); }
            50%  { transform: perspective(700px) translateY(0px); }
            100% { transform: perspective(700px) translateY(10px); }
        }
    }
}
