/* ============================================================
   OFFLINE / NO-CONNECTION OVERLAY
   ============================================================ */
#offline-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: #f0f2f8;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s, visibility 0.4s;
}
#offline-overlay.show { opacity: 1; visibility: visible; }

/* ---- Scene ---- */
.ol-scene {
  position: relative;
  width: 340px; height: 160px;
  margin-bottom: 40px;
}

/* Road */
.ol-road {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 48px;
  background: #38487D;
  border-radius: 6px;
  overflow: hidden;
}
.ol-road::before {
  content: '';
  position: absolute; top: 50%; left: -60%;
  width: 220%; height: 4px;
  margin-top: -2px;
  background: repeating-linear-gradient(
    90deg,
    #fff 0px, #fff 28px,
    transparent 28px, transparent 52px
  );
  animation: roadScroll 0.9s linear infinite;
}
/* Road stops when truck stalls */
.stalled .ol-road::before { animation-play-state: paused; }

@keyframes roadScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(80px); }
}

/* Truck body */
.ol-truck {
  position: absolute; bottom: 48px; left: 30px;
  width: 120px; height: 68px;
}

/* Cab */
.ol-cab {
  position: absolute; right: 0; bottom: 0;
  width: 52px; height: 52px;
  background: #38487D;
  border-radius: 6px 6px 0 0;
}
.ol-cab::before {
  content: '';
  position: absolute; top: 10px; left: 8px; right: 8px; bottom: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 3px 3px 0 0;
}
/* Windshield glare */
.ol-cab::after {
  content: '';
  position: absolute; top: 6px; left: 10px;
  width: 14px; height: 10px;
  background: rgba(255,255,255,0.5);
  border-radius: 2px;
  transform: skewX(-8deg);
}

/* Cargo trailer */
.ol-cargo {
  position: absolute; left: 0; bottom: 0;
  width: 76px; height: 44px;
  background: #D0373A;
  border-radius: 4px 2px 0 0;
}
.ol-cargo::after {
  content: 'IT';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px; font-weight: 800;
  color: rgba(255,255,255,0.7);
  letter-spacing: 1px;
}

/* Wheels */
.ol-wheel {
  position: absolute; bottom: -10px;
  width: 20px; height: 20px;
  background: #1a1a2e;
  border-radius: 50%;
  border: 3px solid #555;
  animation: wheelSpin 0.5s linear infinite;
}
.ol-wheel::after {
  content: '';
  position: absolute; inset: 3px;
  background: #333;
  border-radius: 50%;
  border-top: 2px solid #888;
}
.ol-wheel-r { right: 6px; }
.ol-wheel-l { left: 14px; }
.stalled .ol-wheel { animation-play-state: paused; }

@keyframes wheelSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Truck bob while moving */
.ol-truck { animation: truckBob 0.4s ease-in-out infinite alternate; }
.stalled .ol-truck { animation: none; }

@keyframes truckBob {
  from { transform: translateY(0); }
  to   { transform: translateY(-2px); }
}

/* Exhaust puffs */
.ol-exhaust {
  position: absolute; bottom: 58px; left: -4px;
  display: flex; flex-direction: column-reverse; gap: 2px;
}
.ol-puff {
  width: 10px; height: 10px;
  background: rgba(150,150,170,0.6);
  border-radius: 50%;
  animation: puffRise 1.2s ease-out infinite;
}
.ol-puff:nth-child(2) { animation-delay: 0.4s; width: 8px; height: 8px; }
.ol-puff:nth-child(3) { animation-delay: 0.8s; width: 6px; height: 6px; }
.stalled .ol-puff { animation: none; opacity: 0; }

@keyframes puffRise {
  0%   { transform: translateY(0) scale(1); opacity: 0.7; }
  100% { transform: translateY(-22px) scale(1.8); opacity: 0; }
}

