/* === Сборка мебели: тематические анимации === */

/* Hero — плавающие «детали» (как на инструкции IKEA) */
.hero-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.hero-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(253, 186, 116, 0.45);
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.35);
  animation: particle-drift 14s ease-in-out infinite;
}
.hero-particle:nth-child(1) { top: 18%; left: 12%; animation-delay: 0s; }
.hero-particle:nth-child(2) { top: 62%; left: 8%; width: 6px; height: 6px; animation-delay: -3s; }
.hero-particle:nth-child(3) { top: 35%; right: 15%; animation-delay: -6s; }
.hero-particle:nth-child(4) { bottom: 22%; right: 28%; width: 5px; height: 5px; animation-delay: -9s; }
.hero-particle:nth-child(5) { top: 78%; left: 42%; animation-delay: -2s; }

@keyframes particle-drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); opacity: 0.35; }
  25% { transform: translate(12px, -18px) rotate(90deg); opacity: 0.7; }
  50% { transform: translate(-8px, -32px) rotate(180deg); opacity: 0.5; }
  75% { transform: translate(16px, -12px) rotate(270deg); opacity: 0.65; }
}

/* Hero — появление текста */
.hero__content > * {
  opacity: 0;
  transform: translateY(24px);
  animation: fade-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.hero__badge { animation-delay: 0.1s; }
.hero h1 { animation-delay: 0.22s; }
.hero__subtitle { animation-delay: 0.34s; }
.hero__bullets { animation-delay: 0.46s; }
.hero__cta { animation-delay: 0.58s; }
.hero__trust { animation-delay: 0.7s; }

@keyframes fade-up {
  to { opacity: 1; transform: translateY(0); }
}

/* Hero — анимация «сборки» (заметная, зацикленная) */
.hero__visual {
  opacity: 0;
  transform: translateY(30px) scale(0.96);
  animation: fade-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
}

.assembly-widget {
  padding: 4px;
}
.assembly-widget__steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}
.assembly-widget__step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.72rem;
  font-weight: 700;
  transition: background 0.2s, color 0.2s, transform 0.2s, border-color 0.2s;
}
.assembly-widget__num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 800;
}
.assembly-widget__step--1 { animation: asm-step-1 7s ease-in-out infinite; }
.assembly-widget__step--2 { animation: asm-step-2 7s ease-in-out infinite; }
.assembly-widget__step--3 { animation: asm-step-3 7s ease-in-out infinite; }

@keyframes asm-step-1 {
  0%, 8% { background: rgba(249, 115, 22, 0.35); border-color: rgba(253, 186, 116, 0.6); color: #fff; transform: scale(1.05); }
  8%, 100% { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.15); color: rgba(255, 255, 255, 0.55); transform: scale(1); }
}
@keyframes asm-step-2 {
  0%, 28% { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.55); transform: scale(1); }
  28%, 38% { background: rgba(249, 115, 22, 0.35); border-color: rgba(253, 186, 116, 0.6); color: #fff; transform: scale(1.05); }
  38%, 100% { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.55); transform: scale(1); }
}
@keyframes asm-step-3 {
  0%, 58% { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.55); transform: scale(1); }
  58%, 68% { background: rgba(249, 115, 22, 0.35); border-color: rgba(253, 186, 116, 0.6); color: #fff; transform: scale(1.05); }
  68%, 100% { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.55); transform: scale(1); }
}

.assembly-widget__stage {
  position: relative;
  height: 220px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #1e3a5f 0%, #0f172a 55%, #172554 100%);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 28px;
}
.assembly-widget__stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 80%, rgba(37, 99, 235, 0.2), transparent 60%);
}
.assembly-widget__caption {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
}

