/* ========================================
   MOBILE-FIRST OPTIMIZATIONS
   Phase 1: Critical mobile improvements
   Phase 4: Mobile-specific layout fixes
   ======================================== */

/* === MOBILE HEADER FIXES === */
@media (max-width: 768px) {
  /* Reduce header/banner height */
  .nav {
    padding: 12px 0 !important;
  }

  .nav-logo {
    font-size: 14px !important;
    gap: 8px !important;
  }

  .nav-logo img {
    height: 32px !important;
    width: auto !important;
  }

  /* Hide desktop menu, show hamburger */
  .nav-menu {
    display: none !important;
  }

  /* REMOVED: CSS-generated fake hamburger (was overlapping real button) */
  /* The real .mobile-menu-toggle button is created by JavaScript */

  .nav-container {
    position: relative;
  }
}

/* === TOUCH TARGETS === */
/* All interactive elements minimum 48x48px */

.btn {
  min-height: 48px;
  min-width: 120px;
  padding: 16px 32px;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: rgba(249, 208, 36, 0.2);
}

.nav-link {
  min-height: 48px;
  padding: 12px 20px;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
}

/* Touch feedback */
.btn:active,
.nav-link:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* === COMPREHENSIVE BREAKPOINTS === */

/* Extra small devices (iPhone SE) */
@media (min-width: 320px) {
  :root {
    font-size: 14px;
  }

  .container {
    padding: 0 16px;
  }

  h1 {
    font-size: clamp(36px, 10vw, 72px);
  }

  h2 {
    font-size: clamp(28px, 7vw, 48px);
  }
}

/* Small devices (iPhone 12/13/14, Android phones) */
@media (min-width: 375px) {
  :root {
    font-size: 15px;
  }

  .container {
    padding: 0 20px;
  }

  h1 {
    font-size: clamp(42px, 10vw, 72px);
  }
}

/* Medium phones (iPhone Pro Max, large Android) */
@media (min-width: 414px) {
  h1 {
    font-size: clamp(48px, 10vw, 72px);
  }

  .btn {
    padding: 18px 36px;
    font-size: 18px;
    min-height: 56px;
  }
}

/* Tablets (iPad Mini portrait) */
@media (min-width: 768px) {
  :root {
    font-size: 16px;
  }

  .container {
    padding: 0 32px;
  }

  .film-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .about-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

/* Tablet landscape / Small laptop */
@media (min-width: 1024px) {
  .film-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .process-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop */
@media (min-width: 1280px) {
  .container {
    padding: 0 48px;
  }
}

/* Large desktop */
@media (min-width: 1920px) {
  .container {
    max-width: 1600px;
    margin: 0 auto;
  }
}

/* === ORIENTATION-SPECIFIC === */

/* Landscape on mobile - compress vertical space */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    min-height: 80vh;
  }

  .nav {
    padding: 12px 0;
  }

  h1 {
    font-size: clamp(32px, 8vw, 48px);
  }

  section {
    padding: var(--spacing-lg) 0;
  }
}

/* === HERO CTA BUTTONS - MOBILE FIX === */
@media (max-width: 768px) {
  .hero-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
  }

  /* Standard button sizing (NOT full width) */
  .hero-buttons .btn {
    width: auto !important;
    min-width: 200px !important;
    max-width: 280px !important;
    padding: 16px 32px !important;
    font-size: 16px !important;
    min-height: 48px !important;
  }

  /* Fix button colors - Work with Us (yellow bg, black text) */
  .btn-ghost-hero {
    background: var(--yellow) !important;
    color: var(--black) !important;
    border: 2px solid var(--black) !important;
  }

  /* Fix button colors - Pitch Project (black bg, yellow text) */
  .btn-black-hero {
    background: var(--black) !important;
    color: var(--yellow) !important;
    border: 2px solid var(--black) !important;
  }
}

/* === STATS HORIZONTAL LAYOUT - MOBILE === */
@media (max-width: 768px) {
  .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
    text-align: center !important;
  }

  .stat-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  .stat-item h2 {
    font-size: 36px !important;
    margin-bottom: 4px !important;
  }

  .stat-item p {
    font-size: 12px !important;
    line-height: 1.3 !important;
  }
}

/* === MOBILE-SPECIFIC ENHANCEMENTS === */