/* GPS signal icon above truck */
.ol-signal {
  position: absolute; top: 0; right: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.ol-signal-icon {
  width: 28px; height: 28px;
  background: #6B7FBF;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 0 rgba(107,127,191,0.4);
  animation: gpsPing 1.6s ease-out infinite;
  transition: background 0.4s;
}
.ol-signal-icon svg { flex-shrink: 0; }
.stalled .ol-signal-icon {
  background: #D0373A;
  animation: none;
  box-shadow: none;
}

@keyframes gpsPing {
  0%   { box-shadow: 0 0 0 0 rgba(107,127,191,0.5); }
  70%  { box-shadow: 0 0 0 14px rgba(107,127,191,0); }
  100% { box-shadow: 0 0 0 0 rgba(107,127,191,0); }
}

/* Signal bars */
.ol-bars {
  display: flex; align-items: flex-end; gap: 3px;
}
.ol-bar {
  background: #6B7FBF;
  border-radius: 2px;
  transition: background 0.4s, opacity 0.4s;
}
.ol-bar:nth-child(1) { width: 4px; height: 6px; }
.ol-bar:nth-child(2) { width: 4px; height: 10px; }
.ol-bar:nth-child(3) { width: 4px; height: 14px; }
.ol-bar:nth-child(4) { width: 4px; height: 18px; }

.stalled .ol-bar:nth-child(3),
.stalled .ol-bar:nth-child(4) { background: #ddd; opacity: 0.4; }
.stalled .ol-bar:nth-child(1),
.stalled .ol-bar:nth-child(2) { background: #D0373A; }

/* Warning triangle */
.ol-warn {
  position: absolute; top: -4px; left: 26px;
  opacity: 0; transform: scale(0.5);
  transition: opacity 0.4s 0.3s, transform 0.4s 0.3s;
}
.stalled .ol-warn { opacity: 1; transform: scale(1); }

/* ---- Text ---- */
.ol-title {
  font-size: 22px; font-weight: 800;
  color: #38487D; margin: 0 0 8px;
  text-align: center;
}
.ol-sub {
  font-size: 14px; color: #666;
  text-align: center; max-width: 280px;
  line-height: 1.6; margin: 0 0 28px;
}

.ol-retry-btn {
  padding: 12px 28px;
  background: #38487D; color: #fff;
  border: none; border-radius: 50px;
  font-size: 14px; font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.2s, transform 0.2s;
}
.ol-retry-btn:hover { background: #2C3A66; transform: translateY(-2px); }
.ol-retry-btn svg { animation: retryRotate 2s linear infinite; }
.ol-retry-btn:hover svg { animation-play-state: running; }

@keyframes retryRotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ---- Text loader (used on initial page load) ---- */
#page-loader {
  position: fixed;
  top: 0; left: 0; right: 0;
  /* 100dvh = dynamic viewport height: shrinks when mobile URL bar is visible,
     so the loader content stays visually centred on all mobile browsers.
     Falls back to 100vh on older engines. */
  height: 100vh;
  height: 100dvh;
  z-index: 88888;
  background: #ffffff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2rem;
  transition: opacity 0.5s, visibility 0.5s;
}
#page-loader.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-logo {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: clamp(42px, 8vw, 80px);
  letter-spacing: -1.5px;
  line-height: 1;
  display: flex;
  overflow: hidden;
}
.loader-info,
.loader-track {
  display: inline-block;
  opacity: 0;
  transform: translateY(30px);
  animation: loader-rise 0.55s cubic-bezier(0.22,1,0.36,1) forwards;
}
.loader-info { color: #D0373A; animation-delay: 0.1s; }
.loader-track { color: #38487D; animation-delay: 0.28s; }
@keyframes loader-rise {
  to { opacity: 1; transform: translateY(0); }
}
.loader-bar {
  width: clamp(120px, 20vw, 200px);
  height: 2px;
  background: rgba(56,72,125,0.12);
  border-radius: 99px;
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #D0373A, #38487D);
  border-radius: 99px;
  animation: loader-progress 1.2s cubic-bezier(0.4,0,0.2,1) forwards;
  animation-delay: 0.3s;
}
@keyframes loader-progress {
  0% { width: 0%; } 60% { width: 75%; } 100% { width: 100%; }
}
