/* ==========================================================================
   Сцена подачи машины.
   Фигура — упрощённый знак из логотипа: графитовый тягач с белым бликом,
   янтарным серпом в колесе и янтарным габаритом. Машина въезжает справа
   налево по направлению кабины, открывается задний борт, груз уходит
   на площадку. Классы и события анимации не меняются — их ждёт
   loading-scene.js.
   ========================================================================== */

.loading-scene {
  position: relative;
  min-height: clamp(232px, 21vw, 286px);
  overflow: hidden;
  border: 1px solid var(--steel-700);
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 72% 76%, rgba(246, 172, 15, .12), transparent 60%),
    linear-gradient(162deg, #121820, #0a0d11 64%);
}

.loading-stage {
  --curb: 30px;
  --dock-height: 26px;
  --cycle: 5s;
  position: absolute;
  inset: 38px 0 0;
  container-type: inline-size;
}

/* Дорожное полотно и разметка */
.loading-stage::before {
  position: absolute;
  inset: auto 0 0;
  height: var(--curb);
  border-top: 1px solid var(--steel-600);
  background: linear-gradient(180deg, #0d1116, #06080a);
  content: "";
}

.loading-stage::after {
  position: absolute;
  inset: auto 7% calc(var(--curb) + 9px);
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(140, 153, 164, .32) 0 17px, transparent 17px 29px);
  content: "";
}

/* Площадка погрузки — слева, у заднего борта машины */
.loading-dock {
  position: absolute;
  inset: auto auto var(--curb) 4%;
  width: 15%;
  height: var(--dock-height);
  border-top: 2px solid var(--signal);
  background: linear-gradient(180deg, #232c34, #12171c);
}

.loading-dock::before {
  position: absolute;
  inset: 100% 0 auto;
  height: 8px;
  border-right: 1px solid var(--steel-500);
  border-left: 1px solid var(--steel-500);
  background: #0a0d10;
  content: "";
}

.loading-dock::after {
  position: absolute;
  inset: 4px auto 3px 5px;
  width: 6px;
  background: repeating-linear-gradient(-45deg, rgba(246, 172, 15, .8) 0 2px, transparent 2px 5px);
  content: "";
}

/* Тягач: кабина справа, задний борт у площадки слева */
.loading-truck {
  position: absolute;
  inset: auto 12% var(--curb) 20%;
  height: clamp(96px, 10.9vw, 138px);
}

.loading-truck::before {
  position: absolute;
  inset: auto 3% 13% 3%;
  height: 7px;
  border-radius: 2px;
  background: #1b232a;
  content: "";
}

/* Трейлер */
.loading-trailer {
  position: absolute;
  inset: 17% 33% 24% 0;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(178deg, #5d6874 0%, #454f5b 56%, #333c46 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
}

.loading-trailer::before {
  position: absolute;
  inset: 30% 46% auto 10%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .55);
  content: "";
}

.loading-trailer::after {
  position: absolute;
  inset: auto 16% 18% 6%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .26);
  content: "";
}

