/* ============================
   Index Hero — компактные полоски снизу hero, плавный morph в большие
   карточки при скролле, без lock body / state-machine.

   Реализация: section высотой 200vh, внутри stage position:sticky 100vh.
   На скролле JS обновляет registered custom properties:
     --pText  0..1 (за первые 50% — уходит текст hero)
     --p      0..1 (за вторые 50% — растут карточки + видео уезжает)
   Все размеры/opacity/padding в industries-strip — линейные функции от --p.

   Кнопка «Другие отрасли — Показать все» появляется под гридом в expanded
   режиме и раскрывает скрытый ряд (1 карточка food) — как было в bak.
   ============================ */

@property --p {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}
@property --pText {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}

.index-hero {
  position: relative;
  width: 100%;
  height: 130vh;
  background: #0d1117;
  color: #fff;
  --p: 0;
  --pText: 0;
}

/* Smooth morph: при коротком scroll-диапазоне (130vh) резкие изменения --p
   сглаживаются короткой transition — анимация догоняет скролл за 120мс,
   ощущается плавно даже от одного тика колеса. На мобильных --p=1
   статичен, transition не нужен. */
@media (min-width: 768px) {
  .index-hero {
    transition: --p 0.12s linear, --pText 0.12s linear;
  }
}

/* === Sticky stage: один экран, плавающий поверх дополнительных 100vh === */
.index-hero__stage {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: #0d1117;
}

/* === Видео-слой (уезжает вверх по --p) === */
.index-hero__video-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  transform: translate3d(0, calc(var(--p) * -58vh), 0);
  will-change: transform;
}

.index-hero__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.7s ease;
  background: #000 url(../../assets/images/hero-poster-desktop.jpg) center / cover no-repeat;
}

.index-hero__video--ready { opacity: 1; }

.index-hero__video-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10,26,61,0.55) 0%, rgba(13,17,23,0.35) 48%, rgba(10,14,26,0.95) 100%),
    repeating-linear-gradient(45deg, transparent, transparent 22px, rgba(255,255,255,0.02) 22px, rgba(255,255,255,0.02) 23px);
}

/* === Контент hero (заголовок + теглайн + аквариум) — уходит по --pText === */
.index-hero__content {
  position: absolute;
  box-sizing: border-box;
  left: 50%;
  top: 0;
  bottom: 0;
  transform: translateX(-50%) translateY(calc(var(--pText) * -60px));
  width: 100%;
  max-width: var(--container-max);
  padding: 136px var(--container-padding) 320px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: calc(1 - var(--pText));
  pointer-events: auto;
  will-change: opacity, transform;
}

.index-hero__eyebrow {
  font-family: var(--font-heading);
  font-size: 12px;
  color: var(--color-accent-light);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  margin-bottom: 22px;
}

.index-hero__title {
  font-family: var(--font-heading);
  font-size: 64px;
  font-weight: 700;
  line-height: 1.04;
  margin: 0 0 22px;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  color: #fff;
  max-width: 900px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}

.index-hero__tagline {
  font-family: var(--font-body);
  font-size: 18px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.6;
  margin: 0 0 36px;
  max-width: 620px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
}

/* === Аквариум-кнопка — приглушённая, в нижнем правом углу stage,
       чтобы не перетягивать внимание с заголовка/CTA.
       DOM: прямой ребёнок stage (НЕ внутри .index-hero__content),
       чтобы z-index 7 конкурировал с .index-hero__industries (z:6)
       в stacking-контексте stage и кнопка не пряталась под карточками. */
.index-hero__aquarium {
  position: absolute;
  right: 32px;
  bottom: 124px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-family: var(--font-heading);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(10, 14, 26, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
  z-index: 7;
  /* Гаснет вместе с заголовком/теглайном (раньше унаследовала это
     значение от .index-hero__content; теперь правило — на самой кнопке). */
  opacity: calc(1 - var(--pText));
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, opacity 0.25s ease;
}
.index-hero__aquarium:hover {
  background: rgba(155, 21, 21, 0.3);
  border-color: rgba(155, 21, 21, 0.6);
  color: rgba(255, 255, 255, 0.95);
}
.index-hero__aquarium-dot {
  width: 6px; height: 6px;
  background: var(--color-accent);
  border-radius: 50%;
  opacity: 0.65;
  animation: index-hero-pulse 2.4s ease-in-out infinite;
}
@keyframes index-hero-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 0.8;  transform: scale(1.1); }
}

/* ============================
   Industries strip — прижат к низу stage, растёт по --p
   ============================ */
.index-hero__industries {
  position: absolute;
  box-sizing: border-box;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--container-max);
  padding: 0 var(--container-padding);
  z-index: 6;
}

