/*
 * Ritremis mobile performance layer
 * Loaded last by every interactive layout.
 * It keeps the desktop design intact while reducing expensive paint,
 * blur, animation and oversized decoration work on phones/WebView.
 */

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

img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
a,
input,
select,
textarea,
[role="button"] {
  touch-action: manipulation;
}

.table-responsive,
.rr-trip-table-wrap,
.rr-res-table,
.rr-landowners-table,
.rr-history-table,
.rr-network-tabs,
.org-chart-viewport {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

@media (max-width: 991.98px) {
  html {
    scroll-behavior: auto !important;
  }

  html,
  body {
    overflow-x: hidden;
    background-attachment: scroll !important;
  }

  *,
  *::before,
  *::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background-attachment: scroll !important;
    will-change: auto !important;
  }

  /* Keep sticky bars opaque so the browser does not continuously blur them. */
  .rr-topbar,
  .rr-client-topbar,
  .rr-lo-topbar,
  .rr-public-header,
  .rr-auth-estate-header {
    background: var(--rr-surface, #ffffff) !important;
    box-shadow: 0 1px 0 var(--rr-border, #dce5f0) !important;
  }

  /* Keep portal sidebars lightweight. The internal staff sidebar is excluded
     so the shared Ritremis light/dark brand layer remains intact on mobile. */
  .rr-client-sidebar,
  .rr-lo-sidebar {
    background-image: none !important;
    background-color: #123b6d !important;
    box-shadow: none !important;
  }

  body.rr-app-body .rr-sidebar {
    box-shadow: none !important;
  }

  /* Remove non-essential skyline/ring decorations on the small viewport. */
  .rr-workspace-skyline,
  .rr-workspace-banner::before,
  .rr-client-workspace-banner::before,
  .rr-client-workspace-banner::after,
  .rr-lo-hero::before,
  .rr-lo-hero::after,
  .rr-users-toolbar::after,
  .rr-branch-toolbar::after,
  .rr-landowners-toolbar::after,
  .rr-clients-hero::after,
  .rr-trip-hero::after,
  .rr-res-hero::after,
  .rr-location-header::after,
  .rr-plan-head::after,
  .rr-client-page-hero::after,
  .rr-nearest-hero::after,
  .rr-access-heading::after {
    display: none !important;
  }

  .rr-client-workspace-banner img,
  .rr-auth-estate-property-glass {
    display: none !important;
  }

  /* Replace large layered shadows with one light mobile shadow. */
  .card,
  .modal-content,
  .dropdown-menu,
  .rr-workspace-banner,
  .rr-client-workspace-banner,
  .rr-lo-hero,
  .rr-auth-estate-panel-inner,
  .rr-module-frame > section,
  .rr-client-module-frame > section,
  .rr-users-card,
  .rr-branch-card,
  .rr-landowners-card,
  .rr-clients-panel,
  .rr-access-card,
  .rr-trip-list-card,
  .rr-res-table-card,
  .rr-plan-card,
  .rr-section-box,
  .rr-content-panel,
  .rr-client-panel,
  .rr-network-card,
  .org-chart-panel,
  .org-pool-panel {
    box-shadow: 0 4px 14px rgba(18, 59, 109, .07) !important;
  }

  /* Hover motion is not useful on touch devices and triggers extra paints. */
  .rr-nav a,
  .rr-client-nav a,
  .rr-lo-nav a,
  .rr-public-nav a,
  .rr-icon-btn,
  .rr-client-icon-button,
  .rr-lo-icon,
  .btn,
  .org-node-card,
  .org-chart-canvas,
  .modal.fade .modal-dialog,
  .collapsing {
    transition: none !important;
  }

  .rr-nav a:hover,
  .rr-client-nav a:hover,
  .rr-lo-nav a:hover,
  .org-node-card:hover {
    transform: none !important;
  }

  /* Prevent Android from zooming the whole page when a form field is focused. */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .rr-content,
  .rr-client-content,
  .rr-lo-content {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .rr-workspace-banner,
  .rr-client-workspace-banner,
  .rr-lo-hero {
    min-height: auto !important;
  }
}

@media (max-width: 767.98px) {
  /* Disable remaining decorative animation only on phone-sized screens. */
  .rr-workspace-banner *,
  .rr-client-workspace-banner *,
  .rr-lo-hero *,
  .rr-auth-estate-visual *,
  .rr-public-hero *,
  .rr-hero * {
    animation: none !important;
    transition: none !important;
  }

  .rr-module-frame,
  .rr-client-module-frame,
  .rr-lo-frame {
    min-width: 0;
  }

  .rr-module-frame table,
  .rr-client-module-frame table,
  .rr-lo-frame table {
    font-size: .84rem;
  }
}

/* The APK appends RitremisAndroid to the WebView user agent. */
html.rr-android-app *,
html.rr-android-app *::before,
html.rr-android-app *::after {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  background-attachment: scroll !important;
  will-change: auto !important;
}

html.rr-android-app .rr-workspace-skyline,
html.rr-android-app .rr-client-workspace-banner img,
html.rr-android-app .rr-auth-estate-property-glass {
  display: none !important;
}

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