/* ================================================================
   AGE CALCULATOR - MOBILE ENHANCEMENTS
   Critical mobile optimizations for better UX
   ================================================================ */

/* ===== MOBILE-FIRST IMPROVEMENTS ===== */

/* Larger touch targets for mobile */
@media (max-width: 768px) {
  /* Enhanced Input Fields */
  .agec-input {
    min-height: 56px !important;
    font-size: 1.05rem !important;
    padding: 1rem !important;
    border-width: 2px;
    transition: all 0.2s ease;
  }

  .agec-input:focus {
    transform: translateY(-1px);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15) !important;
  }

  .agec-input.has-value {
    border-color: #10b981;
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
  }

  /* Larger Buttons */
  .agec-btn {
    min-height: 56px !important;
    font-size: 1.1rem !important;
    padding: 1rem 1.5rem !important;
    font-weight: 700;
  }

  .agec-btn-primary {
    width: 100%;
    font-size: 1.15rem !important;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
  }

  .agec-btn-primary:hover:not(:disabled),
  .agec-btn-primary:focus:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(59, 130, 246, 0.4);
  }

  /* Compact Header */
  .site-header {
    padding: 0.5rem 1rem !important;
  }

  body.tools-page .header-wrap {
    padding: 0.5rem 0.75rem !important;
  }

  .logo {
    font-size: 1rem !important;
  }

  .logo img {
    height: 28px !important;
  }

  /* Hide secondary CTA on mobile */
  .cta-button:not(:last-child) {
    display: none;
  }

  /* Readable Typography */
  body {
    font-size: 1rem;
  }

  .agec-hero h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem) !important;
    line-height: 1.2;
    margin-bottom: 0.75rem;
  }

  .agec-hero p {
    font-size: 1.05rem !important;
    line-height: 1.6;
  }

  /* Single Column Layouts */
  .agec-tool-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }

  .agec-field-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .agec-results-panel {
    order: 2;
  }

  /* Simplified Hero */
  .agec-hero {
    padding: 1.25rem 1rem !important;
    background: linear-gradient(135deg, #eef4ff 0%, #f8f5ff 100%);
  }

  .agec-badges {
    display: none; /* Hide on mobile to reduce clutter */
  }

  .agec-hero-links {
    font-size: 0.95rem;
  }
}

/* ===== STICKY CTA BUTTON (Mobile Only) ===== */
@media (max-width: 768px) {
  /* Create space for sticky bar */
  body {
    padding-bottom: 80px;
  }

  /* Sticky Action Bar */
  .agec-mobile-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,1));
    backdrop-filter: blur(10px);
    padding: 0.75rem 1rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 999;
    border-top: 1px solid rgba(59, 130, 246, 0.1);
    /* Safe area for iPhone notch */
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  .agec-mobile-action-bar .agec-btn-primary {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    display: block;
    min-height: 56px;
    border-radius: 16px;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    border: none;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .agec-mobile-action-bar .agec-btn-primary:active {
    transform: scale(0.98);
  }

  /* Hide original buttons when mobile bar is present */
  .agec-cta-row {
    display: none;
  }
}

/* ===== THUMB-FRIENDLY ZONES ===== */
@media (max-width: 768px) {
  /* Ensure tappable areas are at least 48x48 */
  button, a, input[type="checkbox"], input[type="radio"] {
    min-height: 48px;
    min-width: 48px;
  }

  /* Increase spacing for easier tapping */
  .agec-format-options label {
    padding: 0.75rem;
    min-height: 48px;
  }

  .agec-advanced label {
    padding: 0.75rem 0;
    min-height: 48px;
  }
}

/* ===== IMPROVED SCROLLING ===== */
@media (max-width: 768px) {
  /* Smooth scroll behavior */
  html {
    scroll-behavior: smooth;
  }

  body {
    -webkit-overflow-scrolling: touch;
  }

  /* Remove tap highlight */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Safe areas for notched devices */
  .agec-page {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* ===== ENHANCED FOCUS STATES (for keyboard users) ===== */
@media (max-width: 768px) {
  .agec-input:focus-visible,
  .agec-btn:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 2px;
  }
}

/* ===== LANDSCAPE MODE OPTIMIZATIONS ===== */
@media (max-width: 768px) and (orientation: landscape) {
  .agec-hero {
    padding: 1rem !important;
  }

  .agec-hero h1 {
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem;
  }

  .agec-hero p {
    font-size: 0.95rem !important;
  }

  .agec-mobile-action-bar {
    padding: 0.5rem 1rem;
  }
}

/* ===== TABLET ADJUSTMENTS (768px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
  .agec-tool-grid {
    grid-template-columns: 1fr !important;
    max-width: 700px;
    margin: 0 auto;
  }

  .agec-input,
  .agec-btn {
    min-height: 52px;
    font-size: 1.05rem;
  }
}

/* ===== ANIMATION FOR MOBILE ===== */
@media (max-width: 768px) {
  /* Fade in animation */
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .agec-mobile-action-bar {
    animation: fadeInUp 0.3s ease-out;
  }

  /* Slide in animation for results */
  @keyframes slideInRight {
    from {
      opacity: 0;
      transform: translateX(20px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  .agec-results.has-result {
    animation: slideInRight 0.4s ease-out;
  }
}

/* ===== REDUCED MOTION (Accessibility) ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
