:root {
    --bg: #f5f5f7;
    /* Apple's premium light grey for true luxury */
    --text: #1d1d1f;
    /* Deep dark grey text for perfect readable contrast */
    --card: rgba(255, 255, 255, 0.4);
    /* Thinner opacity for stronger frosted look */
    /* Glassmorphism base light */
    --muted: #86868b;
    /* Apple's muted text color */
    /* Cube Border - Darker for Light Mode */
    --cube-border-color: 1.5px dashed rgba(76, 29, 149, 0.6);
}

body.dark {
    --bg: #0a0a0c;
    /* Slightly deeper dark for better contrast with glass */
    --text: #f5f5f7;
    --card: rgba(30, 30, 35, 0.25);
    /* Ultra-sleek transparency in dark mode */
    /* Glassmorphism base dark */
    --muted: #a0a0a0;
    /* Cube Border - Lighter for Dark Mode */
    --cube-border-color: 1px dashed rgba(177, 158, 239, 0.4);
}

/* Custom Scroll Progress Bar */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #8a2be2, #b19eef);
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.8);
    z-index: 9999;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    /* Let clicks pass through */
}

/* Ambient Background Glow for Glassmorphism Refraction */
.ambient-glow {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 80vw;
    height: 80vw;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(138, 43, 226, 0.08) 0%, transparent 60%);
    filter: blur(80px);
    z-index: -1;
    pointer-events: none;
    animation: pulseGlow 8s infinite alternate ease-in-out;
}

body.dark .ambient-glow {
    background: radial-gradient(circle, rgba(138, 43, 226, 0.15) 0%, transparent 65%);
}

@keyframes pulseGlow {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

/* CUSTOM SCROLLBAR REPLACEMENT */
::-webkit-scrollbar {
    width: 0px;
    display: none;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(138, 43, 226, 0.9);
    /* Solid thematic purple */
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(138, 43, 226, 1);
    /* Intense neon glow */
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(177, 158, 239, 1);
    /* Brighter on hover */
    box-shadow: 0 0 25px rgba(138, 43, 226, 1);
    /* Massive glow expansion */
}

/* PAGE FADE IN */
body {
    opacity: 0;
    animation: fadePage 0.8s ease forwards;
}

@keyframes fadePage {
    to {
        opacity: 1;
    }
}

/* NAV */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 20px 10%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.nav-links {
    display: flex;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    margin-left: 25px;
    font-weight: 500;
    transition: 0.3s;
}

.nav-links a:hover {
    opacity: 0.6;
}

/* TOGGLE BUTTON */
.toggle-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--text);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    margin-left: 20px;
    transition: 0.3s;
}

.toggle-btn:hover {
    background: var(--text);
    color: var(--bg);
}

/* HAMBURGER MENU STYLES */
.menu-btn {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 6px;
}

.menu-btn span {
    width: 25px;
    height: 2px;
    background-color: var(--text);
    transition: 0.3s;
}

/* HERO */
.hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 10%;
    position: relative;
    overflow: hidden;
}

.hero>* {
    position: relative;
    z-index: 2;
}

#cubes-container {
    position: absolute;
    top: 0;
    right: 0;
    /* Move to right */
    left: auto;
    width: 50%;
    /* Take up right half */
    height: 100%;
    z-index: 1;
    overflow: hidden;
    /* Center the animation */
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero h1 {
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 20px;
    min-height: 1.2em;
    /* Ensure height doesn't collapse during typing */
    max-width: 60%;
    /* Limit width so text doesn't overlap cubes */
}

.hero p {
    font-size: 1.35rem;
    max-width: 600px;
    color: var(--muted);
    line-height: 1.7;
    /* Increased for breathability */
    letter-spacing: -0.01em;
}

/* CUBES ANIMATION STYLES */
:root {
    --col-gap: 5%;
    /* Standard gap */
    --row-gap: 5%;
    /* Standard gap */
    --cube-perspective: 99999999px;
    --cube-face-border: 1px dashed rgba(177, 158, 239, 0.4);
    /* Dashed Purple */
    --cube-face-bg: transparent;
    /* Transparent */
}

.default-animation {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.default-animation--scene {
    display: grid;
    width: 50%;
    /* Standard size */
    aspect-ratio: 1 / 1;
    column-gap: var(--col-gap);
    row-gap: var(--row-gap);
    perspective: var(--cube-perspective);
    grid-auto-rows: 1fr;
}

.cube {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    transform-style: preserve-3d;
}

.cube::before {
    content: '';
    position: absolute;
    top: -36px;
    right: -36px;
    bottom: -36px;
    left: -36px;
}

.cube-face {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cube-face-bg);
    border: var(--cube-face-border);
    opacity: 1;
}