/* Заголовок виден только в expanded (--p ~ 0.4..1) */
.index-hero__industries-head {
  text-align: center;
  margin-bottom: calc(var(--p) * 18px);
  max-height: calc(var(--p) * 80px);
  opacity: calc(var(--p) * 2.5 - 1);
  overflow: hidden;
}

.index-hero__industries-head .section-title {
  color: #fff;
  margin: 0;
  white-space: nowrap;
  font-size: 32px;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
}

/* === Grid: 4 колонки (3 карточки + кнопка-toggle в 4-й колонке) === */
.index-hero__industries-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: calc(2px + var(--p) * 16px);
  align-items: stretch;
}

/* === Card === */
.index-hero__card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: var(--color-dark);
  overflow: hidden;
  transition: box-shadow 0.35s ease, transform 0.35s ease, border-color 0.35s ease;
}

.index-hero__card:hover {
  z-index: 2;
  box-shadow: 0 0 0 2px var(--color-accent), 0 16px 48px rgba(0, 0, 0, 0.45);
  transform: translateY(-3px);
}

.index-hero__card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-accent);
  z-index: 3;
  transition: width 0.3s ease;
}
.index-hero__card:hover::before { width: 6px; }

.index-hero__card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 36px;
  height: 36px;
  border-top: 3px solid var(--color-accent);
  border-right: 3px solid var(--color-accent);
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.index-hero__card:hover::after { opacity: 1; }

/* Изображение — высота линейно от --p */
.index-hero__card-image {
  position: relative;
  height: calc(var(--p) * 200px);
  overflow: hidden;
  background-color: #1a1a2e;
  flex-shrink: 0;
}
.index-hero__card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.index-hero__card-image::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60%;
  background: linear-gradient(
    to top,
    rgba(10, 10, 25, 0.85) 0%,
    rgba(10, 10, 25, 0.30) 60%,
    transparent 100%
  );
  z-index: 1;
}
.index-hero__card-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 20px,
    rgba(255, 255, 255, 0.02) 20px,
    rgba(255, 255, 255, 0.02) 21px
  );
  z-index: 2;
  pointer-events: none;
}

/* Body: padding и шрифт расширяются */
.index-hero__card-body {
  position: relative;
  padding: calc(12px + var(--p) * 12px) calc(14px + var(--p) * 10px);
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to bottom, #0d1117, #141a24);
  border-top: 2px solid rgba(155, 21, 21, 0.4);
}
.index-hero__card-body::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 30%,
    rgba(255, 255, 255, 0.15) 70%,
    transparent 100%
  );
}

.index-hero__card-title {
  font-family: var(--font-heading);
  font-size: calc(13px + var(--p) * 3px);
  font-weight: 700;
  color: #fff;
  margin: 0 0 calc(var(--p) * 10px);
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: color 0.3s ease;
}
.index-hero__card:hover .index-hero__card-title { color: #ff4444; }

.index-hero__card-desc {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.55);
  line-height: var(--leading-normal);
  margin: 0 0 calc(var(--p) * 18px);
  max-height: calc(var(--p) * 80px);
  opacity: var(--p);
  overflow: hidden;
  flex: 1;
}

