/* ==========================================================================
   Portfolio — custom styles & animations
   ========================================================================== */

/* ---------- Smooth base ---------- */
html {
    scroll-behavior: smooth;
}

body {
    background-color: #020617; /* slate-950 */
    overflow-x: hidden;
}

/* Subtle gradient overlay for the entire page */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59, 130, 246, 0.08), transparent 60%),
                radial-gradient(ellipse 60% 50% at 100% 50%, rgba(168, 85, 247, 0.06), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

main, header, footer {
    position: relative;
    z-index: 1;
}

/* ---------- Custom scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #020617; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3b82f6, #8b5cf6);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #60a5fa, #a78bfa); }

/* ==========================================================================
   Navbar
   ========================================================================== */
#navbar {
    backdrop-filter: blur(0px);
    background: transparent;
    border-bottom: 1px solid transparent;
}
#navbar.scrolled {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(2, 6, 23, 0.7);
    border-bottom-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.nav-link {
    position: relative;
    padding: 0.5rem 1rem;
    color: rgb(203 213 225); /* slate-300 */
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: color 0.3s ease, background-color 0.3s ease;
}
.nav-link:hover { color: white; background-color: rgba(255, 255, 255, 0.05); }

.nav-link.active {
    color: white;
}
.nav-link.active::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -2px;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    border-radius: 2px;
}

.mobile-link {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: rgb(203 213 225);
    font-weight: 500;
    transition: all 0.2s ease;
}
.mobile-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   Hero / Orbs
   ========================================================================== */
@keyframes float {
    0%, 100% { transform: translateY(0) translateX(0); }
    50%      { transform: translateY(-20px) translateX(10px); }
}
@keyframes float-delay {
    0%, 100% { transform: translateY(0) translateX(0); }
    50%      { transform: translateY(20px) translateX(-15px); }
}
.animate-float      { animation: float 7s ease-in-out infinite; }
.animate-float-delay{ animation: float-delay 8s ease-in-out infinite; }

@keyframes bounce-slow {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50%      { transform: translateX(-50%) translateY(-8px); }
}
.animate-bounce-slow { animation: bounce-slow 2.5s ease-in-out infinite; }

/* ==========================================================================
   Social icons
   ========================================================================== */
.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgb(203 213 225);
    transition: all 0.3s ease;
}
.social-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-3px);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 8px 20px -8px rgba(99, 102, 241, 0.6);
}
.social-icon[href^="https://linkedin.com"],
.social-icon[href^="https://twitter.com"],
.social-icon[href^="https://x.com"] {
    display: none;
}

/* ==========================================================================
   About / Info / Stats
   ========================================================================== */
.info-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}
.info-item:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}
.info-label {
    font-size: 0.75rem;
    color: rgb(100 116 139); /* slate-500 */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.info-value {
    color: rgb(226 232 240); /* slate-200 */
    font-weight: 500;
    font-size: 0.95rem;
}

/* ==========================================================================
   Skills
   ========================================================================== */
.skill-card {
    position: relative;
    padding: 1.5rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}
.skill-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99,102,241,0.0), rgba(168,85,247,0.0));
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
.skill-card:hover {
    transform: translateY(-6px);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 20px 40px -20px rgba(99, 102, 241, 0.5);
}
.skill-card:hover::before { opacity: 0.05; }

.skill-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}
.skill-card:hover .skill-icon { transform: scale(1.1) rotate(-5deg); }

.skill-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
}

/* The card title doubles as the mobile accordion trigger.
   Reset it so it renders exactly like the original plain heading. */
.skill-toggle {
    display: inline;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    line-height: inherit;
    text-align: left;
    cursor: pointer;
}
.skill-desc {
    font-size: 0.875rem;
    color: rgb(148 163 184);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}
