/* ====================================================
   ENHANCED RESPONSIVE DESIGN
   Breakpoints: Mobile-first approach with strategic breakpoints
==================================================== */

/* ================= SMALL MOBILE (Extra Small) ================= */
@media (max-width: 480px) {
    :root {
        --section-padding: 40px 0;
        --card-padding: 20px;
    }

    /* Typography scaling for small screens */
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    .hero h1 { font-size: 2rem; line-height: 1.2; }

    /* Core layout adjustments */
    .container,
    .container-sm,
    .container-lg {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Button adjustments */
    .btn,
    .button-group .btn {
        width: 100%;
        max-width: 300px;
        margin: 5px 0;
        padding: 12px 20px;
    }

    /* Form elements */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 12px 15px;
    }

    /* Card optimizations */
    .service-card,
    .project-card,
    .team-card,
    .pricing-card {
        padding: var(--card-padding);
        margin-bottom: 20px;
    }

    /* Hide non-essential elements on small screens */
    .desktop-only { display: none !important; }
    .mobile-only { display: block !important; }
}

/* ================= MOBILE (Portrait) ================= */
@media (max-width: 768px) {
    :root {
        --section-padding: 50px 0;
        --grid-gap: 20px;
    }

    /* Improved mobile navigation */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        z-index: 1001;
        background: none;
        border: none;
        cursor: pointer;
    }

    .menu-toggle span {
        display: block;
        width: 24px;
        height: 2px;
        background: currentColor;
        position: relative;
        transition: all 0.3s ease;
    }

    .menu-toggle span::before,
    .menu-toggle span::after {
        content: '';
        position: absolute;
        width: 100%;
        height: 2px;
        background: currentColor;
        transition: all 0.3s ease;
    }

    .menu-toggle span::before { top: -8px; }
    .menu-toggle span::after { bottom: -8px; }

    .menu-toggle.active span {
        background: transparent;
    }

    .menu-toggle.active span::before {
        top: 0;
        transform: rotate(45deg);
    }

    .menu-toggle.active span::after {
        bottom: 0;
        transform: rotate(-45deg);
    }

    nav {
        position: fixed;
        top: 70px; /* Adjust based on header height */
        left: 0;
        width: 100%;
        background: var(--card-bg);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        max-height: 0;
        overflow-y: auto;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
    }

    nav.active {
        max-height: 80vh;
        opacity: 1;
        visibility: visible;
        padding: 20px 0;
    }

    nav ul {
        flex-direction: column;
        padding: 0;
        gap: 0;
    }

    nav ul li {
        margin: 0;
        width: 100%;
    }

    nav ul li a {
        display: block;
        padding: 15px 25px;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        text-align: left;
        font-size: 1.1rem;
        transition: all 0.2s ease;
    }

    nav ul li a:hover {
        background: rgba(0,0,0,0.03);
        padding-left: 30px;
    }

    /* Hero section optimization */
    .hero {
        padding: 80px 0 60px;
        text-align: center;
    }

    .hero h1 {
        font-size: 2.2rem;
        margin-bottom: 20px;
    }

    .hero-subtitle {
        font-size: 1.1rem;
        margin-bottom: 30px;
    }

    .cta-buttons {
        flex-direction: column;
        align-items: stretch;
        max-width: 300px;
        margin: 0 auto;
        gap: 15px;
    }

    .cta-buttons .btn {
        width: 100%;
        text-align: center;
    }

    /* Grid layouts */
    .services-grid,
    .about-grid,
    .pricing-grid,
    .projects-grid,
    .testimonials-grid {
        grid-template-columns: 1fr;
        gap: var(--grid-gap);
    }

    /* Contact section */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .contact-wrapper,
    .calculator-box {
        padding: 25px 20px;
    }

    /* Footer enhancements */
    .footer-row {
        flex-direction: column;
        text-align: center;
        gap: 30px;
    }

    .footer-brand {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 20px;
    }

    .footer-logo {
        margin-bottom: 15px;
    }

    .footer-info,
    .footer-social {
        justify-content: center;
        flex-wrap: wrap;
        gap: 15px;
    }

    .footer-links {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }

    /* Utility classes for mobile */
    .text-center-mobile { text-align: center; }
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }

    /* Image optimizations */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Table adjustments */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ================= TABLET (Landscape) ================= */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --grid-gap: 30px;
    }

    /* Tablet grid layouts */
    .services-grid,
    .about-grid,
    .pricing-grid,
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--grid-gap);
    }

    .contact-grid {
        grid-template-columns: 1fr;
    }

    /* Navigation for tablet */
    nav ul {
        gap: 20px;
    }

    nav ul li a {
        font-size: 0.95rem;
        padding: 8px 12px;
    }

    /* Hero adjustments */
    .hero h1 {
        font-size: 2.5rem;
    }

    /* Footer tablet layout */
    .footer-row {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 40px;
    }

    .footer-brand {
        flex: 0 0 100%;
        text-align: center;
    }

    .footer-links {
        grid-template-columns: repeat(2, 1fr);
        gap: 40px;
    }
}