/* Боковые панели */
.assembly-panel {
  position: absolute;
  background: linear-gradient(180deg, #e2e8f0, #cbd5e1);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 2;
}
.assembly-panel--left {
  width: 14px;
  height: 90px;
  left: 22%;
  bottom: 40px;
  animation: asm-panel-left 7s ease-in-out infinite;
}
.assembly-panel--right {
  width: 14px;
  height: 90px;
  right: 22%;
  bottom: 40px;
  animation: asm-panel-right 7s ease-in-out infinite;
}
.assembly-panel--top {
  width: 120px;
  height: 14px;
  left: 50%;
  margin-left: -60px;
  bottom: 130px;
  animation: asm-panel-top 7s ease-in-out infinite;
}

@keyframes asm-panel-left {
  0%, 5% { opacity: 0; transform: translateX(-60px) rotate(-12deg); }
  12%, 88% { opacity: 1; transform: translateX(0) rotate(0); }
  95%, 100% { opacity: 0; transform: translateX(-60px) rotate(-12deg); }
}
@keyframes asm-panel-right {
  0%, 5% { opacity: 0; transform: translateX(60px) rotate(12deg); }
  12%, 88% { opacity: 1; transform: translateX(0) rotate(0); }
  95%, 100% { opacity: 0; transform: translateX(60px) rotate(12deg); }
}
@keyframes asm-panel-top {
  0%, 18% { opacity: 0; transform: translateY(-50px); }
  28%, 88% { opacity: 1; transform: translateY(0); }
  95%, 100% { opacity: 0; transform: translateY(-50px); }
}

/* Корпус */
.assembly-corpus {
  position: relative;
  width: 130px;
  height: 100px;
  background: linear-gradient(180deg, #f1f5f9 0%, #94a3b8 100%);
  border-radius: 0 0 6px 6px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px;
  z-index: 3;
  transform-origin: bottom center;
  animation: asm-corpus 7s ease-in-out infinite;
}
@keyframes asm-corpus {
  0%, 22% { opacity: 0; transform: scaleY(0.2); }
  32%, 88% { opacity: 1; transform: scaleY(1); }
  95%, 100% { opacity: 0; transform: scaleY(0.2); }
}

.assembly-door {
  background: rgba(37, 99, 235, 0.15);
  border: 2px solid rgba(37, 99, 235, 0.35);
  border-radius: 3px;
  transform-origin: center;
}
.assembly-door--left {
  animation: asm-door-l 7s ease-in-out infinite;
}
.assembly-door--right {
  animation: asm-door-r 7s ease-in-out infinite;
}
@keyframes asm-door-l {
  0%, 48% { opacity: 0; transform: scaleX(0); }
  58%, 88% { opacity: 1; transform: scaleX(1); }
  95%, 100% { opacity: 0; transform: scaleX(0); }
}
@keyframes asm-door-r {
  0%, 52% { opacity: 0; transform: scaleX(0); }
  62%, 88% { opacity: 1; transform: scaleX(1); }
  95%, 100% { opacity: 0; transform: scaleX(0); }
}

/* Ключ/отвёртка */
.assembly-tool {
  position: absolute;
  right: 18%;
  bottom: 55px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), #fb923c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.55);
  z-index: 5;
  animation: asm-tool 7s ease-in-out infinite;
}
.assembly-tool svg { width: 22px; height: 22px; }
@keyframes asm-tool {
  0%, 55% { opacity: 0; transform: translate(30px, 20px) rotate(-40deg); }
  62%, 88% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  70% { transform: translate(-3px, 0) rotate(-20deg); }
  78% { transform: translate(2px, 0) rotate(15deg); }
  86% { transform: translate(0, 0) rotate(0deg); }
  95%, 100% { opacity: 0; transform: translate(30px, 20px) rotate(-40deg); }
}

/* «Винтики» */
.assembly-screw {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  border: 2px solid #94a3b8;
  z-index: 1;
  animation: asm-screw 7s ease-in-out infinite;
}
.assembly-screw--1 { left: 30%; top: 25%; animation-delay: 0s; }
.assembly-screw--2 { right: 28%; top: 35%; animation-delay: 0.15s; }
.assembly-screw--3 { left: 45%; top: 18%; animation-delay: 0.3s; }
@keyframes asm-screw {
  0%, 3% { opacity: 0; transform: scale(0) rotate(0deg); }
  10%, 20% { opacity: 1; transform: scale(1) rotate(180deg); }
  20%, 88% { opacity: 0.3; transform: scale(0.6); }
  95%, 100% { opacity: 0; transform: scale(0); }
}

/* Плавающие карточки hero */
.hero-float {
  animation: float 5s ease-in-out infinite, fade-up 0.6s ease 1.2s backwards;
}
.hero-float--stat { animation-delay: -2.5s, 1.4s; }

/* Логотип — лёгкое покачивание при наведении */
.logo:hover .logo__mark {
  animation: logo-wiggle 0.5s ease;
}
@keyframes logo-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}

