/* =====================================================================
   KURGAN-HUNT — заставка «Охотничьи хозяйства» (владелец C5a)
   7 карточек-перевёртышей на 3D-дуге. Секция закрепляется (pin) —
   трансформируем только внутренние обёртки (.kh-grounds__formation/wall).
   ===================================================================== */

.kh-grounds {
  --g: clamp(12px, 1.7vh, 26px);
  --cw: 220px;
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 620px;
  z-index: var(--z-content);
}
.kh-grounds__stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--header-h) + 1.2vh) var(--gutter) clamp(10px, 2vh, 22px);
}
.kh-grounds__vignette {
  position: absolute;
  inset: 0;
  z-index: -1; /* всегда под заголовком и карточками (в т. ч. при перестановке order) */
  pointer-events: none;
  background:
    radial-gradient(75% 65% at 50% 55%, rgba(2, 8, 5, 0) 0%, rgba(2, 8, 5, .45) 70%, rgba(2, 8, 5, .85) 100%),
    linear-gradient(180deg, rgba(4, 13, 9, .6) 0%, rgba(4, 13, 9, 0) 18%, rgba(4, 13, 9, 0) 85%, rgba(4, 13, 9, .6) 100%);
}

/* Заголовок */
.kh-grounds__head { position: relative; flex: none; text-align: center; isolation: isolate; }
/* мягкая тёмная подложка под заголовком — читается на любом фоне 3D-мира */
.kh-grounds__head::before {
  content: '';
  position: absolute;
  inset: -26px -12%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(3, 10, 7, .62), rgba(3, 10, 7, 0));
}
.kh-grounds__eyebrow { font-size: clamp(.62rem, .55rem + .2vw, .75rem); }
.kh-grounds__title {
  margin-top: clamp(4px, .8vh, 10px);
  font-size: clamp(1.9rem, .4rem + 4.6vh, 4rem);
  line-height: 1.02;
  perspective: 700px;
}
.kh-grounds__split { display: inline-block; }
.kh-grounds__word { display: inline-block; white-space: nowrap; transform-style: preserve-3d; }
.kh-grounds__ch {
  display: inline-block;
  background: var(--grad-gold);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  transform-origin: 50% 100%;
  backface-visibility: hidden;
}

/* Подсказка */
.kh-grounds__hint {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  margin-top: clamp(6px, 1.2vh, 14px);
  font-size: clamp(.72rem, .66rem + .2vw, .85rem);
  letter-spacing: .06em;
  color: var(--text-3);
  text-align: center;
  text-shadow: 0 0 2px rgba(3, 10, 7, .9), 0 1px 14px rgba(3, 10, 7, .95);
}
@media (max-width: 1023px) { .kh-grounds__hint { color: var(--text-2); } }
.kh-grounds__hint-ico { display: inline-flex; color: var(--gold-400); }
.kh-grounds__hint-ico .kh-icon { width: 1.3em; height: 1.3em; }
.kh-grounds__hint--touch { display: none; }
html.no-hover .kh-grounds__hint--hover { display: none; }
html.no-hover .kh-grounds__hint--touch { display: inline; }

/* Строй карточек */
.kh-grounds__formation {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: clamp(8px, 1.6vh, 20px);
  perspective: 1800px;
  perspective-origin: 50% 45%;
}
.kh-grounds__wall {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--g);
  transform-style: preserve-3d;
}
.kh-grounds__row {
  display: flex;
  justify-content: center;
  gap: var(--g);
  transform-style: preserve-3d;
}
.kh-grounds__fallback { display: grid; gap: 10px; padding: 0; list-style: none; text-align: center; }
.kh-grounds__fallback a { color: var(--gold-200); font-family: var(--ff-head); font-size: 1.5rem; }
.kh-grounds__fallback a:hover { color: var(--gold-100); }

.kh-gslot {
  position: relative;
  width: var(--cw);
  flex: none;
  transform-style: preserve-3d;
}
/* Компьютер: указатель ловят только сами карточки. Средняя карточка нижнего
   ряда лежит в одной плоскости со строем, и Safari при равной глубине часть
   точек отдавал строю — карточка теряла наведение посреди себя */
