/* Mobile-First Responsive Design for Nyika Foundation */

/* Loading spinner optimization */
#spinner {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.spinner-border {
    border-width: 4px;
}

/* Base mobile styles (320px+) */
@media (max-width: 768px) {
    /* General mobile optimizations */
    * {
        touch-action: manipulation; /* Disable double-tap zoom */
    }
    
    body {
        font-size: 16px; /* Prevent zoom on iOS */
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: antialiased;
        overflow-x: hidden;
    }
    
    /* Container adjustments */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Header optimizations */
    .carousel-caption h1 {
        font-size: 2rem !important;
        line-height: 1.2;
        margin-bottom: 1rem !important;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    }
    
    .carousel-caption .btn {
        font-size: 14px;
        padding: 12px 20px;
        margin-top: 15px;
    }
    
    /* Navbar mobile optimization */
    .navbar-brand {
        padding-left: 10px !important;
        font-size: 1.2rem !important;
    }
    
    .navbar-toggler {
        border: none;
        padding: 8px;
        margin-right: 10px;
        font-size: 1.2rem;
    }
    
    .navbar-toggler:focus {
        box-shadow: none;
    }
    
    .navbar-collapse {
        background: rgba(255, 255, 255, 0.98);
        border-radius: 8px;
        margin: 10px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .navbar-nav {
        text-align: center;
        padding: 10px 0;
    }
    
    .navbar-nav .nav-link {
        font-size: 16px;
        padding: 12px 20px !important;
        color: #333 !important;
        border-bottom: 1px solid #eee;
        transition: all 0.3s ease;
        border-radius: 4px;
        margin: 2px 10px;
    }
    
    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }
    
    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:active {
        background-color: #f8f9fa;
        color: var(--primary) !important;
        transform: translateY(-1px);
    }
    
    /* Top feature cards stack properly */
    .top-feature .row > div {
        margin-bottom: 15px;
    }
    
    .top-feature .bg-white {
        padding: 20px 15px !important;
        min-height: 140px !important;
        transition: transform 0.2s ease;
        border-radius: 8px;
    }
    
    .top-feature .bg-white:active {
        transform: scale(0.98);
    }
    
    .top-feature h4 {
        font-size: 1.1rem;
    }
    
    .top-feature span {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    /* About section mobile */
    .display-5 {
        font-size: 1.8rem !important;
        line-height: 1.3;
    }
    
    .display-1 {
        font-size: 3rem !important;
    }
    
    /* Project cards mobile optimization */
    .portfolio-item {
        margin-bottom: 20px;
    }
    
    .portfolio-inner {
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .portfolio-inner:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    
    .portfolio-text {
        padding: 15px !important;
        background: linear-gradient(135deg, rgba(0,0,0,0.7), rgba(0,0,0,0.5));
    }
    
    .portfolio-text h4 {
        font-size: 1rem !important;
        line-height: 1.3;
        margin-bottom: 10px !important;
        color: white !important;
    }
    
    /* Modal optimizations for mobile */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-body {
        padding: 15px;
        flex-direction: column !important;
    }
    
    .modal-body .col-md-6 {
        width: 100% !important;
        margin-bottom: 15px;
    }
    
    .modal-body img {
        border-radius: 8px;
        margin-bottom: 15px;
    }
    
    .modal-body h3 {
        font-size: 1.3rem;
        line-height: 1.3;
        margin-bottom: 15px;
    }
    
    .modal-body p {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* Footer mobile optimization */
    .footer {
        padding: 30px 0 !important;
    }
    
    .footer .col-lg-6,
    .footer .col-lg-3 {
        margin-bottom: 25px;
        text-align: center;
    }
    
    .footer h4 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    
    .footer p,
    .footer .btn-link {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* Copyright section */
    .copyright {
        padding: 15px 0 !important;
        text-align: center !important;
    }
    
    .copyright .col-md-6 {
        margin-bottom: 15px;
    }
    
    .copyright img {
        height: 60px !important;
        margin-left: 0 !important;
    }
    
    /* Buttons mobile optimization */
    .btn {
        font-size: 14px;
        padding: 12px 20px;
        border-radius: 25px;
        font-weight: 600;
        transition: all 0.2s ease;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-primary {
        background: linear-gradient(135deg, var(--primary), #2d7a32);
        border: none;
        box-shadow: 0 4px 15px rgba(52, 142, 56, 0.3);
    }
    
    .btn-primary:hover,
    .btn-primary:active {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(52, 142, 56, 0.4);
        background: linear-gradient(135deg, #2d7a32, var(--primary));
    }
    
    .btn.touched {
        transform: scale(0.96);
    }
    
    /* WhatsApp button mobile adjustment */
    .whatsapp-btn {
        bottom: 70px !important;
        right: 20px !important;
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
        animation: pulse 2s infinite;
    }
    
    @keyframes pulse {
        0% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.05);
        }
        100% {
            transform: scale(1);
        }
    }
    
    /* Back to top button */
    .back-to-top {
        bottom: 20px !important;
        right: 20px !important;
        width: 45px !important;
        height: 45px !important;
    }
    
    /* Carousel mobile enhancements */
    .carousel-control-prev,
    .carousel-control-next {
        width: 10% !important;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 2rem !important;
        height: 2rem !important;
    }
    
    /* Spacing adjustments */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .mb-5 {
        margin-bottom: 2rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Text adjustments */
    .text-center p {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    /* Image responsiveness */
    .img-fluid {
        border-radius: 8px;
    }
    
    /* Touch feedback */
    .portfolio-item.touched,
    .btn.touched {
        transform: scale(0.96);
    }
    
    /* Improved spinner for mobile */
    #spinner {
        background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    }
    
    /* Add subtle drop shadows */
    .card,
    .bg-white {
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
}

/* Small mobile devices (320px - 480px) */
@media (max-width: 480px) {
    .carousel-caption h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .display-5 {
        font-size: 1.5rem !important;
    }
    
    .display-1 {
        font-size: 2.5rem !important;
    }
    
    .navbar-brand {
        font-size: 1rem !important;
    }
    
    .container-fluid {
        padding-left: 5px;
        padding-right: 5px;
    }
    
    .top-feature .bg-white {
        padding: 15px 10px !important;
        min-height: 120px !important;
    }
    
    .top-feature h4 {
        font-size: 1rem;
    }
    
    .top-feature span {
        font-size: 0.8rem;
    }
    
    .btn {
        font-size: 13px;
        padding: 10px 16px;
    }
    
    /* Countdown mobile adjustments */
    #countdown {
        gap: 15px !important;
    }
    
    .countdown-item .number {
        font-size: 1.5rem !important;
    }
    
    .countdown-item .label {
        font-size: 0.7rem !important;
    }
}

/* App-like enhancements */
@media (max-width: 768px) {
    /* Add subtle animations */
    .portfolio-item {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    .portfolio-item:active {
        transform: scale(0.98);
    }
    
    .btn:active {
        transform: scale(0.96);
    }
    
    /* Improve touch targets */
    .nav-link,
    .btn,
    .portfolio-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
    }
    
    /* Loading optimization */
    .wow {
        animation-duration: 0.5s;
    }
    
    /* Fix for iOS Safari */
    .carousel-item {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    /* Lazy loading placeholder */
    img.lazy {
        opacity: 0.5;
        transition: opacity 0.3s ease;
    }
    
    img.lazy:not(.lazy) {
        opacity: 1;
    }
    
    /* Add focus styles for accessibility */
    .btn:focus,
    .nav-link:focus {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }
    
    /* Improve form elements */
    input, textarea, select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Landscape phone optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .carousel-caption h1 {
        font-size: 1.3rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .carousel-caption {
        padding: 10px;
    }
    
    #countdown {
        gap: 10px !important;
    }
    
    .countdown-item .number {
        font-size: 1.2rem !important;
    }
    
    .countdown-item .label {
        font-size: 0.6rem !important;
    }
    
    .navbar-brand h2 {
        font-size: 1rem !important;
    }
}

/* Dark mode considerations */
@media (prefers-color-scheme: dark) {
    .navbar-collapse {
        background: rgba(30, 30, 30, 0.98);
    }
    
    .navbar-nav .nav-link {
        color: #fff !important;
        border-bottom-color: #444;
    }
    
    #spinner {
        background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
        color: #fff;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        background-size: 100% 100%;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .wow,
    .btn,
    .portfolio-item,
    .whatsapp-btn {
        animation: none !important;
        transition: none !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}
