/* ============================================
   Truck Loader v2 - Reusable Loading Animation
   KingPao delivery van + storefront house
   ============================================ */

.truck-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: #1a1410;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.truck-loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ─── Scene ─── */
.truck-loader-scene {
  position: relative;
  width: 300px;
  height: 120px;
  overflow: hidden;
}

/* ─── Sky / Clouds ─── */
.truck-cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50px;
}

.truck-cloud::before,
.truck-cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.truck-cloud-1 {
  width: 40px;
  height: 12px;
  top: 10px;
  left: -50px;
  animation: cloudDrift 12s linear infinite;
}

.truck-cloud-1::before { width: 18px; height: 14px; top: -6px; left: 8px; }
.truck-cloud-1::after { width: 14px; height: 10px; top: -3px; left: 22px; }

.truck-cloud-2 {
  width: 32px;
  height: 10px;
  top: 22px;
  left: -40px;
  animation: cloudDrift 16s linear infinite;
  animation-delay: -5s;
  opacity: 0.6;
}

.truck-cloud-2::before { width: 14px; height: 11px; top: -5px; left: 6px; }
.truck-cloud-2::after { width: 11px; height: 8px; top: -2px; left: 17px; }

@keyframes cloudDrift {
  from { transform: translateX(0); }
  to { transform: translateX(380px); }
}

/* ─── Ground ─── */
.truck-ground {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 14px;
  background: linear-gradient(180deg, #2a2218 0%, #1e1812 100%);
}

/* ─── Road ─── */
.truck-loader-road {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(249, 115, 22, 0.3);
  border-radius: 2px;
}

.truck-loader-road::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: repeating-linear-gradient(
    90deg,
    rgba(249, 115, 22, 0.4) 0px,
    rgba(249, 115, 22, 0.4) 8px,
    transparent 8px,
    transparent 16px
  );
}

/* ─── Tree ─── */
.truck-tree {
  position: absolute;
  bottom: 16px;
  right: 90px;
}

.truck-tree-trunk {
  width: 4px;
  height: 14px;
  background: #6b5a48;
  margin: 0 auto;
  border-radius: 1px;
}

.truck-tree-top {
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 16px solid #3a7a3a;
  position: relative;
}

.truck-tree-top::after {
  content: '';
  position: absolute;
  top: 8px;
  left: -7px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid #2d6a2d;
}

/* ─── Street Lamp ─── */
.truck-lamp {
  position: absolute;
  bottom: 16px;
  right: 55px;
}

.truck-lamp-pole {
  width: 2px;
  height: 28px;
  background: #6b5a48;
  margin: 0 auto;
}

.truck-lamp-head {
  width: 10px;
  height: 4px;
  background: #6b5a48;
  border-radius: 2px 2px 0 0;
  position: relative;
  left: -4px;
}

.truck-lamp-glow {
  width: 6px;
  height: 6px;
  background: #ffeaa0;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 2px;
  box-shadow: 0 0 10px 4px rgba(255, 234, 160, 0.4);
  animation: lampFlicker 3s ease-in-out infinite;
}

@keyframes lampFlicker {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ─── Storefront / House ─── */
.truck-loader-house {
  position: absolute;
  bottom: 16px;
  right: 14px;
  width: 56px;
  height: 52px;
}

.truck-house-roof {
  position: absolute;
  top: 0;
  left: -3px;
  width: 62px;
  height: 18px;
  background: #ef7a00;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.truck-house-roof::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0px,
    transparent 3px,
    rgba(255,255,255,0.15) 3px,
    rgba(255,255,255,0.15) 6px
  );
}

.truck-house-sign {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 5px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  z-index: 1;
  white-space: nowrap;
  font-family: Arial, sans-serif;
}

.truck-house-awning {
  position: absolute;
  top: 16px;
  left: -1px;
  width: 58px;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    #ef7a00 0px,
    #ef7a00 5px,
    #fff 5px,
    #fff 10px
  );
  border-radius: 0 0 4px 4px;
}

.truck-house-body {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 56px;
  height: 30px;
  background: #2a2218;
  border: 2px solid #3a3028;
  border-top: none;
}

