/* ==========================================================================
   Блок «3D-сцена»: холодильный шкаф в магазине (public/scene3d/)
   Без класса .fx3d-live на <html> — обычный первый экран с постером:
   так блок видят превью в админке, браузеры без WebGL и при «уменьшить движение».
   С .fx3d-live (его ставит boot.js ещё в <head>) — длинная секция, сцена закреплена
   под шапкой (--fx-top), подписи меняются по скроллу.
   На широком экране верхняя полоса шапки (телефоны) при прокрутке уезжает вверх. Чтобы под ней
   не открывалась пустая полоса, сцена выше на её высоту (--fx-under) и начинается под этой частью шапки:
   --fx-top — высота шапки без полосы. Точные значения ставит app.js, здесь — до его загрузки.
   ========================================================================== */

.fx3d {
  --fx-under: 0px;
  --fx-top: var(--header-h);
  --fx-bg: #05080B;
  --fx-ink: #EAF4F6;
  --fx-ink-2: rgba(226, 238, 242, .68);
  --fx-accent: #6FD3DE;
  --fx-line: rgba(143, 208, 216, .22);
  position: relative;
  background: var(--fx-bg);
  color: var(--fx-ink);
}

/* Обычный первый экран: колонка слева, промежуточные подписи скрыты */
.fx3d-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: calc(100vh - var(--fx-top));
  height: calc(100svh - var(--fx-top));
  min-height: 480px;
  padding: 48px var(--gutter);
  padding-left: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  overflow: hidden;
}
@media (min-width: 1200px) {
  :root:has(.header-contact) .fx3d { --fx-under: 47px; --fx-top: 70px; }
}
/* Первым блоком страницы — заезжает под полосу шапки. Ниже по странице блок стоит как обычно,
   а сцена всё равно закрепляется под строкой меню — полоса шапки её лишь накрывает */
main > .fx3d:first-child { margin-top: calc(-1 * var(--fx-under)); }

/* В превью админки 100vw — это окно админки, а не блок: отступ задаём явно */
.fx3d--preview { --fx-under: 0px; }
.fx3d--preview .fx3d-stage { height: 600px; min-height: 0; padding-left: 64px; }

.fx3d-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 70% 50%;
}

.fx3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.2s var(--ease);
}
.fx3d.is-ready .fx3d-canvas { opacity: 1; }

.fx3d-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 8, 11, .7) 0%, rgba(5, 8, 11, 0) 42%),
    linear-gradient(0deg, rgba(5, 8, 11, .6) 0%, rgba(5, 8, 11, 0) 22%);
}

.fx3d :is(.fx3d-hint, .fx3d-steps, .fx3d-skip, .fx3d-loader) { display: none; }

/* ---------- Подписи ---------- */

.fx3d-cap {
  position: relative;
  z-index: 2;
  max-width: 560px;
}
/* :where — нулевой вес, чтобы правила живого режима ниже спокойно их перекрывали */
.fx3d-cap:where(:not(.fx3d-cap--intro):not(.fx3d-cap--cta)) { display: none; }
.fx3d-cap--cta .fx3d-title { display: none; }

.fx3d-title {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-variation-settings: var(--display-axes);
  font-weight: 560;
  font-size: clamp(2.5rem, 1.2rem + 4.2vw, 5rem);
  line-height: 1.02;
  letter-spacing: -.02em;
  text-wrap: balance;
  color: var(--fx-ink);
}
.fx3d-title em { font-style: normal; color: var(--fx-accent); }
.fx3d-title--sm { font-size: clamp(2rem, 1.1rem + 2.8vw, 3.6rem); }

.fx3d-lead {
  margin: 0;
  max-width: 440px;
  font-size: clamp(1rem, .95rem + .3vw, 1.15rem);
  line-height: 1.55;
  color: var(--fx-ink-2);
}

.fx3d-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  color: var(--fx-accent);
  font: 500 12.5px/1 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color .2s;
}
.fx3d-more svg { width: 16px; height: 16px; transition: translate .25s var(--ease); }
.fx3d-more:hover { color: var(--fx-ink); }
.fx3d-more:hover svg { translate: 3px 0; }
.fx3d-more:focus-visible { outline: 2px solid var(--fx-accent); outline-offset: 4px; border-radius: 4px; }

.fx3d .hero-actions { margin-top: 12px; justify-content: flex-start; }
.fx3d .fx3d-ghost { color: var(--fx-ink); border-color: var(--fx-line); }
.fx3d .fx3d-ghost:hover { border-color: var(--fx-ink); }

/* ---------- Живой режим ---------- */

.fx3d-live .fx3d { height: 560vh; }
.fx3d-live .fx3d-stage {
  position: sticky;
  top: var(--fx-top);
  display: block;
  padding: 0;
}
.fx3d-live .fx3d-poster { display: none; }

.fx3d-live .fx3d-cap {
  display: block;
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 24px, 0);
  will-change: opacity, transform;
}
.fx3d-live .fx3d-cap.is-on { visibility: visible; }
/* Пока грузится 3D, заголовок уже на месте */
.fx3d-live .fx3d:not(.is-ready) .fx3d-cap--intro { opacity: 1; visibility: visible; transform: none; }
.fx3d-live .fx3d-cap--cta .fx3d-title { display: block; }
.fx3d-live .fx3d .hero-actions { margin-top: 28px; }

