/* ============================================
   MOBILE-RESPONSIVE MEDIA QUERIES
   Portfolio Website for Kashif Ibrar
   Mobile-First Approach
   ============================================ */

/* ============================================
   BASE MOBILE OPTIMIZATIONS (applies to all)
   ============================================ */

/* Prevent horizontal overflow on mobile */
html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Touch-friendly improvements for all interactive elements */
button,
.btn,
a,
.carousel-arrow,
.portfolio-link,
.case-study-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Momentum scrolling for all scroll containers */
.carousel-scroll-wrapper,
.case-studies-wrapper {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.carousel-scroll-wrapper::-webkit-scrollbar,
.case-studies-wrapper::-webkit-scrollbar {
  display: none;
}

/* Skip link mobile improvements */
.skip-link {
  background: #0066ff;
  color: #ffffff;
  padding: 12px 20px;
  font-size: 1rem;
  border-radius: 0 0 8px 8px;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #0052cc;
  outline-offset: 2px;
}

/* ============================================
   SMALL MOBILE (320px - 479px)
   Very small phones like Galaxy Fold
   ============================================ */

/* Navigation Toggle for all mobile/tablet devices */
@media screen and (max-width: 1199px) {
  #desktop-nav {
    display: none;
  }

  #hamburger-nav {
    display: flex;
  }
}

