/* ===================================
   MOBILE OPTIMIZATIONS
   =================================== */

/* Tablet and Below */
@media (max-width: 1024px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile Devices */
@media (max-width: 768px) {

    /* Mobile Navigation */
    .nav-links {
        position: fixed !important;
        display: flex !important;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: #ffffff !important;
        border-left: 1px solid var(--border-color);
        flex-direction: column;
        padding: 100px 1.5rem 1.5rem;
        gap: 0.5rem;
        transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        z-index: 1000;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 280px;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(5px);
        z-index: -1;
        animation: fadeIn 0.3s ease;
    }

    .nav-link {
        font-size: 1rem !important;
        padding: 0.75rem 0 !important;
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        color: #000000 !important;
    }

    .subscribe-btn {
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
        min-height: 48px;
        font-size: 0.95rem;
    }

    .mobile-menu-btn {
        display: flex !important;
    }

    /* Hero Section */
    .hero {
        padding: calc(70px + 2rem) 0 2rem !important;
        min-height: auto !important;
    }

    .hero-badge {
        font-size: 0.85rem;
        padding: 0.4rem 1rem;
    }

    .hero-title {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }

    .hero-description {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .hero-cta {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .cta-primary,
    .cta-secondary {
        width: 100% !important;
        justify-content: center !important;
        min-height: 50px;
        padding: 1rem 1.5rem !important;
        font-size: 0.95rem;
    }

    .hero-stats {
        gap: 1.5rem !important;
        margin-top: 2rem;
    }

    .stat-number {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.85rem !important;
    }

    /* Category Section */
    .category-section {
        padding: 1.5rem 0 !important;
    }

    .category-filter {
        gap: 0.5rem !important;
    }

    .filter-btn {
        min-height: 44px;
        padding: 0.75rem 1.25rem !important;
        font-size: 0.9rem !important;
    }

    /* Featured Section */
    .featured-section {
        padding: 2rem 0 !important;
    }

    .featured-card {
        padding: 1.5rem !important;
    }

    .featured-content {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .featured-image {
        order: -1;
        justify-content: center;
    }

    .featured-title {
        font-size: 1.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .featured-description {
        font-size: 0.95rem !important;
        margin-bottom: 1rem !important;
    }

    .featured-btn {
        width: 100%;
        justify-content: center;
        min-height: 50px;
    }

    .image-placeholder svg {
        width: 100px !important;
        height: 100px !important;
    }

    /* Projects Section */
    .projects-section {
        padding: 2rem 0 !important;
        overflow-x: hidden;
    }

    .section-header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.75rem !important;
        margin-bottom: 1.5rem !important;
        flex-wrap: wrap;
    }

    .section-title {
        font-size: 1.5rem !important;
        flex: 1 1 auto;
        min-width: 0;
    }

    .view-all {
        font-size: 0.9rem !important;
        padding: 0.5rem 0.75rem !important;
        white-space: nowrap;
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0 !important;
    }

    /* Compact mobile project cards - 2 columns, full image visible */
    .project-card {
        border-radius: 12px !important;
        min-height: auto !important;
        min-width: 0 !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    }

    .project-card:hover {
        transform: translateY(-2px) !important;
    }

    .card-image {
        height: 140px !important;
        border-radius: 12px 12px 0 0 !important;
        background-size: contain !important;
        background-repeat: no-repeat !important;
        background-position: center !important;
        background-color: var(--bg-tertiary, #e8e8e8) !important;
    }

    .card-icon {
        font-size: 2.5rem !important;
    }

    .card-category {
        padding: 0.3rem 0.65rem !important;
        font-size: 0.7rem !important;
        top: 0.6rem !important;
        left: 0.6rem !important;
        border-radius: 6px !important;
    }

    .card-content {
        padding: 0.65rem 0.75rem !important;
        min-width: 0 !important;
    }

    .card-title {
        font-size: 0.9rem !important;
        line-height: 1.35 !important;
        margin-bottom: 0 !important;
        font-weight: 600 !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .card-description {
        display: none !important;
    }

    .card-footer {
        display: none !important;
    }

    /* Newsletter Section */
    .newsletter-section {
        padding: 2rem 0 !important;
    }

    .newsletter-card {
        padding: 1.5rem !important;
        grid-template-columns: 1fr !important;
    }

    .newsletter-title {
        font-size: 1.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .newsletter-description {
        font-size: 0.95rem !important;
        margin-bottom: 1rem !important;
    }

    .form-group {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .email-input {
        min-height: 50px;
        padding: 0.9rem 1.25rem !important;
        font-size: 0.95rem !important;
    }

    .submit-btn {
        width: 100% !important;
        justify-content: center !important;
        min-height: 50px;
        font-size: 0.95rem !important;
    }

    /* Footer */
    .footer {
        padding: 2rem 0 1rem !important;
    }

    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .footer-column {
        text-align: left;
    }

    .footer-logo {
        font-size: 1.25rem !important;
    }

    .footer-description {
        font-size: 0.9rem !important;
        max-width: 100% !important;
    }

    .social-links {
        gap: 0.5rem !important;
    }

    .social-link {
        width: 44px !important;
        height: 44px !important;
    }

    .footer-heading {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .footer-links {
        gap: 0.5rem !important;
    }

    .footer-links a {
        font-size: 0.9rem;
    }

    .footer-bottom {
        flex-direction: column !important;
        text-align: center !important;
        gap: 1rem !important;
        padding-top: 1.5rem !important;
    }

    .copyright {
        font-size: 0.85rem !important;
    }

    .footer-bottom-links {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .footer-bottom-links a {
        font-size: 0.85rem !important;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .container {
        padding: 0 1rem !important;
        width: 100%;
        box-sizing: border-box;
    }

    .navbar {
        padding: 0.75rem 0 !important;
    }

    .logo {
        font-size: 1.15rem !important;
    }

    .logo-icon {
        font-size: 1.4rem !important;
    }

    .nav-links {
        width: 100% !important;
        padding: 90px 1.25rem 1.25rem !important;
    }

    .nav-links.active::before {
        right: 0 !important;
    }

    .hero {
        padding: calc(70px + 1.5rem) 0 1.5rem !important;
    }

    .hero-title {
        font-size: 1.75rem !important;
    }

    .hero-description {
        font-size: 0.95rem !important;
    }

    .hero-stats {
        gap: 1rem !important;
    }

    .stat-number {
        font-size: 1.25rem !important;
    }

    .stat-label {
        font-size: 0.8rem !important;
    }

    .stat-divider {
        height: 30px !important;
    }

    .category-filter {
        flex-direction: column !important;
        width: 100%;
    }

    .filter-btn {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .featured-card {
        padding: 1.25rem !important;
    }

    .featured-title {
        font-size: 1.35rem !important;
    }

    .section-title {
        font-size: 1.4rem !important;
    }

    .section-header {
        margin-bottom: 1.25rem !important;
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }

    .project-card {
        border-radius: 10px !important;
    }

    .card-image {
        height: 120px !important;
        background-size: contain !important;
        background-repeat: no-repeat !important;
        background-position: center !important;
    }

    .card-content {
        padding: 0.5rem 0.6rem !important;
    }

    .card-title {
        font-size: 0.85rem !important;
    }

    .card-icon {
        font-size: 2.5rem !important;
    }

    .newsletter-card {
        padding: 1.25rem !important;
    }

    .newsletter-title {
        font-size: 1.35rem !important;
    }
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .project-card:hover {
        transform: none !important;
        border-color: var(--border-color) !important;
    }

    .project-card:active {
        transform: scale(0.98) !important;
        border-color: rgba(102, 126, 234, 0.5) !important;
    }

    .cta-primary:hover,
    .cta-secondary:hover,
    .featured-btn:hover,
    .submit-btn:hover,
    .filter-btn:hover {
        transform: none !important;
    }

    .cta-primary:active,
    .cta-secondary:active,
    .featured-btn:active,
    .submit-btn:active {
        transform: scale(0.97) !important;
    }

    .filter-btn:active {
        transform: translateY(0) !important;
    }

    .card-btn:hover {
        transform: none !important;
    }

    .card-btn:active {
        transform: scale(0.9) !important;
    }

    .social-link:hover {
        transform: none !important;
    }

    .social-link:active {
        transform: scale(0.9) !important;
    }

    /* Disable parallax on touch devices */
    .hero-background {
        transform: none !important;
    }

    .gradient-orb {
        transform: none !important;
    }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden !important;
    }

    html {
        overflow-x: hidden;
    }

    .container {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
        overflow-x: hidden;
    }

    /* Constrain sections and grid - no global * max-width */
    .projects-section,
    .category-section {
        overflow-x: hidden;
    }

    .projects-grid {
        min-width: 0;
        width: 100%;
    }

    /* Card link wrapper and card must not overflow */
    .projects-grid > a {
        min-width: 0;
        max-width: 100%;
    }

    .project-card {
        min-width: 0;
        max-width: 100%;
    }

    .card-content {
        min-width: 0;
        overflow: hidden;
    }

    .card-title {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    img {
        max-width: 100%;
        height: auto;
    }
}