@import url("/wp-content/themes/codex/style.css") (reset);
@import url("./typography.css") (typography);

@layer base {
  :root {
    --color_main_1: #200606;
    --color_main_2: #592907;
    --soft_warm: #eae0d2;
    --soft_cold: #e5eef5;
    --white: #ffffff;
    --bg: #f6f4f1;
    --dark: #4d4d4d;

    --transparent: transparent;
    --header: transparent;
    --display: 1640px;
    --display-small: 75rem;
    --display-full: 1920px;
    --padding-inline: 2.5rem;
  }

  @media (width < 768px) {
    :root {
      --padding-inline: 1.25rem;
    }
  }

  .grid {
    --columns-desktop: 5;
    --columns-mobile: 2;
    --collumn-min-size: 16rem;
    --gap: 1rem;

    display: grid;
    grid-template-columns: repeat(
      auto-fill,
      minmax(
        max(
          var(--collumn-min-size),
          calc(
            (100% - (var(--gap) * (var(--columns-desktop) - 1))) /
              var(--columns-desktop)
          )
        ),
        1fr
      )
    );
    gap: var(--gap);
    @media (width < 768px) {
      grid-template-columns: repeat(var(--columns-mobile), minmax(0, 1fr));
    }
  }

  html,
  body {
    width: 100%;
    scroll-behavior: smooth;
    color: var(--blue);
    background-color: var(--bg);
    position: relative;
    overflow-x: hidden;
    /* padding-top: 30px; */
  }

  body {
    padding-top: 70px;
  }

  body.home {
    padding-top: 0;
  }

  html.modal-open,
  body.modal-open {
    overflow: hidden;
  }

  @media (width < 980px) {
    body {
      padding-top: 50px;
    }
  }
  .body {
    max-width: min(var(--display-full), 100%);
    margin: auto;
  }

  .wrapper {
    width: min(var(--display), 100% - var(--padding-inline) * 2);
    margin-inline: auto;
  }

  @media (width <768px) {
    .wrapper {
      width: min(var(--display), 100% - var(--padding-inline) * 2);
      margin-inline: auto;
    }
  }

  .wrapper--full {
    width: min(var(--display-full), 100%);
  }
  .wrapper--small {
    width: min(var(--display-small), 100% - var(--padding-inline) * 2);
  }
}

