/* ============================================================================
   ReticPro Field Lite — Mobile Phone Companion Stylesheet
   Thumb-first 100dvh layout, Sunlight Field Mode & Animated Hydraulic Flow
   ============================================================================ */

:root {
  --mob-bg: #0b1120;
  --mob-surface: rgba(15, 23, 42, 0.94);
  --mob-surface-solid: #0f172a;
  --mob-border: rgba(51, 65, 85, 0.85);
  --mob-text: #f1f5f9;
  --mob-muted: #94a3b8;
  --mob-safe-top: env(safe-area-inset-top, 0px);
  --mob-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--mob-bg);
  color: var(--mob-text);
  touch-action: manipulation;
}

.font-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* Full-Viewport Map Canvas */
#mobMap {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  z-index: 1;
  background: #0b1120;
}

.leaflet-container {
  background: #0b1120;
  font-family: 'Inter', system-ui, sans-serif;
}

/* Hide default Leaflet zoom buttons on phone (pinch-to-zoom + custom right-rail buttons) */
.leaflet-control-zoom {
  display: none !important;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(15, 23, 42, 0.68) !important;
  color: #94a3b8 !important;
  margin-bottom: calc(74px + var(--mob-safe-bottom)) !important;
  padding: 1px 5px !important;
  border-radius: 4px;
}

/* Top Compact Bar */
.mob-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  padding: calc(8px + var(--mob-safe-top)) 10px 8px;
  background: linear-gradient(180deg, rgba(11, 17, 32, 0.96) 0%, rgba(11, 17, 32, 0.88) 78%, rgba(11, 17, 32, 0) 100%);
  pointer-events: none;
}

