/**
 * edtech-eg.com homepage - production mobile overrides
 * Loaded last to normalize earlier legacy and marketplace rules.
 */

@media (max-width: 768px) {
  html {
    width: 100%;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
  }

  body {
    width: 100%;
    min-width: 0;
    overflow-x: clip;
  }

  body > *,
  main,
  section,
  .container {
    min-width: 0;
    max-width: 100%;
  }

  /* Header: compact, readable and usable with one thumb. */
  .top-nav {
    width: 100% !important;
    padding: 10px 14px !important;
    gap: 10px !important;
  }

  .top-nav-brand-group {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    align-items: center !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .top-nav-brand-group .brand-logo {
    width: auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
  }

  .ai-subject-badge-wrap {
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  .ai-subject-badge {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 6px 10px !important;
    justify-content: center !important;
  }

  .ai-subject-badge .badge-title {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .nav-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    align-items: center !important;
    width: 100% !important;
    gap: 8px !important;
    margin: 0 !important;
  }

  .nav-actions > a {
    min-height: 44px !important;
    margin: 0 !important;
  }

  .nav-actions .btn-explore {
    width: 100% !important;
    min-width: 0 !important;
  }

  .nav-actions .icon-btn {
    width: 44px !important;
    height: 44px !important;
  }

  .sub-nav {
    width: 100% !important;
    min-height: 56px !important;
    padding: 6px 14px !important;
    gap: 0 !important;
  }

  .sub-nav .nav-menu {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .sub-nav .nav-menu li,
  .sub-nav .nav-menu a {
    width: 100% !important;
    min-width: 0 !important;
  }

  .sub-nav .nav-menu a {
    min-height: 44px !important;
    padding: 8px 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1.25 !important;
  }

  /* Search and filters: prevent the 24-26px controls measured on mobile. */
  .search-hero {
    width: calc(100% - 28px) !important;
    margin-inline: 14px !important;
    padding: 14px !important;
  }

  .search-hero form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .search-hero input,
  .search-hero button,
  .filter-select,
  .btn-filter-apply,
  .btn-filter-reset {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
    font-size: 16px !important;
  }

  .filters-panel {
    width: 100% !important;
    padding: 0 14px !important;
    margin: 0 0 20px !important;
  }

  .filters-bar {
    width: 100% !important;
    padding: 14px !important;
    gap: 10px !important;
    margin: 0 !important;
  }

  .track-chips {
    width: 100% !important;
    padding: 2px 14px 8px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .track-chips::-webkit-scrollbar { display: none; }
  .track-chip { min-height: 44px !important; flex: 0 0 auto !important; }

  .results-bar {
    width: calc(100% - 28px) !important;
    margin-inline: 14px !important;
    padding: 12px !important;
    gap: 10px !important;
  }

  /* Teacher cards: fluid columns and 44px actions, including 320px devices. */
  .instructors-grid {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 36px !important;
    padding: 0 14px !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 16px !important;
  }

  .inst-card,
  .card-header,
  .card-body,
  .card-actions {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .card-header { padding: 16px 12px 14px !important; }
  .card-header-info h3 {
    white-space: normal !important;
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis !important;
  }

  .card-body { padding: 14px 12px 16px !important; }
  .card-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    padding: 8px 0 0 !important;
    margin: 0 !important;
  }

  .btn-profile {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    height: auto !important;
    padding: 8px !important;
    white-space: normal !important;
    line-height: 1.25 !important;
  }

  .btn-profile.details {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-height: 44px !important;
    height: auto !important;
  }

  /* Content sections: remove legacy negative offsets and oversized padding. */
  .enterprise-sections,
  .section-categories,
  .section-how,
  .section-testimonials,
  .section-cta {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
  }

  .specialty-highlights,
  .section-how,
  .section-testimonials,
  .section-cta { padding-inline: 14px !important; }

  .specialty-highlights-heading {
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .specialty-rank-card {
    width: 100% !important;
    min-width: 0 !important;
    padding: 14px 12px !important;
    gap: 10px !important;
  }

  .timeline-container,
  .masonry-testimonials {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  .timeline-step,
  .testi-glass-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    transform: none !important;
    box-sizing: border-box !important;
  }

  .testi-glass-card { padding: 22px !important; }
  .enterprise-cta-banner { padding: 26px 20px !important; }
  .enterprise-cta-banner .btn-large { min-height: 48px !important; }

  .enterprise-footer { padding-top: 48px !important; }
  .footer-grid {
    width: 100% !important;
    padding-inline: 18px !important;
    gap: 26px !important;
    margin-bottom: 36px !important;
  }

  .footer-grid a { min-height: 40px; display: inline-flex; align-items: center; }

  .card-modal-overlay { padding: 0 !important; align-items: flex-end !important; }
  .card-modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88dvh !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  :where(a, button, input, select):focus-visible {
    outline: 3px solid #38bdf8 !important;
    outline-offset: 2px !important;
  }
}

@media (max-width: 360px) {
  .ai-subject-badge .badge-tag { display: none !important; }
  .ai-subject-badge { font-size: .76rem !important; }
  .top-nav-brand-group .brand-logo { font-size: .92rem !important; }
  .nav-actions .top-nav-text { display: none !important; }
  .nav-actions { grid-template-columns: minmax(0, 1fr) 44px !important; }
  .card-avatar,
  .card-avatar-wrap { width: 50px !important; height: 50px !important; }
  .card-header-info h3 { font-size: .98rem !important; }
  .specialty-rank-number { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
