/**
 * Mobile Responsive Enhancements (2025)
 * Comprehensive mobile-first responsive design
 * 
 * Purpose: Ensure full mobile compatibility while maintaining desktop appearance
 * Target devices: 360px - 430px width (Android & iOS)
 * Desktop preservation: ≥1024px (no visual changes)
 */

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

/* Ensure proper box-sizing globally */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Prevent horizontal overflow */
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%; /* Prevent iOS text inflation */
}

body {
  overflow-x: hidden;
  min-width: 320px; /* Minimum supported width */
}

/* ========================================
   FLUID TYPOGRAPHY SYSTEM (Mobile-First)
   ======================================== */

/* Base font size - fluid scaling */
html {
  font-size: clamp(0.9375rem, 2.5vw, 1rem); /* 15-16px */
}

/* Reset font-size for larger screens to maintain desktop appearance */
@media (min-width: 1024px) {
  html {
    font-size: 16px; /* Fixed at 16px for desktop */
  }
}

/* Hero H1 - Main title "Pracownia Mocnych Stron" */
#home h1 {
  font-size: clamp(1.75rem, 7vw, 3.75rem) !important; /* 28px mobile → 60px desktop */
  line-height: clamp(1.15, 1.2, 1.25) !important;
  letter-spacing: clamp(-0.02em, -0.01em, -0.005em) !important;
  /* Prevent inappropriate word breaking and hyphenation */
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
}

/* Section H2 headings */
section h2,
.text-3xl,
.text-4xl {
  font-size: clamp(1.5rem, 5vw, 2.5rem) !important; /* 24px mobile → 40px desktop */
  line-height: 1.2 !important;
}

/* Section H3 headings */
section h3,
.text-2xl {
  font-size: clamp(1.125rem, 3.5vw, 1.5rem) !important; /* 18px mobile → 24px desktop */
  line-height: 1.3 !important;
}

/* Paragraph text */
p,
.text-lg {
  font-size: clamp(0.9375rem, 2vw, 1.125rem) !important; /* 15px mobile → 18px desktop */
  line-height: clamp(1.5, 1.6, 1.7) !important;
}

/* Small text */
.text-sm {
  font-size: clamp(0.8125rem, 1.8vw, 0.875rem) !important; /* 13px mobile → 14px desktop */
}

/* Extra small text and badges */
.text-xs {
  font-size: clamp(0.75rem, 1.5vw, 0.8125rem) !important; /* 12px mobile → 13px desktop */
}

/* Badge/pill elements */
span[class*='rounded-full'],
.inline-block.rounded-full {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ========================================
   HERO SECTION MOBILE OPTIMIZATION
   ======================================== */

#home {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for iOS */
  padding-top: clamp(4rem, 15vh, 8rem) !important;
  padding-bottom: clamp(2rem, 5vh, 4rem) !important;
}

/* Hero grid - stack on mobile */
#home > div {
  padding-left: clamp(1rem, 4vw, 1.5rem);
  padding-right: clamp(1rem, 4vw, 1.5rem);
}

@media (max-width: 767px) {
  #home .grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }
}

/* Hero text content */
#home > div > div:first-child {
  max-width: 100% !important;
}

/* Hero tagline paragraph */
#home p {
  max-width: 100% !important;
  margin-top: 1.25rem !important;
}

/* Hero buttons - stack on small mobile */
#home .flex.gap-4 {
  gap: clamp(0.75rem, 3vw, 1rem);
}

@media (max-width: 480px) {
  #home .flex.gap-4 {
    flex-direction: column !important;
  }

  #home .flex.gap-4 > a {
    width: 100%;
    text-align: center;
  }
}

/* Hero image container - responsive sizing */
#home .relative.flex {
  justify-content: center !important;
}

/* Target all size variants of hero image */
#home img[src*='hero'] {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
}

/* Hero image wrapper - responsive */
@media (max-width: 767px) {
  #home .relative > div {
    width: clamp(240px, 80vw, 360px) !important;
    height: clamp(240px, 80vw, 360px) !important;
  }

  #home .relative.flex {
    margin-bottom: 1rem;
  }
}

/* ========================================
   ABOUT SECTION ("O mnie") MOBILE LAYOUT
   ======================================== */

#about-preview {
  margin-top: clamp(-4rem, -8vw, -6rem) !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* About card grid - stack on mobile */
#about-preview .grid {
  gap: clamp(1.5rem, 4vw, 2rem) !important;
}

@media (max-width: 767px) {
  #about-preview .grid {
    grid-template-columns: 1fr !important;
  }

  /* Photo container */
  #about-preview .grid > div:first-child {
    order: 1;
    padding: 2rem 1.5rem !important;
  }

  /* Text content */
  #about-preview .grid > div:last-child {
    order: 2;
    padding: 1.5rem !important;
  }
}

/* Photo sizing - responsive */
#about-preview .relative.w-64,
#about-preview .relative.md\\:w-80 {
  width: clamp(180px, 60vw, 320px) !important;
  height: clamp(180px, 60vw, 320px) !important;
}

/* About text - ensure readability */
#about-preview p {
  max-width: 100% !important;
}

/* ========================================
   SECTION SPACING OPTIMIZATION
   ======================================== */

/* General section padding */
section {
  padding-top: clamp(3rem, 8vw, 5rem);
  padding-bottom: clamp(3rem, 8vw, 5rem);
}