@media screen and (max-width: 479px) {

  /* Section Layout */
  section {
    margin: 0 0.75rem;
    padding: 2rem 0.75rem;
    height: auto !important;
    min-height: auto !important;
    position: relative;
    background: var(--bg-white);
    overflow: visible;
  }

  /* Typography */
  .title {
    font-size: clamp(1.75rem, 6vw, 2rem);
    line-height: 1.2;
    margin-bottom: 2rem;
  }

  .section__text__p1 {
    font-size: clamp(0.9rem, 3vw, 1rem);
    letter-spacing: 0.05em;
  }

  .section__text__p2 {
    font-size: clamp(1rem, 4vw, 1.15rem);
    line-height: 1.5;
  }

  .logo {
    font-size: 1.25rem;
  }

  /* Profile Section */
  #profile {
    height: auto;
    min-height: 70vh;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0.5rem;
  }

  .section__pic-container {
    width: 200px;
    height: 200px;
    margin: 0 auto;
  }

  .section__pic-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
  }

  /* Button Container */
  .btn-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
  }

  .btn {
    width: 100%;
    min-height: 50px;
    padding: 1rem;
    font-size: 1rem;
  }

  /* Metrics Section - 2x2 grid on very small */
  .metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .metric .num {
    font-size: 1.5rem;
    word-break: break-word;
  }

  .metric .label {
    font-size: 0.7rem;
  }

  /* Partners */
  .partners {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .partner-icon {
    font-size: 1.5rem;
  }

  /* About Section - Ensure proper containment */
  #about {
    height: auto !important;
    min-height: auto !important;
    padding-bottom: 3rem;
    background: var(--bg-white);
    position: relative;
    z-index: 1;
  }

  #about .section-container {
    height: auto;
  }

  #about .text-container {
    padding-bottom: 1rem;
  }

  #about .text-container p {
    font-size: 0.85rem;
  }

  /* Services Section - Fix text overlap */
  #services {
    position: relative;
    z-index: 2;
    background: var(--bg-white);
    padding-top: 3rem;
    margin-top: 0;
  }

  #services .section__text__p1,
  #services .title {
    background: var(--bg-white);
    position: relative;
    z-index: 3;
  }

  #services .section__text {
    background: var(--bg-white);
    padding: 1rem 0;
    margin-bottom: 1rem;
  }

  .services-container {
    margin-top: 1rem;
  }

  .carousel-container {
    overflow: hidden;
    margin: 0 -0.75rem;
    padding: 0 0.75rem;
  }

  /* Experience Section - Fix horizontal cutoff */
  #experience {
    overflow-x: hidden;
    padding: 2rem 1rem;
    margin: 0;
  }

  .experience-details-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-x: hidden;
    width: 100%;
  }

  .details-container {
    width: 100%;
    flex: none;
    min-width: 0;
    box-sizing: border-box;
    padding: 1.25rem;
  }

  .about-containers {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-x: hidden;
  }

  .article-container {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  article {
    padding: 0.75rem;
  }

  .experience-sub-title {
    font-size: 1.25rem;
  }

  /* Cards - 85% with snap scrolling */
  .card-3-per-view,
  .case-study-card {
    flex: 0 0 85% !important;
    scroll-snap-align: start;
  }
  
  .carousel-scroll-wrapper {
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1.5rem !important; /* space for scroll bar */
  }

  .carousel-arrow {
    display: none !important;
  }

  /* Carousel arrows */
  .carousel-arrow {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .carousel-arrow.prev {
    left: 5px;
  }

  .carousel-arrow.next {
    right: 5px;
  }

  /* Modal - full screen */
  .modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    padding: 1rem;
    overflow-y: auto;
  }

  .close-modal {
    width: 44px;
    height: 44px;
    font-size: 32px;
    top: 5px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Contact Grid */
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .contact-form {
    padding: 1.25rem;
    order: 1;
  }

  .booking-card {
    order: 2;
    padding: 1.5rem;
    min-height: auto;
  }

  .form-group input,
  .form-group textarea {
    padding: 0.875rem 1rem;
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  .btn-primary,
  .contact-form .btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    min-height: 50px;
  }

  .booking-card .cta-btn {
    width: 100%;
    max-width: none;
    justify-content: center;
    padding: 1rem;
    min-height: 50px;
  }

  /* Text containers */
  .text-container {
    padding: 0 0.5rem;
  }

  /* Case Study Cards */
  .case-study-stats {
    flex-direction: column;
    gap: 0.75rem;
  }

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

  /* Testimonials */
  .testimonial-card {
    padding: 1rem;
  }

  .quote-icon {
    font-size: 1.5rem;
  }

  /* Footer */
  footer nav {
    height: auto;
    margin-bottom: 1rem;
  }

  footer .nav-links {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
}

/* ============================================
   MOBILE (480px - 639px)
   Standard mobile phones
   ============================================ */

@media screen and (max-width: 639px) and (min-width: 480px) {

  /* Section Layout */
  section {
    margin: 0 1rem;
    padding: 2rem 1rem;
    height: auto !important;
    min-height: auto !important;
    position: relative;
    background: var(--bg-white);
    overflow: visible;
  }

  /* About Section - Ensure proper containment */
  #about {
    padding-bottom: 3rem;
  }

  #about .section-container {
    height: auto;
  }

  #about .text-container p {
    font-size: 0.9rem;
  }

  /* Services Section - Fix positioning */
  #services {
    position: relative;
    z-index: 2;
    padding-top: 3rem;
  }

  /* Typography */
  .title {
    font-size: 2rem;
    margin-bottom: 2.5rem;
  }

  .section__text__p2 {
    font-size: 1.15rem;
  }

  .logo {
    font-size: 1.5rem;
  }

  /* Profile Section */
  #profile {
    height: auto;
    min-height: 75vh;
    flex-direction: column;
    gap: 2rem;
    padding: 2rem 1rem;
  }

  .section__pic-container {
    width: 250px;
    height: 250px;
    margin: 0 auto;
  }

  .section__pic-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Metrics Section */
  .metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }

  .metric .num {
    font-size: 1.75rem;
  }

  .metric .label {
    font-size: 0.8rem;
  }

  /* Partners */
  .partners {
    flex-wrap: wrap;
    gap: 1.25rem;
  }

  /* Services Section - Fix text overlap */
  #services .section__text {
    background: var(--bg-white);
    padding: 1rem 0;
    margin-bottom: 1rem;
  }

  .carousel-container {
    overflow: hidden;
  }

  /* Experience Section - Fix horizontal cutoff */
  #experience {
    overflow-x: hidden;
  }

  .experience-details-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  .details-container {
    width: 100%;
    flex: none;
  }

  .about-containers {
    flex-direction: column;
    gap: 1rem;
  }

  /* Cards - 85% with snap scrolling */
  .card-3-per-view,
  .case-study-card {
    flex: 0 0 85% !important;
    scroll-snap-align: start;
  }
  
  .carousel-scroll-wrapper {
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1.5rem !important; /* space for scroll bar */
  }

  .carousel-arrow {
    display: none !important;
  }

  /* Carousel arrows */
  .carousel-arrow {
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
  }

  .carousel-arrow.prev {
    left: 8px;
  }

  .carousel-arrow.next {
    right: 8px;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    max-height: 90vh;
    margin: 5vh auto;
    padding: 1.5rem;
    overflow-y: auto;
  }

  .close-modal {
    width: 48px;
    height: 48px;
    font-size: 36px;
    top: 8px;
    right: 15px;
  }

  /* Contact Grid */
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .contact-form {
    padding: 1.5rem;
    order: 1;
  }

  .booking-card {
    order: 2;
    padding: 1.75rem;
  }

  .form-group input,
  .form-group textarea {
    padding: 1rem;
    font-size: 16px;
  }

  .btn-primary,
  .contact-form .btn-primary {
    width: 100%;
    padding: 1rem;
  }

  .booking-card .cta-btn {
    width: 100%;
    max-width: none;
    justify-content: center;
  }

  /* Text containers */
  .text-container {
    padding: 0 0.75rem;
  }

  /* Case Study Cards */
  .case-study-stats {
    flex-direction: column;
    gap: 1rem;
  }

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

  /* Footer */
  footer nav {
    height: auto;
    margin-bottom: 1.5rem;
  }

  footer .nav-links {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* ============================================
   LARGE MOBILE / SMALL TABLET (640px - 767px)
   Large phones in landscape, small tablets
   ============================================ */

@media screen and (max-width: 767px) and (min-width: 640px) {

  /* Section Layout */
  section {
    margin: 0 2rem;
    padding: 3rem 1.5rem;
  }

  /* Typography */
  .title {
    font-size: 2.25rem;
    margin-bottom: 3rem;
  }

  .section__text__p2 {
    font-size: 1.25rem;
  }

  /* Profile Section */
  #profile {
    height: auto;
    min-height: 80vh;
    flex-direction: column;
    gap: 2.5rem;
  }

  .section__pic-container {
    width: 280px;
    height: 280px;
  }

  /* Metrics */
  .metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
  }

  .metric {
    flex: 0 0 auto;
    min-width: 120px;
  }

  .metric .num {
    font-size: 2rem;
  }

  /* Cards - 2 per view */
  .card-3-per-view {
    flex: 0 0 calc(50% - 0.25rem);
  }

  .case-study-card {
    flex: 0 0 100%;
  }

  /* Carousel arrows */
  .carousel-arrow {
    width: 48px;
    height: 48px;
    font-size: 2rem;
  }

  .carousel-arrow.prev {
    left: 10px;
  }

  .carousel-arrow.next {
    right: 10px;
  }

  /* Modal */
  .modal-content {
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
  }

  .close-modal {
    width: 48px;
    height: 48px;
    font-size: 36px;
  }

  /* Contact Grid */
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .contact-form {
    order: 1;
  }

  .booking-card {
    order: 2;
  }

  .form-group input,
  .form-group textarea {
    padding: 1rem;
    font-size: 16px;
  }

  .booking-card .cta-btn {
    width: auto;
    max-width: 280px;
  }
}

