/* ==========================================================================
   RICHER PLATFORM — MOBILE-FIRST RESPONSIVE DESIGN SYSTEM
   Fluid Layouts (%) | Flexbox & CSS Grid | 48x48px Touch Targets | Auto-Images
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. UNIVERSAL FLUID BASE & TOUCH ESSENTIALS (Mobile-First)
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: rgba(123, 47, 247, 0.16);
}

:root {
  /* Fluid Spacing (Scales with viewport width) */
  --spacing-fluid-xs: clamp(0.25rem, 0.5vw, 0.375rem);
  --spacing-fluid-sm: clamp(0.5rem, 1vw, 0.75rem);
  --spacing-fluid-md: clamp(0.875rem, 1.5vw, 1.25rem);
  --spacing-fluid-lg: clamp(1.25rem, 2.5vw, 1.75rem);
  --spacing-fluid-xl: clamp(1.75rem, 3.5vw, 2.5rem);
  --spacing-fluid-2xl: clamp(2.25rem, 5vw, 3.5rem);

  /* Fluid Typography */
  --font-fluid-h1: clamp(1.85rem, 4.5vw + 0.5rem, 3.25rem);
  --font-fluid-h2: clamp(1.5rem, 3.2vw + 0.4rem, 2.4rem);
  --font-fluid-h3: clamp(1.25rem, 2.2vw + 0.3rem, 1.85rem);
  --font-fluid-body: clamp(0.95rem, 0.8vw + 0.75rem, 1.05rem);

  /* Minimum WCAG AAA Touch Target Boundary */
  --touch-target-min: 48px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-size: var(--font-fluid-body);
  line-height: 1.6;
}

/* Fluid Typography Application */
h1 { font-size: var(--font-fluid-h1); line-height: 1.2; }
h2 { font-size: var(--font-fluid-h2); line-height: 1.25; }
h3 { font-size: var(--font-fluid-h3); line-height: 1.3; }

/* Fluid Percentage Container */
.container {
  width: 100%;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(16px, 4%, 32px);
  padding-right: clamp(16px, 4%, 32px);
}

/* --------------------------------------------------------------------------
   2. FLUID IMAGES & MEDIA AUTO-RESIZING
   -------------------------------------------------------------------------- */
img, picture, video, canvas, svg {
  max-width: 100% !important;
  height: auto;
  vertical-align: middle;
}

img {
  object-fit: cover;
  image-rendering: auto;
}