/* Override specific section padding */
.py-20 {
  padding-top: clamp(3rem, 8vw, 5rem) !important;
  padding-bottom: clamp(3rem, 8vw, 5rem) !important;
}

/* Container padding */
.px-4 {
  padding-left: clamp(1rem, 4vw, 1.5rem) !important;
  padding-right: clamp(1rem, 4vw, 1.5rem) !important;
}

/* ========================================
   NAVIGATION MOBILE ENHANCEMENTS
   ======================================== */

/* Mobile menu improvements */
@media (max-width: 767px) {
  .nav-header {
    padding: 0.5rem 0 !important;
  }

  #navBtn {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.5rem;
  }

  #mobileMenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
  }

  #mobileMenu:not(.hidden) {
    max-height: 500px;
  }

  #mobileMenu a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
  }
}

/* ========================================
   GRID LAYOUTS - MOBILE OPTIMIZATION
   ======================================== */

/* Offer grid */
@media (max-width: 767px) {
  #offer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
}

/* Process timeline */
@media (max-width: 767px) {
  .process-timeline {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
}

/* Pricing grid */
@media (max-width: 767px) {
  #pricing .grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
}

/* ========================================
   IMAGE OPTIMIZATIONS
   ======================================== */

/* Global image responsive rules */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Images with aspect-ratio support */
img[loading='lazy'] {
  aspect-ratio: attr(width) / attr(height);
}

/* Hero image specific */
#home img {
  object-fit: cover;
  border-radius: 1rem;
}

/* About section image */
#about-preview img {
  object-fit: cover;
}

/* ========================================
   TOUCH TARGET OPTIMIZATION
   ======================================== */

/* Ensure all interactive elements have minimum 44x44px touch targets */
a,
button,
input,
select,
textarea {
  min-height: 44px;
  min-width: 44px;
}

/* Exception for inline text links */
p a,
li a {
  min-height: auto;
  min-width: auto;
  padding: 0.25rem 0;
}

/* Button padding for comfortable tapping */
@media (max-width: 767px) {
  button,
  a.rounded-full {
    padding: 0.875rem 1.5rem !important;
  }
}

/* ========================================
   iOS/ANDROID SPECIFIC OPTIMIZATIONS
   ======================================== */

/* iOS Safari - dynamic viewport height */
@supports (height: 100dvh) {
  #home {
    min-height: 100dvh;
  }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .nav-header {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* Tap highlight color */
* {
  -webkit-tap-highlight-color: rgba(244, 196, 48, 0.2);
}

/* Disable text selection on UI elements */
button,
.nav-link,
.nav-logo {
  -webkit-user-select: none;
  user-select: none;
}

/* Disable touch callout on images and links */
img,
a {
  -webkit-touch-callout: none;
}

/* ========================================
   FORM OPTIMIZATIONS
   ======================================== */

/* Form inputs - comfortable on mobile */
@media (max-width: 767px) {
  input,
  textarea,
  select {
    font-size: 16px !important; /* Prevent iOS zoom on focus */
    padding: 0.875rem 1rem !important;
    min-height: 44px;
  }

  textarea {
    min-height: 120px;
  }
}

/* ========================================
   CARD HOVER STATES - TOUCH OPTIMIZATION
   ======================================== */

/* Disable hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
  .offer-card:hover,
  .process-step:hover,
  .trust-card:hover {
    transform: none !important;
  }

  /* But keep active states for touch feedback */
  .offer-card:active,
  .process-step:active,
  .trust-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* ========================================
   PROGRESS NAVIGATION - HIDE ON MOBILE
   ======================================== */

@media (max-width: 767px) {
  #progressNav {
    display: none !important;
  }
}

/* ========================================
   FAQ SECTION - MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 767px) {
  #faq details {
    padding: 1rem !important;
  }

  #faq summary {
    font-size: 0.9375rem !important;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ========================================
   CONTACT SECTION - STACK ON MOBILE
   ======================================== */

@media (max-width: 767px) {
  #contact .md\\:flex {
    flex-direction: column !important;
  }

  #contact .md\\:w-1\\/2 {
    width: 100% !important;
  }

  #contact form {
    margin-top: 2rem !important;
  }
}

/* ========================================
   UTILITIES
   ======================================== */

/* Hide on mobile */
.hide-mobile {
  display: none !important;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: inherit !important;
  }
}

/* Show only on mobile */
.show-mobile {
  display: inherit !important;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none !important;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   LANDSCAPE MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 767px) and (orientation: landscape) {
  #home {
    min-height: auto;
    padding-top: 6rem !important;
    padding-bottom: 2rem !important;
  }

  #home .grid {
    gap: 1.5rem !important;
  }
}

/* ========================================
   SMALL MOBILE (360px) SPECIFIC FIXES
   ======================================== */

@media (max-width: 375px) {
  /* Extra compact spacing */
  section {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }

  /* Smaller buttons */
  button,
  a.rounded-full {
    padding: 0.75rem 1.25rem !important;
    font-size: 0.875rem !important;
  }

  /* Tighter grid gaps */
  #offer-grid,
  .process-timeline {
    gap: 1rem !important;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  /* Hide navigation and interactive elements */
  .nav-header,
  #progressNav,
  #navBtn,
  #mobileMenu {
    display: none !important;
  }

  /* Reset transforms and shadows */
  * {
    transform: none !important;
    box-shadow: none !important;
  }

  /* Ensure readable text */
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: black;
    background: white;
  }
}
