/* Global responsive hardening
   Goal: eliminate horizontal overflow and make layouts/components scale cleanly on small screens
   across ALL templates (including ones with page-level styles). */

/* Safer box model everywhere */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Prevent accidental horizontal scrolling from fixed-width children */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Media should never overflow their containers */
img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

/* Long strings should wrap instead of pushing the viewport */
p,
h1,
h2,
h3,
h4,
h5,
h6,
li,
small,
label,
span,
a,
button {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Forms: avoid iOS zoom + keep controls within the viewport */
input,
textarea,
select,
button {
  max-width: 100%;
}

@media (max-width: 768px) {
  input,
  textarea,
  select {
    font-size: 16px;
  }
}

/* Tables/code blocks: allow horizontal scroll instead of breaking layout */
@media (max-width: 768px) {
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  pre {
    max-width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  code {
    white-space: pre-wrap;
  }
}

/* ========================================= */
/* Mobile-first layout + type scale (0-768px) */
/* ========================================= */

.label-mobile,
.mobile-only {
  display: none;
}

.label-desktop,
.mobile-hide {
  display: inline;
}

.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 768px) {
  body {
    font-size: 16px;
    line-height: 1.6;
  }

  h1,
  .h1 {
    font-size: 1.75rem;
    line-height: 1.3;
    letter-spacing: 0;
  }

  h2,
  .h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    letter-spacing: 0;
  }

  h3,
  .h3 {
    font-size: 1.25rem;
    line-height: 1.35;
    letter-spacing: 0;
  }

  h4,
  .h4 {
    font-size: 1.1rem;
    line-height: 1.4;
    letter-spacing: 0;
  }

  h5,
  .h5,
  h6,
  .h6 {
    font-size: 1rem;
    line-height: 1.45;
    letter-spacing: 0;
  }

  p {
    margin-bottom: 0.75rem;
  }

  small,
  .text-xs,
  .text-sm {
    font-size: 0.875rem;
  }

  .label-mobile,
  .mobile-only {
    display: inline;
  }

  .label-desktop,
  .mobile-hide {
    display: none;
  }

  .page,
  .page-grid,
  .page-grid > * {
    max-width: 100%;
    width: 100%;
  }

  .page-grid,
  .dashboard-grid,
  .card-grid,
  .team-card-grid,
  .user-card-grid,
  .team-cards-grid,
  .user-cards-grid,
  .network-grid,
  .resume-compare-grid,
  .match-grid {
    grid-template-columns: 1fr !important;
  }

  .card,
  .team-card,
  .user-card,
  .network-panel,
  .team-card-modern,
  .user-card-modern {
    padding: 1rem;
    border-radius: 16px;
  }

  .card__header,
  .card__footer {
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .card__footer {
    padding-top: 0.75rem;
    margin-top: 0.75rem;
  }

  .team-card__description,
  .notification-item__subtitle,
  .network-card__meta,
  .dashboard-section-subtitle,
  .page-header__subtitle,
  .settings-subtitle,
  .resume-editor-cta__text p,
  .work-profile-header__content p,
  .wp-accordion-trigger__text p {
    display: none;
  }

  .team-card__cta,
  .btn.btn-block,
  .form-actions .btn,
  .form-actions .auth-button {
    width: 100%;
    justify-content: center;
  }

  .team-card__skills,
  .skill-chips {
    gap: 0.35rem;
  }

  .team-card__meta,
  .team-card-modern__meta,
  .user-location {
    font-size: 0.875rem;
  }

  .team-card__title,
  .team-card-modern__header h4,
  .user-card-modern__info h4,
  .match-card__name,
  .team-drawer__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .network-scroll {
    flex-direction: column;
  }

  .network-card {
    flex: 1 1 auto;
    width: 100%;
  }

  .user-card-modern__avatar {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
  }

  .user-avatar--clean {
    width: 48px;
    height: 48px;
  }

  .user-summary {
    -webkit-line-clamp: 2;
  }

  .match-card__avatar {
    width: 40px;
    height: 40px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-input,
  .form-select,
  .form-textarea,
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
    padding: 0.875rem 1rem;
  }

  .form-actions {
    flex-direction: column;
    gap: 0.75rem;
    justify-content: flex-start;
  }

  .wp-checkbox-grid {
    grid-template-columns: 1fr;
  }

  .btn,
  .auth-button {
    min-height: 48px;
    font-size: 1rem;
  }

  .btn-sm {
    min-height: 44px;
  }
}

/* ========================================= */
/* Mobile: Edge-to-edge layout + fixed nav */
/* ========================================= */
@media (max-width: 768px) {
  /* Remove ALL left/right padding and margin from containers */
  .app-container,
  .main-content,
  .main-content__body,
  body.is-mobile .main-content__body,
  body.is-mobile.app-shell .main-content__body,
  .dashboard-page,
  .dashboard-shell,
  .page,
  .mobile-page {
    padding-top: 0 !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
    padding-right: 0 !important;
    margin-right: 0 !important;
  }

  /* Override desktop margin-left for main-content */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Add padding to content elements instead */
  .card,
  .hub-card,
  .dashboard-card,
  .settings-layout,
  .network-section,
  .content-section,
  .teams-surface,
  .dashboard-page > *:not(.dashboard-navbar) {
    margin-left: 0.75rem;
    margin-right: 0.75rem;
  }

  /* Dashboard navbar container edge-to-edge */
  .dashboard-navbar__container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    margin-left: 0;
    margin-right: 0;
  }

  /* Settings page */
  .settings-nav,
  .settings-main {
    margin-left: 0.75rem;
    margin-right: 0.75rem;
  }

  /* Page headers */
  .page-header {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Ensure content doesn't hide behind fixed bottom nav */
  .main-content__body {
    padding-bottom: calc(64px + var(--safe-area-bottom, 0px)) !important;
  }

  /* Dashboard content offset for fixed navbar */
  .dashboard-navbar + .mobile-page {
    padding-top: 60px !important;
  }

  /* Full-width sections that should be edge-to-edge */
  .bottom-nav,
  .sidebar-fixed {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }
}