/* Кабина: округлая крыша и покатый кап */
.loading-cab {
  position: absolute;
  inset: 5% 0 24% 66%;
  background: linear-gradient(176deg, #7d8895 0%, #525d69 48%, #3d4650 100%);
  clip-path: polygon(0 14%, 12% 2%, 48% 0, 62% 22%, 85% 42%, 100% 58%, 100% 100%, 0 100%);
}

.loading-cab::before {
  position: absolute;
  inset: 11% 44% auto 11%;
  height: 24%;
  background: #eef2f6;
  clip-path: polygon(0 100%, 42% 0, 100% 0, 54% 100%);
  content: "";
}

.loading-cab::after {
  position: absolute;
  inset: auto 5% 24% auto;
  width: 12px;
  height: 5px;
  border-radius: 2px;
  background: var(--signal);
  box-shadow: 0 0 9px rgba(246, 172, 15, .55);
  content: "";
}

/* Задний борт */
.loading-door {
  position: absolute;
  inset: 17% auto 24% 0;
  width: 4.5%;
  background: linear-gradient(180deg, #6c7885, #414b56);
  transform-origin: left center;
}

/* Колёса: переднее с янтарным серпом, задние с ободом */
.loading-wheel {
  position: absolute;
  bottom: 0;
  width: clamp(24px, 2.8vw, 36px);
  height: clamp(24px, 2.8vw, 36px);
  border: 2px solid #333d46;
  border-radius: 50%;
  background: #0d1116;
}

.loading-wheel-front { right: 2%; }

.loading-wheel-front::after {
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  background: var(--signal);
  -webkit-mask: radial-gradient(circle at 64% 34%, transparent 0 50%, #000 51%);
  mask: radial-gradient(circle at 64% 34%, transparent 0 50%, #000 51%);
  content: "";
}

.loading-wheel-middle,
.loading-wheel-rear {
  width: clamp(16px, 1.9vw, 24px);
  height: clamp(16px, 1.9vw, 24px);
  background: radial-gradient(circle, #39434d 0 26%, #0d1116 27% 64%, #39434d 65% 78%, #0d1116 79%);
}

.loading-wheel-middle { right: 38%; }
.loading-wheel-rear { right: 30%; }

/* Паллета на погрузку */
.loading-pallet {
  position: absolute;
  bottom: calc(var(--curb) + var(--dock-height));
  left: 6.5%;
  width: clamp(22px, 2.6vw, 32px);
  height: clamp(15px, 1.8vw, 22px);
  border-bottom: 3px solid #8d6231;
}

.loading-pallet::before,
.loading-pallet::after {
  position: absolute;
  bottom: 1px;
  width: 45%;
  border: 1px solid #d8ac70;
  border-radius: 1px;
  background: linear-gradient(90deg, #b5854f 38%, #e0b57c 38% 60%, #b5854f 60%);
  content: "";
}

.loading-pallet::before { left: 2%; height: 78%; }
.loading-pallet::after { right: 2%; height: 58%; }

/* Управление сценой */
.loading-controls {
  position: absolute;
  inset: 13px 15px auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.loading-controls h3 {
  margin-left: 2px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .01em;
}

.loading-replay:not([hidden]) {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding-inline: 12px;
  border: 1px solid var(--steel-600);
  border-radius: 4px;
  background: rgba(16, 21, 25, .8);
  color: var(--muted-strong);
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease;
}

.loading-replay:hover { border-color: var(--signal); color: var(--signal); }
.loading-replay:focus-visible { outline-offset: 2px; }

.play-icon {
  width: 0;
  height: 0;
  border-block: 4px solid transparent;
  border-left: 6px solid currentColor;
}

/* Движение */
.loading-scene.is-playing .loading-truck { animation: truck-arrival var(--cycle) both; }
.loading-scene.is-playing .loading-wheel-front { animation: wheel-turn 1.5s ease-out both; }
.loading-scene.is-playing .loading-wheel-middle,
.loading-scene.is-playing .loading-wheel-rear { animation: wheel-turn 1.5s ease-out both; }
.loading-scene.is-playing .loading-door { animation: door-movement var(--cycle) both; }
.loading-scene.is-playing .loading-pallet { animation: pallet-unloading var(--cycle) both; }

@keyframes truck-arrival {
  0% { transform: translateX(168%); animation-timing-function: cubic-bezier(.28, .5, .38, 1); }
  38%, 100% { transform: translateX(0); }
}

@keyframes wheel-turn { to { transform: rotate(-1.5turn); } }

@keyframes door-movement {
  0%, 46% { transform: scaleX(1); }
  58%, 86% { transform: scaleX(.16); }
  97%, 100% { transform: scaleX(1); }
}

@keyframes pallet-unloading {
  0%, 50% { left: 30%; opacity: 0; }
  56% { opacity: 1; }
  84%, 100% { left: 6.5%; opacity: 1; }
}
