/* ============================================
   MOBILE-FIRST OPTIMIZATION - PROFESSIONAL
   Complete mobile CSS overhaul
   Tested: iPhone, Android, iPad, Desktop
   ============================================ */

:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --dark-bg: #0a0a0a;
    --card-bg: #111;
    --card-hover: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #e5e7eb;
    --text-tertiary: #9ca3af;
    --border: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    background: var(--dark-bg);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
}

/* ============================================
   SAFE AREA & VIEWPORT (MOBILE FIX)
   ============================================ */

html {
    padding-top: max(env(safe-area-inset-top), 0px);
}

body {
    padding-left: max(env(safe-area-inset-left), 0px);
    padding-right: max(env(safe-area-inset-right), 0px);
    padding-bottom: max(env(safe-area-inset-bottom), 0px);
}

/* ============================================
   TYPOGRAPHY - MOBILE OPTIMIZED
   ============================================ */

h1 {
    font-size: clamp(24px, 8vw, 48px);
    font-weight: 800;
    line-height: 1.1;
    margin: 12px 0 8px;
    letter-spacing: -0.5px;
}

h2 {
    font-size: clamp(20px, 6vw, 36px);
    font-weight: 700;
    line-height: 1.2;
    margin: 10px 0 6px;
    letter-spacing: -0.3px;
}

h3 {
    font-size: clamp(16px, 5vw, 28px);
    font-weight: 600;
    line-height: 1.3;
    margin: 8px 0 4px;
}

p, span, li {
    font-size: clamp(14px, 2vw, 16px);
    line-height: 1.6;
    color: var(--text-secondary);
}

small {
    font-size: clamp(12px, 1.5vw, 14px);
    color: var(--text-tertiary);
}

/* ============================================
   IMAGES - PROFESSIONAL FIX
   ============================================ */

img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: cover;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(10, 10, 10, 0.5) 100%);
}

img[src=""],
img:not([src]) {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(10, 10, 10, 0.5) 100%);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container,
[class*="image"],
[class*="img"] {
    width: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(10, 10, 10, 0.5) 100%);
    border-radius: 8px;
}

.image-container img,
[class*="image"] img,
[class*="img"] img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============================================
   CONTAINERS & SPACING
   ============================================ */

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(16px, 4vw, 48px);
}

.section {
    margin-bottom: clamp(24px, 6vw, 64px);
}

/* ============================================
   BUTTONS - TOUCH OPTIMIZED
   ============================================ */

button,
[role="button"],
.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: clamp(10px, 2vw, 12px) clamp(16px, 3vw, 24px);
    min-height: 44px;
    min-width: 44px;
    font-size: clamp(13px, 1.5vw, 14px);
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    letter-spacing: 0.3px;
}

button:active,
.btn:active,
[role="button"]:active {
    transform: scale(0.95);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

/* ============================================
   FORM ELEMENTS - MOBILE OPTIMIZED
   ============================================ */

input,
textarea,
select {
    width: 100%;
    padding: clamp(10px, 2vw, 12px) clamp(12px, 2vw, 16px);
    font-size: 16px; /* Prevents iOS zoom */
    font-family: inherit;
    background: var(--card-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    transition: all var(--transition);
    box-sizing: border-box;
    touch-action: manipulation;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

label {
    display: block;
    font-size: clamp(13px, 1.5vw, 14px);
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ============================================
   CARDS - OPTIMIZED
   ============================================ */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(16px, 4vw, 24px);
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
    transform: translateY(-4px);
}

/* ============================================
   GRID LAYOUT - RESPONSIVE
   ============================================ */

.grid {
    display: grid;
    gap: clamp(12px, 3vw, 24px);
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (min-width: 1024px) {
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* ============================================
   PROJECT CARDS - MOBILE PROFESSIONAL
   ============================================ */

.project-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card:active {
    transform: scale(0.98);
}

.project-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.2);
    transform: translateY(-4px);
}

/* PROJECT IMAGE CONTAINER */
.project-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(10, 10, 10, 0.5) 100%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all var(--transition);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(10, 10, 10, 0.5) 100%);
}

.project-card:hover .project-image {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.project-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(10, 10, 10, 0.6) 100%);
    font-size: 48px;
    color: rgba(255, 255, 255, 0.3);
}