.fx3d-live :is(.fx3d-cap--intro, .fx3d-cap--left, .fx3d-cap--cta, .fx3d-cap--card) {
  left: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  /* По центру видимой части: верх сцены может быть под полосой шапки */
  top: calc(50% + var(--fx-under) / 2);
  translate: 0 -50%;
}
.fx3d-live .fx3d-cap--right {
  right: max(calc(var(--gutter) + 40px), calc((100vw - var(--container)) / 2 + var(--gutter) + 40px));
  top: calc(50% + var(--fx-under) / 2);
  translate: 0 -50%;
  max-width: 460px;
}
.fx3d-live .fx3d-cap--bottom {
  left: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  bottom: 48px;
}
/* Подписи поверх полок крупным планом и поверх светлого чертежа зала — без плашки и рамки,
   как остальные. Читаемость даёт мягкая тень за текстом без видимых краёв */
.fx3d-live :is(.fx3d-cap--bottom, .fx3d-cap--card) { max-width: 520px; }
.fx3d-live :is(.fx3d-cap--bottom, .fx3d-cap--card)::before {
  content: '';
  position: absolute;
  inset: -90px -140px -90px -120px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(5, 8, 11, .82), rgba(5, 8, 11, .55) 45%, rgba(5, 8, 11, 0));
}

/* ---------- Интерфейс сцены ---------- */

.fx3d-ui { position: absolute; inset: 0; z-index: 3; pointer-events: none; }

.fx3d-live .fx3d-steps {
  position: absolute;
  right: calc(var(--gutter) - 6px);
  top: calc(50% + var(--fx-under) / 2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  translate: 0 -50%;
  pointer-events: auto;
}
.fx3d-steps button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.fx3d-steps button::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(143, 208, 216, .35);
  transition: background-color .3s, scale .3s var(--ease), box-shadow .3s;
}
.fx3d-steps button:hover::before { background: var(--fx-ink-2); }
.fx3d-steps button[aria-current]::before {
  background: var(--fx-accent);
  scale: 1.4;
  box-shadow: 0 0 0 4px rgba(111, 211, 222, .14);
}
.fx3d-steps button:focus-visible { outline: 2px solid var(--fx-accent); outline-offset: 2px; }

.fx3d-live .fx3d-hint {
  position: absolute;
  left: 50%;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  translate: -50% 0;
  color: var(--fx-ink-2);
  font: 500 11.5px/1 var(--font-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: opacity .5s;
}
.fx3d-hint i {
  position: relative;
  width: 1px;
  height: 40px;
  background: var(--fx-line);
  overflow: hidden;
}
.fx3d-hint i::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--fx-accent);
  animation: fx3d-drip 1.8s var(--ease) infinite;
}
@keyframes fx3d-drip {
  0% { transform: translateY(-100%); }
  60%, 100% { transform: translateY(100%); }
}
.fx3d.is-scrolled .fx3d-hint { opacity: 0; }

.fx3d-live .fx3d-skip {
  position: absolute;
  right: var(--gutter);
  bottom: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--fx-line);
  border-radius: 999px;
  background: rgba(5, 8, 11, .5);
  color: var(--fx-ink-2);
  font: 500 11.5px/1 var(--font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: color .2s, border-color .2s, opacity .4s, visibility .4s;
}
.fx3d-skip:hover { color: var(--fx-ink); border-color: var(--fx-ink-2); }
.fx3d-skip:focus-visible { outline: 2px solid var(--fx-accent); outline-offset: 2px; }
.fx3d.is-end .fx3d-skip { opacity: 0; visibility: hidden; }

.fx3d-live .fx3d-loader {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--fx-accent), transparent) no-repeat;
  background-size: 40% 100%;
  animation: fx3d-load 1.2s linear infinite;
  transition: opacity .6s;
}
.fx3d.is-ready .fx3d-loader { opacity: 0; animation: none; }
@keyframes fx3d-load { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* ---------- Телефоны и узкие экраны: шкаф сверху, подписи снизу ---------- */

@media (max-width: 899px) {
  .fx3d-live .fx3d { height: 460vh; }
  .fx3d-shade {
    background: linear-gradient(0deg, var(--fx-bg) 0%, rgba(5, 8, 11, .85) 30%, rgba(5, 8, 11, 0) 55%);
  }
  .fx3d-stage { justify-content: flex-end; }
  .fx3d-live .fx3d-cap,
  .fx3d-live :is(.fx3d-cap--intro, .fx3d-cap--left, .fx3d-cap--cta, .fx3d-cap--right, .fx3d-cap--bottom, .fx3d-cap--card) {
    left: var(--gutter);
    right: var(--gutter);
    top: auto;
    bottom: 36px;
    translate: none;
    max-width: none;
    padding: 0;
    border: 0;
    background: none;
  }
  /* Внизу и так тёмная подложка сцены */
  .fx3d-live :is(.fx3d-cap--bottom, .fx3d-cap--card)::before { display: none; }
  .fx3d-title { font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3rem); margin-bottom: 12px; }
  .fx3d-title--sm { font-size: clamp(1.7rem, 1.2rem + 2.6vw, 2.4rem); }
  .fx3d-lead { font-size: 15px; }
  .fx3d-more { margin-top: 14px; }
  .fx3d-live .fx3d .hero-actions { margin-top: 18px; }
  .fx3d-live .fx3d-steps {
    top: 14px;
    right: calc(var(--gutter) - 6px);
    flex-direction: row;
    translate: none;
  }
  .fx3d-live .fx3d-skip { top: 12px; bottom: auto; left: var(--gutter); right: auto; }
  .fx3d-live .fx3d-hint { display: none; }
}