.skill-tag {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background-color: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: rgb(199 210 254); /* indigo-200 */
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.skill-tag:hover {
    background-color: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
}

@media (max-width: 767px) {
    /* ---------- Skills: accordion list ----------
       One compact row per skill so all six are visible at once.
       Tap the title to expand the description + tags. */

    #skills .skills-card-stack {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    #skills .skill-card {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            'icon title chevron'
            'body  body  body';
        align-items: center;
        column-gap: 0.85rem;
        padding: 1rem 1.1rem;
        cursor: pointer;
        transition: border-color 0.3s ease, background-color 0.3s ease;
    }

    /* Touch devices can stick :hover after a tap — keep the row flat. */
    #skills .skill-card:hover {
        transform: none;
        box-shadow: none;
    }

    #skills .skill-card.is-open {
        border-color: rgba(99, 102, 241, 0.45);
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.09), rgba(168, 85, 247, 0.05));
    }

    #skills .skill-icon {
        grid-area: icon;
        margin-bottom: 0;
    }

    #skills .skill-title {
        grid-area: title;
        margin-bottom: 0;
        font-size: 1.05rem;
    }

    #skills .skill-body {
        grid-area: body;
        display: grid;
        grid-template-rows: 0fr;
        margin-top: 0;
        transition: grid-template-rows 0.36s cubic-bezier(0.16, 1, 0.3, 1);
    }

    #skills .skill-body > .skill-body-inner {
        min-height: 0;
        overflow: hidden;
    }

    #skills .skill-card.is-open .skill-body {
        grid-template-rows: 1fr;
        margin-top: 0.85rem;
    }

    /* Chevron affordance — drawn with borders, so no extra markup needed. */
    #skills .skill-card::after {
        content: '';
        grid-area: chevron;
        width: 0.55rem;
        height: 0.55rem;
        margin-right: 0.3rem;
        border-right: 2px solid rgb(148 163 184);
        border-bottom: 2px solid rgb(148 163 184);
        transform: rotate(45deg) translate(-2px, -2px);
        transition: transform 0.3s ease, border-color 0.3s ease;
    }

    #skills .skill-card.is-open::after {
        transform: rotate(-135deg) translate(-2px, -2px);
        border-color: rgb(129 140 248);
    }
}

/* Desktop keeps the original grid card exactly as it was — the collapsible
   wrapper is layout-neutral and the title is plain, non-interactive text. */
@media (min-width: 768px) {
    #skills .skill-body,
    #skills .skill-body-inner {
        display: contents;
    }

    #skills .skill-toggle {
        cursor: default;
        pointer-events: none;
    }
}

/* ==========================================================================
   Projects
   ========================================================================== */
.project-card {
    position: relative;
    border-radius: 1rem;
    background-color: rgba(15, 23, 42, 0.5); /* slate-900/50 */
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.project-card:hover {
    transform: translateY(-8px);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 25px 50px -12px rgba(99, 102, 241, 0.4);
}

.project-image {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.3) 100%);
    z-index: 1;
}

.project-category {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 2;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.project-thumbnail {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.project-card:hover .project-thumbnail { transform: scale(1.05); }

.tech-pill {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgb(165 180 252); /* indigo-300 */
    background-color: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 0.375rem;
    letter-spacing: 0.02em;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgb(199 210 254);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 0.5rem;
    background-color: rgba(99, 102, 241, 0.05);
    transition: all 0.3s ease;
}
.project-link:hover {
    background-color: rgba(99, 102, 241, 0.15);
    color: white;
    border-color: rgba(99, 102, 241, 0.6);
    transform: translateY(-2px);
}

@media (max-width: 767px) {
    #projects .projects-scroll-track.is-project-sequence {
        position: relative;
        height: 226vh;
        height: 226svh;
        overflow: clip;
    }

    #projects .project-card-stack.is-project-sequence {
        position: sticky;
        top: max(4rem, 6vh);
        top: max(4rem, 6svh);
        display: block;
        height: min(86vh, calc(100vh - max(4rem, 6vh) - 1rem));
        height: min(86svh, calc(100svh - max(4rem, 6svh) - 1rem));
    }

    #projects .project-card.is-project-sequence-card {
        position: absolute;
        inset: 0;
        box-sizing: border-box;
        width: 100%;
        height: 100%;
        margin: 0;
        background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(8, 13, 27, 0.98));
        box-shadow: 0 18px 35px -24px rgba(99, 102, 241, 0.65);
        transform-origin: center center;
        transition: none;
        will-change: transform;
    }

    #projects .project-card.is-project-sequence-card .project-image {
        flex: 0 0 auto;
        aspect-ratio: 16 / 9;
    }

    #projects .project-card.is-project-sequence-card > div:last-child {
        padding: 1.25rem;
    }

    #projects .project-card.is-project-sequence-card > * {
        opacity: 0;
    }

    #projects .project-card.is-project-sequence-card.has-visible-content > * {
        opacity: 1;
    }
}