/* PROJECT INFO */
.project-info {
    padding: clamp(16px, 3vw, 20px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.project-title {
    font-size: clamp(16px, 3vw, 18px);
    font-weight: 700;
    color: var(--text-primary);
    transition: all var(--transition);
    line-height: 1.3;
}

.project-card:hover .project-title {
    color: var(--primary-color);
}

.project-desc {
    font-size: clamp(12px, 2vw, 13px);
    color: var(--text-tertiary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* TECHNOLOGIES */
.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.tech-tag {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid rgba(59, 130, 246, 0.3);
    white-space: nowrap;
    transition: all var(--transition);
}

.tech-tag:hover {
    background: rgba(59, 130, 246, 0.25);
    transform: scale(1.05);
}

/* PROJECT LINK */
.project-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
    border: none;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    margin-top: auto;
}

.project-link:hover,
.project-link:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

@media (max-width: 480px) {
    .project-link {
        width: 100%;
    }
}

/* ============================================
   NAVBAR - MOBILE OPTIMIZED
   ============================================ */

.navbar,
.home-navbar {
    position: fixed;
    top: clamp(12px, 2vw, 20px);
    left: 50%;
    transform: translateX(-50%);
    width: clamp(95%, 90vw, 1400px);
    padding: clamp(8px, 2vw, 12px) clamp(20px, 3vw, 30px);
    background: rgba(59, 59, 59, 0.95);
    backdrop-filter: blur(18px);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-time {
    font-size: clamp(12px, 2vw, 14px);
    font-weight: 600;
    letter-spacing: 0.5px;
    color: white;
}

.menu-btn {
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.menu-btn:active {
    transform: scale(0.95);
}

/* ============================================
   MODALS & OVERLAYS
   ============================================ */

.modal,
.menu-overlay {
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(env(safe-area-inset-top), 12px);
}

.modal.active,
.menu-overlay.show {
    display: flex;
}

.modal-content {
    position: relative;
    max-width: min(90vw, 600px);
    max-height: 85vh;
    background: var(--card-bg);
    border-radius: 12px;
    padding: clamp(16px, 4vw, 24px);
}

.modal img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
}

/* ============================================
   FILTERS & SEARCH
   ============================================ */

.filters {
    background: rgba(26, 26, 46, 0.5);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(12px, 3vw, 20px);
    margin-bottom: clamp(20px, 4vw, 30px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

@media (min-width: 640px) {
    .filters {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 12px;
    }
}

.filters input,
.filters select {
    flex: 1;
    min-width: 150px;
    font-size: 14px;
}

.results-count {
    font-size: clamp(12px, 1.5vw, 14px);
    color: var(--text-tertiary);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: clamp(40px, 8vw, 80px) 20px;
    color: var(--text-tertiary);
}

.empty-state-icon {
    font-size: clamp(36px, 10vw, 64px);
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ============================================
   SCROLLBAR (HIDDEN ON MOBILE)
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    ::-webkit-scrollbar {
        display: none;
    }
}

/* ============================================
   BREAKPOINTS - MOBILE FIRST
   ============================================ */

/* MOBILE (320px - 479px) */
@media (max-width: 479px) {
    body {
        padding-top: 70px;
    }

    .container {
        padding: 16px;
    }

    .grid {
        gap: 12px;
    }

    .filters {
        flex-direction: column;
    }

    .filters input,
    .filters select {
        width: 100%;
    }

    .navbar,
    .home-navbar {
        width: 98%;
        padding: 8px 12px;
    }

    .project-card {
        border-radius: 10px;
    }

    .project-image-container {
        aspect-ratio: 16 / 10;
    }
}

/* TABLET (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .container {
        padding: 20px;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .navbar,
    .home-navbar {
        width: 96%;
        padding: 10px 20px;
    }
}

/* DESKTOP (768px+) */
@media (min-width: 768px) {
    body {
        padding-top: 100px;
    }

    .container {
        padding: 40px 20px;
    }

    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }

    .filters {
        flex-direction: row;
    }

    .navbar,
    .home-navbar {
        width: 85%;
        max-width: 1400px;
    }

    .project-card:hover {
        transform: translateY(-8px);
    }
}

/* LARGE DESKTOP (1200px+) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }

    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-color-scheme: light) {
    :root {
        --dark-bg: #ffffff;
        --card-bg: #f5f5f5;
        --text-primary: #000000;
        --text-secondary: #333333;
        --border: rgba(0, 0, 0, 0.1);
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    body {
        background: white;
    }

    .navbar,
    .menu-btn {
        display: none;
    }
}
