/**
 * Cross-browser layout fixes — WeChat WebView, iOS Safari, legacy flex gap.
 * Works with .ua-* classes set by browser_compat.js
 */

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

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Portal site footer — legal + version only; no slogan (hero already has it) */
.main-footer.site-footer {
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  background: #fff;
  border-top: 1px solid rgba(10, 31, 51, 0.1);
  color: #5c6f82;
}
.main-footer.site-footer .site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1.25rem;
  max-width: 100%;
}
.main-footer.site-footer .site-footer-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.85rem;
  min-width: 0;
  flex: 1 1 16rem;
}
.main-footer.site-footer .site-footer-legal strong {
  color: #0a1f33;
  font-weight: 600;
  margin: 0;
}
.main-footer.site-footer .site-footer-legal a {
  color: #5c6f82;
  text-decoration: none;
  white-space: nowrap;
}
.main-footer.site-footer .site-footer-legal a:hover {
  color: #1a7a8c;
}
.main-footer.site-footer .site-footer-build {
  flex: 0 0 auto;
  margin: 0;
  float: none !important;
  font-size: 0.72rem;
  color: #5c6f82;
  white-space: nowrap;
}
.main-footer.site-footer .site-footer-build-label {
  margin-right: 0.35rem;
  font-weight: 600;
  color: #1e4a6e;
}
.main-footer.site-footer .site-footer-build code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  background: transparent;
  color: #1e4a6e;
  padding: 0;
}
@media (max-width: 575.98px) {
  .main-footer.site-footer .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .main-footer.site-footer .site-footer-build {
    order: -1;
  }
}

/* Safe area (notch / home indicator) */
@supports (padding: env(safe-area-inset-top)) {
  .main-header.navbar {
    padding-top: env(safe-area-inset-top);
  }
  .main-footer.no-print {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }
}

/* WeChat: reduce tap delay / highlight */
.ua-wechat a,
.ua-wechat button,
.ua-wechat .btn {
  -webkit-tap-highlight-color: rgba(0, 123, 255, 0.15);
}

/* flex gap fallback (Safari < 14.1, some embedded WebViews) */
.no-flex-gap .home-hero .brand-row > * + * {
  margin-left: 1rem;
  margin-top: 0.5rem;
}
.navbar-site-search .form-control {
  width: 9.5rem;
  max-width: 28vw;
}
@media (min-width: 1200px) {
  .navbar-site-search .form-control {
    width: 12rem;
  }
}
.navbar-site-search {
  position: relative;
}
.navbar-search-suggest {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 16rem;
  max-width: min(22rem, 90vw);
  margin-top: 0.15rem;
  z-index: 1050;
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.25rem 0;
}
.navbar-search-suggest.show:not([hidden]) {
  display: block;
}
.navbar-search-suggest-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  white-space: normal;
  line-height: 1.25;
}
.navbar-search-suggest-item .suggest-type {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: #6c757d;
  text-transform: uppercase;
  min-width: 3.2rem;
}
.navbar-search-suggest-item .suggest-title {
  flex: 1 1 auto;
  font-size: 0.875rem;
}

.no-flex-gap .navbar-toolbar .nav-link i + .toolbar-label {
  margin-left: 0.35rem;
}
.no-flex-gap .ops-embed-toolbar > * + * {
  margin-left: 0.5rem;
}
.no-flex-gap .navbar-nav.ml-auto > .nav-item + .nav-item,
.no-flex-gap .navbar-toolbar > * + * {
  margin-left: 0.25rem;
}
.no-flex-gap .ops-fold > summary > * + *,
.no-flex-gap .ops-machine > summary > * + * {
  margin-left: 0.35rem;
}
.no-flex-gap .ops-bars > * + * {
  margin-left: 6px;
}
.no-flex-gap .ops-metric-grid > * {
  margin-right: 0.85rem;
  margin-bottom: 0.35rem;
}
.no-flex-gap .d-flex[style*="gap"] > * + *,
.no-flex-gap .interaction-bar .d-flex > * + * {
  margin-left: 0.5rem;
}
.no-flex-gap .about-hero > * + * {
  margin-left: 1.25rem;
}
.no-flex-gap .home-feature-row > * + *,
.no-flex-gap .portal-home-cards > * + * {
  margin-left: 0.65rem;
}

/* No fetch / Promise: hide features that require modern XHR helpers */
.ua-no-fetch .js-requires-fetch {
  display: none !important;
}

/* Dynamic viewport — prefer --app-vh from JS, then dvh, then vh */
.ops-embed-frame-wrap iframe {
  height: calc(var(--app-vh, 1vh) * 100 - 220px);
  min-height: calc(var(--app-vh, 1vh) * 70);
}
@supports (height: 100dvh) {
  .ops-embed-frame-wrap iframe {
    height: calc(100dvh - 220px);
    min-height: 70dvh;
  }
}
.ua-ios .ops-embed-frame-wrap iframe {
  min-height: -webkit-fill-available;
}

/* iframe embed wrapper */
.ops-embed-frame-wrap {
  -webkit-overflow-scrolling: touch;
}

/* Legacy IE banner spacing */
.portal-browser-banner {
  position: sticky;
  top: 0;
  z-index: 1050;
}

/* Print QR / canvas — avoid overflow on narrow WebViews */
@media (max-width: 575.98px) {
  .print-qr-box {
    max-width: 100%;
  }
}

/* Reduce motion for users / systems that prefer it */
@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;
  }
}

/* Touch / high-DPI: avoid 300ms-feel; keep focus rings for keyboard */
.ua-ios button,
.ua-android button,
.ua-wechat button,
.ua-ios .btn,
.ua-android .btn,
.ua-wechat .btn {
  touch-action: manipulation;
}

/* Firefox / non-WebKit scrollbars (cosmetic; -webkit-scrollbar ignored there) */
@supports not selector(::-webkit-scrollbar) {
  .sidebar,
  .table-responsive {
    scrollbar-width: thin;
    scrollbar-color: rgba(27, 58, 90, 0.35) transparent;
  }
}

/* Android WebView: prevent input zoom jump when font-size < 16px on focus */
@media (max-width: 767.98px) {
  .ua-android input.form-control,
  .ua-android select.form-control,
  .ua-android textarea.form-control,
  .ua-ios input.form-control,
  .ua-ios select.form-control,
  .ua-ios textarea.form-control {
    font-size: 16px;
  }
}