/* Aspect Ratio Utilities for Fluid Video & Cards */
.responsive-media-16-9 {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.responsive-media-4-3 {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.responsive-media-square {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* --------------------------------------------------------------------------
   3. UNIVERSAL 48x48px TOUCH TARGETS & VISUAL FEEDBACK (WCAG 2.1 AAA)
   -------------------------------------------------------------------------- */

/* Buttons & CTAs */
button,
.btn,
.cta-button,
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-ghost,
.auth-btn-login,
.auth-btn-signup,
.app-store-btn {
  min-height: var(--touch-target-min) !important;
  min-width: var(--touch-target-min) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  touch-action: manipulation;
  user-select: none;
  cursor: pointer;
}

/* Touch Input Visual Feedback (:active) */
button:active,
.btn:active,
.cta-button:active,
.auth-btn-login:active,
.auth-btn-signup:active,
.social-link:active,
.mobile-toggle:active,
.accordion-header:active {
  transform: scale(0.96) !important;
  transition: transform 0.08s cubic-bezier(0, 0, 0.2, 1) !important;
}

/* Focus Visible for Accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary-color, #7B2FF7) !important;
  outline-offset: 3px !important;
}

/* Mobile Toggle Hamburger Button (Minimum 48x48px Touch Area) */
.mobile-toggle {
  min-width: var(--touch-target-min) !important;
  min-height: var(--touch-target-min) !important;
  width: var(--touch-target-min) !important;
  height: var(--touch-target-min) !important;
  padding: 12px 8px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer;
  z-index: 102;
  position: relative;
  touch-action: manipulation;
}

/* Navigation Links (Minimum 48px Height on Touch) */
.nav-link,
.nav-dropdown li a {
  min-height: var(--touch-target-min) !important;
  display: flex !important;
  align-items: center !important;
  touch-action: manipulation;
}

/* Pagination Links (Minimum 48x48px Touch Box) */
.pagination a,
.pagination span,
.page-link {
  min-width: var(--touch-target-min) !important;
  min-height: var(--touch-target-min) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 12px !important;
  touch-action: manipulation;
}

/* Social & Icon Links (Minimum 48x48px Touch Target) */
.social-link,
.footer-socials a,
.contact-icon,
.about-feature-icon {
  min-width: var(--touch-target-min) !important;
  min-height: var(--touch-target-min) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  touch-action: manipulation;
}

.scroll-to-top {
  min-width: 50px !important;
  min-height: 50px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  touch-action: manipulation;
}

/* Form Inputs & Touch Usability */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  min-height: var(--touch-target-min) !important;
  font-size: 16px !important; /* Prevents unwanted auto-zoom on iOS Safari */
  padding: 12px 16px !important;
  width: 100% !important;
  border-radius: 10px;
  touch-action: manipulation;
}

/* Checkbox & Radio Touch Hit Areas */
input[type="checkbox"],
input[type="radio"] {
  min-width: 22px !important;
  min-height: 22px !important;
  cursor: pointer;
  accent-color: var(--primary-color, #7B2FF7);
}

.checkbox-label,
.radio-label {
  min-height: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

/* Accordion Questions (Minimum 48px Height) */
.accordion-header {
  min-height: var(--touch-target-min) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 14px 18px !important;
  touch-action: manipulation;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   4. PERCENTAGE & FLEXBOX FLUID LAYOUT UTILITIES
   -------------------------------------------------------------------------- */
.row-fluid {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  margin-left: -12px;
  margin-right: -12px;
}

.col-fluid-12 { flex: 0 0 100%; max-width: 100%; padding: 12px; }
.col-fluid-6  { flex: 0 0 50%;  max-width: 50%;  padding: 12px; }
.col-fluid-4  { flex: 0 0 33.333%; max-width: 33.333%; padding: 12px; }
.col-fluid-3  { flex: 0 0 25%;  max-width: 25%;  padding: 12px; }

/* --------------------------------------------------------------------------
   5. BREAKPOINT: MOBILE PORTRAIT & COMPACT PHONES (max-width: 576px)
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  /* Fluid Container on compact screens */
  .container {
    padding-left: 14px;
    padding-right: 14px;
  }

  /* Full Stack Layouts */
  .col-fluid-6,
  .col-fluid-4,
  .col-fluid-3 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Header & Navigation */
  .header {
    padding: 10px 0;
  }

  .logo img {
    max-height: 44px;
    width: auto;
  }

  .nav-menu {
    position: fixed;
    top: 64px;
    left: 0;
    width: 100%;
    background: #ffffff;
    flex-direction: column;
    padding: 16px 12px 24px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 20px 20px;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
  }

  .nav-menu.active {
    max-height: calc(100vh - 64px);
    opacity: 1;
    visibility: visible;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    width: 100%;
    border-bottom: 1px solid var(--border-color, #e8e4f5);
  }

  .nav-link {
    padding: 14px 16px;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
  }

  .nav-auth-mobile {
    display: block !important;
    width: 100%;
    padding: 16px 0 0 0;
    margin-top: 10px;
  }

  .nav-auth-mobile .auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .nav-auth-mobile .auth-buttons a {
    width: 100%;
    min-height: 48px;
    font-size: 0.95rem;
  }

  .cta-button {
    display: none !important; /* Replaced by touch-optimized mobile drawer buttons */
  }

  /* Hero Section */
  .hero {
    padding: clamp(24px, 6vw, 44px) 0;
    text-align: center;
  }

  .hero-buttons {
    flex-direction: column !important;
    width: 100%;
    gap: 12px;
  }

  .hero-buttons .btn {
    width: 100% !important;
  }

  /* Grids & Cards: 100% Fluid Width */
  .courses-grid,
  .testimonials-grid,
  .impact-grid,
  .about-content,
  .founder-content,
  .team-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    gap: 18px !important;
  }

  .course-card,
  .plan-card,
  .testimonial-card,
  .team-card {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Checkout Grid (Eliminate horizontal scroll) */
  .checkout-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 20px !important;
  }

  .checkout-grid > div {
    width: 100% !important;
  }

  /* Footer Stack */
  .footer-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
    text-align: center;
  }

  .footer-socials {
    justify-content: center !important;
  }

  .contact-info {
    justify-content: center !important;
    text-align: center !important;
  }

  /* Modals */
  .modal-content {
    width: 95% !important;
    max-width: 95% !important;
    margin: 12px auto !important;
    padding: 20px 16px !important;
  }

  /* Tables: Fluid Horizontal Scroll with touch inertia */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    border-radius: 8px;
  }

  .table-responsive table {
    min-width: 520px;
  }
}

/* --------------------------------------------------------------------------
   6. BREAKPOINT: PHABLETS & TABLETS PORTRAIT (577px to 768px)
   -------------------------------------------------------------------------- */
@media (min-width: 577px) and (max-width: 768px) {
  .col-fluid-6 { flex: 0 0 50%; max-width: 50%; }
  .col-fluid-4,
  .col-fluid-3 { flex: 0 0 50% !important; max-width: 50% !important; }

  /* 2-Column Responsive Card Grids */
  .courses-grid,
  .team-grid,
  .impact-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  .checkout-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
  }

  /* Mobile Drawer Menu on 768px */
  .nav-menu {
    position: fixed;
    top: 68px;
    left: 0;
    width: 100%;
    background: #ffffff;
    flex-direction: column;
    padding: 16px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 20px 20px;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: all 0.35s ease;
    z-index: 100;
  }

  .nav-menu.active {
    max-height: calc(100vh - 68px);
    opacity: 1;
    visibility: visible;
    overflow-y: auto;
  }

  .cta-button {
    display: none !important;
  }

  .nav-auth-mobile {
    display: block !important;
    padding-top: 14px;
  }

  .nav-auth-mobile .auth-buttons {
    display: flex;
    gap: 12px;
  }

  .nav-auth-mobile .auth-buttons a {
    flex: 1;
    min-height: 48px;
  }

  .footer-content {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px !important;
  }
}

/* --------------------------------------------------------------------------
   7. BREAKPOINT: TABLETS LANDSCAPE & SMALL LAPTOPS (769px to 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 769px) and (max-width: 1024px) {
  .mobile-toggle {
    display: none !important;
  }

  .nav-menu {
    display: flex !important;
    position: static !important;
    max-height: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: transparent !important;
    box-shadow: none !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: clamp(12px, 1.8vw, 24px) !important;
  }

  .nav-auth-mobile {
    display: none !important;
  }

  .cta-button {
    display: inline-flex !important;
    min-height: 48px !important;
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
  }

  .courses-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
  }

  .checkout-grid {
    display: grid !important;
    grid-template-columns: 1fr 320px !important;
    gap: 24px !important;
  }

  .about-content,
  .founder-content {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 24px !important;
  }

  .footer-content {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px !important;
  }
}

/* --------------------------------------------------------------------------
   8. BREAKPOINT: DESKTOPS & WIDESCREEN DISPLAYS (min-width: 1025px)
   -------------------------------------------------------------------------- */
@media (min-width: 1025px) {
  .mobile-toggle {
    display: none !important;
  }

  .nav-menu {
    display: flex !important;
    gap: var(--spacing-fluid-lg) !important;
    list-style: none !important;
    align-items: center !important;
  }

  .nav-auth-mobile {
    display: none !important;
  }

  .cta-button {
    display: inline-flex !important;
    min-height: 52px !important;
    padding: 12px 28px !important;
  }

  /* Multi-column grid on desktop */
  .courses-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 28px !important;
  }

  .checkout-grid {
    display: grid !important;
    grid-template-columns: 1fr 360px !important;
    gap: 32px !important;
  }

  .team-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 24px !important;
  }

  .footer-content {
    display: grid !important;
    grid-template-columns: 2fr 1fr 1fr 1.5fr !important;
    gap: 36px !important;
  }

  /* Desktop Hover Interactions */
  .btn:hover,
  .cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(123, 47, 247, 0.35);
  }

  .course-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  }
}

/* --------------------------------------------------------------------------
   9. ACCESSIBILITY & DEVICE HARDWARE ADAPTATIONS
   -------------------------------------------------------------------------- */

/* Touch-Only Device Rules (Phones & Tablets) */
@media (hover: none) and (pointer: coarse) {
  /* Enforce touch target limits even if CSS specificity conflicts */
  a, button, input, select, textarea, .nav-link, .pagination a {
    min-height: var(--touch-target-min);
  }

  /* Remove sticky desktop hover states on touch */
  .btn:hover,
  .course-card:hover,
  .team-card:hover {
    transform: none !important;
  }
}

/* Reduced Motion Preference (Vestibular Disorder Support) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Modern Device Notch & Safe Area Support (iPhone X/12/13/14/15/16) */
@supports (padding: max(0px)) {
  .header {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .scroll-to-top {
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
  }
}