.truck-house-door {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 18px;
  background: linear-gradient(180deg, #c49060 0%, #b07848 100%);
  border-radius: 3px 3px 0 0;
  border: 1.5px solid #a06838;
}

.truck-house-door-knob {
  position: absolute;
  top: 50%;
  right: 2px;
  width: 2px;
  height: 2px;
  background: #ffd700;
  border-radius: 50%;
  box-shadow: 0 0 3px rgba(255, 215, 0, 0.6);
}

.truck-house-window {
  position: absolute;
  top: 6px;
  width: 11px;
  height: 11px;
  background: linear-gradient(135deg, #fff8e0 0%, #ffeaa0 100%);
  border: 1.5px solid #a08060;
  border-radius: 2px;
  box-shadow: inset 0 0 4px rgba(255, 234, 160, 0.4);
}

.truck-house-window::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: #a08060; }
.truck-house-window::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #a08060; }

.truck-house-window.left { left: 4px; }
.truck-house-window.right { right: 4px; }

.truck-house-chimney {
  position: absolute;
  top: -6px;
  right: 8px;
  width: 7px;
  height: 14px;
  background: #8b6040;
  border-radius: 1px 1px 0 0;
}

.truck-house-smoke {
  position: absolute;
  top: -18px;
  right: 7px;
}

.smoke-puff {
  position: absolute;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  opacity: 0;
  animation: truckSmoke 2.4s ease-out infinite;
}

.smoke-puff:nth-child(2) { left: 5px; animation-delay: 0.8s; }
.smoke-puff:nth-child(3) { left: 2px; animation-delay: 1.6s; }

@keyframes truckSmoke {
  0% { opacity: 0.5; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-18px) scale(2.2); }
}

/* ─── KingPao Delivery Van ─── */
.truck-loader-truck {
  position: absolute;
  bottom: 16px;
  left: 0;
  /* Default: auto-drive for static HTML preloaders */
  animation: truckDrive 3s ease-in-out infinite;
}

.truck-loader-truck.truck-moving {
  /* JS controls position; replace drive loop with bounce micro-animation */
  animation: truckBounce 0.35s ease-in-out infinite;
}

.truck-loader-truck.truck-arrived {
  animation: truckArrived 0.5s ease-out forwards;
}

@keyframes truckBounce {
  0%, 100% { transform: translateX(var(--truck-x, 0px)) translateY(0); }
  50% { transform: translateX(var(--truck-x, 0px)) translateY(-1px); }
}

@keyframes truckArrived {
  0% { transform: translateX(var(--truck-x, 0px)) translateY(0) scale(1); }
  40% { transform: translateX(var(--truck-x, 0px)) translateY(-3px) scale(1.02); }
  100% { transform: translateX(var(--truck-x, 0px)) translateY(0) scale(1); }
}

@keyframes truckDrive {
  0% { transform: translateX(0) translateY(0); }
  8% { transform: translateX(0) translateY(-1px); }
  16% { transform: translateX(0) translateY(0); }
  24% { transform: translateX(0) translateY(-1px); }
  32% { transform: translateX(0) translateY(0); }
  40% { transform: translateX(calc(100vw - 60px)) translateY(0); }
  60% { transform: translateX(calc(100vw - 60px)) translateY(0); }
  65% { transform: translateX(0) translateY(0); }
  100% { transform: translateX(0) translateY(0); }
}

/* Exhaust puffs */
.truck-exhaust {
  position: absolute;
  bottom: 6px;
  left: -8px;
}

.truck-exhaust-puff {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  opacity: 0;
  animation: exhaustPuff 0.9s ease-out infinite;
}

.truck-arrived .truck-exhaust-puff {
  animation: none;
}

.truck-exhaust-puff:nth-child(2) { left: -3px; top: -2px; animation-delay: 0.3s; }
.truck-exhaust-puff:nth-child(3) { left: -6px; top: 1px; animation-delay: 0.6s; }

@keyframes exhaustPuff {
  0% { opacity: 0.35; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(-12px, -4px) scale(2); }
}

/* Van body */
.truck-van-body {
  position: relative;
  width: 58px;
  height: 28px;
  background: linear-gradient(180deg, #ef7a00 0%, #e06800 100%);
  border-radius: 4px 8px 2px 2px;
  box-shadow: 0 3px 10px rgba(239, 122, 0, 0.4);
}

.truck-van-body::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 20px;
  bottom: 4px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.08) 0px,
    rgba(255,255,255,0.08) 1px,
    transparent 1px,
    transparent 6px
  );
  border-radius: 2px;
}