/* ==========================================================================
   Tablet layout refinements
   ========================================================================== */
@media (min-width: 1024px) and (max-width: 1279px) {
    #home .grid.items-center { gap: 2rem; }
    #home h1 { font-size: clamp(3.5rem, 5vw, 4rem); }
    #home .animate-float > .relative { padding: 1.25rem; }
    #home pre { font-size: 0.75rem; line-height: 1.5; }

    #skills .skills-card-stack,
    #projects .project-card-stack {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #projects .project-card-stack > :last-child {
        grid-column: 1 / -1;
        width: calc(50% - 0.75rem);
        justify-self: center;
    }
}

/* ==========================================================================
   Education timeline
   ========================================================================== */
.timeline-item {
    position: relative;
    margin-bottom: 2.5rem;
    padding-left: 3rem;
}
.timeline-track::after {
    content: '';
    position: absolute;
    top: 1.5625rem; /* Centers on the first timeline dot before traveling. */
    left: 50%;
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, #60a5fa, #a855f7);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2), 0 0 16px rgba(129, 140, 248, 0.85);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 3;
    animation: timeline-bubble-travel 6s linear infinite;
}
@keyframes timeline-bubble-travel {
    0% { top: 1.5625rem; opacity: 0; }
    8% { opacity: 1; }
    92% { opacity: 1; }
    100% { top: calc(100% - 0.875rem); opacity: 0; }
}
@media (min-width: 640px) {
    .timeline-item {
        width: 50%;
        padding-left: 0;
        padding-right: 2.5rem;
    }
    .timeline-item:nth-child(even) {
        margin-left: auto;
        padding-left: 2.5rem;
        padding-right: 0;
    }
    .timeline-item:nth-child(even) .timeline-dot { left: -0.55rem; }
}

.timeline-dot {
    position: absolute;
    top: 1.5rem;
    left: 0.85rem;
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, #3b82f6, #a855f7);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
    z-index: 2;
}
@media (min-width: 640px) {
    .timeline-dot { left: -0.7rem; }
}
@media (max-width: 639px) {
    #education .timeline-dot { left: 0.5rem; }
}

.timeline-card {
    padding: 1.25rem 1.5rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}
.timeline-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px -10px rgba(99, 102, 241, 0.3);
}

.timeline-date {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgb(165 180 252);
    background-color: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 9999px;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}
.timeline-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.25rem;
}
.timeline-org {
    font-size: 0.85rem;
    color: rgb(129 140 248); /* indigo-400 */
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.timeline-desc {
    font-size: 0.875rem;
    color: rgb(148 163 184);
    line-height: 1.5;
}

/* ==========================================================================
   Contact
   ========================================================================== */
.contact-info-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.3s ease;
}
.contact-info-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background-color: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}
.contact-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.625rem;
    background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(168,85,247,0.15));
    color: rgb(165 180 252);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.glass-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    backdrop-filter: blur(10px);
}

/* ==========================================================================
   Scroll-triggered animations
   ========================================================================== */
[data-animate] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-animate].is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children — the JS adds delays up to 0.4s */

/* ==========================================================================
   Accessibility — respect reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    [data-animate] { opacity: 1; transform: none; }
    .timeline-track::after { display: none; }
}

/* ==========================================================================
   Selection / focus polish
   ========================================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid rgb(129 140 248);
    outline-offset: 2px;
}