.index-hero__card-link {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent-light);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  align-self: flex-start;
  max-height: calc(var(--p) * 24px);
  opacity: var(--p);
  overflow: hidden;
  transition: gap 0.25s ease, color 0.25s ease;
}
.index-hero__card-link svg { width: 16px; height: 16px; }
.index-hero__card:hover .index-hero__card-link { gap: var(--space-sm); color: #ff6666; }

/* === Toggle и 4-я карта (food) — на одной ячейке (4 колонка, 1 строка) === */
.index-hero__card--toggle,
.index-hero__card--extra {
  grid-column: 4 / 5;
  grid-row: 1 / 2;
}

/* food-карточка появляется только при --more-open */
.index-hero__card--extra {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.index-hero--more-open .index-hero__card--extra {
  opacity: 1;
  pointer-events: auto;
}

/* === Toggle = .index-hero__card с модификатором: чтобы геометрия
       (image height, body padding, title/desc/link rhythm) полностью
       совпадала с обычными карточками и при изменении --p ничего
       не "прыгало" между ячейками 4-колоночного грида. === */
.index-hero__card--toggle {
  background: linear-gradient(135deg, #0a275d 0%, #0d1117 100%);
  border-color: rgba(155, 21, 21, 0.3);
  cursor: pointer;
  font: inherit;
  text-align: left;
  padding: 0;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.35s ease,
              transform 0.35s ease, opacity 0.3s ease;
}

.index-hero__card--toggle:hover {
  background: linear-gradient(135deg, #0d3175 0%, #1a2030 100%);
  border-color: var(--color-accent);
}

/* Прозрачный image-плейсхолдер у toggle: убираем фон, gradient overlay
   и hatch-узор, оставляем только размер. */
.index-hero__card--toggle .index-hero__card-image {
  background-color: transparent;
}
.index-hero__card--toggle .index-hero__card-image::before,
.index-hero__card--toggle .index-hero__card-image::after { content: none; }

/* В body тоже снимаем тёмный gradient карточки, чтобы виден был
   синий gradient самой кнопки. Border-top и тонкая декоративная
   линия остаются — они держат тот же rhythm высоты, что и у card. */
.index-hero__card--toggle .index-hero__card-body {
  background: transparent;
}

/* Прячем кнопку при раскрытии скрытой карточки. */
.index-hero--more-open .index-hero__card--toggle {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
}

/* === Aquarium fullscreen view === */
.index-hero__aquarium-view {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.index-hero__aquarium-view--open { opacity: 1; visibility: visible; }
.index-hero__aquarium-video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.index-hero__aquarium-close {
  position: absolute;
  top: 24px; right: 24px;
  width: 44px; height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.index-hero__aquarium-close:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.index-hero__aquarium-corner-tl,
.index-hero__aquarium-corner-tr,
.index-hero__aquarium-corner-bl,
.index-hero__aquarium-corner-br {
  position: absolute; width: 36px; height: 36px; pointer-events: none;
}
.index-hero__aquarium-corner-tl { top: 24px;    left: 24px;  border-top: 2px solid var(--color-accent); border-left: 2px solid var(--color-accent); }
.index-hero__aquarium-corner-tr { top: 24px;    right: 24px; border-top: 2px solid var(--color-accent); border-right: 2px solid var(--color-accent); }
.index-hero__aquarium-corner-bl { bottom: 24px; left: 24px;  border-bottom: 2px solid var(--color-accent); border-left: 2px solid var(--color-accent); }
.index-hero__aquarium-corner-br { bottom: 24px; right: 24px; border-bottom: 2px solid var(--color-accent); border-right: 2px solid var(--color-accent); }

.index-hero__aquarium-label {
  position: absolute;
  left: 24px; bottom: 32px;
  font-family: var(--font-heading);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

/* === Responsive === */
@media (max-width: 1100px) {
  .index-hero__title { font-size: 52px; }
  .index-hero__industries-head .section-title { font-size: 26px; }
}

@media (max-width: 1023px) {
  .index-hero__aquarium { display: none; }
  .index-hero__industries-grid { grid-template-columns: repeat(2, 1fr); }
  .index-hero__card--toggle,
  .index-hero__card--extra {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
  }
}

@media (max-width: 900px) {
  .index-hero__title { font-size: 32px; }
  .index-hero__industries-head .section-title { font-size: 22px; }
  .index-hero__industries { bottom: 30px; width: 100%; }
}

/* На мобильных отключаем sticky/scroll-progress: статический flow,
   --p и --pText форсируем 1, чтобы карточки сразу в expanded виде. */
@media (max-width: 767px) {
  .index-hero { height: auto; --p: 1; --pText: 1; }
  .index-hero__stage {
    position: relative;
    height: auto;
    overflow: visible;
  }
  .index-hero__video-layer {
    position: relative;
    height: 60vh;
    transform: none;
  }
  .index-hero__content {
    position: relative;
    inset: auto;
    padding: 80px var(--container-padding-mobile) 40px;
    transform: none;
    opacity: 1;
    width: auto;
    max-width: unset;
  }
  .index-hero__aquarium {
    position: relative;
    right: auto;
    bottom: auto;
    align-self: flex-start;
    margin-top: 8px;
  }
  .index-hero__industries {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    padding: 40px var(--container-padding-mobile) 60px;
  }
  .index-hero__industries-head .section-title { white-space: normal; font-size: 22px; }
  .index-hero__industries-grid { grid-template-columns: 1fr; }
  .index-hero__card--toggle,
  .index-hero__card--extra {
    grid-column: 1 / 2;
    grid-row: 4 / 5;
  }
}

@media (max-width: 640px) {
  .index-hero__title { font-size: 30px; }
  .index-hero__tagline { font-size: 15px; }
  .index-hero__aquarium-close { width: 36px; height: 36px; font-size: 22px; }
  .index-hero__aquarium-corner-tl,
  .index-hero__aquarium-corner-tr,
  .index-hero__aquarium-corner-bl,
  .index-hero__aquarium-corner-br { width: 24px; height: 24px; }
}

@media (max-width: 375px) {
  .index-hero__title { font-size: 22px; line-height: 1.14; }
}