@media (min-width: 1024px) {
  .kh-grounds__wall { pointer-events: none; }
  .kh-gcard, .kh-grounds__fallback { pointer-events: auto; }
}
/* издали подлетающая карточка (kh-grounds.js) и весь строй, пока нажатая карточка улетает */
.kh-gslot.is-far .kh-gcard, .kh-grounds.is-flying .kh-gslot, .kh-grounds.is-flying .kh-gcard { pointer-events: none; }

/* ---------- Карточка ---------- */
.kh-gcard {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  color: var(--text);
  transform-style: preserve-3d;
  container-type: inline-size;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
/* Парит (GSAP) обёртка, а не сама ссылка: цель наведения неподвижна.
   Попадания ловит только ссылка — края карточки не «дрожат» под указателем */
.kh-gcard__float {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
  pointer-events: none;
}
.kh-gcard__flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .9s cubic-bezier(.55, .05, .2, 1);
}
.kh-gcard.is-flipped .kh-gcard__flip { transform: translateZ(50px) rotateY(180deg); }
.kh-gcard__face {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border-radius: 10px;
  /* Грань — отдельная группа наложения: фото, рамка, номер, название и блик
     рисуются внутри неё и прячутся вместе с ней. Без этого Safari выносил их
     отдельными слоями в общее 3D-пространство переворота: они проступали
     сквозь оборот зеркально, а при сортировке с самой гранью часть фото
     уходила под тёмно-зелёный фон («наполовину зелёная» карточка).
     Поэтому хватает backface-visibility — без переключения visibility по
     таймеру, из-за которого карточка пропадала при прерванном перевороте */
  isolation: isolate;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .85), 0 0 0 1px rgba(221, 176, 74, .45);
}
/* Оборот виден только перевёрнутым — сразу с золотым свечением: переход
   тени перерисовывал обе грани каждый кадр */
.kh-gcard__back {
  transform: rotateY(180deg);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, .9), 0 0 0 1px rgba(239, 205, 115, .8), 0 0 50px -10px rgba(221, 176, 74, .45);
}
.kh-gcard:focus-visible .kh-gcard__face { box-shadow: 0 0 0 2px var(--gold-200), 0 0 40px -6px rgba(239, 205, 115, .7); }

/* Двойная золотая рамка с уголками */
.kh-gcard__frame {
  position: absolute;
  inset: 4.5cqw;
  z-index: 3;
  border: 1px solid rgba(239, 205, 115, .65);
  border-radius: 4px;
  pointer-events: none;
}
.kh-gcard__frame::before {
  content: '';
  position: absolute;
  inset: 2.4cqw;
  border: 1px solid rgba(239, 205, 115, .28);
  border-radius: 2px;
}
.kh-gcard__corner {
  position: absolute;
  width: 15cqw;
  height: 15cqw;
  background: url('../../media/ornaments/corner.svg') center / contain no-repeat;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .6));
}
.kh-gcard__corner--tl { left: -2.5cqw; top: -2.5cqw; }
.kh-gcard__corner--tr { right: -2.5cqw; top: -2.5cqw; transform: scaleX(-1); }
.kh-gcard__corner--bl { left: -2.5cqw; bottom: -2.5cqw; transform: scaleY(-1); }
.kh-gcard__corner--br { right: -2.5cqw; bottom: -2.5cqw; transform: scale(-1, -1); }

/* Лицевая сторона */
.kh-gcard__front { background: linear-gradient(165deg, #0f2a20 0%, #06140f 60%, #020805 100%); }
.kh-gcard__media { position: absolute; inset: 0; display: block; }
/* Без увеличения при наведении: лицевая сторона сразу отворачивается,
   а слой фото пересоздавался бы на каждое наведение */
.kh-gcard__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(.75) saturate(.9);
  transform: scale(1.04);
}
.kh-gcard__media.is-missing img { visibility: hidden; }
.kh-gcard__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(3, 10, 7, .45) 0%, rgba(3, 10, 7, 0) 26%, rgba(3, 10, 7, .25) 48%, rgba(3, 10, 7, .92) 80%, #030a07 100%);
}
.kh-gcard__mark {
  position: absolute;
  left: 50%; top: 40%;
  width: 62cqw;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}