.cube-face--top {
    transform: translateY(-50%) rotateX(90deg);
}

.cube-face--bottom {
    transform: translateY(50%) rotateX(-90deg);
}

.cube-face--left {
    transform: translateX(-50%) rotateY(-90deg);
}

.cube-face--right {
    transform: translateX(50%) rotateY(90deg);
}

.cube-face--back,
.cube-face--front {
    transform: rotateY(-90deg) translateX(50%) rotateY(90deg);
}

@media (max-width: 768px) {
    .default-animation--scene {
        width: 90%;
    }
}

/* SECTIONS */
section {
    padding: 160px 10%;
    /* Much more breathing room between sections */
    opacity: 0;
    transform: translateY(40px);
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1), opacity 1s cubic-bezier(0.16, 1, 0.3, 1);
}

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

section h2 {
    font-size: 2.5rem;
    margin-bottom: 40px;
}

/* CARDS (Glassmorphism) */
.card {
    background: var(--card);
    padding: 32px;
    border-radius: 20px;
    margin-bottom: 30px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border 0.4s ease;

    /* Strong Backdrop Blur */
    -webkit-backdrop-filter: blur(40px);
    backdrop-filter: blur(40px);

    /* Translucent border & subtle inner glow */
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.04),
        inset 0 1px 2px rgba(255, 255, 255, 0.5);
    /* Inner Top Highlight */

    position: relative;
    overflow: hidden;
}

body.dark .card {
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    /* Soft Top Inner Glow */
}

/* CARDS Init Staggering states */
.card.stagger-item {
    opacity: 0;
    transform: translateY(30px);
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border 0.4s ease;
}

.card.stagger-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Smooth Hover Elevation */
.card.stagger-item.visible:hover,
.card:hover {
    /* Ensure hover overrides stagger position cleanly */
    transform: translateY(-4px);
    box-shadow:
        0 14px 40px rgba(0, 0, 0, 0.06),
        0 4px 12px rgba(0, 0, 0, 0.03),
        inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

body.dark .card.stagger-item.visible:hover,
body.dark .card:hover {
    box-shadow:
        0 16px 45px rgba(0, 0, 0, 0.4),
        0 4px 15px rgba(0, 0, 0, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.15);
    /* Glow intensifies slightly */
}

/* SKILLS (Glassmorphism Badges) */
.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.skills a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    border-radius: 50px;
    background: var(--card);
    /* Uses the same glass background variable */
    color: var(--text);
    text-decoration: none;

    /* Strong Backdrop Blur */
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);

    /* Subtle Borders & Glows */
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.02),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);

    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
    cursor: pointer;
}

body.dark .skills a {
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    /* Inner top edge */
}

/* Hover effect */
.skills a:hover {
    transform: translateY(-3px);
    background: radial-gradient(circle at top, rgba(138, 43, 226, 0.1), transparent 80%), var(--card);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(138, 43, 226, 0.15);
    /* Soft purple border on hover */
}

body.dark .skills a:hover {
    background: radial-gradient(circle at top, rgba(138, 43, 226, 0.25), transparent 80%), var(--card);
    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(138, 43, 226, 0.4);
}

/* CONTACT ICONS */
.contact {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
}

.contact a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text);
    font-size: 2rem;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s ease, text-shadow 0.3s ease;
}

.contact a:hover {
    transform: translateY(-5px) scale(1.1);
    color: #8a2be2;
    /* Thematic purple glow */
    text-shadow: 0 5px 15px rgba(138, 43, 226, 0.4);
    opacity: 1;
}

/* FOOTER */
footer {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* MOBILE RESPONSIVENESS */
@media(max-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }

    section {
        padding: 80px 5%;
    }

    nav {
        padding: 20px 5%;
        background: var(--bg);
        /* Solid background for legibility */
    }

    .menu-btn {
        display: flex;
        z-index: 1001;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        /* Hidden by default */
        width: 70%;
        height: 100vh;
        background: var(--card);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        transition: right 0.4s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    .nav-links.active {
        right: 0;
        /* Slide in */
    }

    .nav-links a {
        margin: 20px 0;
        font-size: 1.2rem;
    }

    .toggle-btn {
        margin: 20px 0 0 0;
    }
}

/* TYPING EFFECT STYLES */
.text-type {
    display: inline;
    /* Changed from inline-block to allow wrapping seamlessly with the span */
    white-space: pre-wrap;
    word-break: break-word;
}

.text-type__cursor {
    display: inline-block;
    opacity: 1;
    color: var(--text);
    vertical-align: bottom;
    /* Keep it nicely resting on the baseline */
    animation: blink 1s step-end infinite;
}

.text-type__cursor--hidden {
    display: none !important;
}

/* Keyframes for the cursor blink instead of relying solely on JS, giving it that raw terminal feel */
@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* PROJECT FILTERS */
.project-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--card);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text);
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

