/* Вариант «Мягкий»: воздух внутри светлого блока */

.recipe {
  --recipe-line: rgba(var(--color-black-rgb, 0, 0, 0), 0.09);
  --recipe-muted: #6b6b6b;
  --recipe-primary: var(--color-primary, #58bbfd);
  --recipe-space: clamp(1.75rem, 1rem + 3vw, 64px);
  font-family: var(--font-regular, inherit);
}

.entry-content > :has(+ .recipe):not(:last-child),
.entry-content > .recipe:not(:last-child) {
  margin-bottom: var(--content-space);
}

/* На отдельной странице рецепта карточка — это и есть страница:
   подложка, скругления и внутренние поля там лишние. Внутри статьи
   карточка остаётся плашкой, чтобы отделяться от текста. */
.recipe--plain {
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.recipe--plain .recipe__section:first-child {
  margin-top: 0;
}

.recipe *,
.recipe *::before,
.recipe *::after {
  box-sizing: border-box;
}

.recipe li::marker {
  content: "";
}

/* Шапка */

.recipe__head {
  display: grid;
  gap: 1.5rem;
}

.recipe__photo {
  margin: var(--content-space) 0;
}

.recipe__photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: calc(var(--radius, 1.5rem) / 1.25);
}

.recipe__label {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--recipe-primary);
}

.recipe .recipe__title {
  margin: 0 0 0.75rem;
  font-family: var(--font-regular, inherit);
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-align: center;
  text-transform: none;
  text-wrap: balance;
}

.recipe__summary {
  margin: 0 0 calc(var(--content-space) / 2) 0;
  font-size: 1rem;
  line-height: 1.25;
  text-align: center;
}

.recipe__facts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 10px 35px;
  margin: 0;
  padding: 0 !important;
  list-style: none;
}

.recipe__fact {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.6rem 1.4rem !important;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
}

/* На узком экране плашки фактов выстраиваются в столбик и съедают пол-экрана —
   там показываем их строкой через точки */
@media (max-width: 33.99rem) {
  .recipe__facts {
    gap: 0.3rem 0.9rem;
  }

  .recipe__fact {
    padding: 0;
    background: transparent;
  }
}

.recipe__fact-label,
.recipe__fact-value {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
  text-transform: uppercase;
  color: inherit;
}

.recipe__fact:not(.recipe__fact--difficulty) .recipe__fact-label::after {
  content: ":";
}

/* Слово «Легко» нужно читалкам, но на экране его заменяют звёзды. */
.recipe__fact-value--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.recipe__fact-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  line-height: 0;
}

.recipe__fact-star {
  /* Незакрашенная звезда рисуется той же обводкой, что и капсула. */
  opacity: 0.85;
}

/* Секции */

.recipe__section:not(:last-child) {
  padding-bottom: var(--recipe-space);
}

/* По макету ингредиенты занимают всю колонку страницы, а приготовление
   и КБЖУ идут по мере текста — как абзацы в материале. */
.recipe__section--steps,
.recipe__section--nutrition,
.recipe__section--notes {
  max-width: var(--entry-measure, 52.5rem);
  margin-inline: auto;
}

.recipe__section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 32px;
}
.recipe .recipe__section-divider {
  height: 0;
  margin: 0 0 var(--recipe-space) 0;
  border: 0;
  border-top: 2px solid rgba(var(--color-divider-rgb), 1);
}

.recipe .recipe__section-title {
  margin: 0;
  font-family: var(--font-regular, inherit);
  font-size: clamp(1.5rem, 3vw, 36px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 4%;
  text-transform: uppercase;
}

.recipe__section--steps .recipe__section-title {
  margin-bottom: 1.5rem;
}

/* Калькулятор */

.recipe__calc {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 24px 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}
@media screen and (max-width: 767px) {
  .recipe__calc {
    width: 100%;
    flex-direction: column;
    padding: 1.5rem;
    border-radius: 1rem;
  }
}

.recipe__calc-label,
.recipe__calc-unit {
  font-size: 20px;
  line-height: 1.2;
  color: var(--recipe-muted);
}

.recipe__stepper {
  display: inline-flex;
  align-items: center;
  /* gap: 0.5rem; */
}

.recipe__stepper-btn {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: 150ms all linear;
}

.recipe__stepper-btn:hover {
  border-color: var(--recipe-primary);
  background: var(--recipe-primary);
  color: var(--color-primary-foreground, #fff);
}

.recipe__stepper-input {
  width: 4rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font: inherit;
  font-size: 28px;
  font-weight: 600;
  -moz-appearance: textfield;
}

.recipe__stepper-input::-webkit-outer-spin-button,
.recipe__stepper-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

/* Кнопка живёт в общем ряду инструментов и появляется только после пересчёта */
.recipe .recipe__tool[hidden] {
  display: none;
}

/* Ингредиенты в две колонки */

.recipe__group + .recipe__group {
  margin-top: 40px;
}

/* В макете подписи групп идут с двоеточием: «ДЛЯ КРЕМА:». */
.recipe .recipe__group-title::after {
  content: ":";
}

.recipe .recipe__group-title {
  margin: 0 0 24px;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 4%;
  text-transform: uppercase;
  color: var(--color-primary);
  text-align: center;
}

.recipe .recipe__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 34rem) {
  .recipe .recipe__list {
    columns: 2;
    column-gap: 120px;
  }
}

.recipe .recipe__ingredient {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr) auto;
  column-gap: 16px;
  /* align-items: baseline; */
  align-items: center;
  margin: 0 -12px;
  padding: 12px;
  border-top: 0;
  border-radius: 1.5rem;
  cursor: pointer;
  break-inside: avoid;
  transition: 150ms background linear;
}