/* Шапка при скролле */
.header {
  transition: height 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.logo__mark {
  transition: width 0.25s ease, height 0.25s ease, transform 0.25s ease;
}
.header--scrolled {
  height: 60px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}
.header--scrolled .logo__mark {
  width: 34px;
  height: 34px;
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal--left {
  transform: translateX(-28px);
}
.reveal--left.is-visible { transform: translateX(0); }
.reveal--scale {
  transform: scale(0.92);
}
.reveal--scale.is-visible { transform: scale(1); }

/* Stagger через JS: data-reveal-delay */
.reveal[data-reveal-delay="1"] { transition-delay: 0.08s; }
.reveal[data-reveal-delay="2"] { transition-delay: 0.16s; }
.reveal[data-reveal-delay="3"] { transition-delay: 0.24s; }
.reveal[data-reveal-delay="4"] { transition-delay: 0.32s; }
.reveal[data-reveal-delay="5"] { transition-delay: 0.4s; }
.reveal[data-reveal-delay="6"] { transition-delay: 0.48s; }

/* Процесс — линия «сборки» */
.process-wrap { position: relative; }
.process-line {
  position: absolute;
  top: 28px;
  left: 10%;
  width: 80%;
  height: 4px;
  z-index: 0;
  overflow: visible;
}
.process-line__track {
  stroke: var(--border);
  stroke-width: 3;
  fill: none;
}
.process-line__fill {
  stroke: url(#processGradient);
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.process-wrap .process::before { display: none; }
.process-wrap.is-visible .process-line__fill {
  stroke-dashoffset: 0;
}
.process__item.is-active .process__num {
  animation: process-pulse 0.6s ease;
  box-shadow: 0 0 0 4px var(--bg-alt), 0 0 0 8px rgba(37, 99, 235, 0.25);
}
@keyframes process-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Калькулятор — смена шагов */
.quiz__panel {
  display: none;
  opacity: 0;
  transform: translateX(16px);
}
.quiz__panel.active {
  display: block;
  animation: quiz-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.quiz__panel.active.quiz__panel--back {
  animation: quiz-back 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes quiz-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes quiz-back {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}
.quiz__step-dot {
  transition: transform 0.3s ease, background 0.3s ease;
}
.quiz__step-dot.active {
  transform: scaleY(1.8);
  border-radius: 4px;
}
.quiz__option.selected {
  animation: option-select 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes option-select {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Счётчики */
[data-count] {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* Кнопки — микроинтеракция (как у IKEA / Profi) */
.btn--primary {
  position: relative;
  overflow: hidden;
}
.btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.25) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.btn--primary:hover::after {
  transform: translateX(100%);
}

/* Портфолио — лёгкий zoom */
.portfolio-item {
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
}
.portfolio-item:hover .portfolio-item__img {
  transform: scale(1.04);
}

/* FAQ — плавное раскрытие */
.faq__answer {
  max-height: 0;
  overflow: hidden;
  padding: 0 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: max-height 0.4s cubic-bezier(0.22, 1, 0.36, 1), padding 0.4s ease;
}
.faq__item.open .faq__answer {
  max-height: 280px;
  padding: 0 20px 18px;
}

/* Отключаем анимации при запросе пользователя */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .hero__content > *, .hero__visual { opacity: 1; transform: none; }
  /* Сборка — показываем финальное состояние */
  .assembly-panel, .assembly-corpus, .assembly-door, .assembly-tool { opacity: 1 !important; transform: none !important; }
  .assembly-widget__step { opacity: 1; color: #fff; }
}

@media (max-width: 768px) {
  .hero__grid {
    display: flex;
    flex-direction: column;
  }
  .hero__visual {
    order: -1;
    min-height: auto;
    margin-bottom: 8px;
  }
  .assembly-widget__label { display: none; }
  .assembly-widget__stage { height: 190px; }
  .process-line { display: none; }
  .hero-particles { display: none; }
}
