/* ===================================
  Mindfulness AI - Responsive Styles
  =================================== */

/* General cross-device improvements */
* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

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

/* Ensure all containers are responsive */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  padding-left: var(--spacing-xl);
  padding-right: var(--spacing-xl);
}

/* Tablet (768px and below) */
@media (max-width: 768px) {
  /* Typography */
  :root {
    --font-size-5xl: 2.25rem;
    --font-size-4xl: 1.875rem;
    --font-size-3xl: 1.5rem;
    --font-size-2xl: 1.25rem;
  }

  /* Container */
  .container {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
    width: 100%;
  }
  
  /* Image optimizations for all sections */
  img {
    object-fit: cover;
    object-position: center;
  }
  
  /* Section spacing adjustments */
  section {
    padding: var(--spacing-2xl) 0;
  }

  /* Navigation */
  .nav-links {
    position: fixed;
    top: 72px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--white);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
  }

  .nav-links.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  /* Hero */
  .hero-title {
    font-size: var(--font-size-4xl);
  }

  .hero-subtitle {
    font-size: var(--font-size-lg);
  }

  .hero-layout {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-xl);
  }

  .hero-visual {
    margin-top: var(--spacing-lg);
  }

  .hero-cta {
    flex-direction: column;
    width: 100%;
  }

  .hero-cta .btn {
    width: 100%;
  }

  /* Scroll indicator responsive */
  .scroll-indicator {
    bottom: 2rem;
    padding: 0.75rem;
    font-size: var(--font-size-sm);
  }

  .scroll-arrow {
    font-size: var(--font-size-lg);
  }

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

  .section-title {
    font-size: var(--font-size-3xl);
  }

  /* Mission Values */
  .mission-values {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }
  
  .mission-quote {
    padding: var(--spacing-lg);
  }
  
  .mission-quote blockquote {
    font-size: var(--font-size-base);
  }

  /* Features Grid */
  .features-grid,
  .features-constellation {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }

  /* Screenshots */
  .screenshots-carousel {
    flex-direction: column;
    align-items: center;
  }

  .phone-mockup {
    width: 240px;
    height: 480px;
  }

  /* Donation Tiers */
  .donation-tiers {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .tier-card.featured {
    transform: scale(1);
  }

  /* Download Badges */
  .download-badges {
    flex-direction: column;
    width: 100%;
  }

  .store-badge-fallback {
    width: 100%;
    justify-content: center;
  }

  /* Footer */
  .footer-content {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    text-align: center;
  }

  .footer-brand {
    max-width: 100%;
  }

  .footer-column {
    text-align: center;
  }

  .social-links {
    justify-content: center;
  }

  /* Modal */
  .modal-content {
    margin: var(--spacing-md);
  }

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

/* Mobile (640px and below) */
@media (max-width: 640px) {
  /* Typography */
  :root {
    --font-size-5xl: 2rem;
    --font-size-4xl: 1.5rem;
    --font-size-3xl: 1.25rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
  }

  /* Hero */
  .hero {
    min-height: 100svh; /* Use svh for mobile browsers */
  }

  .hero-title {
    font-size: var(--font-size-3xl);
    line-height: 1.3;
  }

  .hero-subtitle {
    font-size: var(--font-size-base);
  }

  .hero-tagline {
    font-size: var(--font-size-base);
  }

  .floating-particles {
    display: none; /* Hide on small screens for performance */
  }

  /* Buttons */
  .btn {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-size-sm);
  }

  /* Section Headers */
  .section-title {
    font-size: var(--font-size-2xl);
  }

  .section-subtitle {
    font-size: var(--font-size-base);
  }

  /* Mission */
  .mission-text {
    font-size: var(--font-size-base);
  }

  .stat-card {
    padding: var(--spacing-lg);
  }

  .stat-number {
    font-size: var(--font-size-2xl);
  }

  /* Features */
  .feature-card {
    padding: var(--spacing-lg);
  }

  .feature-icon {
    font-size: var(--font-size-4xl);
  }

  .feature-title {
    font-size: var(--font-size-lg);
  }

  /* Screenshots */
  .phone-mockup {
    width: 200px;
    height: 400px;
    padding: 0.75rem;
  }

  /* Support */
  .support-text {
    font-size: var(--font-size-base);
  }

  .tier-card {
    padding: var(--spacing-lg);
  }

  .tier-icon {
    font-size: var(--font-size-3xl);
  }

  .tier-amount {
    font-size: var(--font-size-2xl);
  }

  /* Download */
  .qr-code {
    width: 150px;
    height: 150px;
  }

  /* Footer */
  .footer {
    padding: var(--spacing-xl) 0 var(--spacing-md);
  }

  .footer-logo {
    justify-content: center;
  }

  /* Modal */
  .modal {
    padding: 0;
  }

  .modal-content {
    border-radius: 0;
    max-height: 100vh;
    margin: 0;
  }

  .modal-header {
    padding: var(--spacing-lg);
  }

  .modal-body {
    padding: var(--spacing-lg);
  }

  .amount-selector {
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xs);
  }

  .amount-btn {
    padding: var(--spacing-sm);
    font-size: var(--font-size-sm);
  }
}