/* ================= SMALL DESKTOP ================= */
@media (min-width: 1025px) and (max-width: 1200px) {
    .container {
        max-width: 95%;
    }

    .services-grid,
    .about-grid,
    .pricing-grid,
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    nav ul {
        gap: 25px;
    }
}

/* ================= LARGE DESKTOPS ================= */
@media (min-width: 1201px) {
    .container {
        max-width: 1200px;
    }
}

/* ================= HIGH-DPI (RETINA) DISPLAYS ================= */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering for high-DPI screens */
    .logo img,
    .hero-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ================= PRINT STYLES ================= */
@media print {
    .menu-toggle,
    nav,
    .footer-social,
    .cta-buttons,
    .contact-form {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    .container {
        width: 100%;
        max-width: none;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }

    .hero {
        padding: 20px 0 !important;
    }
}

/* ================= ACCESSIBILITY: REDUCED MOTION ================= */
@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;
    }

    nav {
        transition: none;
    }
}

/* ================= ORIENTATION SPECIFIC ================= */
@media (max-width: 768px) and (orientation: landscape) {
    nav.active {
        max-height: 70vh;
    }

    .hero {
        padding: 40px 0;
        min-height: auto;
    }
}

/* ================= TOUCH DEVICE OPTIMIZATIONS ================= */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    nav ul li a,
    .form-check label,
    .tab-button {
        min-height: 44px;
        padding: 12px 20px;
    }

    /* Remove hover states for touch */
    .btn:hover,
    nav ul li a:hover {
        transform: none;
    }

    /* Increase spacing for finger navigation */
    .services-grid,
    .projects-grid {
        gap: 25px;
    }
}


/* ====================================================
   PORTFOLIO PAGE RESPONSIVE
==================================================== */

/* ===== Large Tablet (≤ 1024px) ===== */
@media (max-width: 1024px) {

    .portfolio-hero {
        padding: 70px 20px;
    }

    .portfolio-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 25px;
    }

    .portfolio-card-media {
        height: 200px;
    }

    .portfolio-process {
        padding: 70px 0;
    }
}

/* ===== Tablet (≤ 992px) ===== */
@media (max-width: 992px) {

    .portfolio-filter {
        gap: 8px;
    }

    .filter-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .process-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

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

    .portfolio-hero {
        padding: 60px 20px;
    }

    .hero-title {
        font-size: 2rem;
        line-height: 1.3;
    }

    .hero-description {
        font-size: 0.95rem;
        padding: 0 10px;
    }

    .hero-actions {
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    .portfolio-section {
        padding: 60px 15px;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .portfolio-card-body {
        padding: 20px;
    }

    .portfolio-meta,
    .portfolio-info {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }

    .portfolio-tech {
        gap: 6px;
    }

    .portfolio-process {
        padding: 60px 15px;
    }

    .process-grid {
        grid-template-columns: 1fr;
    }

    .load-more-wrapper {
        margin-top: 30px;
    }
}

/* ===== Small Phones (≤ 480px) ===== */
@media (max-width: 480px) {

    .portfolio-card-media {
        height: 180px;
    }

    .filter-btn {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .portfolio-card h3 {
        font-size: 1rem;
    }
}

/* ====================================================
   CASE STUDY PAGE RESPONSIVE
==================================================== */

/* ===== Large Tablet (≤ 1024px) ===== */
@media (max-width: 1024px) {

    .case-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .case-image {
        order: -1;
    }

    .case-image img {
        max-height: 500px;
    }
}

/* ===== Tablet (≤ 992px) ===== */
@media (max-width: 992px) {

    .case-wrapper {
        padding: 60px 20px;
    }

    .case-content {
        max-width: 100%;
    }

    .bottom-grid {
        gap: 30px;
    }
}

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

    .case-wrapper {
        padding: 50px 15px;
    }

    .case-breadcrumb {
        font-size: 13px;
    }

    .case-layout {
        gap: 30px;
    }

    .case-content h2 {
        font-size: 1.5rem;
    }

    .case-content h3 {
        font-size: 1.2rem;
    }

    .case-content p {
        font-size: 0.95rem;
        line-height: 1.7;
        text-align: left;
    }

    .case-image img {
        border-radius: 14px;
        max-height: 350px;
    }

    .bottom-grid {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .tech-tags {
        justify-content: flex-start;
    }
}

/* ===== Small Phones (≤ 480px) ===== */
@media (max-width: 480px) {

    .case-content h2 {
        font-size: 1.3rem;
    }

    .case-content h3 {
        font-size: 1.1rem;
    }

    .case-image img {
        max-height: 280px;
    }

    .bottom-header h3 {
        font-size: 1.1rem;
    }

    .short-desc {
        font-size: 0.9rem;
    }
}