/* ============================================
   TABLET (768px - 1023px)
   ============================================ */

@media screen and (max-width: 1023px) and (min-width: 768px) {

  /* Navigation - show hamburger */
  #desktop-nav {
    display: none;
  }

  #hamburger-nav {
    display: flex;
  }

  /* Section Layout */
  section {
    margin: 0 2rem;
    padding: 3.5rem 2rem;
  }

  /* Typography */
  .title {
    font-size: clamp(2rem, 5vw, 2.5rem);
  }

  .section__text__p1 {
    font-size: clamp(0.95rem, 3vw, 1.1rem);
  }

  /* Button Container */
  .btn-container {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .btn {
    width: auto;
    min-width: 150px;
  }

  /* Profile Section */
  #profile {
    flex-direction: row;
    gap: 3rem;
  }

  .section__pic-container {
    width: 300px;
    height: 300px;
  }

  /* Metrics */
  .metrics {
    display: flex;
    justify-content: space-around;
    gap: 1.5rem;
  }

  .metric .num {
    font-size: 2.25rem;
  }

  /* Cards - 2 per view */
  .card-3-per-view {
    flex: 0 0 calc(50% - 0.25rem);
  }

  .case-study-card {
    flex: 0 0 calc(50% - 0.75rem);
  }

  /* Carousel arrows */
  .carousel-arrow {
    width: 48px;
    height: 48px;
  }

  .carousel-arrow.prev {
    left: 15px;
  }

  .carousel-arrow.next {
    right: 15px;
  }

  /* Modal */
  .modal-content {
    width: 85%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
  }

  .close-modal {
    width: 48px;
    height: 48px;
    font-size: 32px;
  }

  /* Contact Grid - 2 columns on tablet */
  .contact-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }

  /* Experience Section */
  #experience,
  .experience-details-container {
    margin-top: 2rem;
  }

  .about-containers {
    flex-wrap: wrap;
  }
}