/* Small Mobile (375px and below) */
@media (max-width: 375px) {
  :root {
    --font-size-5xl: 1.75rem;
    --font-size-4xl: 1.375rem;
    --font-size-3xl: 1.125rem;
  }

  .hero-title {
    font-size: var(--font-size-2xl);
  }

  .section-title {
    font-size: var(--font-size-xl);
  }

  .phone-mockup {
    width: 180px;
    height: 360px;
  }

  .store-badge-fallback {
    min-width: 160px;
    padding: 0.5rem 1rem;
  }

  .store-text-large {
    font-size: var(--font-size-base);
  }
}

/* Tablet Landscape (1024px and below) */
@media (max-width: 1024px) and (orientation: landscape) {
  .hero {
    min-height: 100vh;
    padding-top: 100px;
    padding-bottom: var(--spacing-2xl);
  }

  .hero-content {
    padding: var(--spacing-lg) 0;
  }

  .scroll-indicator {
    display: none;
  }
}

/* Large Desktop (1280px and above) */
@media (min-width: 1280px) {
  .container {
    max-width: 1400px;
  }

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

  .donation-tiers {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Extra Large Desktop (1536px and above) */
@media (min-width: 1536px) {
  .container {
    max-width: 1536px;
  }

  .hero-title {
    font-size: 4rem;
  }

  .section-title {
    font-size: 3rem;
  }
}

/* Print Styles */
@media print {
  .navbar,
  .floating-particles,
  .scroll-indicator,
  .modal,
  .footer {
    display: none;
  }

  body {
    color: #000;
    background: #fff;
  }

  .hero {
    min-height: auto;
    page-break-after: always;
  }

  section {
    page-break-inside: avoid;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --primary: #1a7a6a;
    --gray-500: #404040;
  }

  .btn-primary {
    border: 2px solid var(--gray-900);
  }

  .feature-card,
  .stat-card,
  .tier-card {
    border: 2px solid var(--gray-300);
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --white: #1a1a1a;
    --gray-50: #2a2a2a;
    --gray-100: #333333;
    --gray-200: #404040;
    --gray-900: #f5f5f5;
    --gray-700: #e0e0e0;
    --gray-500: #b0b0b0;
  }

  body {
    background-color: var(--white);
    color: var(--gray-900);
  }

  .navbar {
    background: rgba(26, 26, 26, 0.95);
  }

  .feature-card,
  .stat-card,
  .tier-card,
  .phone-mockup {
    background: var(--gray-100);
  }

  .modal-content {
    background: var(--gray-100);
  }

  .input-group input {
    background: var(--gray-200);
    color: var(--gray-900);
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  .btn,
  .nav-links a,
  .amount-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Disable hover effects on touch devices */
  .hover-lift:hover,
  .hover-scale:hover,
  .hover-glow:hover {
    transform: none;
    box-shadow: none;
  }

  /* Remove hover states */
  .feature-card:hover,
  .stat-card:hover,
  .tier-card:hover {
    transform: none;
  }
}

/* Landscape Phone */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding: var(--spacing-2xl) 0;
  }

  .hero-title {
    font-size: var(--font-size-3xl);
  }

  .scroll-indicator {
    display: none;
  }

  .floating-particles {
    display: none;
  }
}

/* Accessibility: Focus Visible */
@media (prefers-reduced-motion: no-preference) {
  :focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
  }
}

/* ================================
   Stories Section Responsive
   ================================ */