.kh-gcard__mark img { width: 100%; height: 100%; object-fit: contain; }
.kh-gcard__media.is-missing + .kh-gcard__mark { opacity: .16; }
.kh-gcard__media.is-missing { background: radial-gradient(80% 60% at 50% 35%, rgba(18, 148, 102, .38), transparent 75%), linear-gradient(165deg, #0c3a2a, #04120c 70%); }

.kh-gcard__num {
  position: absolute;
  left: 10cqw; top: 9cqw;
  z-index: 4;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 15cqw;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(239, 205, 115, .85);
  text-shadow: 0 0 18px rgba(221, 176, 74, .25);
}
.kh-gcard__info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 4;
  display: block;
  padding: 0 10cqw 11cqw;
}
.kh-gcard__name {
  display: block;
  font-family: var(--ff-head);
  font-weight: 600;
  font-size: clamp(1.15rem, 12.5cqw, 2.6rem);
  line-height: 1;
  background: var(--grad-gold);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .8));
}
.kh-gcard__district {
  display: block;
  margin-top: 2cqw;
  font-size: clamp(.56rem, 3.6cqw, .78rem);
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-300);
}
.kh-gcard__tagline {
  display: block;
  margin-top: 2.6cqw;
  font-family: var(--ff-head);
  font-style: italic;
  font-size: clamp(.8rem, 5.6cqw, 1.2rem);
  line-height: 1.25;
  color: var(--text);
}
.kh-gcard__species { display: flex; gap: 2.4cqw; margin-top: 4cqw; }
.kh-gcard__sp {
  width: 10.5cqw;
  height: 10.5cqw;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(221, 176, 74, .45);
  background: rgba(3, 10, 7, .55);
}
.kh-gcard__sp img { width: 72%; height: 72%; object-fit: contain; }

/* Оборотная сторона */
.kh-gcard__back {
  display: flex;
  flex-direction: column;
  padding: 11cqw 10cqw 10cqw;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(31, 191, 133, .22), transparent 70%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .014) 0 2px, transparent 2px 6px),
    linear-gradient(165deg, #0b5039 0%, #063a2a 40%, #03190f 100%);
}
.kh-gcard__bname {
  display: block;
  font-family: var(--ff-head);
  font-weight: 600;
  font-size: clamp(1.1rem, 11cqw, 2.3rem);
  line-height: 1;
  color: var(--gold-100);
}
.kh-gcard__bdistrict {
  display: block;
  margin-top: 1.8cqw;
  font-size: clamp(.54rem, 3.4cqw, .74rem);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold-300);
}
.kh-gcard__rule { display: block; height: 1px; margin: 4cqw 0; background: var(--grad-gold-line); opacity: .7; }
.kh-gcard__short {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
  font-size: clamp(.7rem, 5.1cqw, .98rem);
  line-height: 1.45;
  color: var(--text);
}
.kh-gcard__facts { display: grid; gap: 2.4cqw; margin-top: 4.5cqw; padding: 0; list-style: none; }
.kh-gcard__fact { display: flex; align-items: center; gap: 2.6cqw; font-size: clamp(.64rem, 4.3cqw, .86rem); line-height: 1.25; }
.kh-gcard__fact .kh-icon { width: 1.25em; height: 1.25em; color: var(--gold-300); }
.kh-gcard__fact b { font-weight: 700; color: var(--gold-100); }
.kh-gcard__fact span { color: var(--text-2); }
.kh-gcard__chips { display: flex; flex-wrap: wrap; gap: 1.6cqw; margin-top: 4cqw; }
.kh-gcard__chip {
  padding: .3em .8em;
  font-size: clamp(.56rem, 3.5cqw, .74rem);
  font-weight: 600;
  color: var(--gold-200);
  border: 1px solid rgba(221, 176, 74, .4);
  border-radius: 999px;
  background: rgba(3, 14, 10, .45);
}
.kh-gcard__more {
  --btn-h: clamp(30px, 15cqw, 46px);
  align-self: flex-start;
  margin-top: auto;
  padding: 0 1.3em;
  font-size: clamp(.56rem, 3.6cqw, .72rem);
  pointer-events: auto; /* блик кнопки при наведении (обёртка карточки попадания не ловит) */
}
.kh-gcard__more .kh-icon { width: 1.3em; height: 1.3em; }