/* ============================================
   SMALL DESKTOP (1024px - 1199px)
   ============================================ */

@media screen and (max-width: 1199px) and (min-width: 1024px) {

  /* Navigation - show hamburger on smaller desktops */
  #desktop-nav {
    display: none;
  }

  #hamburger-nav {
    display: flex;
  }

  /* Section Layout */
  section {
    margin: 0 5rem;
  }

  /* Cards - 3 per view */
  .card-3-per-view {
    flex: 0 0 calc(33.333% - 0.333rem);
  }

  .case-study-card {
    flex: 0 0 calc(50% - 0.75rem);
  }

  /* Carousel arrows */
  .carousel-arrow.prev {
    left: 20px;
  }

  .carousel-arrow.next {
    right: 20px;
  }

  /* Experience */
  #experience,
  .experience-details-container {
    margin-top: 2rem;
  }

  .about-containers {
    flex-wrap: wrap;
    margin-top: 0;
  }
}

/* ============================================
   DESKTOP (1200px - 1399px)
   ============================================ */

@media screen and (max-width: 1399px) and (min-width: 1200px) {

  /* Navigation - show desktop nav */
  #desktop-nav {
    display: flex;
  }

  #hamburger-nav {
    display: none;
  }

  /* Profile */
  #profile {
    height: 83vh;
    margin-bottom: 6rem;
  }

  /* Cards - 3 per view */
  .card-3-per-view {
    flex: 0 0 calc(33.333% - 0.333rem);
  }

  .case-study-card {
    flex: 0 0 calc(50% - 0.75rem);
  }

  /* Carousel arrows */
  .carousel-arrow.prev {
    left: 20px;
  }

  .carousel-arrow.next {
    right: 20px;
  }

  .about-containers {
    flex-wrap: wrap;
  }

  .stats-container {
    gap: 2rem;
  }
}

/* ============================================
   DESKTOP OPTIMIZATIONS (1200px+)
   Better spacing and reading width
   ============================================ */

@media screen and (min-width: 1200px) {
  /* Improve line length for better readability */
  section {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
  }

  .section-container {
    display: flex;
    gap: 4rem;
    align-items: center;
  }

  /* Better button spacing on desktop */
  .btn-container {
    display: flex;
    gap: 1.5rem;
    flex-direction: row;
  }

  .btn {
    width: auto;
    flex-grow: 1;
    max-width: 200px;
  }

  /* Improved form width */
  .contact-form {
    max-width: 600px;
    margin: 0 auto;
  }

  /* Better carousel spacing */
  .carousel-scroll-wrapper {
    padding: 1rem 0;
  }

  .card-3-per-view {
    flex: 0 0 calc(33.333% - 0.333rem);
  }
}

/* ============================================
   LARGE DESKTOP (1400px+)
   ============================================ */

