.carousel-hero {
  position: relative;
  padding: 48px 0 80px;
  background: transparent;
  --hero-title-size: clamp(30px, 3.2vw, 48px);
  --hero-text-size: clamp(15px, 1.2vw + 10px, 20px);
  --hero-content-max: 520px;
}

.carousel-hero .carousel-viewport {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border-radius: 32px;
  /* Optimize for smooth animations */
  contain: layout style paint;
  isolation: isolate;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  will-change: scroll-position;
}

.carousel-hero .carousel-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 0; /* avoid inter-slide seam */
  /* Optimize for smooth transforms */
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Smooth slide transition effects */
.carousel-hero {
  --hero-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --dir: 1; /* 1 for forward, -1 for backward */
}

.carousel-hero.is-backward { --dir: -1; }
.carousel-hero.is-forward { --dir: 1; }

/* Optimize animated layers - only set will-change when needed */
.carousel-hero .hero-slide {
  will-change: transform;
}

.carousel-hero .hero-slide.is-entering,
.carousel-hero .hero-slide.is-leaving {
  will-change: transform, opacity;
}

/* Effect: smooth slide (simplified smooth transition) */
.carousel-hero[data-carousel-effect="glitch"] .hero-slide { 
  backface-visibility: hidden; 
  -webkit-backface-visibility: hidden; 
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-entering { 
  z-index: 2; 
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-leaving { 
  z-index: 1; 
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide__media img {
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  display: block;
  transform: scale(1);
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-entering .hero-slide__media img {
  animation: smoothSlideIn .6s var(--hero-ease) both;
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-leaving .hero-slide__media img {
  animation: smoothSlideOut .4s var(--hero-ease) both;
}

@keyframes smoothSlideIn {
  0% { 
    transform: translateX(calc(20px * var(--dir))) scale(1); 
    opacity: 0.8; 
  }
  100% { 
    transform: translateX(0) scale(1); 
    opacity: 1; 
  }
}

@keyframes smoothSlideOut {
  0% { 
    transform: translateX(0) scale(1); 
    opacity: 1; 
  }
  100% { 
    transform: translateX(calc(-20px * var(--dir))) scale(0.98); 
    opacity: 0.8; 
  }
}

/* Smooth content animation */
.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-entering .hero-slide__brand { 
  animation: contentSlideUp .5s var(--hero-ease) both .1s; 
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-entering h2 { 
  animation: contentSlideUp .5s var(--hero-ease) both .15s; 
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-entering p { 
  animation: contentSlideUp .5s var(--hero-ease) both .2s; 
}

.carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-entering .btn-hero { 
  animation: contentSlideUp .5s var(--hero-ease) both .25s; 
}

@keyframes contentSlideUp { 
  0% { 
    opacity: 0; 
    transform: translateY(20px); 
  } 
  100% { 
    opacity: 1; 
    transform: translateY(0); 
  } 
}

/* Mobile optimizations for smoother animations */
@media (max-width: 768px) {
  .carousel-hero .carousel-viewport {
    /* Reduce complexity on mobile */
    contain: layout paint;
  }
  
  .carousel-hero .hero-slide {
    /* Faster transitions on mobile */
    transition: opacity .2s ease;
  }
  
  .carousel-hero .hero-slide__content {
    transition: transform .2s ease, opacity .2s ease;
  }
  
  /* Simplify animations on mobile */
  .carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-entering .hero-slide__media img {
    animation: smoothSlideIn .4s var(--hero-ease) both;
  }
  
  .carousel-hero[data-carousel-effect="glitch"] .hero-slide.is-leaving .hero-slide__media img {
    animation: smoothSlideOut .3s var(--hero-ease) both;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-hero .hero-slide,
  .carousel-hero .hero-slide__media,
  .carousel-hero .hero-slide__content {
    animation: none !important;
    transition: none !important;
  }
}

/* Progress bar base layout */
.carousel-progress {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr; /* stretch segments evenly across full width */
  gap: 8px;
}

/* Fixed overlay progress bar at the top of the viewport */
.carousel-progress--overlay {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  z-index: 6;
  pointer-events: none; /* do not block interactions */
  /* Constrain width for balanced look */
  width: clamp(160px, 66%, 720px);
  margin: 0 auto;
}

/* Прогресс-бар внутри контента слайдов */
.hero-slide .carousel-progress {
  margin-bottom: 24px;
  pointer-events: auto;
}

.carousel-progress__item {
  position: relative;
  display: block;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.4);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.carousel-progress__fill {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  background: linear-gradient(90deg, #ffffff 0%, #f0f0f0 100%);
  border-radius: inherit;
  transform-origin: left center;
  will-change: transform;
}

.carousel-progress__item.is-complete .carousel-progress__fill {
  transform: scaleX(1);
}

.carousel-progress__item.is-active .carousel-progress__fill {
  animation: carouselProgressFill var(--carousel-duration, 4000ms) linear forwards;
}

.carousel-progress.is-paused .carousel-progress__fill {
  animation-play-state: paused;
}

@keyframes carouselProgressFill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.hero-slide {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 440px;
  padding: 72px 80px;
  color: #fff;
  border-radius: 0; /* viewport provides rounded mask */
  overflow: hidden;
  box-shadow: 0 28px 65px rgba(15,23,42,.35);
  /* Optimize for smooth animations */
  opacity: 1;
  transition: opacity .3s ease;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
}

/* Затемнение убрано по запросу пользователя
.hero-slide::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(9,12,27,.85) 0%, rgba(9,12,27,.65) 0%, rgba(9,12,27,.15) 0%);
  z-index: 1;
}
*/

.hero-slide__media {
  position: absolute;
  inset: 0;
  background-image: var(--hero-image);
  background-size: cover;
  background-position: center;
  transform: scale(1.06);
  filter: saturate(1.1);
  z-index: 0;
  /* Optimize for smooth animations */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}

/* Cinematic Ken Burns on active slide */
.hero-slide.is-active .hero-slide__media {
  animation: heroKenBurns 10s ease-in-out both;
}

@keyframes heroKenBurns {
  0% { transform: scale(1.06); filter: saturate(1.06) brightness(0.98); }
  55% { transform: scale(1.1) translate3d(2px,2px,0) rotateZ(0deg); filter: saturate(1.1) brightness(1); }
  100% { transform: scale(1.12) translate3d(6px,4px,0) rotateZ(0.08deg); filter: saturate(1.12) brightness(1.02); }
}

.hero-slide__content {
  position: relative;
  z-index: 2;
  max-width: var(--hero-content-max);
  min-width: 0;
  display: grid;
  gap: 20px;
  align-items: flex-start;
  text-align: left;
  /* Optimize content animations */
  transform: translateY(6px);
  opacity: 0.96;
  transition: transform .3s ease, opacity .3s ease;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.hero-slide.is-active {
  opacity: 1;
}

.hero-slide.is-active .hero-slide__content {
  transform: translateY(0);
  opacity: 1;
}

.hero-slide__brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 0;
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: rgba(255,255,255,.68);
  opacity: .92;
}

.hero-slide__brand::before {
  content: "";
  width: 32px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,.32) 0%, rgba(255,255,255,0) 100%);
}

.hero-slide h2 {
  margin: 0;
  font-size: var(--hero-title-size);
  line-height: 1.08;
  letter-spacing: -0.02em;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.hero-slide p {
  margin: 0;
  font-size: var(--hero-text-size);
  font-weight: 600;
  line-height: 1.55;
  color: rgba(255,255,255,.82);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.hero-slide__text {
  margin: 0;
  display: grid;
  gap: 10px;
  font-size: var(--hero-text-size);
  font-weight: 400;
  line-height: 1.55;
  color: rgba(255,255,255,.82);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.hero-slide__text > * {
  margin: 0;
}

.hero-slide__text p {
  display: block;
  font-weight: 400;
}

.btn-hero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 28px;
  border-radius: 999px;
  background: #fff;
  color: #111827;
  font-weight: 400;
  line-height: 1.2;
  text-decoration: none;
  border: none;
  box-shadow: 0 16px 40px rgba(15,23,42,.24);
  transition: transform .2s ease, box-shadow .2s ease;
}

.btn-hero:hover {
  transform: scale(1.02);
  box-shadow: 0 24px 54px rgba(15,23,42,.3);
}

.btn-hero:active {
  transform: scale(0.99);
  box-shadow: 0 12px 28px rgba(15,23,42,.2);
}

.carousel-controls {
  position: absolute;
  right: 32px;
  bottom: 32px;
  display: flex;
  gap: 12px;
  z-index: 7; /* above overlays */
}

.carousel-controls .carousel-btn {
  position: static;
  transform: none;
  background: var(--carousel-control-bg);
  border-color: var(--carousel-control-border);
  color: var(--carousel-control-fg);
  box-shadow: 0 18px 38px rgba(15,23,42,.18);
}

.carousel-controls .carousel-btn:hover {
  background: var(--carousel-control-hover-bg);
  border-color: var(--carousel-control-hover-border);
  color: var(--carousel-control-hover-fg);
}

.carousel-hero .carousel-dots {
  display: none;
}

/* Carousel */
.carousel {
  position: relative;
  display: grid;
  align-items: center;
  gap: 8px;
}

.carousel-viewport {
  overflow: hidden;
  position: relative;
}

.carousel-track {
  display: flex;
  gap: 16px;
  will-change: transform;
}

/* Edge fade masks (disabled as requested) */

/* Full-width carousel variant */
.carousel-full {
  width: calc(100vw - var(--scrollbar-width, 0px));
  margin-left: 50%;
  transform: translateX(-50%);
}

.carousel-full .carousel-viewport {
  width: 100%;
}

/* Constrain hero carousel width (no full-bleed) */
.carousel-hero.carousel-full {
  width: min(1360px, 96%);
  margin-left: auto;
  margin-right: auto;
  transform: none;
}

.carousel .card {
  /* One-at-a-time by default; responsive can override if needed */
  flex: 0 0 100%;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.15);
  transition: transform .25s ease, box-shadow .25s ease;
}

.carousel .card:hover { 
  transform: none; 
  box-shadow: 0 24px 60px rgba(0,0,0,.18); 
}

/* Badges (top-left) */
.card-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  color: #fff;
  background: rgba(17,24,39,.7);
  border: 1px solid rgba(255,255,255,.22);
}

.badge-type { background: rgba(37,99,235,.7); border-color: rgba(255,255,255,.28); }
.badge-city { background: rgba(17,24,39,.7); }

.carousel-btn {
  position: absolute;
  top: auto;
  bottom: 16px;
  transform: none;
  z-index: 7; /* ensure always on top */
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--carousel-control-border);
  background: var(--carousel-control-bg);
  color: var(--carousel-control-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.carousel-btn.prev { left: auto; right: 64px; }
.carousel-btn.next { right: 16px; }

.carousel-btn:hover { 
  transform: scale(1.05); 
  box-shadow: 0 12px 28px rgba(0,0,0,.18); 
  background: var(--carousel-control-hover-bg);
  border-color: var(--carousel-control-hover-border);
  color: var(--carousel-control-hover-fg);
}

.carousel-btn .carousel-btn__arrow { color: currentColor; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.carousel-dots button { width: 8px; height: 8px; border-radius: 999px; border: 0; background: #e5e7eb; cursor: pointer; transition: background .2s ease, transform .2s ease, width .2s ease; }
.carousel-dots button:hover { transform: scale(1.15); }
.carousel-dots button[aria-current="true"] { background: var(--primary); width: 18px; }

.card { 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  overflow: hidden; 
  background: #fff; 
}

/* Remove border for hero slides */
.carousel-hero .card,
.carousel-hero .hero-slide {
  border: none !important;
}

.card-link { 
  display: block; 
  color: inherit; 
  text-decoration: none; 
}

.card-link:focus-visible { 
  outline: 2px solid var(--primary); 
  outline-offset: 2px; 
}

.card img { 
  width: 100%; 
  height: 160px; 
  object-fit: cover; 
  background: #f8fafc; 
}

/* Taller images inside the news carousel */
.carousel .card img { height: 420px; display: block; }

/* Gradient overlay for better text contrast */
.carousel .card::after {
  content: "";
  position: absolute;
  inset: 0;
  /* background: linear-gradient(180deg, rgba(0,0,0,0.0) 35%, rgba(0,0,0,0.6) 100%); */
  pointer-events: none;
}

.card-content { 
  padding: 12px; 
  display: grid; 
  gap: 6px; 
}

/* Lift content above overlay */
.carousel .card .card-content { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 1; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.35); background: linear-gradient(180deg, rgba(17,24,39,0.68), rgba(17,24,39,0.5)); border: 1px solid rgba(255,255,255,0.18); border-radius: 12px; padding: 14px; }
.carousel .card .card-content .meta { color: rgba(255,255,255,.85); }

/* Emphasize heading inside carousel card */
.carousel .card .card-content h3 { 
  margin: 0; 
  font-size: 22px; 
  line-height: 1.25; 
}
.carousel .card .card-content p { 
  margin: 6px 0 0; 
  font-size: 14px; 
  color: rgba(255,255,255,.92); 
}

.meta { 
  font-size: 12px; 
  color: var(--muted); 
}

@media (max-width: 1024px) {
  .carousel-hero {
    padding: 56px 0 36px;
    --hero-title-size: clamp(28px, 3.8vw, 40px);
    --hero-text-size: clamp(15px, 2vw, 18px);
    --hero-content-max: min(460px, 56%);
  }

  .carousel-hero .hero-slide {
    padding: clamp(36px, 6vw, 52px);
    min-height: 360px;
  }

  .carousel-hero .hero-slide__content {
    max-width: var(--hero-content-max);
  }
}

@media (max-width: 639px) {
  .hero-carousel {
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: 0;
    padding-right: 0;
    width: 100vw;
    position: relative;
  }

  .carousel-hero {
    padding: 0 0 24px;
    --hero-title-size: clamp(24px, 6.8vw, 32px);
    --hero-text-size: clamp(14px, 3.6vw, 16px);
    --hero-content-max: 100%;
  }

  .carousel-hero.carousel-full {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    transform: none;
  }

  .carousel-hero .carousel-viewport {
    border-radius: 0;
    border: none;
    box-shadow: none;
    outline: none;
  }

  .carousel-hero .hero-slide {
    min-height: 500px;
    padding: 28px 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    align-items: center;
  }

  .carousel-hero .hero-slide__content {
    max-width: 100%;
    gap: 14px;
    padding: 0 22px;
    align-items: center;
    text-align: center;
  }

  .carousel-hero .hero-slide__brand {
    display: none;
  }

  .carousel-hero .hero-slide__text {
    display: none;
  }

  .carousel-hero .btn-hero {
    width: min(320px, 100%);
    padding: 12px 18px;
    font-size: 15px;
    align-self: center;
    justify-self: center;
    margin-left: auto;
    margin-right: auto;
  }

  .carousel-hero .carousel-controls {
    display: none;
  }

  .carousel-progress--overlay {
    pointer-events: auto;
  }
}