.mob-topbar-inner {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mob-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 14px;
  background: var(--mob-surface);
  border: 1px solid var(--mob-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.mob-suite-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--mob-surface);
  border: 1px solid var(--mob-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.mob-suite-btn {
  border: none;
  border-radius: 9px;
  padding: 7px 4px;
  font-size: 11.5px;
  font-weight: 800;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
}

.mob-suite-btn.active[data-suite="water"]    { background: #0284c7; color: #fff; box-shadow: 0 2px 10px rgba(2, 132, 199, 0.45); }
.mob-suite-btn.active[data-suite="effluent"] { background: #059669; color: #fff; box-shadow: 0 2px 10px rgba(5, 150, 105, 0.45); }
.mob-suite-btn.active[data-suite="pacific"]  { background: #d97706; color: #fff; box-shadow: 0 2px 10px rgba(217, 119, 6, 0.45); }
.mob-suite-btn.active[data-suite="civil"]    { background: #4f46e5; color: #fff; box-shadow: 0 2px 10px rgba(79, 70, 229, 0.45); }

/* Live KPI Ribbon */
.mob-kpi-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 11px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(51, 65, 85, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 10.5px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Right-Side Map Controls (Basemap, Fit, Flow Toggle, Crosshair) */
.mob-map-fabs {
  position: fixed;
  right: 10px;
  top: calc(146px + var(--mob-safe-top));
  z-index: 1050;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mob-fab {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  border: 1px solid var(--mob-border);
  background: var(--mob-surface);
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.mob-fab:active { transform: scale(0.93); }
.mob-fab.is-on  { background: #0284c7; border-color: #38bdf8; color: #fff; }
.mob-fab.is-gps { background: #059669; border-color: #34d399; color: #fff; }

/* Center Aim Crosshair (shown when dropping pin by crosshair or tap-measuring) */
#mobCrosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1020;
  pointer-events: none;
  display: none;
}

#mobCrosshair.active {
  display: block;
}

/* Live Walk-the-Line Telemetry Banner */
#mobWalkHud {
  position: fixed;
  left: 10px;
  right: 64px;
  top: calc(146px + var(--mob-safe-top));
  z-index: 1060;
  display: none;
  border-radius: 14px;
  background: rgba(6, 78, 59, 0.94);
  border: 1.5px solid #34d399;
  padding: 10px 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}

#mobWalkHud.active {
  display: block;
}

/* Bottom Thumb Dock */
.mob-bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  padding: 8px 10px calc(8px + var(--mob-safe-bottom));
  background: var(--mob-surface-solid);
  border-top: 1px solid var(--mob-border);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.55);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mob-dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1px solid rgba(51, 65, 85, 0.85);
  background: #1e293b;
  color: #e2e8f0;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.mob-dock-btn:active { transform: scale(0.95); }
.mob-dock-btn .mob-dock-ico { font-size: 17px; line-height: 1; }
.mob-dock-btn.is-primary { background: #0284c7; border-color: #38bdf8; color: #fff; }
.mob-dock-btn.is-walk    { background: #059669; border-color: #34d399; color: #fff; }
.mob-dock-btn.is-active  { background: #f59e0b; border-color: #fcd34d; color: #0f172a; }

/* Slide-Up Bottom Sheet */
#mobSheetBackdrop {
  position: fixed;
  inset: 0;
  z-index: 1290;
  background: rgba(2, 6, 23, 0.48);
  display: none;
}
#mobSheetBackdrop.open { display: block; }

#mobSheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1300;
  max-height: 78dvh;
  background: #0f172a;
  border-top: 1.5px solid rgba(56, 189, 248, 0.45);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -16px 42px rgba(0, 0, 0, 0.72);
  transform: translateY(105%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(10px + var(--mob-safe-bottom));
}

#mobSheet.open {
  transform: translateY(0);
}

.mob-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: #475569;
  margin: 8px auto 4px;
  flex-shrink: 0;
}

#mobSheetBody {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 14px 14px;
  flex: 1;
}

/* Toast Banner */
#mobToast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + var(--mob-safe-bottom));
  transform: translateX(-50%) translateY(16px);
  z-index: 1400;
  max-width: calc(100vw - 24px);
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid #38bdf8;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}

#mobToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Map Node Badges & Live GPS Blue Dot */
.mob-node-marker {
  background: transparent !important;
  border: none !important;
  overflow: visible !important;
}

.mob-node-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);
}

.mob-node-tag {
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(9, 15, 30, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #e2e8f0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}

@keyframes gpsPulse {
  0%   { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.85); }
  70%  { box-shadow: 0 0 0 16px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.mob-gps-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #0ea5e9;
  border: 3px solid #ffffff;
  animation: gpsPulse 1.8s infinite;
}

/* Pipe Labels & Animated Flow Pulses */
.pipe-label-marker,
.pipe-flow-arrow-marker {
  background: transparent !important;
  border: none !important;
  pointer-events: none !important;
  overflow: visible !important;
}

.pipe-flow-arrow-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.85));
}

@keyframes pipeFlowMarch {
  from { stroke-dashoffset: 26; }
  to   { stroke-dashoffset: 0; }
}

@keyframes pipeArrowGlide {
  0%, 100% { transform: translateX(-2px) scale(0.95); opacity: 0.8; }
  50%      { transform: translateX(2.2px) scale(1.06); opacity: 1; }
}

.pipe-flow-pulse { pointer-events: none !important; animation: pipeFlowMarch 0.95s linear infinite; }
.pipe-flow-pulse.pipe-flow-slow  { animation-duration: 1.45s; }
.pipe-flow-pulse.pipe-flow-med   { animation-duration: 0.95s; }
.pipe-flow-pulse.pipe-flow-fast  { animation-duration: 0.62s; }
.pipe-flow-pulse.pipe-flow-turbo { animation-duration: 0.40s; }

.pipe-flow-arrow-svg { display: block; will-change: transform, opacity; animation: pipeArrowGlide 1.15s ease-in-out infinite; }
.pipe-flow-arrow-svg.pipe-flow-slow  { animation-duration: 1.65s; }
.pipe-flow-arrow-svg.pipe-flow-med   { animation-duration: 1.15s; }
.pipe-flow-arrow-svg.pipe-flow-fast  { animation-duration: 0.80s; }
.pipe-flow-arrow-svg.pipe-flow-turbo { animation-duration: 0.55s; }

@media (prefers-reduced-motion: reduce) {
  .pipe-flow-pulse, .pipe-flow-arrow-svg, .mob-gps-dot { animation: none !important; }
}

/* High-Contrast Outdoor Sunlight Field Mode */
body.theme-sunlight {
  --mob-bg: #f1f5f9;
  --mob-surface: rgba(255, 255, 255, 0.96);
  --mob-surface-solid: #ffffff;
  --mob-border: #94a3b8;
  --mob-text: #0f172a;
  --mob-muted: #475569;
}

body.theme-sunlight .mob-topbar {
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.95) 0%, rgba(241, 245, 249, 0.82) 78%, rgba(241, 245, 249, 0) 100%);
}
body.theme-sunlight .mob-kpi-strip {
  background: rgba(255, 255, 255, 0.96);
  border-color: #94a3b8;
  color: #0f172a;
}
body.theme-sunlight .mob-kpi-strip .text-slate-400 { color: #475569 !important; }
body.theme-sunlight .mob-kpi-strip .text-slate-200 { color: #0f172a !important; }
body.theme-sunlight .mob-kpi-strip .text-sky-300   { color: #0369a1 !important; }
body.theme-sunlight .mob-kpi-strip .text-emerald-300 { color: #047857 !important; }
body.theme-sunlight .mob-kpi-strip .text-amber-300 { color: #b45309 !important; }
body.theme-sunlight .mob-kpi-strip .text-rose-400  { color: #be123c !important; }
body.theme-sunlight .mob-suite-btn { color: #334155; }
body.theme-sunlight .mob-fab { color: #0f172a; }
body.theme-sunlight .mob-fab.is-on,
body.theme-sunlight .mob-fab.is-gps { color: #ffffff; }
body.theme-sunlight .mob-dock-btn { background: #e2e8f0; border-color: #94a3b8; color: #0f172a; }
body.theme-sunlight .mob-dock-btn.is-primary { background: #0284c7 !important; border-color: #0369a1 !important; color: #ffffff !important; }
body.theme-sunlight .mob-dock-btn.is-walk    { background: #059669 !important; border-color: #047857 !important; color: #ffffff !important; }
body.theme-sunlight .mob-dock-btn.is-active  { background: #f59e0b !important; border-color: #d97706 !important; color: #0f172a !important; }
body.theme-sunlight #mobSheet { background: #ffffff; color: #0f172a; border-top-color: #0284c7; }
body.theme-sunlight #mobSearchBar { background: rgba(255, 255, 255, 0.98) !important; border-color: #0284c7 !important; }
body.theme-sunlight #mobSearchInput { color: #0f172a !important; }
body.theme-sunlight #mobSheet .bg-\[\#0b1120\],
body.theme-sunlight #mobSheet .bg-slate-900,
body.theme-sunlight #mobSheet .bg-slate-800 { background: #f1f5f9 !important; color: #0f172a !important; border-color: #cbd5e1 !important; }
body.theme-sunlight #mobSheet .text-white { color: #0f172a !important; }
body.theme-sunlight #mobSheet .text-slate-300,
body.theme-sunlight #mobSheet .text-slate-400 { color: #475569 !important; }
body.theme-sunlight .text-white { color: #0f172a; }
body.theme-sunlight .mob-suite-btn.active,
body.theme-sunlight button.bg-sky-600,
body.theme-sunlight button.bg-emerald-600,
body.theme-sunlight button.bg-indigo-600,
body.theme-sunlight button.bg-amber-600,
body.theme-sunlight button.bg-rose-600 { color: #ffffff !important; }