/* Компактные карточки: убираем второстепенное */
@container (max-width: 250px) {
  .kh-gcard__chips, .kh-gcard__fact:nth-child(n+3) { display: none; }
  .kh-gcard__short { -webkit-line-clamp: 4; }
}
@container (max-width: 200px) {
  .kh-gcard__facts { display: none; }
}

/* Блик по золотому краю во время переворота */
.kh-gcard__glint {
  position: absolute;
  inset: -10%;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 38%, rgba(255, 236, 170, .0) 42%, rgba(255, 236, 170, .55) 50%, rgba(255, 236, 170, 0) 58%, transparent 62%);
  opacity: 0;
  transform: translateX(-60%);
}

/* Точки карусели (телефон) */
.kh-grounds__dots { display: flex; justify-content: center; gap: 4px; margin-top: 16px; }
.kh-grounds__dots[hidden] { display: none; }
.kh-grounds__dot { position: relative; width: 28px; height: 28px; }
.kh-grounds__dot::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  transform: rotate(45deg);
  border: 1px solid var(--gold-400);
  transition: background-color .3s, transform .3s;
}
.kh-grounds__dot.is-active::before { background: var(--gold-300); transform: rotate(45deg) scale(1.25); box-shadow: 0 0 10px rgba(239, 205, 115, .6); }

/* Невысокие экраны: шапка сайта при прокрутке вниз прячется — отступ меньше */
@media (min-width: 1024px) and (max-height: 820px) {
  .kh-grounds__stage { padding-top: calc(var(--header-h) * .6); }
}

/* ---------- Планшет: сетка без закрепления ---------- */
@media (max-width: 1023px) {
  .kh-grounds { height: auto; min-height: 0; padding-block: var(--section-y); }
  .kh-grounds__stage { position: relative; inset: auto; padding: 0 var(--gutter); }
  .kh-grounds__title { font-size: var(--fs-h2); }
  .kh-grounds__formation { margin-top: clamp(28px, 5vw, 48px); perspective: 1400px; }
  .kh-grounds__wall { flex-direction: row; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 900px; }
  .kh-grounds__row { display: contents; }
  .kh-gslot { width: calc((100% - var(--g) * 2) / 3); }
  .kh-grounds__head { order: -2; }
  .kh-grounds__vignette { inset: calc(-1 * var(--section-y)) 0; }
  .kh-grounds__head::before { inset: -40px -6%; background: radial-gradient(closest-side, rgba(3, 10, 7, .8), rgba(3, 10, 7, 0)); }
  .kh-grounds__hint { order: -1; margin-top: 14px; }
}

/* ---------- Телефон: горизонтальная карусель ---------- */
@media (max-width: 767px) {
  .kh-grounds__stage { padding: 0; }
  .kh-grounds__head { padding-inline: var(--gutter); }
  .kh-grounds__hint { padding-inline: var(--gutter); }
  .kh-grounds__formation { display: block; perspective: none; margin-top: 22px; }
  .kh-grounds__wall {
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    max-width: none;
    gap: 14px;
    padding: 30px 11vw 36px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    transform-style: flat;
  }
  .kh-grounds__wall::-webkit-scrollbar { display: none; }
  .kh-gslot { width: 78vw; max-width: 340px; scroll-snap-align: center; }
  .kh-gcard__short { -webkit-line-clamp: 6; }
}
