/* --- ANIMATIONS --- */
.fade-in {
    opacity: 0;
    transform: translateY(15px);
    transition:
        opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger Helpers */
.stagger-1 {
    transition-delay: 0.05s;
}
.stagger-2 {
    transition-delay: 0.1s;
}
.stagger-3 {
    transition-delay: 0.15s;
}
.stagger-4 {
    transition-delay: 0.2s;
}
.stagger-5 {
    transition-delay: 0.25s;
}
.stagger-6 {
    transition-delay: 0.3s;
}
.stagger-7 {
    transition-delay: 0.35s;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
}

/* --- CURSOR GLOW & EFFECTS --- */
#cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 500px;
    height: 500px;
    background: radial-gradient(
        circle,
        rgba(201, 168, 108, 0.07) 0%,
        transparent 65%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    transform: translate(-50%, -50%);
}

[data-theme="light"] #cursor-glow {
    background: radial-gradient(
        circle,
        rgba(122, 98, 64, 0.04) 0%,
        transparent 65%
    );
}

.cursor-ripple {
    position: fixed;
    border-radius: 50%;
    border: 1px solid var(--accent-primary);
    transform: translate(-50%, -50%) scale(0);
    animation: ripple-anim 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.5;
}

@keyframes ripple-anim {
    0% {
        width: 0;
        height: 0;
        opacity: 0.6;
    }
    100% {
        width: 120px;
        height: 120px;
        opacity: 0;
    }
}

/* --- MOBILE RESPONSIVE FIX --- */
@media (max-width: 900px) {
    .bento-grid.masonry {
        grid-template-columns: repeat(2, 1fr);
    }
    .col-span-2 {
        grid-column: span 2;
    }
    .col-span-1 {
        grid-column: span 1;
    }
    .hero-meta {
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .bento-grid.masonry {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }
    .col-span-2,
    .col-span-1,
    .row-span-2,
    .row-span-1 {
        grid-column: span 1;
        grid-row: auto;
    }

    .timeline-row {
        flex-direction: column;
        gap: 0.75rem;
    }
    .timeline-row::before,
    .timeline-simple::before {
        display: none;
    }
    .year {
        width: auto;
        padding-right: 0;
    }

    .nav-container {
        padding: 0.875rem 1rem;
    }
    .nav-content {
        gap: 0.75rem;
        padding: 0.6rem 1rem;
        max-width: calc(100vw - 2rem);
    }

    .nav-links {
        display: flex;
        overflow-x: auto;
        gap: 1.25rem;
        flex: 1;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-mask-image: linear-gradient(
            to right,
            transparent,
            black 8%,
            black 92%,
            transparent
        );
        mask-image: linear-gradient(
            to right,
            transparent,
            black 8%,
            black 92%,
            transparent
        );
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .bento-card {
        padding: 1.75rem;
    }

    .hero-meta {
        display: none;
    }

    .git-left {
        width: 80px;
    }
    .git-hash {
        font-size: 0.62rem;
    }
    .git-right {
        padding-bottom: 2rem;
        padding-left: 1.25rem;
    }

    .section-container {
        padding: 5rem 1.5rem;
    }

    .large-text {
        font-size: 1.35rem;
    }
}

@media (max-width: 480px) {
    .nav-logo {
        font-size: 0.78rem;
    }
    .nav-links a {
        font-size: 0.75rem;
    }
    .headline {
        font-size: clamp(2.75rem, 14vw, 3.5rem);
    }
}

/* --- BACK TO TOP --- */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    z-index: 999;
    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease,
        border-color 0.2s,
        color 0.2s,
        box-shadow 0.2s;
    pointer-events: none;
    box-shadow: var(--shadow-base);
}

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

#back-to-top:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 16px rgba(201, 168, 108, 0.2);
}

/* --- MOBILE CARD EXPAND --- */
@media (max-width: 768px) {
    .bento-card {
        cursor: pointer;
    }

    .bento-card .bento-card-body {
        max-height: 80px;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .bento-card.expanded .bento-card-body {
        max-height: 400px;
    }

    .card-expand-hint {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        font-family: var(--font-mono);
        font-size: 0.7rem;
        color: var(--accent-primary);
        opacity: 0.6;
        margin-top: 0.75rem;
        transition: opacity 0.2s;
    }

    .card-expand-hint svg {
        transition: transform 0.3s ease;
    }

    .bento-card.expanded .card-expand-hint svg {
        transform: rotate(180deg);
    }

    .bento-card.expanded .card-expand-hint {
        opacity: 0;
        height: 0;
        margin: 0;
        overflow: hidden;
    }
}

@media (min-width: 769px) {
    .card-expand-hint {
        display: none;
    }
}
