/* KipSlide — спільний старт каталогів у стилі /courses.
 * Стилі скоповані атрибутом data-catalog-hero-page; /
 * і /trees його не отримують. Відео лишається фоном, а клік завжди
 * веде на YouTube watch — саме такі перегляди враховує канал. */

[data-catalog-hero-page] .cv-feature {
  display: grid;
  position: relative;
  isolation: isolate;
  grid-template-columns: minmax(0, 1fr);
  align-content: end;
  min-height: clamp(156px, 18vw, 220px);
  margin: 12px 0 var(--ksds-space-5, 40px);
  padding: clamp(12px, 2vw, 20px);
  overflow: hidden;
  border-radius: var(--ksds-radius-xxl, 32px);
  background: var(--ksds-color-surface-muted);
  color: #fff;
}

[data-catalog-hero-page] .cv-feature .phead__content {
  display: grid;
  justify-items: start;
  gap: 0;
  min-width: 0;
  position: relative;
  z-index: 2;
  pointer-events: none;
}

[data-catalog-hero-page] .cv-feature h2 {
  max-width: 24ch;
  margin: 0;
  color: inherit;
  font: var(--ksds-font-weight-bold, 700) clamp(1.5rem, 4vw, 3rem)/1.2 var(--ksds-font-family-display, var(--cv-fd));
  text-wrap: balance;
}

[data-catalog-hero-page] .cv-feature :is(.phead__eyebrow, .phead__meta, .phead__lead) {
  margin: 0;
  color: #fff !important;
  font-size: var(--ksds-font-size-body-sm, 14px);
}

[data-catalog-hero-page] .cv-feature .phead__lead {
  max-width: 72ch;
  line-height: 1.5;
}

[data-catalog-hero-page] .cv-feature .phead__cta {
  position: relative;
  z-index: 3;
  justify-self: start;
  justify-content: flex-start;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--ksds-button-radius, 14px);
  background: linear-gradient(135deg, var(--cv-action-start), var(--cv-action-end));
  color: var(--cv-action-ink);
  font: 700 15px/1.3 var(--cv-fb);
  text-decoration: none;
  pointer-events: auto;
}

[data-catalog-hero-page] .cv-feature .phead__cta::after {
  content: "›";
  display: inline-block;
  margin-left: 8px;
  font: inherit;
  line-height: 1;
}

[data-catalog-hero-page] .cv-feature .phead__cta:hover {
  background: var(--cv-action-start);
}

[data-catalog-hero-page] .cv-feature__visual {
  display: block;
  position: absolute;
  inset: 0;
  z-index: -1;
  height: auto;
  border: 0;
  border-radius: inherit;
  overflow: hidden;
}

[data-catalog-hero-page] .cv-feature__visual::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(90deg, rgb(0 0 0 / .82), rgb(0 0 0 / .35)),
    linear-gradient(0deg, rgb(0 0 0 / .62), transparent);
}

[data-catalog-hero-page] .cv-feature__visual :is(img, iframe, video) {
  display: block;
  border: 0;
}

[data-catalog-hero-page] .cv-feature__poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

[data-catalog-hero-page] .cv-feature__visual video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* HTML/canvas-сцена заповнює банер повністю; кліки лишаються за CTA. */
[data-catalog-hero-page] .cv-feature__visual--scene iframe {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  transform: none;
  border: 0;
  pointer-events: none;
}

/* hide_text прибирає лише описи; CTA лишається доступним у всіх каталогах. */
[data-catalog-hero-page] .cv-feature--no-text .phead__content > :not(.phead__cta) {
  display: none !important;
}

/* YouTube тримає 16:9; розтягуємо по shortest-side, щоб не було порожніх смуг. */
[data-catalog-hero-page] .cv-feature__visual iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-width: 177.78vh;
  min-height: 56.25vw;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

[data-catalog-hero-page] .cv-feature__surface {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: #fff;
  text-decoration: none;
}

[data-catalog-hero-page] .cv-feature__play {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 1px solid rgb(255 255 255 / .55);
  border-radius: 50%;
  background: rgb(0 0 0 / .45);
  box-shadow: 0 8px 24px rgb(0 0 0 / .35);
  font-size: 26px;
  line-height: 1;
  transition: transform .18s ease, background-color .18s ease;
}

[data-catalog-hero-page] .cv-feature__surface:hover .cv-feature__play {
  transform: scale(1.06);
  background: rgb(0 0 0 / .62);
}

[data-catalog-hero-page] .cv-feature__surface:focus-visible,
[data-catalog-hero-page] .cv-feature .phead__cta:focus-visible {
  outline: 2px solid var(--cv-focus, #0b5fd1);
  outline-offset: 4px;
}

/* На сторінках з автоматичним стартом лишаємо один акуратний шлях .cv-crumbs.
   Старі різностильові breadcrumbs приховуємо, але не видаляємо з DOM. */
body[data-catalog-hero-page]:has(.cv-crumbs) :is(nav, div, ul)[class*="breadcrumb"]:not(.cv-crumbs),
body[data-catalog-hero-page]:has(.cv-crumbs) .crumbs:not(.cv-crumbs){display:none!important}

/* Пошук і напрями — ті самі сіткові правила, що й у каталозі /courses. */
[data-catalog-hero-page] .catalog-hero-play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
  margin-bottom: var(--ksds-space-5, 40px);
}

[data-catalog-hero-page] .catalog-hero-play--single {
  grid-template-columns: minmax(0, 1fr);
}

[data-catalog-hero-page] .catalog-hero-play .catalog-hero-sidebar {
  display: grid;
  gap: 16px;
  min-width: 0;
}

[data-catalog-hero-page] .catalog-hero-play .cv-direction-section {
  min-width: 0;
  margin: 0;
}

[data-catalog-hero-page] .catalog-hero-play .cv-direction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 128px), 1fr));
  gap: 16px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

[data-catalog-hero-page] .catalog-hero-play .cv-direction-grid a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--cv-line);
  border-radius: var(--ksds-radius-md, 16px);
  background: var(--cv-catalog-panel);
  color: var(--cv-ink);
  text-align: center;
  font: 600 var(--ksds-font-size-body-sm, 14px)/1.25 var(--cv-fb);
  text-decoration: none;
  overflow-wrap: anywhere;
}

[data-catalog-hero-page] .catalog-hero-play .cv-direction-grid a[aria-current="true"] {
  background: linear-gradient(135deg, var(--cv-action-start), var(--cv-action-end));
  color: var(--cv-action-ink);
}

[data-catalog-hero-page] .catalog-hero-play :is(a, button, input, select, summary):focus-visible {
  outline: 2px solid var(--cv-focus, #0b5fd1);
  outline-offset: 2px;
}

@media (max-width: 940px) {
  [data-catalog-hero-page] .catalog-hero-play {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  [data-catalog-hero-page] .cv-feature {
    min-height: 156px;
    padding: 12px;
  }

  [data-catalog-hero-page] .catalog-hero-play .cv-direction-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(100px, 32%);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
  }

  [data-catalog-hero-page] .catalog-hero-play .cv-direction-grid li {
    scroll-snap-align: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-catalog-hero-page] .cv-feature__play {
    transition: none;
  }

  [data-catalog-hero-page] .cv-feature__surface:hover .cv-feature__play {
    transform: none;
  }
}

/* /teacher: looping local animation is text-free.
   Scoped by the injected media class, not by a single uploaded filename,
   so replacing the asset in admin does not leave stale hero text. */
body[data-page="teacher.index"] .cv-feature:has(.cv-feature__visual--video) .phead__content > :not(.phead__cta) {
  display: none !important;
}