/* Tablet and below */
@media (max-width: 1024px) {
  .story-card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
  }
  
  .story-card-right .story-content,
  .story-card-left .story-content {
    order: 2;
    width: 100%;
  }
  
  .story-card-right .story-image-wrapper,
  .story-card-left .story-image-wrapper {
    order: 1;
    width: 100%;
    max-width: 100%;
  }
  
  .story-image-wrapper {
    aspect-ratio: 16/9;
    height: auto;
  }
  
  .story-image {
    width: 100%;
    height: auto;
    max-height: 350px;
    object-fit: cover;
    object-position: center;
  }
  
  .story-title {
    font-size: var(--font-size-lg);
    margin-top: var(--spacing-md);
  }
  
  .cta-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .cta-buttons .btn {
    width: 100%;
    justify-content: center;
  }
  
  .stories-grid {
    width: 100%;
    padding: 0 var(--spacing-md);
    box-sizing: border-box;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .container {
    width: 100%;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
    box-sizing: border-box;
  }
  
  .stories-section {
    padding: var(--spacing-2xl) 0;
  }
  
  .stories-grid {
    gap: var(--spacing-xl);
    margin-top: var(--spacing-lg);
    padding: 0;
  }
  
  .story-card {
    padding: var(--spacing-md);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
  }
  
  .story-image-wrapper {
    aspect-ratio: 4/3;
    max-height: 250px;
  }
  
  .story-image {
    width: 100%;
    height: 100%;
    max-height: 250px;
  }
  
  .story-title {
    font-size: var(--font-size-md);
    line-height: 1.4;
  }
  
  .story-text {
    font-size: var(--font-size-sm);
    line-height: 1.5;
  }
  
  .story-impact {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    margin-top: var(--spacing-md);
  }
  
  .impact-icon {
    font-size: 1.25rem;
  }
  
  .cta-content {
    padding: var(--spacing-lg) var(--spacing-md);
    margin: 0 var(--spacing-md);
  }
  
  .cta-content h3 {
    font-size: var(--font-size-lg);
  }
  
  .cta-content > p {
    font-size: var(--font-size-sm);
  }
  
  .section-header {
    padding: 0 var(--spacing-md);
  }
}

/* Small mobile */
@media (max-width: 480px) {
  /* General container */
  .container {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
  }
  
  /* Typography */
  h1, h2, h3, h4 {
    word-break: break-word;
    hyphens: auto;
  }

  .story-tag {
    font-size: var(--font-size-xs);
    padding: 0.25rem 0.5rem;
  }
  
  .story-image-wrapper {
    aspect-ratio: 1/1;
    max-height: 200px;
    width: 100%;
  }
  
  .story-image {
    height: 100%;
    width: 100%;
    object-position: center top;
  }
  
  /* Make spacing tighter */
  .story-content {
    padding: var(--spacing-xs);
  }
  
  .stories-grid {
    gap: var(--spacing-lg);
  }
  
  /* Button sizing */
  .btn-large {
    padding: 0.7rem 1.3rem;
    font-size: var(--font-size-sm);
    width: 100%;
    margin-bottom: var(--spacing-sm);
  }
  
  .section-title {
    font-size: var(--font-size-xl);
    line-height: 1.3;
  }
  
  .section-subtitle {
    font-size: var(--font-size-sm);
  }
  
  /* Fix overflow issues */
  .story-card {
    padding: var(--spacing-sm);
    overflow: hidden;
  }

  /* CTA adjustments */
  .cta-content {
    padding: var(--spacing-md);
    width: 100%;
  }
}

/* Cross-Browser Compatibility Fixes */
@supports (-webkit-overflow-scrolling: touch) {
  /* iOS specific fixes */
  input, textarea {
    font-size: 16px; /* Prevents iOS zoom on input focus */
  }
  
  .story-image-wrapper {
    -webkit-transform: translateZ(0); /* Fixes iOS image rendering issues */
    transform: translateZ(0);
  }
}

/* Safari specific fixes */
@media not all and (min-resolution:.001dpcm) { 
  @supports (-webkit-appearance:none) {
    .story-image {
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
    }
    
    .story-card {
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
    }
  }
}

/* Fix for Firefox image aspect ratio */
@-moz-document url-prefix() { 
  .story-image-wrapper {
    height: 0;
    padding-bottom: 75%;
  }
}
