/* Smart Property Platform 1.3.95: mobile-only canvas normalization.
   This file is loaded after other SPP styles, never on other plugins' admin pages.
   Intent: full viewport-width SPP shell, consistent 12px internal breathing room,
   self-contained scrolling for genuinely wide tabular data. No global overflow clip. */
@media screen and (max-width:767px) {
  /* Logged-in private portal and institutional home. Their viewport position is
     calculated by layout-unified.js to neutralize narrow WordPress theme wrappers. */
  body .sj-portal,
  body .spp-home {
    box-sizing:border-box!important;
    width:100vw!important;
    max-width:100vw!important;
    min-width:0!important;
    margin:8px 0 20px!important;
    padding:0 12px 24px!important;
  }
  body .sj-portal > *, body .spp-home > * {min-width:0;max-width:100%;box-sizing:border-box;}
  body .sj-portal :is(.sj-header,.sj-nav,.sj-grid,.sj-cards,.sj-panel,.sj-form,
    .sj-student-switch,.spp-student-profile,.spp-profile-focus,.spp-profile-form-grid,
    .spp-profile-form-actions,.spp-identity-card),
  body .spp-home :is(.spp-home-hero,.spp-home-hero-copy,.spp-home-hero-actions,
    .spp-home-feature,.spp-home-intro-grid,.spp-home-stats,.spp-home-links,
    .spp-home-section,.spp-home-link,.spp-home-stat,.spp-ai-home-section) {
    min-width:0;max-width:100%;box-sizing:border-box;
  }
  /* Compact internal spacing; the 12px outer padding is not a width loss. */
  body .sj-portal :is(.sj-header,.sj-card:not(.sj-card-visual),.sj-panel,
    .sj-login-card,.sj-student-switch) {padding:14px;}
  body .sj-portal .spp-student-profile {padding:12px;}
  body .sj-portal :is(.spp-profile-card,.spp-profile-edit) {padding:14px;}
  body .spp-home :is(.spp-home-hero,.spp-home-feature,
    .spp-home-stat:not(.spp-home-stat--visual),
    .spp-home-link:not(.spp-home-link--visual)) {padding:16px;}
  body .spp-home .spp-home-hero {gap:14px;}
  body .spp-home .spp-home-section {margin-top:18px;}
  body .spp-home :is(.spp-home-btn,.spp-home-hero-actions a) {
    max-width:100%;min-width:0;white-space:normal;overflow-wrap:break-word;text-align:center;
  }
  body .sj-portal :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
  body .spp-home :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
  body .spp-access-page :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
    box-sizing:border-box;max-width:100%;min-width:0;
  }
  /* Keep native tables intact: scroll *inside* the relevant SPP panel, not page. */
  body .sj-portal :is(.sj-panel,.sj-table-wrap) {
    max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch;
  }
  body .sj-portal :is(.sj-details dd,.spp-identity-card__email,.sj-notice),
  body .spp-home :is(.spp-home-hero-copy,.spp-home-link-body) {
    min-width:0;overflow-wrap:break-word;
  }
  /* Authentication/recovery screens are SPP screens but have separate shells. */
  body .spp-access-page {
    box-sizing:border-box;width:100%;max-width:100%;min-width:0;
    margin:0;padding:8px 12px 20px;
  }
  body .spp-access-page .spp-access-shell {
    box-sizing:border-box;width:100%;max-width:100%;min-width:0;
    padding:18px 14px;
  }
  body .spp-access-page :is(.spp-access-grid,.spp-access-form,.spp-access-brand) {
    min-width:0;max-width:100%;
  }
  /* Scoped WP-admin screens: never apply these rules to unrelated plugins. */
  body.wp-admin :is(.wrap.hop-wrap,.hop-wrap:not(.hop-wrap .hop-wrap),
    .hop-documents:not(.hop-wrap .hop-documents),
    .spp-admin-shell:not(.hop-wrap .spp-admin-shell),.spp-portal-admin) {
    box-sizing:border-box!important;width:100%!important;max-width:100%!important;
    min-width:0!important;margin-left:0!important;margin-right:0!important;
    padding-left:10px!important;padding-right:10px!important;
  }
  body.wp-admin :is(.hop-wrap,.spp-admin-shell,.spp-portal-admin)
    :is(.hop-grid,.hop-card,.hop-section,.hop-form,.hop-form-grid,.hop-floor-layout,
    .spp-portal-admin__group,.spp-portal-admin__records,.spp-portal-admin__record) {
    min-width:0;max-width:100%;box-sizing:border-box;
  }
  body.wp-admin :is(.hop-wrap,.spp-admin-shell,.spp-portal-admin)
    :is(.hop-form,.hop-card,.spp-portal-admin__record) {padding:14px;}
  body.wp-admin :is(.hop-wrap,.spp-admin-shell,.spp-portal-admin)
    :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
    box-sizing:border-box;max-width:100%;min-width:0;
  }
  body.wp-admin :is(.hop-wrap,.spp-admin-shell,.spp-portal-admin)
    :is(.hop-section,.hop-table,.spp-table-scroll) {
    max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch;
  }
  /* Narrow tab headers, labels and emails may wrap; no arbitrary word break. */
  body .sj-portal :is(.sj-nav-label,.sj-portal-title),
  body.wp-admin :is(.hop-wrap,.spp-portal-admin) :is(.hop-page-heading,.hop-lead) {
    overflow-wrap:break-word;word-break:normal;
  }
}
