/* Здесь вы напишете основную часть стилей страницы.

Будьте внимательны! Для корректной работы скриптов на этом сайте нужно, чтобы в HTML некоторые классы были названы особым образом:
✦ like-icon — для svg-иконки анимированного сердца
✦ card__like-button — для кнопки Like рядом с иконкой
✦ card__icon-button — для кнопки, оборачивающей иконку
✦ is-liked — для обозначения состояния лайкнутой иконки в виде сердца
✦ button__text — для обозначения текстового элемента внутри кнопки

*/

/* Страница*/
.page {
  min-inline-size: 320px;
  min-block-size: 100dvb;
  /* Фон страницы: множественный градиент-сетка + плавное затемнение */
  background-image: var(--page-gradient);
  background-attachment: fixed;
  /* Фон фиксирован при прокрутке */
  background-size: cover;
  /* Растянуть фон на всю область */
  background-repeat: no-repeat;
  /* Без повторения, слои и так повторяются где надо */
  background-position: center;
  /* Центрирование для совместимости */
  font-family: var(--font-main);
}

/* Универсальный контейнер с адаптивной шириной */
.container {
  inline-size: var(--container-inline-size);
  margin-inline: auto;
}

/* Шапка страницы (page-header): белый прямоугольник по центру */
.page-header {
  background-color: #ffffff;
  color: #000;
  border: 2px solid #000;
  padding-block: var(--header-pad-block);
  padding-inline: var(--header-pad);
  margin-block-start: var(--header-mt);
  margin-block-end: var(--header-mb);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--header-gap);
  text-align: center;
  container-type: inline-size;
}

.page-header__logo {
  font-family: var(--font-accent);
  /* Масштабируем от ширины контейнера: 1cqw = 1% content-box .page-header */
  font-size: clamp(50px, 10cqw, var(--header-logo-size));
  line-height: 1;
  white-space: nowrap;
}

.page-header__subtitle {
  font-family: var(--font-accent);
  font-weight: var(--header-subtitle-weight);
  font-size: clamp(23px, calc(var(--container-inline-size) * 23 / 700), var(--header-subtitle-size));
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.page-cards__item-heading {
  font-family: var(--font-main);
  font-variation-settings: 'wght' var(--card-title-weight);
  font-size: var(--card-title-size);
  line-height: var(--card-title-line-height);
  letter-spacing: var(--card-title-letter);
  padding-left: 5px;
}

/* Основной контент (page-main / page-cards) */

/* Секция карточек страницы */
.page-cards {
  display: flex;
  flex-direction: column;
  gap: 50px;
}

/* Элемент списка карточек */
.page-cards__item {
  background-color: #fff;
  color: #000;
  border: 2px solid #000;
  display: grid;
  grid-template-rows: auto auto auto;
}

/* Заголовок карточки на белом фоне */
.page-cards__item-header {
  background-color: #fff;
  border-block-end: 2px solid #000;
  display: flex;
  align-items: center;
  padding: 6px;
}

/* Квадратное изображение */
.page-cards__item-image {
  aspect-ratio: 1 / 1;
  position: relative;
}

.page-cards__item-image img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: center;
}

/* Фильтры изображений: классы на самих тегах img */
/* Важно: изображения без этих классов остаются без фильтров */

/* ЧБ */
.filter-grayscale {
  filter: grayscale(1);
}

/* Винтаж: сепия + пониженная насыщенность */
.filter-sepia-saturate {
  filter: sepia(0.9) saturate(0.8);
}

/* Мягкий: немного ярче и ниже контраст */
.filter-brightness-contrast {
  filter: brightness(1.05) contrast(0.9);
}

/* Солнечный: ярче + насыщеннее */
.filter-brightness-saturate {
  filter: brightness(1.2) saturate(1.25);
}

/* Розовый оттенок: hue-rotate + saturate */
.filter-hue-rotate-saturate {
  filter: hue-rotate(345deg) saturate(2);
}

/* Лёгкая инверсия + повышение контраста */
.filter-invert-contrast {
  filter: invert(0.1) contrast(1.5);
}

/* Подчёркнутый контраст + немного темнее */
.filter-contrast-brightness {
  filter: contrast(1.55) brightness(0.98);
}

/* Размытие */
.filter-blur {
  filter: blur(3px);
}

/* Лейбл на изображении */
.page-cards__item-label {
  position: absolute;
  top: 25px;
  right: 25px;
  opacity: var(--label-opacity);
  mix-blend-mode: hard-light;
  pointer-events: none;

  /* Типографика */
  font-family: var(--font-accent);
  font-weight: 400;
  font-style: normal;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #000;

  /* Фоллбэк-обводка через тень (поддерживается везде) */
  text-shadow:
    1px 0 0 var(--label-stroke-color),
    -1px 0 0 var(--label-stroke-color),
    0 1px 0 var(--label-stroke-color),
    0 -1px 0 var(--label-stroke-color),
    1px 1px 0 var(--label-stroke-color),
    -1px 1px 0 var(--label-stroke-color),
    1px -1px 0 var(--label-stroke-color),
    -1px -1px 0 var(--label-stroke-color);
}

/* Обводка текста через text-stroke, если поддерживается; отключаем тени */
@supports (text-stroke: 1px var(--label-stroke-color)) or (-webkit-text-stroke: 1px var(--label-stroke-color)) {
  .page-cards__item-label {
    text-shadow: none;
    -webkit-text-stroke: 1px var(--label-stroke-color);
    color: transparent;
  }
}