@layer components {
  .page-wrapper {
    margin-block: 12rem 8rem;

    h1 {
      margin-bottom: 2rem;
    }
  }

  .wp-the_content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  /* ============ font-styles ============ */

  .font-secondary {
    font-family: "Neutral Face";
  }

  .fs-40 {
    font-size: clamp(2rem, 3.25vw, 2.5rem);
    font-style: normal;
    line-height: normal;
    letter-spacing: -0.8px;
    font-weight: 600;
  }

  .fs-32 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-style: normal;
    line-height: normal;
    letter-spacing: -0.4px;
  }

  .fs-24 {
    font-size: clamp(1.125rem, 1.5vw, 1.5rem);
    font-style: normal;
    line-height: normal;
    letter-spacing: -0.48px;
  }

  .fs-20 {
    font-size: clamp(1.25rem, 2vw, 1.25rem);
    font-style: normal;
    line-height: normal;
    letter-spacing: -0.4px;
  }

  .fs-16 {
    font-size: 1rem;
    font-style: normal;
    line-height: normal;
    letter-spacing: -0.32px;
  }

  /* .fs-14 {
    font-size: 0.875rem;
    font-style: normal;
    font-weight: 400;
    line-height: 110%;
    letter-spacing: 0.14px;
  } */

  .f-upper {
    text-transform: uppercase;
  }

  .fw-400 {
    font-weight: 400;
  }

  .fw-500 {
    font-weight: 500;
  }

  .fw-600 {
    font-weight: 600;
  }

  /* ============ Медиа-рамка (для всех изображений) ============ */

  .media-frame {
    overflow: hidden;
    background: var(--soft_cold);
  }

  .media-frame > img,
  .media-frame > picture,
  .media-frame > video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* ============ Хлебные крошки ============ */

  .breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    margin-block: clamp(4rem, 6vw, 5.625rem);
    background: transparent;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
  }

  .breadcrumbs a {
    color: var(--color_main_2);
    text-decoration: none;
  }

  .breadcrumbs a:hover {
    text-decoration: underline;
  }

  .breadcrumbs__current {
    color: var(--dark);
  }

  /* ============ Секции ============ */

  .section-head {
    margin-top: clamp(3rem, 4vw, 6.25rem);
    background: transparent;
  }

  .section-main {
    margin-block: clamp(4rem, 6vw, 5.625rem);
    background: transparent;
  }

  .section-head .wrapper {
    max-width: 100%;
  }

  /* ============ Баннеры ============ */

  /* ---------- Основной баннер ---------- */
  .banner-main {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    padding: clamp(1rem, 4vw, 2.5rem);
    aspect-ratio: 2/1;
    border-radius: 2rem;
    color: var(--white);
    max-height: 590px;
    border-radius: 32px;
    background: linear-gradient(
        207deg,
        rgba(0, 0, 0, 0) 53.61%,
        rgba(0, 0, 0, 0.7) 91.01%
      ),
      linear-gradient(0deg, #d6ba99 0%, #d6ba99 100%),
      url("/wp-content/themes/codex/assets/img/photo-stock.jpg") lightgray 50% /
        cover no-repeat;
    background-blend-mode: normal, multiply, normal;
  }

  .banner-main__content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 50%;
  }

  .banner-main__subtitle {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--white);
    align-self: stretch;
    background-color: rgba(0, 0, 0, 0.15);
  }

  @media (max-width: 850px) {
    .banner-main {
      aspect-ratio: 1;
    }

    .banner-main__content {
      max-width: 100%;
    }
  }
  /* ---------- Баннер второрго типа ---------- */
  .banner-secondary {
    position: relative;
    display: flex;
    aspect-ratio: 2/1;
    max-height: 560px;
    width: 100%;
    background: url("/wp-content/themes/codex/assets/img/photo-stock.jpg")
      lightgray 50% / cover no-repeat;
    background-blend-mode: normal, multiply, normal;
  }

  /* ============ Сетка каталога ============ */

  .grid--catalog {
    --columns-desktop: 4;
    --columns-mobile: 1;
    --collumn-min-size: 18rem;
    --gap: 2.5rem;
    width: 100%;
  }

  @media (max-width: 768px) {
    .grid--catalog {
      --gap: 1.25rem;
    }
  }

  /* ============ Карточки ============ */

  /* ---------- Карточка товара ---------- */
  :root {
    --card-bg: var(--white);
    --text-main: var(--color_main_1);
    --text-muted: var(--dark);
  }

  /* Карточка товара */
  .product-card {
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
    border-radius: 0.75rem;
    box-sizing: border-box;
    color: var(--text-main);
  }

  .product-card:hover {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  }

  .product-card__image {
    display: flex;
    background: var(--card-bg);
    width: 100%;
    height: 100%;
    max-height: 250px;
    aspect-ratio: 1;
    margin-block: 1rem;
    border-bottom: 1px solid var(--color_main_2);
    justify-content: center;
    align-items: center;
    align-self: stretch;

    img {
      object-fit: contain !important;
    }
  }

  .product-card__body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem;
    align-self: stretch;
    height: 100%;
  }

  .product-card__info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--soft_cold);
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
    height: 100%;
  }

  .product-card__info-headline {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--color_main_1);

    h3 {
      color: var(--color_main_2);
    }
  }

  .product-card__info-chars {
    display: flex;
    justify-content: space-between;
    gap: 1.25rem;
    /* margin-bottom: 14px; */
  }

  .product-card__info-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--dark);
  }

  .product-card__icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color_main_2);
  }

  .product-card__info-text {
    white-space: nowrap;
    color: var(--dark);
  }

  /* ---------- Карточка "причины" ---------- */
  .reason-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    align-self: stretch;
    justify-self: stretch;
    padding: clamp(1rem, 4vw, 1.5rem);
    border-radius: 0.75rem;
    background: var(--white);
    color: var(--color_main_1);
    cursor: pointer;
    border: none;
    transition: background-color 0.3s ease, color 0.3s ease,
      box-shadow 0.3s ease;
    aspect-ratio: 4/3;
  }

  .reason-card:hover,
  .reason-card:focus-within {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  }

  .reason-card.is-active {
    background: var(--color_main_2);
    color: var(--white);
  }

  .reason-card__icon {
    display: inline-flex;
    aspect-ratio: 1/1;
    max-width: 3rem;
    margin-bottom: 1.5rem;
  }

  .reason-card__content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .reason-card__head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    align-self: stretch;
  }

  .reason-card__index {
    color: var(--color_main_2);
  }

  .reason-card.is-active .reason-card__index {
    color: var(--white);
  }

  .reason-card__details {
    width: 100%;
    /* margin-top: 16px; */

    max-height: 0;
    overflow: hidden;
    opacity: 0;

    transition: max-height 0.3s ease, opacity 0.3s ease;
  }

  .reason-card__divider {
    display: block;
    max-width: 70%;
    height: 2px;
    margin-bottom: 0.5rem;
    background-color: currentColor;
  }

  .reason-card.is-active .reason-card__details {
    max-height: 200px; /* достаточно для пары абзацев */
    opacity: 1;
  }

  /* ============ Кнопки ============ */

  /* ---------- Основная кнопка кнопка ---------- */
  :root {
    --btn-dark-bg: var(--color_main_1);
    --btn-dark-text: var(--white);
    --btn-light-bg: var(--white);
    --btn-light-text: var(--color_main_1);
    --btn-radius: 0.75rem;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    padding: 0.75rem 1.5rem;
    border-radius: var(--btn-radius);
    border: none;
    text-transform: uppercase;

    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease,
      box-shadow 0.2s ease, transform 0.1s ease;
  }

  .btn--dark {
    background-color: var(--btn-dark-bg);
    color: var(--btn-dark-text);
  }

  .btn--light {
    background-color: var(--btn-light-bg);
    color: var(--btn-light-text);
  }

  /* Иконка справа */
  .btn--with-icon .btn__icon {
    display: inline-flex;
  }

  /* Размер иконки */
  .btn__icon svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  .btn--dark:hover {
    background-color: var(--color_main_2);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  }

  .btn--light:hover {
    background-color: var(--soft_warm);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  }

  .btn:active {
    transform: translateY(1px);
    box-shadow: none;
  }

  /* ---------- Кнопка сортировки ---------- */

  .catalog-filter {
    position: relative;
    min-width: 220px;
  }

  .catalog-filter__btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;

    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    border: 1px solid var(--color_main_2);
    background: var(--bg);
    cursor: pointer;

    color: var(--color_main_1);
    text-align: left;

    transition: background-color 0.2s ease, box-shadow 0.2s ease,
      border-color 0.2s ease;
  }

  .catalog-filter__btn:hover {
    background: var(--white);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  }

  .catalog-filter__btn:focus-visible {
    outline: 2px solid var(--color_main_2);
    outline-offset: 2px;
  }

  .catalog-filter__label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* стрелка */

  .catalog-filter__icon {
    display: inline-flex;
  }

  .catalog-filter__icon svg {
    transition: transform 0.2s ease;
  }

  .catalog-filter.is-open .catalog-filter__icon svg {
    transform: rotate(180deg);
  }

  /* выпадающий список */

  .catalog-filter__dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;

    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    padding: 0.25rem 0;

    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 10;
  }

  .catalog-filter.is-open .catalog-filter__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .catalog-filter__option {
    width: 100%;
    padding: 0.5rem 1.25rem;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--color_main_1);
  }

  .catalog-filter__option:hover {
    background: #f7f3ee;
  }

  .catalog-filter__option.is-active {
    font-weight: 600;
  }

  /* ---------- Барджи (переиспользуем barge-group / barge) ---------- */

  :root {
    --barge-bg: var(--white);
    --barge-bg-active: #e9ded0;
    --barge-text: var(--color_main_1);
  }

  .barge-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .barge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;

    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(90, 50, 20, 0.25);

    background: var(--barge-bg);
    color: var(--barge-text);

    font-size: 0.875rem;
    white-space: nowrap;
    cursor: pointer;

    transition: background-color 0.2s ease, box-shadow 0.2s ease,
      border-color 0.2s ease;
  }

  .barge:hover {
    background: #f7f3ee;
  }

  .barge__close {
    font-size: 0.8em;
  }

  .barge--active {
    background: var(--barge-bg-active);
    border-color: var(--color_main_2);
  }

  .barge--reset {
    border-style: dashed;
  }

  /* ============ main-modal (overlay + анимация) ============ */

  .modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none; /* по умолчанию скрыто */
    justify-content: center; /* центр по горизонтали */
    align-items: flex-start; /* прижимаем к верху, а не по центру */
    padding: 2.5rem 1rem; /* отступы сверху/снизу для «воздуха» */
    overflow-y: auto; /* СКРОЛЛИМ МОДАЛКУ, а не body */
  }

  .modal.is-open {
    display: flex;
  }

  /* затемнение фона */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  #modal-form.is-open .modal-overlay {
    opacity: 1;
  }

  /* обёртка контента — просто держатель для карточки */
  .modal-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 920px;
    display: flex;
    justify-content: center;
    /* убираем max-height и трансформации */
    padding: 0;
    background: transparent;
    transform: none;
    opacity: 1;
  }

  /* сама «карточка» модалки */
  .modal-card {
    position: relative;
    /* width: 100%; */
    background: var(--white);
    border-radius: 32px;
    padding: clamp(1.75rem, 3vw, 2.5rem) clamp(1.75rem, 4vw, 3rem);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);

    /* чтобы на маленьких экранах карточка не вылезала за окно */
    max-height: calc(100vh - 5rem); /* высота окна минус отступы модалки */
    overflow-y: auto;
  }

  /* внутрянка карточки */
  .main-modal__inner {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  /* шапка модалки */
  .main-modal__head {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--color_main_1);
  }

  .main-modal__title {
    letter-spacing: 0.02em;
    color: var(--color_main_2);
  }

  .main-modal__subtitle {
    max-width: 32rem;
    line-height: 1.3;
  }

  /* кнопка закрытия */
  .main-modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
  }

  .main-modal-close svg,
  .main-modal-close i {
    width: 20px;
    height: 20px;
    color: var(--color_main_1);
  }

  /* на мобилке уменьшаем отступы и скругление */
  @media (max-width: 910px) {
    .modal {
      padding: 1.5rem 0.75rem;
    }

    .modal-card {
      border-radius: 24px;
      padding: 1.5rem 1.25rem 1.75rem;
      max-height: calc(100vh - 3rem);
    }

    .main-modal__inner {
      gap: 1.25rem;
    }

    .main-modal__title {
      font-size: 1.5rem;
    }
  }
}

@layer main {
}