.truck-van-logo {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  font-size: 8px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  font-family: Arial, sans-serif;
  z-index: 1;
}

.truck-van-headlight {
  position: absolute;
  bottom: 6px;
  right: -2px;
  width: 4px;
  height: 5px;
  background: #ffeaa0;
  border-radius: 1px;
  box-shadow: 0 0 8px 3px rgba(255, 234, 160, 0.5);
}

.truck-van-bumper {
  position: absolute;
  bottom: -2px;
  left: 2px;
  right: 2px;
  height: 3px;
  background: #b06020;
  border-radius: 0 0 2px 2px;
}

/* Cabin */
.truck-van-cabin {
  position: absolute;
  right: -18px;
  bottom: 0;
  width: 20px;
  height: 20px;
  background: linear-gradient(180deg, #d86000 0%, #c05000 100%);
  border-radius: 2px 6px 2px 2px;
}

.truck-van-windshield {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 10px;
  background: linear-gradient(135deg, rgba(192,232,255,0.5) 0%, rgba(160,208,240,0.4) 100%);
  border-radius: 1px 4px 1px 1px;
  border: 1px solid rgba(128,176,208,0.4);
}

.truck-van-mirror {
  position: absolute;
  top: 6px;
  right: -5px;
  width: 4px;
  height: 3px;
  background: #888;
  border-radius: 1px;
}

/* Packages on top */
.truck-van-packages {
  position: absolute;
  top: -8px;
  left: 6px;
}

.truck-package {
  position: absolute;
  background: #ff9800;
  border: 1.5px solid #e08000;
  border-radius: 2px;
}

.truck-package::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.4);
  border-radius: 1px;
}

.truck-package-1 { width: 10px; height: 8px; left: 0; bottom: 0; }
.truck-package-1::after { width: 6px; height: 1px; }
.truck-package-2 { width: 8px; height: 7px; left: 12px; bottom: 0; }
.truck-package-2::after { width: 5px; height: 1px; }
.truck-package-3 { width: 7px; height: 6px; left: 5px; bottom: 8px; }
.truck-package-3::after { width: 4px; height: 1px; }

/* ─── Wheels ─── */
.truck-wheel {
  position: absolute;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #1a1a1a;
  border-radius: 50%;
  border: 2px solid #444;
}

.truck-moving .truck-wheel {
  animation: truckWheelSpin 0.4s linear infinite;
}

.truck-wheel::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 4px;
  background: #777;
  border-radius: 50%;
  border: 1px solid #999;
}

.truck-wheel::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 1px;
  background: #555;
}

.truck-wheel.front { right: -10px; }
.truck-wheel.back { left: 6px; }

@keyframes truckWheelSpin {
  to { transform: rotate(360deg); }
}

/* ─── Package drop ─── */
.truck-drop-package {
  position: absolute;
  bottom: 18px;
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, #ff9800 0%, #ef7a00 100%);
  border: 1.5px solid #d06800;
  border-radius: 2px;
  opacity: 0;
}

.truck-arrived ~ .truck-drop-package {
  animation: packageDrop 0.6s ease-out forwards;
  animation-delay: 0.3s;
}

.truck-drop-package::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 2px;
  width: 5px;
  height: 1px;
  background: rgba(255,255,255,0.5);
}

@keyframes packageDrop {
  0% { opacity: 0; transform: translateY(0); }
  5% { opacity: 1; transform: translateY(0); }
  12% { opacity: 1; transform: translateY(-8px); }
  20% { opacity: 0; transform: translateY(2px); }
  100% { opacity: 0; }
}

/* ─── Loading Text ─── */
.truck-loader-text {
  color: #f97316;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: Arial, sans-serif;
}