/* Текст на белом фоне + действия */
.page-cards__item-body {
  background-color: #fff;
  padding: 25px;
  border-block-start: 2px solid #000;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.page-cards__item-description {
  margin: 0;
  font-family: var(--font-main);
  font-variation-settings: 'wght' var(--card-desc-weight);
  font-size: var(--card-desc-size);
  line-height: var(--card-desc-line-height);
}

.page-cards__item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

/* Кнопки карточки (сохраняем совместимость с JS-классами) */
/* Базовый класс для кнопок с текстом */
.btn {
  appearance: none;
  border: 2px solid #000;
  background: #fff;
  color: #000;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  outline: none;
  transition: box-shadow 0.3s ease;
  z-index: 0;
}

/* Фиксируем ширину кнопки Like, чтобы текст Like/Unlike не менял размер кнопки */
.card__like-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 37px;
  inline-size: 130px;
  white-space: nowrap;
}

/* Сердце без рамки — квадратная кнопка фиксированной высоты */
.card__icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  border: 2px solid transparent;
  background: transparent;
  padding: 0;
  block-size: 34px;
  inline-size: 34px;
  outline: none;
  transition: border-color 0.3s ease;
}

/* Фокус: показываем акцентную границу, размеры не меняем */
.card__icon-button:focus-visible {
  border-color: currentColor;
}

/* Иконка сердца внутри кнопки */
.like-icon {
  display: block;
  inline-size: 27px;
  block-size: 24px;
  overflow: visible;
}

/* Текст внутри кнопок */
.btn .button__text {
  font-family: var(--font-accent);
  font-weight: 400;
  font-style: normal;
  font-size: 14px;
  line-height: 0.9;
  letter-spacing: 0;
  display: inline-block;
  position: relative;
  z-index: 1;
  color: #fff;
  mix-blend-mode: difference;
}

/* Блок действий страницы */

/* Одна центральная кнопка действий под основным контентом */
.page-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-block-start: 50px;
  margin-block-end: 100px;
}

.cta-save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 10px;
  appearance: none;
  border: 2px solid #000;
  background: #fff;
  color: #000;
  padding: 15px 16px;
  cursor: pointer;
  flex-wrap: wrap;
}

.cta-save-button .save-icon {
  position: relative;
  z-index: 1;
  color: #000;
  fill: currentColor;
  stroke: none;
  flex-shrink: 0;
}

.cta-save-button .button__text {
  text-transform: none;
}

/* Тень при фокусе (2px 2px 0, цвет = currentColor) */
.btn:focus-visible {
  box-shadow: 2px 2px 0 currentColor;
}

/* Скользящий псевдоэлемент для наведения: слева направо */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  transform: translateX(-100%);
  transition: transform 0.5s ease-in-out;
  z-index: 0;
}

.btn:hover::before {
  transform: translateX(0);
}

/* Поддерживаем читаемость иконки на тёмном оверлее без фильтров */
.btn:hover .save-icon,
.btn:focus-visible .save-icon {
  color: #fff;
}

/* Иконка дискеты рядом с текстом */
.save-icon {
  display: inline-block;
  vertical-align: middle;
  width: 22px;
  height: 21px;
  fill: currentColor;
  stroke: none;
}

/* Размер иконки в модальном окне по макету: 39×39px */
.modal .save-icon {
  width: 39px;
  height: 39px;
  align-self: center;
}

/* Модальное окно сохранения */
.modal {
  display: none;
  border: none;
  padding: 0;
  background: transparent;
}

/* Модальное окно */
.modal[open] {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 20px;
  row-gap: 30px;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  padding-block: 30px;
  padding-inline: 30px;
  box-sizing: border-box;
  margin-inline: auto;
  max-inline-size: 100%; /* Не выходим за пределы экрана */
}

.modal__content {
  display: contents;
}

.modal__text {
  max-inline-size: 18ch; /* Ограничиваем кол-во символов */
  min-inline-size: 230px;
}

/* Типографика описания модального окна */
.modal__text p {
  margin: 0;
  font-family: var(--font-accent);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  text-transform: uppercase;
}

.modal__actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: stretch;
}

/* Кнопка ОК — на всю ширину модального окна */
.modal__actions .card__like-button {
  inline-size: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding-block: 10px;
}

/* Типографика текста кнопки ОК в модальном окне */
.modal .button__text {
  text-transform: uppercase;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.75);
}

/* Адаптивность: контрольная точка 375px */
@media (max-width: 375px) {

  /* Растягиваем контейнер на всю ширину, убираем боковые поля */
  .container {
    inline-size: 100%;
    margin-inline: 0;
  }

  .page-header__subtitle {
    font-size: 14px;
  }

  /* Размер шапки на минимальной мобильной: 375×327, и отступ снизу 100px */
  .page-header {
    margin-block-start: 100px;
    margin-block-end: 100px;
  }

  /* CTA-кнопка: иконка сверху, текст ниже */
  .cta-save-button {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  /* Размер иконки CTA-кнопки на мобилке: 28×28 */
  .cta-save-button .save-icon {
    width: 28px;
    height: 28px;
  }

  /* Фиксируем отступ над блоком действий на 50px в мобилке */
  .page-actions {
    margin-block-start: 50px;
    padding: 0px 35px;
  }

  .page-cards__item-heading {
    line-height: 1.15;
  }

  .page-cards__item-header {
    padding: 3px 5px;
  }
}