.car-card {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 20px 16px 24px;
  border: 1px solid #000;
  background: var(--c-card-bg);
  grid-template-areas:
    "title"
    "price"
    "gallery"
    "pills"
    "features"
    "actions";
}

.car-card__title {
  grid-area: title;
  font-size: clamp(28px, 2.78vw, 53px);
  font-weight: 600;
  line-height: 1.2;
  text-transform: uppercase;
}

.car-card__price {
  grid-area: price;
  font-size: clamp(18px, 1.57vw, 30px);
  font-weight: 500;
  line-height: 1.3;
  text-transform: uppercase;
}

.car-card__price-value {
  font-size: 1.43em;
  font-weight: 600;
  color: var(--c-accent-hover);
}

.car-card__pills {
  grid-area: pills;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.pill-group {
  position: relative;
  display: flex;
  flex: 0 0 auto;
}

.pill {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 170px;
  min-height: 68px;
  padding: 5px 26px 6px 19px;
  white-space: nowrap;
  font-size: clamp(16px, 1.23vw, 23px);
  font-weight: 500;
  line-height: 1.2;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%);
}

.pill--benefit {
  background: var(--c-teal);
}

.pill--payment {
  background: var(--c-teal-dark);
}

.pill__text {
  display: block;
}

.pill__info {
  position: absolute;
  top: 6px;
  right: 4px;
  z-index: 1;
  width: 20px;
  height: 20px;
  border: 1px solid #fff;
  border-radius: 50%;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.pill__info::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.pill__info:hover,
.pill__info:focus {
  opacity: 1;
}

.pill__info::before {
  content: "?";
  position: absolute;
  inset: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.pill__hint {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 3;
  display: block;
  width: max-content;
  max-width: min(320px, calc(100vw - 80px));
  padding: 10px 12px;
  font-size: clamp(12px, 0.73vw, 14px);
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}

.pill__info:hover~.pill__hint,
.pill__info:focus~.pill__hint {
  opacity: 1;
  visibility: visible;
}

.car-card__features {
  grid-area: features;
  display: grid;
  gap: 16px;
  align-content: start;
}

.feature {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 16px;
}

.feature__icon.is-missing,
.swatch img.is-missing {
  visibility: hidden;
}

.feature__icon {
  width: 44px;
  height: auto;
  max-height: 49px;
  object-fit: contain;
}

.feature__text {
  font-size: clamp(15px, 1.1vw, 21px);
  font-weight: 500;
  line-height: 1.25;
}

.feature__accent {
  font-weight: 600;
  color: var(--c-accent);
}

.feature__accent--lg {
  font-size: 1.75em;
  line-height: 1;
}

.car-card__actions {
  grid-area: actions;
  display: grid;
  gap: 12px;
  align-self: end;
}

.car-card__actions .btn:hover {
  color: #000;
  background: #fff;
  border-color: #fff;
}

.car-card__colors {
  display: flex;
  gap: 14px;
  margin-top: 18px;
}

.swatch {
  display: block;
  width: 29px;
  height: 28px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #4a4e52;
  cursor: pointer;
}

.swatch img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.swatch[aria-pressed="true"] {
  outline: 1px solid var(--c-accent);
  outline-offset: 0;
}

.car-card__gallery {
  grid-area: gallery;
  position: relative;
  min-width: 0;
}

.car-card__badge {
  position: absolute;
  top: -0.5em;
  left: -0.60em;
  z-index: 2;

  /* Высота плашки = line-height (1.2em) + padding по вертикали (0.37em + 1.5em).
     От неё зависят ширина боковых частей картинки: 34px и 35px на 184px
     высоты исходника badge-hit.png. */
  --badge-height: calc(1.2em + 0.37em + 1.5em);
  --badge-part-left-width: calc(var(--badge-height) * 34 / 184);
  --badge-part-right-width: calc(var(--badge-height) * 35 / 184);

  padding: 0.37em 1.33em 1.5em 1.2em;
  font-size: clamp(15px, 1.57vw, 30px);
  font-weight: 500;
  line-height: 1.2;
  text-transform: uppercase;
  /* Плашка всегда в одну строку: иначе изменится высота и разъедется ширина
     боковых частей, рассчитанная от --badge-height */
  white-space: nowrap;
}

/* Плашка собрана из трёх частей PNG (левый уголок / середина / правый срез,
   см. carcard.html.twig): уголки не растягиваются, тянется только середина.
   height: 100% — у всех частей всегда одинаковая высота, равная padding-box
   бейджа (top/bottom у replaced-элементов высоту не задают). Родитель — стековый
   контекст (z-index: 2), поэтому z-index: -1 кладёт картинки под текст бейджа */
.car-card__badge-part {
  position: absolute;
  top: 0;
  height: 100%;
  z-index: -1;
  width: auto;
}

.car-card__badge-part--left {
  left: 0;
}

.car-card__badge-part--middle {
  left: var(--badge-part-left-width);
  width: calc(100% - var(--badge-part-left-width) - var(--badge-part-right-width));
  object-fit: fill;
}

.car-card__badge-part--right {
  right: 0;
}

.gallery__main {
  position: relative;
  aspect-ratio: 670 / 447;
  overflow: hidden;
  background: var(--c-bg-alt);
}

.gallery__track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.gallery__track::-webkit-scrollbar {
  display: none;
}

.gallery__slide {
  flex: 0 0 100%;
  height: 100%;
  overflow: hidden;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.gallery__slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
}

.gallery__slide img:not([src]),
.gallery__thumb img:not([src]) {
  opacity: 0;
}

.car-card.is-empty .gallery__arrow,
.car-card.is-single .gallery__arrow,
.car-card.is-empty .gallery__thumbs {
  display: none;
}

.gallery__arrow {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 40px;
  height: 64px;
  transform: translateY(-50%);
  opacity: 0.85;
  transition: opacity 0.2s;
}

.gallery__arrow:hover {
  opacity: 1;
}

.gallery__arrow--prev {
  left: 4px;
}

.gallery__arrow--next {
  right: 4px;
}

.gallery__arrow::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 43px;
  transform: translate(-50%, -50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 43'%3E%3Cpath d='M18 2 4 21.5 18 41' fill='none' stroke='%23202a2b' stroke-width='2'/%3E%3C/svg%3E") center / contain no-repeat;
}

.gallery__arrow--next::before {
  transform: translate(-50%, -50%) scaleX(-1);
}

.gallery__thumbs {
  --thumbs-gap: 8px;
  display: flex;
  gap: var(--thumbs-gap);
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.gallery__thumbs::-webkit-scrollbar {
  display: none;
}

.gallery__thumbs>li {
  flex: 0 0 calc((100% - 3 * var(--thumbs-gap)) / 4);
  min-width: 0;
}

.gallery__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 156 / 106;
  overflow: hidden;
  background: var(--c-bg-alt);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.gallery__thumb:hover,
.gallery__thumb.is-current {
  opacity: 1;
}

.gallery__thumb.is-current {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (min-width: 768px) {
  .car-card {
    gap: 22px;
    padding: 28px 28px 32px;
  }

  .car-card__actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .car-card__colors {
    gap: 20px;
    margin-top: 22px;
  }

  .pill__hint--payment {
    right: 0;
    left: auto;
  }

  .gallery__thumbs {
    --thumbs-gap: 12px;
  }
}

@media (min-width: 1100px) {
  .car-card {
    grid-template-columns: minmax(380px, 1fr) minmax(0, 740px);
    grid-template-rows: auto auto auto 1fr auto;
    gap: 0 32px;
    padding: 18px 13px 25px 53px;
    grid-template-areas:
      "title gallery"
      "price gallery"
      "pills gallery"
      "features gallery"
      "actions gallery";
  }

  .car-card__price {
    margin-top: 2px;
  }

  .car-card__pills {
    gap: 25px;
    margin-top: 9px;
  }

  .pill {
    min-width: 200px;
  }

  .car-card__features {
    gap: 30px;
    margin-top: 25px;
    margin-bottom: 26px;
  }

  .car-card__actions {
    gap: 14px;
  }

  .car-card__actions .btn {
    border-color: var(--c-btn-line);
  }

  .car-card__actions .btn--accent {
    border-color: var(--c-accent);
  }

  .car-card__actions .btn--teal {
    border-color: var(--c-teal);
  }

  .car-card__gallery {
    display: grid;
    grid-template-columns: 30px minmax(0, 678px);
    grid-template-rows: auto auto;
    column-gap: 32px;
  }

  .gallery__main {
    grid-column: 2;
    grid-row: 1;
  }

  /* Абсолютно позиционированному ребёнку grid-контейнера с заданными
     grid-column/grid-row содержимым-блоком служит его grid-область, поэтому
     top/left из базового правила снова считаются от угла фотографии
     (а не от полосы цветов) и плашка «наезжает» на фото как раньше */
  .car-card__badge {
    grid-column: 2;
    grid-row: 1;
  }

  .car-card__colors {
    grid-column: 1;
    grid-row: 1;
    align-self: end;
    flex-direction: column;
    gap: 24px;
    margin-top: 0;
  }

  .gallery__arrow {
    width: 22px;
    height: 43px;
  }

  .gallery__arrow--prev {
    left: 11px;
  }

  .gallery__arrow--next {
    right: 11px;
  }

  .gallery__thumbs {
    --thumbs-gap: 8px;
    grid-column: 2;
    grid-row: 2;
    margin-top: 19px;
  }
}

@media (min-width: 1500px) {
  .car-card__actions {
    grid-template-columns: repeat(3, 219px);
  }
}
