/* Mobile-Optimized Styles for Vintage Letter Studio */

/* Mobile-First Base Styles */
@media (max-width: 768px) {
  
  /* Navigation Improvements */
  nav .container {
    padding: 0.75rem 1rem;
  }
  
  nav .text-xl {
    font-size: 1.125rem;
  }
  
  /* Mobile Menu Styles */
  #mobileMenu {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }
  
  #mobileMenu button,
  #mobileMenu a {
    padding: 1rem;
    font-size: 1.125rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }
  
  /* Theme Selector - Mobile Optimized */
  .theme-card {
    min-height: 120px;
    padding: 0.75rem;
  }
  
  .theme-card i {
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .theme-card p {
    font-size: 0.75rem !important;
  }
  
  .theme-card span {
    font-size: 0.625rem !important;
  }
  
  /* Main Editor Section - Stack on Mobile */
  .grid.lg\:grid-cols-2 {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  /* Letter Writing Section */
  .bg-gradient-to-r {
    padding: 1rem !important;
  }
  
  .bg-gradient-to-r h2 {
    font-size: 1.5rem;
  }
  
  /* Form Elements */
  #letterForm {
    padding: 1rem !important;
  }
  
  #letterForm input,
  #letterForm textarea {
    font-size: 1rem;
    padding: 0.75rem;
  }
  
  #message {
    min-height: 250px;
    max-height: 400px;
  }
  
  /* Writing Tools - Better Mobile Layout */
  .flex.flex-wrap.gap-2 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
  
  .flex.flex-wrap.gap-2 button {
    padding: 0.5rem;
    font-size: 0.875rem;
  }
  
  .flex.flex-wrap.gap-2 .border-l {
    display: none;
  }
  
  /* Emoji Buttons Grid */
  .flex.flex-wrap.gap-2 button[onclick*="insertEmoji"] {
    font-size: 1.25rem;
    padding: 0.25rem;
  }
  
  /* Action Buttons - Stack on Mobile */
  #letterForm .flex.gap-4 {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  #letterForm .flex.gap-4 button {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
  }
  
  /* Preview Section - Mobile Optimized */
  .sticky.top-24 {
    position: relative !important;
    top: 0 !important;
  }
  
  #letterPreview {
    max-width: 100%;
    overflow-x: auto;
    font-size: 0.875rem;
  }
  
  .letter-container {
    padding: 1.5rem !important;
    min-height: 400px !important;
  }
  
  .letter-header h2 {
    font-size: 1.25rem !important;
  }
  
  .letter-body {
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
  }
  
  .letter-signature {
    font-size: 1rem !important;
  }
  
  /* Preview Actions - Mobile Layout */
  .bg-gray-50.p-4 .flex {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .bg-gray-50.p-4 .flex > div {
    width: 100%;
  }
  
  .bg-gray-50.p-4 button {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
  }
  
  /* Features Grid - Single Column on Mobile */
  .grid.md\:grid-cols-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .grid.md\:grid-cols-4 > div {
    padding: 1.25rem;
  }
  
  /* Modal Adjustments */
  #inspirationModal .max-w-2xl,
  #qrModal .max-w-sm {
    margin: 1rem;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  #inspirationModal .grid.gap-4 button {
    padding: 1rem;
  }
  
  /* Toast Notification - Mobile Position */
  #toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
  }
  
  /* Loading Screen Adjustments */
  .loading-container {
    padding: 1rem;
  }
  
  .peacock-feather,
  .maple-leaf svg {
    width: 40px;
    height: 40px;
  }
  
  .peacock-text,
  .loading-container h2 {
    font-size: 1.5rem !important;
  }
  
  .loading-container p {
    font-size: 0.875rem;
  }
  
  /* Decorations Scale Down */
  .theme-decorations > div {
    transform: scale(0.7);
  }
  
  /* Password Protection Section */
  .bg-amber-50 {
    padding: 0.75rem !important;
  }
  
  #passwordSection input {
    font-size: 0.875rem;
    padding: 0.5rem;
  }
}

/* Small Mobile Devices (max-width: 480px) */
@media (max-width: 480px) {
  
  /* Even Smaller Theme Cards */
  .grid.grid-cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  
  .theme-card {
    min-height: 100px;
    padding: 0.5rem;
  }
  
  .theme-card i {
    font-size: 1.25rem !important;
  }
  
  .theme-card p {
    font-size: 0.625rem !important;
    font-weight: 600;
  }
  
  /* Smaller Form Elements */
  #letterForm input,
  #letterForm textarea {
    font-size: 0.875rem;
    padding: 0.625rem;
  }
  
  /* Writing Tools - 2 Column Grid */
  .flex.flex-wrap.gap-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Letter Preview Further Reduction */
  .letter-container {
    padding: 1rem !important;
    min-height: 350px !important;
  }
  
  .letter-header h2 {
    font-size: 1.125rem !important;
  }
  
  .letter-body {
    font-size: 0.8125rem !important;
  }
  
  /* Hide Decorations on Very Small Screens */
  .theme-decorations {
    opacity: 0.3;
  }
  
  /* Simplify Navigation */
  nav .w-16 {
    width: 3rem;
    height: 2.5rem;
  }
}

/* Landscape Mobile Adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  
  /* Reduce vertical spacing */
  .py-8 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
  
  .mb-8 {
    margin-bottom: 1rem !important;
  }
  
  /* Smaller message area in landscape */
  #message {
    min-height: 150px;
    max-height: 250px;
  }
  
  /* Side-by-side layout for editor and preview in landscape */
  @media (min-width: 640px) {
    .grid.lg\:grid-cols-2 {
      grid-template-columns: 1fr 1fr;
      gap: 1rem;
    }
  }
}

/* Touch-Friendly Adjustments */
@media (hover: none) and (pointer: coarse) {
  
  /* Larger touch targets */
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Better spacing for touch */
  .gap-2 {
    gap: 0.75rem;
  }
  
  /* Disable hover effects on touch devices */
  .hover\:shadow-xl:hover {
    box-shadow: none;
  }
  
  .hover\:scale-105:hover {
    transform: none;
  }
  
  /* Add active states for better feedback */
  button:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

/* iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {
  /* Fix for iOS input zoom */
  input[type="text"],
  input[type="password"],
  textarea {
    font-size: 16px !important;
  }
  
  /* Fix for iOS scroll bounce */
  .overflow-auto {
    -webkit-overflow-scrolling: touch;
  }
}

/* Improved Mobile Animations */
@media (max-width: 768px) {
  /* Reduce animation complexity on mobile */
  @keyframes featherWrite {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
  }
  
  @keyframes leafFall {
    0% { transform: translateY(-50px); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(100vh); opacity: 0; }
  }
  
  /* Disable complex animations on mobile for performance */
  .animate-float,
  .animate-float-delayed,
  .animate-float-slow {
    animation: none;
    opacity: 0.5;
  }
}

/* Mobile Keyboard Handling */
@media (max-height: 500px) {
  /* When keyboard is open on mobile */
  .fixed.inset-0 {
    position: absolute;
  }
  
  #letterForm {
    padding-bottom: 60px; /* Space for keyboard */
  }
}

/* Mobile Print Styles */
@media print and (max-width: 768px) {
  @page {
    size: A4;
    margin: 0.5cm;
  }
  
  #letterPreview {
    font-size: 10pt !important;
    padding: 1cm !important;
  }
}