*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-bg: #0a0a0f;
    --color-surface: rgba(255, 255, 255, 0.03);
    --color-border: rgba(255, 255, 255, 0.08);
    --color-text-primary: #f0f0f0;
    --color-text-secondary: #8a8a9a;
    --color-accent-blue: #00d4ff;
    --color-accent-purple: #7b2ff7;
    --color-accent-gradient: linear-gradient(135deg, #00d4ff, #7b2ff7);

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-blur: blur(20px);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text-primary);
    overflow-x: hidden;
    cursor: none;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Canvas */
#three-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Grain overlay */
#grain-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    opacity: 0.04;
    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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    animation: grain 0.5s steps(6) infinite;
}

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    30% { transform: translate(3%, -15%); }
    50% { transform: translate(12%, 9%); }
    70% { transform: translate(9%, 4%); }
    90% { transform: translate(-1%, 7%); }
}

/* Custom cursor */
#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99999;
    pointer-events: none;
    mix-blend-mode: difference;
}

.cursor-ring {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid var(--color-text-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.2s, height 0.2s, border-color 0.2s;
}

.cursor-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--color-text-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

#custom-cursor.hovering .cursor-ring {
    width: 60px;
    height: 60px;
    border-color: var(--color-accent-blue);
}

#custom-cursor.hovering .cursor-dot {
    width: 4px;
    height: 4px;
}

/* Sections */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 80px 40px;
}

.section-inner {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.section-header {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 600;
    margin-bottom: 2rem;
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0;
}

.section-content {
    opacity: 0;
}

/* Hero */
.hero-inner {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

#hero-name {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 6rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 1rem;
    position: relative;
    color: #ffffff;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.9), 0 0 20px rgba(255, 255, 255, 0.3);
}

.glitch {
    animation: glitch-skew 4s infinite linear alternate-reverse;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    color: #ffffff;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    animation: glitch-effect 4s infinite linear alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(-1px, 0);
    opacity: 0.6;
}

.glitch::after {
    color: #ffffff;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    animation: glitch-effect 3s infinite linear alternate-reverse;
    clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
    transform: translate(1px, 0);
    opacity: 0.6;
}

@keyframes glitch-effect {
    0% { transform: translate(0); }
    20% { transform: translate(-1px, 1px); }
    40% { transform: translate(-1px, -1px); }
    60% { transform: translate(1px, 1px); }
    80% { transform: translate(1px, -1px); }
    100% { transform: translate(0); }
}

@keyframes glitch-skew {
    0% { transform: skew(0deg); }
    2% { transform: skew(0.5deg); }
    4% { transform: skew(0deg); }
    98% { transform: skew(0deg); }
    100% { transform: skew(-0.3deg); }
}

#hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--color-text-secondary);
    font-weight: 300;
    letter-spacing: 0.05em;
    opacity: 0;
}

.hero-hint {
    margin-top: 2rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    opacity: 0;
    animation: pulse-fade 3s ease-in-out infinite;
    animation-delay: 2s;
}

@keyframes pulse-fade {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

#scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
}

.scroll-arrow {
    width: 24px;
    height: 24px;
    border-right: 2px solid var(--color-text-secondary);
    border-bottom: 2px solid var(--color-text-secondary);
    transform: rotate(45deg);
    animation: scroll-bounce 2s ease-in-out infinite;
}

@keyframes scroll-bounce {
    0%, 100% { transform: rotate(45deg) translate(0, 0); opacity: 0.5; }
    50% { transform: rotate(45deg) translate(5px, 5px); opacity: 1; }
}

/* About */
.about-text {
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    line-height: 1.8;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
    font-weight: 300;
}

.highlight {
    color: var(--color-text-primary);
    font-weight: 500;
    position: relative;
}

.highlight::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-accent-gradient);
    opacity: 0.6;
}

/* Glass card */
.glass-card {
    background: var(--glass-bg);
    border: var(--glass-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-accent-gradient);
    opacity: 0.3;
}

.timeline-item {
    position: relative;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.timeline-dot {
    position: absolute;
    left: -38px;
    top: 1.8rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-accent-blue);
    box-shadow: 0 0 12px var(--color-accent-blue);
}

.timeline-date {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-accent-blue);
    margin-bottom: 0.5rem;
}

.timeline-role {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.timeline-company {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.timeline-impact {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* Skills constellation */
.skills-constellation {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    perspective: 800px;
}

.skill-node {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 0.6rem 1.2rem;
    background: var(--glass-bg);
    border: var(--glass-border);
    border-radius: 30px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--color-text-primary);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: default;
    opacity: 0;
    transform: translateY(20px);
}

.skill-node:hover {
    transform: translateY(-5px) scale(1.05);
    border-color: var(--color-accent-blue);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.2);
}

/* Terminal */
.terminal {
    max-width: 700px;
    margin: 0 auto;
    overflow: hidden;
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.terminal-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.terminal-body {
    padding: 1.5rem;
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.8;
}

.terminal-output {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.terminal-output .cmd-line {
    color: var(--color-accent-blue);
}

.terminal-output .response {
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
    display: block;
}

.terminal-output .response-highlight {
    color: var(--color-text-primary);
}

.terminal-output .response-accent {
    color: var(--color-accent-blue);
}

.terminal-input-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.terminal-prompt {
    color: var(--color-accent-blue);
    font-weight: 600;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    caret-color: var(--color-accent-blue);
}

.terminal-input::placeholder {
    color: rgba(138, 138, 154, 0.5);
}

/* Projects */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.project-card {
    display: block;
    padding: 2rem;
    transition: transform 0.15s ease-out, box-shadow 0.3s ease;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.project-card:hover {
    box-shadow: 0 16px 48px rgba(0, 212, 255, 0.1);
}

.project-card-inner {
    pointer-events: none;
}

.project-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.project-desc {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.project-tags span {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.2);
    color: var(--color-accent-blue);
}

/* Contact */
.contact-inner {
    text-align: center;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.contact-link:hover {
    border-color: var(--color-accent-blue);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.2);
    transform: translateY(-2px);
}

.contact-link.primary {
    background: var(--color-accent-gradient);
    border: none;
    color: white;
}

.contact-link.primary:hover {
    box-shadow: 0 4px 30px rgba(0, 212, 255, 0.4);
}

.contact-link svg {
    width: 20px;
    height: 20px;
}

.footer-note {
    margin-top: 4rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        cursor: auto;
    }

    #custom-cursor {
        display: none;
    }

    #grain-overlay {
        display: none;
    }

    .section {
        padding: 60px 20px;
        min-height: auto;
    }

    #section-hero {
        min-height: 100vh;
    }

    .glitch::before,
    .glitch::after {
        display: none;
    }

    .timeline {
        padding-left: 20px;
    }

    .timeline-dot {
        left: -28px;
    }

    .timeline-item {
        padding: 1.2rem 1.5rem;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .terminal-body {
        min-height: 250px;
        padding: 1rem;
    }

    .contact-links {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    #hero-name {
        font-size: 2rem;
    }

    .section-header {
        font-size: 2rem;
    }

    .about-text {
        font-size: 1rem;
    }
}

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

    #grain-overlay {
        display: none;
    }

    .section-header,
    .section-content,
    #hero-subtitle,
    .hero-hint,
    #scroll-indicator,
    .skill-node {
        opacity: 1 !important;
        transform: none !important;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