@media (max-width: 768px) {
  /* Standard touch targets on mobile */
  .btn {
    min-height: 48px;
  }

  /* Stack navigation */
  .nav-links {
    flex-direction: column;
    gap: 8px;
  }

  /* Single column layouts */
  .about-grid,
  .process-grid,
  .film-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  /* Mobile typography */
  p {
    font-size: 16px;
    line-height: 1.6;
  }

  /* Improve tap area for cards */
  .film-card,
  .process-step {
    padding: var(--spacing-md);
  }

  /* Mobile-friendly spacing */
  section {
    padding: var(--spacing-xl) 0;
  }

  .hero {
    padding: var(--spacing-2xl) 0;
  }
}

/* === LAZY LOADING SUPPORT === */

/* Prevent layout shift while images load */
img[loading="lazy"] {
  min-height: 200px;
  background: var(--gray-100);
}

/* Add aspect ratios to prevent CLS */
.film-card img {
  aspect-ratio: 2/3;
  object-fit: cover;
}

.hero-video video {
  aspect-ratio: 16/9;
  object-fit: cover;
}

/* === ACCESSIBILITY === */

/* Larger text for readability on mobile */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .btn {
    font-size: 18px;
  }

  .nav-link {
    font-size: 18px;
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === PERFORMANCE === */

/* Optimize font rendering on mobile */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Optimize tap delay */
a, button, [role="button"] {
  -webkit-tap-highlight-color: rgba(249, 208, 36, 0.2);
  touch-action: manipulation;
}

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

/* Hamburger menu improvements */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    min-width: 48px;
    min-height: 48px;
    padding: 12px;
  }

  .mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background: var(--white);
    transition: right 0.3s ease;
    z-index: 1000;
  }

  .mobile-menu.active {
    right: 0;
  }

  .mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(10, 10, 10, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
  }

  .mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: all;
  }
}

/* === THUMB ZONE OPTIMIZATION === */

/* Place primary CTAs in easy-reach thumb zone (middle/bottom third) */
@media (max-width: 768px) {
  .hero .btn {
    position: sticky;
    bottom: 20px;
    margin-top: auto;
  }

  /* Sticky footer CTA for mobile */
  .mobile-cta-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 16px;
    box-shadow: 0 -2px 8px rgba(10, 10, 10, 0.1);
    z-index: 100;
  }
}

/* === FORM OPTIMIZATION === */

/* Better mobile keyboard handling */
input[type="email"],
input[type="tel"],
input[type="text"],
textarea,
select {
  font-size: 16px; /* Prevents zoom on iOS */
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 4px;
  border: 2px solid var(--gray-300, #D1D5DB);
  transition: border-color 0.2s ease;
}

/* Focus states for mobile */
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--black, #0A0A0A);
  box-shadow: 0 0 0 3px var(--yellow, #F9D024);
}

/* Error states */
input[type="email"]:invalid:not(:placeholder-shown),
input[type="tel"]:invalid:not(:placeholder-shown),
input[type="text"]:invalid:not(:placeholder-shown) {
  border-color: #EF4444;
}

/* Valid states */
input[type="email"]:valid:not(:placeholder-shown),
input[type="tel"]:valid:not(:placeholder-shown) {
  border-color: #10B981;
}

/* Proper input types for mobile keyboards */
input[type="email"],
input[type="tel"] {
  -webkit-appearance: none;
  appearance: none;
}

/* Select dropdown styling for mobile */
select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  -webkit-appearance: none;
  appearance: none;
}

/* Textarea mobile optimization */
textarea {
  resize: vertical;
  min-height: 120px;
}

/* === VIDEO OPTIMIZATION === */

/* Conditional video loading (handled by JS) */
.hero-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Show poster on slow connections */
@media (prefers-reduced-data: reduce) {
  .hero-video video {
    display: none;
  }
}

/* === CONTENT SECTION BUTTON FIXES - MOBILE === */
@media (max-width: 768px) {
  /* Apply to Join & Pitch buttons in content sections (black bg, yellow text) */
  section .btn-ghost,
  section .btn[href*="join"],
  section .btn[href*="pitch"] {
    background: var(--black, #0A0A0A) !important;
    color: var(--yellow, #F9D024) !important;
    border: 2px solid var(--black, #0A0A0A) !important;
  }
  
  /* Work With Us buttons (yellow bg, black text) - override for specific sections */
  .btn-black {
    background: var(--yellow, #F9D024) !important;
    color: var(--black, #0A0A0A) !important;
    border: 2px solid var(--black, #0A0A0A) !important;
  }
  
  /* Standard button sizing for content buttons */
  section .btn {
    padding: 14px 28px !important;
    font-size: 16px !important;
    min-width: 180px !important;
    max-width: 100% !important;
  }
}