@media screen and (min-width: 1400px) {

  /* Full desktop experience - arrows inside container */
  .carousel-arrow.prev {
    left: 20px;
  }

  .carousel-arrow.next {
    right: 20px;
  }

  /* 3-column layouts */
  .card-3-per-view {
    flex: 0 0 calc(33.333% - 0.333rem);
  }

  .case-study-card {
    flex: 0 0 calc(50% - 0.75rem);
  }
}

/* ============================================
   HAMBURGER MENU MOBILE OPTIMIZATIONS
   ============================================ */

@media screen and (max-width: 1199px) {
  #desktop-nav {
    display: none;
  }

  #hamburger-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    height: 70px;
  }

  .menu-links {
    min-width: 200px;
  }

  .menu-links a {
    padding: 12px 20px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .menu-links.open {
    max-height: 500px;
    overflow-y: auto;
  }

  .hamburger-icon {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
  }

  .hamburger-icon span {
    width: 24px;
    height: 2px;
  }
}

/* ============================================
   ADDITIONAL MOBILE FIXES
   ============================================ */

/* Ensure images are responsive */
@media screen and (max-width: 1023px) {

  .section__pic-container img,
  .about-pic,
  .project-img,
  .portfolio-img,
  .modal-img {
    max-width: 100%;
    height: auto;
  }

  /* Ensure picture elements scale properly on mobile */
  picture {
    display: block;
    width: 100%;
  }

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

  /* Modal images on mobile */
  .modal-content picture img,
  .modal-content .modal-img {
    max-height: 150px;
    width: auto;
    max-width: 100%;
  }

  /* Arrow visibility improvements */
  .arrow {
    display: none;
  }

  /* Height adjustments */
  #contact,
  #projects,
  #services,
  #portfolio,
  #case-studies,
  #testimonials {
    height: fit-content;
    min-height: auto;
  }

  /* Section container stacking */
  #profile,
  .section-container {
    display: flex;
    flex-direction: column;
  }
}

/* Very small screen fixes */
@media screen and (max-width: 359px) {
  section {
    margin: 0 0.5rem;
    padding: 1.5rem 0.5rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .section__pic-container {
    width: 180px;
    height: 180px;
  }

  .metrics {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .carousel-arrow {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  .carousel-arrow.prev {
    left: 2px;
  }

  .carousel-arrow.next {
    right: 2px;
  }
}

/* Corner CTA mobile adjustments */
@media screen and (max-width: 600px) {
  .corner-cta {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .corner-cta span {
    display: none;
  }
}

/* Socials container mobile */
@media screen and (max-width: 600px) {
  #socials-container {
    gap: 0.75rem;
  }

  .social-icon {
    font-size: 1.5rem;
  }

  .icon {
    height: 1.75rem;
  }
}

/* Footer mobile optimizations */
@media screen and (max-width: 600px) {
  footer {
    padding: 1.5rem 1rem;
  }

  footer p {
    font-size: 0.875rem;
  }
}

/* ============================================
   NEW SECTIONS RESPONSIVE (Who I Work With, How It Works)
   ============================================ */

@media screen and (max-width: 479px) {
  #ideal-clients,
  #process {
    padding: 2rem 0.75rem !important;
  }

  #ideal-clients > div:last-child,
  #process > div:last-child {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

@media screen and (max-width: 639px) and (min-width: 480px) {
  #ideal-clients,
  #process {
    padding: 2rem 1rem !important;
  }

  #ideal-clients > div:last-child,
  #process > div:last-child {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
}

@media screen and (max-width: 767px) and (min-width: 640px) {
  #ideal-clients,
  #process {
    padding: 3rem 2rem !important;
  }

  #ideal-clients > div:last-child {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  #process > div:last-child {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media screen and (max-width: 1023px) and (min-width: 768px) {
  #ideal-clients,
  #process {
    padding: 3.5rem 2rem !important;
  }

  #ideal-clients > div:last-child {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  #process > div:last-child {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media screen and (max-width: 1199px) and (min-width: 1024px) {
  #ideal-clients,
  #process {
    padding: 4rem 3rem !important;
  }
}

/* Print styles - hide non-essential elements */
@media print {

  .carousel-arrow,
  .hamburger-menu,
  .corner-cta,
  #hamburger-nav {
    display: none !important;
  }
}