body.dark .filter-btn {
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    /* Inner top edge */
}

.filter-btn:hover,
.filter-btn.active {
    background: #8a2be2;
    color: white;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4);
    border-color: #8a2be2;
    transform: translateY(-2px);
}

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

.projects-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- SCROLL SPY NAVIGATION --- */
.scroll-nav {
    position: fixed;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 9999;
}

.scroll-nav::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 3.5px;
    width: 1px;
    background: rgba(138, 43, 226, 0.2);
    z-index: -1;
}

.scroll-dot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
    text-decoration: none;
    position: relative;
}

.scroll-label {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0;
    /* Hidden by default */
    transform: translateX(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--card);
    padding: 6px 12px;
    border-radius: 8px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(138, 43, 226, 0.1);
    white-space: nowrap;
}

.scroll-dot .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(138, 43, 226, 0.5);
    border: 2px solid var(--bg);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 5px rgba(138, 43, 226, 0);
}

.scroll-dot:hover .scroll-label {
    opacity: 1;
    transform: translateX(0);
}

.scroll-dot:hover .dot {
    background: rgba(177, 158, 239, 1);
    transform: scale(1.5);
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.8);
}

.scroll-dot.active .dot {
    background: #8a2be2;
    transform: scale(1.5);
    box-shadow: 0 0 12px rgba(138, 43, 226, 1);
    border: 2px solid rgba(138, 43, 226, 0.3);
}

.scroll-dot.active .scroll-label {
    opacity: 1;
    color: var(--text);
    transform: translateX(0);
    border-color: rgba(138, 43, 226, 0.4);
}

@media(max-width: 768px) {
    .scroll-nav {
        display: none;
    }
}

/* CARDS */
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* SPOTIFY NOW PLAYING WIDGET */
.spotify-widget {
    position: fixed;
    bottom: 30px;
    left: 45px;
    z-index: 1000;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.spotify-widget:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 30px rgba(29, 185, 84, 0.2);
}

.spotify-inner {
    background: rgba(15, 10, 25, 0.85);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(29, 185, 84, 0.3);
    border-radius: 50px;
    padding: 10px 20px 10px 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.album-art {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1db954, #191414);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spin 4s linear infinite;
    box-shadow: 0 0 15px rgba(29, 185, 84, 0.4);
}

.vinyl-record {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #111;
    border: 2px solid #222;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vinyl-center {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1db954;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.track-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.now-playing-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #1db954;
    font-weight: 700;
    margin-bottom: 2px;
}

.track-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.artist-name {
    font-size: 0.75rem;
    color: var(--muted);
}

.equalizer {
    display: flex;
    align-items: flex-end;
    height: 15px;
    gap: 2px;
    margin-left: 10px;
}

.equalizer .bar {
    width: 3px;
    background: #1db954;
    border-radius: 2px;
    animation: bounce 1s ease-in-out infinite;
}

.equalizer .bar-1 {
    height: 8px;
    animation-delay: 0.1s;
}

.equalizer .bar-2 {
    height: 15px;
    animation-delay: 0.3s;
}

.equalizer .bar-3 {
    height: 10px;
    animation-delay: 0.2s;
}

.equalizer .bar-4 {
    height: 12px;
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    100% {
        transform: scaleY(0.5);
    }

    50% {
        transform: scaleY(1);
    }
}

.spotify-icon {
    color: #1db954;
    font-size: 1.2rem;
    margin-left: 5px;
}

/* SPOTIFY EXPANDED PANEL */
.spotify-panel {
    position: fixed;
    bottom: 90px;
    left: 45px;
    width: 350px;
    background: rgba(15, 10, 25, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(29, 185, 84, 0.4);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    z-index: 999;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.spotify-panel.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.spotify-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.spotify-panel .panel-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.spotify-panel .panel-header h3 i {
    color: #1db954;
}

.spotify-panel .close-panel {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.spotify-panel .close-panel:hover {
    color: #fff;
}

.spotify-panel .panel-content {
    padding: 15px;
}

@media(max-width: 768px) {
    .spotify-widget {
        bottom: 20px;
        left: 20px;
        transform: scale(0.9);
    }

    .spotify-panel {
        bottom: 80px;
        left: 15px;
        width: calc(100% - 30px);
    }
}