/* ==========================================================================
   1. Variables & Base Reset
   ========================================================================== */
:root {
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --color-black: #000000;
    --color-white: #ffffff;
    --color-blue-500: #3b82f6;
    
    --apple-bg: #000000;
    --apple-glass-bg: rgba(255, 255, 255, 0.04);
    --apple-glass-border: rgba(255, 255, 255, 0.08);
    --apple-text: rgba(255, 255, 255, 0.9);
    --apple-muted: rgba(255, 255, 255, 0.5);
}

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

html {
    scroll-behavior: smooth;
    font-family: var(--font-sans);
}

body {
    background-color: var(--color-black);
    color: var(--color-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

::selection {
    background-color: rgba(59, 130, 246, 0.3);
    color: var(--color-white);
}

button, a, [role="button"] { 
    touch-action: manipulation; 
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.8);
    outline-offset: 2px;
    border-radius: 6px;
}

img, video, svg {
    display: block;
    max-width: 100%;
}

/* ==========================================================================
   2. Utility & State Classes
   ========================================================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.opacity-0 { opacity: 0 !important; }
.invisible { visibility: hidden !important; }
.hidden { display: none !important; }
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2;
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ==========================================================================
   3. Layout & Sections
   ========================================================================== */
.container {
    max-width: 80rem;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.section-padding {
    padding-top: 6rem;
    padding-bottom: 6rem;
}

.hero-section {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-fallback { 
    background: radial-gradient(circle at center, #0f0f12 0%, #000000 100%); 
    display: block !important; 
    position: absolute;
    inset: 0;
    z-index: 0;
}

.hero-video-wrapper {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.hero-video-container {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
    pointer-events: none;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.portfolio-section {
    position: relative;
    z-index: 20;
    background-color: var(--color-black);
    min-height: 100vh;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    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);
}

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

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title {
    font-size: 2.25rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.filters-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
}

@media (min-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    .section-title {
        font-size: 3rem;
    }
    .section-header {
        margin-bottom: 4rem;
    }
}

/* ==========================================================================
   4. Components & Custom UI
   ========================================================================== */
/* Overlays & Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background-color: var(--color-black);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s;
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-blue-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Glassmorphism */
.apple-glass {
    background: var(--apple-glass-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--apple-glass-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 24px rgba(0, 0, 0, 0.2);
}

.apple-glass-strong {
    background: #0a0a0c;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Navigation */
.main-nav {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 50;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: max(24px, calc(env(safe-area-inset-right, 0px) + 16px));
}

.menu-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    position: relative;
}

.menu-btn:hover { background-color: rgba(255, 255, 255, 0.1); }

.menu-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: rgba(255, 255, 255, 0.8);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.hamburger-svg { opacity: 1; transform: scale(1); }
.close-svg { position: absolute; opacity: 0; transform: scale(0.8); }

.menu-btn.active .hamburger-svg { opacity: 0; transform: scale(0.8); }
.menu-btn.active .close-svg { opacity: 1; transform: scale(1); }

.menu-dropdown {
    position: absolute;
    top: 3.5rem;
    right: 0;
    width: 10rem;
    padding: 0.375rem;
    border-radius: 1rem;
    transition: all 0.3s ease;
    transform-origin: top right;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.menu-dropdown:not(.invisible) {
    transform: translateY(0) scale(1);
}

.menu-dropdown.invisible {
    transform: translateY(0.5rem) scale(0.95);
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 0.75rem;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.875rem;
}

.menu-link:hover {
    color: var(--color-white);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Hero Scroll Button */
.scroll-btn-container {
    position: absolute;
    top: 62%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 20;
}

.scroll-btn {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 24px rgba(0, 0, 0, 0.2);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.scroll-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-4px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 12px 36px rgba(0, 0, 0, 0.3);
}

.scroll-btn:active { transform: translateY(0); }

.scroll-btn svg {
    width: 24px;
    height: 24px;
    stroke: rgba(255, 255, 255, 0.7);
    stroke-width: 1.5;
    fill: none;
    pointer-events: none;
}

.scroll-btn::before, .scroll-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    animation: pulseRing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.scroll-btn::after { animation-delay: 1s; }

.scroll-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    animation: bounceSlow 2s ease-in-out infinite;
}

/* Tags & Filters */
.apple-tag {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.filter-btn { transition: all 0.3s ease; }
.filter-btn.active-filter {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Projects Card */
.project-card {
    position: relative;
    overflow: hidden;
    background: #000000;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
    width: 100%;
    min-height: 420px;
    cursor: pointer;
    will-change: transform, opacity; /* Hardware acceleration */
}

.project-card.is-filtering {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-media {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.project-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
}

.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.4), transparent);
}

.project-card-content {
    position: relative;
    z-index: 10;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.project-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-white);
    line-height: 1.25;
    margin-bottom: 0.75rem;
    letter-spacing: -0.025em;
}

.project-desc {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    max-width: 28rem;
    margin-bottom: 1.5rem;
    line-height: 1.625;
}

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

@media (min-width: 768px) {
    .project-card-content { padding: 2rem; }
    .project-title { font-size: 2.25rem; }
    .project-desc { font-size: 0.875rem; }
}

/* Hover States for Cards/Tags */
@media (hover: hover) {
    .project-card:hover {
        background: #0a0a0a;
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 12px 36px rgba(0, 0, 0, 0.3);
    }
    .project-card:hover .project-card-image {
        transform: scale(1.03);
        opacity: 0.15;
    }
    .project-card:hover .project-card-content {
        transform: translateY(-4px);
    }
    .apple-tag:hover {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.2);
        color: rgba(255, 255, 255, 0.9);
    }
}

/* Loaders & Reveal Animations */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.img-loading {
    filter: blur(20px);
    transform: scale(1.05);
    transition: filter 0.6s ease, transform 0.6s ease, opacity 0.4s ease;
    opacity: 0.5;
}

.img-loaded {
    filter: blur(0);
    transform: scale(1);
    opacity: 1;
}

.reveal-item {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity; /* Hardware acceleration */
}

.reveal-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    right: max(24px, calc(env(safe-area-inset-right, 0px) + 8px));
    z-index: 40;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}
.back-to-top:hover { background-color: rgba(255, 255, 255, 0.1); }
.back-to-top svg { width: 1.25rem; height: 1.25rem; color: rgba(255, 255, 255, 0.7); }
.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Modals & Sliders */
.modal-wrapper {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.modal-instant {
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay-bg {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.modal-close-btn {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 102;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}
.modal-close-btn:hover { background-color: rgba(255, 255, 255, 0.1); }
.modal-close-btn svg { width: 1.25rem; height: 1.25rem; color: rgba(255, 255, 255, 0.8); }

.modal-content-container {
    position: relative;
    z-index: 101;
    width: 100%;
    min-height: 100%;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 1rem 3rem 1rem;
    padding-bottom: max(32px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    pointer-events: none;
}

.modal-card {
    width: 100%;
    max-width: 56rem;
    border-radius: 2rem;
    padding: 2rem;
    pointer-events: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
@media (min-width: 768px) { .modal-card { padding: 2.5rem; } }

.modal-header { margin-bottom: 1.5rem; }
.modal-title { font-size: 1.875rem; font-weight: 300; margin-bottom: 0.5rem; letter-spacing: -0.025em; }
.modal-desc { font-size: 1rem; color: rgba(255, 255, 255, 0.5); }
@media (min-width: 768px) { .modal-title { font-size: 2.25rem; } }

/* Action Links inside Modal */
.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--color-white);
    color: var(--color-black);
    transition: transform 0.2s, background-color 0.2s;
}
.action-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.9);
}
.action-btn--outline {
    background: transparent;
    color: var(--color-white);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.action-btn--outline:hover {
    background: rgba(255, 255, 255, 0.1);
}
.action-btn svg { width: 1rem; height: 1rem; }

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    border-radius: 1rem;
}
.meta-label { font-size: 0.75rem; color: rgba(255, 255, 255, 0.4); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.meta-value { font-size: 1rem; color: rgba(255, 255, 255, 0.9); font-weight: 500; }

.slider-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--color-black);
    margin-bottom: 1.5rem;
    touch-action: pan-y; /* crucial for allowing smooth swipes horizontally */
}

.slide-item {
    position: absolute;
    inset: 0;
    transition: opacity 0.5s ease;
    will-change: opacity; /* Hardware acceleration */
}
.slide-item img { width: 100%; height: 100%; object-fit: cover; }

.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 20px rgba(0, 0, 0, 0.2);
}
.slider-arrow:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
    transform: translateY(-50%) scale(1.08);
}
.slider-arrow:active { transform: translateY(-50%) scale(0.96); }
.slider-arrow svg {
    width: 20px;
    height: 20px;
    stroke: rgba(255, 255, 255, 0.75);
    stroke-width: 1.5;
    fill: none;
    pointer-events: none;
}
.slider-wrapper:hover .slider-arrow { opacity: 1; }
.slider-arrow--prev { left: 16px; }
.slider-arrow--next { right: 16px; }
.slider-arrow[disabled] { pointer-events: none; opacity: 0 !important; }

.dots-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}
.slide-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background-color: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}
.slide-dot:hover { background-color: rgba(255, 255, 255, 0.5); }
.slide-dot.active {
    width: 1.5rem;
    background-color: var(--color-white);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   5. Animations
   ========================================================================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulseRing {
    0% { width: 100%; height: 100%; opacity: 0.8; }
    100% { width: 200%; height: 200%; opacity: 0; }
}
@keyframes bounceSlow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@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;
    }
}