.recipe .recipe__ingredient:hover {
  background: rgba(255, 255, 255, 1);
}

.recipe .recipe__check {
  grid-column: 1;
  grid-row: 1;
}

.recipe .recipe__ingredient + .recipe__ingredient {
  border-top: 0;
}

.recipe__check {
  flex: none;
  display: grid;
  place-content: center;
  align-self: center;
  width: 21px;
  height: 21px;
  margin: 0;
  padding: 0;
  border: 2px solid #d9d9d9;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition:
    150ms border-color linear,
    150ms background linear;
}

/* Галочка рисуется псевдоэлементом — нативная не поддаётся стилизации */
.recipe__check::after {
  content: "";
  width: 0.5rem;
  height: 0.26rem;
  border-left: 2px solid var(--color-primary-foreground, #fff);
  border-bottom: 2px solid var(--color-primary-foreground, #fff);
  transform: translateY(-0.06em) rotate(-45deg) scale(0.4);
  opacity: 0;
  transition:
    120ms transform ease-out,
    120ms opacity linear;
}

.recipe__check:hover {
  border-color: var(--recipe-primary);
}

.recipe__check:checked {
  border-color: var(--recipe-primary);
  background: var(--recipe-primary);
}

.recipe__check:checked::after {
  transform: translateY(-0.06em) rotate(-45deg) scale(1);
  opacity: 1;
}

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

.recipe .recipe__amount {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: #ebebeb;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 600;
  white-space: nowrap;
}

.recipe .recipe__ingredient-body {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  cursor: pointer;
}

.recipe__ingredient-body::after {
  content: none;
}
/* Ингредиент без количества («по вкусу», «по желанию») не оставляет пустую колонку */
.recipe .recipe__ingredient-body:last-child {
  grid-column: 2 / -1;
}

.recipe__ingredient-name {
  line-height: 1.35;
  font-size: 18px;
}

.recipe__ingredient-note {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--recipe-muted);
}

.recipe.is-scaled .recipe__amount[data-recipe-amount] {
  background: var(--color-accent, #fff3b1);
}

.recipe__ingredient.is-checked .recipe__ingredient-name {
  opacity: 0.5;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.recipe__ingredient.is-checked .recipe__amount,
.recipe__ingredient.is-checked .recipe__ingredient-note {
  opacity: 0.5;
}

/* Кнопки под списком */

.recipe__tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2.5rem;
}

.recipe__tool {
  padding: 0.85rem 2rem;
  border: 0;
  border-radius: 999px;
  background: var(--recipe-primary);
  color: var(--color-primary-foreground, #fff);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: 150ms background linear;
}

.recipe__tool:hover {
  background: var(--color-secondary, #9faeba);
  color: var(--color-primary-foreground, #fff);
}

/* Сброс — та же капсула: в макете обе кнопки одинаковые. */
.recipe__reset {
  color: var(--color-primary-foreground, #fff);
}

/* КБЖУ строкой */

.recipe__switch {
  display: inline-flex;
  gap: 1rem;
  padding: 0;
  background: transparent;
}

.recipe__switch-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--recipe-muted);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.recipe__switch-btn.is-active {
  background: transparent;
  color: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.35em;
}

.recipe .recipe__nutrition-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recipe .recipe__nutrition-item {
  margin: 0;
  /* padding: 1rem 1.15rem;
  border-radius: 1rem;
  background: #fff; */
  text-align: left;
}

.recipe__nutrition-value {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
}

.recipe__nutrition-unit {
  margin-left: 0.15rem;
  font-size: 24px;
  color: var(--recipe-muted);
}

.recipe__nutrition-label {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.2;
  color: var(--recipe-muted);
}

@media screen and (max-width: 767px) {
  .recipe .recipe__nutrition-list {
    gap: 0.5rem;
  }
  .recipe__nutrition-value {
    font-size: 22px;
  }
  .recipe__nutrition-unit {
    font-size: 16px;
    margin-left: 0.1rem;
  }
  .recipe__nutrition-label {
    font-size: 16px;
  }
}

/* Шаги */

.recipe .recipe__steps {
  display: grid;
  gap: 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recipe .recipe__step {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin: 0;
  padding: 0;
}

.recipe__step-number {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  width: 100%;
  color: inherit;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.35;
}

.recipe__step-number::after {
  content: ".";
}

.recipe .recipe__step-title {
  margin: 0 0 0.4rem;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  text-transform: none;
}

.recipe__step-text {
  font-size: 18px;
  line-height: 1.35;
}

.recipe__step-text > * {
  margin-bottom: 1rem;
}

.recipe__step-text > *:last-child {
  margin-bottom: 0;
}

.recipe__step-photo {
  margin-top: 1rem;
}

.recipe__step-photo img {
  display: block;
  width: 100%;
  max-width: 28rem;
  height: auto;
  border-radius: calc(var(--radius, 1.5rem) / 1.5);
}

/* Врезки: одна после ингредиентов, вторая после шагов.
   Своей секции у них нет — врезка относится к предыдущему блоку,
   поэтому и черты сверху не рисуем. Ширина — по мере текста. */

.recipe__note {
  padding: 0 0 0 32px;
  border-left: 2px solid var(--recipe-primary);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.2;
}

.recipe__note a {
  color: var(--recipe-primary);
  text-decoration: underline;
}

.recipe__note > * {
  margin-bottom: 1rem;
}

.recipe__note > *:last-child {
  margin-bottom: 0;
}

@media print {
  /* На печать уходит только рецепт: скрываем всё, что не лежит на ветке к карточке */
  body.recipe-print
    .recipe-print-branch
    > *:not(.recipe-print-branch):not(.recipe-print-target),
  body.recipe-print > *:not(.recipe-print-branch) {
    display: none !important;
  }

  body.recipe-print .recipe-print-branch {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    width: auto !important;
    max-width: none !important;
  }

  .recipe {
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
  }

  .recipe__tools,
  .recipe__stepper-btn,
  .recipe__switch,
  .recipe__calc-label {
    display: none !important;
  }

  /* Число порций на бумаге нужно — оставляем поле и подпись */
  .recipe__calc {
    padding: 0 !important;
    background: none !important;
  }

  .recipe__stepper-input {
    width: auto !important;
    border: 0 !important;
  }

  .recipe__fact,
  .recipe__nutrition-item,
  .recipe__step-number,
  .recipe__note {
    border-left: 2px solid rgba(0, 0, 0, 0.35) !important;
  }

  .recipe__step,
  .recipe__ingredient,
  .recipe__group {
    break-inside: avoid;
  }

  /* Фото печатаем, но ограничиваем — иначе рецепт расползается на лишние листы */
  .recipe__photo img {
    max-width: 11cm;
    max-height: 7cm;
    object-fit: cover;
  }

  .recipe__step-photo img {
    max-width: 7cm;
    max-height: 5cm;
    object-fit: cover;
  }

  .recipe__head,
  .recipe__photo,
  .recipe__step-photo {
    break-inside: avoid;
  }
}

/* Галерея блюда */

.recipe__section--gallery {
  max-width: none;
}

.recipe-gallery__stage {
  position: relative;
  overflow: hidden;
}

.recipe-gallery__slide {
  display: none;
}

.recipe-gallery__slide.is-active {
  display: block;
}

.recipe-gallery__image,
.recipe-gallery__slide img {
  display: block;
  width: 100%;
  height: auto;

  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 0;
}

/* Стрелки лежат поверх фото, по краям — как в макете. */
.recipe-gallery__arrow {
  position: absolute;
  top: 50%;
  z-index: 2;

  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;

  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transform: translateY(-50%);
  transition: 150ms background linear;
}

.recipe-gallery__arrow:hover {
  background: var(--recipe-primary);
}

.recipe-gallery__arrow--prev {
  left: 1.25rem;
}

.recipe-gallery__arrow--next {
  right: 1.25rem;
}

/* Галочку-стрелку рисуем границами: своих иконок у модуля нет. */
.recipe-gallery__arrow::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}

.recipe-gallery__arrow:hover::before {
  border-color: var(--color-primary-foreground, #fff);
}

.recipe-gallery__arrow--prev::before {
  margin-left: 0.2rem;
  transform: rotate(-135deg);
}

.recipe-gallery__arrow--next::before {
  margin-right: 0.2rem;
  transform: rotate(45deg);
}

/* Три миниатюры в ряду, остальные уезжают вбок: сколько бы фотографий
   ни добавили, высота секции не растёт. Лента листается пальцем и
   колесом, а стрелки над ней подтягивают активную миниатюру сами. */
.recipe-gallery__thumbs {
  --thumbs-gap: 1.25rem;

  display: flex;
  gap: var(--thumbs-gap);
  margin-top: 1.25rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

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

.recipe-gallery__thumb {
  flex: 0 0 calc((100% - var(--thumbs-gap) * 2) / 3);
  scroll-snap-align: start;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  transition: 150ms opacity linear;
}

.recipe-gallery__thumb img {
  display: block;
  width: 100%;
  height: 100%;

  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 0;
}

.recipe-gallery__thumb.is-active {
  opacity: 0.55;
}

@media (max-width: 33.99rem) {
  .recipe-gallery__arrow {
    width: 2.5rem;
    height: 2.5rem;
  }

  .recipe-gallery__thumbs {
    --thumbs-gap: 0.5rem;
  }
}
