/* ——— Модальное окно (нативный <dialog>) ———
   Открывается кнопкой [data-dialog="id"], закрывается [data-dialog-close], подложкой и Esc — assets/js/main.js */
.modal {
  width: min(1200px, calc(100% - 20px));
  max-width: none;
  max-height: calc(100vh - 200px);
  margin: auto;
  background: var(--bg);
  color: var(--text-primary);
}

.modal[open] {
  display: flex;
}

/* Отступы здесь, а не у <dialog>: клик по самому <dialog> закрывает модалку как клик по подложке */
.modal__inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 40px 48px;
  box-shadow: 0px 24px 64px 0px #051F1459;
}

.modal::backdrop {
  background: #08241AB8;
}

body:has(.modal[open]) {
  overflow: hidden;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
  padding-bottom: 28px;
  border-bottom: 1px solid color-mix(in srgb, var(--stroke) 50%, transparent);
}

.modal__kicker {
  margin-bottom: 14px;
  color: var(--accent-green);
  text-transform: uppercase;
}

.modal__title {
  color: var(--text-heading);
  font-weight: 600;
  font-size: 48px;
  line-height: 110.00000000000001%;
  letter-spacing: -2%;
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: 1px solid #0F3D2A40;
  border-radius: 10px;
  color: var(--text-heading);
  cursor: pointer;
  transition: background-color 180ms ease-out;
}

@media (hover: hover) {
  .modal__close:hover {
    background: var(--bg-card);
  }
}

.modal__close:active {
  background-color: #A8E6BE99;
}

.modal__close:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

.modal__close svg {
  width: 20px;
  height: 20px;
}

.modal__body {
  overflow-y: auto;
  margin-top: 32px;
  padding-right: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-green) transparent;
}

@media (max-width: 1080px) {
  .modal__title {
    font-weight: 600;
    font-size: 24px;
    line-height: 28px;
    letter-spacing: 0%;
  }
}

@media (max-width: 768px) {
  .modal {
    max-height: calc(100dvh - 20px);
  }

  .modal__inner {
    padding: 16px;
  }

  .modal__head {
    padding-bottom: 16px;
  }

  .modal__close {
    width: 44px;
    height: 44px;
  }

  .modal__body {
    margin-top: 20px;
    padding-right: 8px;
  }

  
}


/* ——— Закреплённый низ модалки с кнопками ——— */
.modal__foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex-shrink: 0;
  padding-top: 20px;
  border-top: 1px solid color-mix(in srgb, var(--stroke) 50%, transparent);
}

.modal__foot-wide {
  grid-column: 1 / -1;
}


/* ——— Окно «Настройки cookie» (template-parts/cookie-settings.php) ——— */
.modal--cookie {
  width: min(640px, calc(100% - 20px));
  max-height: 90vh;
  overflow: hidden;
  border-radius: 16px;
}

.modal--cookie .modal__inner {
  padding: 32px;
}

.modal--cookie .modal__head {
  align-items: center;
  padding-bottom: 0;
  border-bottom: none;
}

.modal--cookie .modal__body {
  margin-top: 24px;
  padding-bottom: 20px;
}

@media (max-width: 768px) {
  /* Лист снизу: шапка и кнопки закреплены, тело прокручивается */
  .modal--cookie {
    width: 100%;
    max-height: 90dvh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
  }

  .modal--cookie .modal__inner {
    padding: 20px 16px;
  }

  .modal__foot {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}


/* ——— Анимация модалок ———
   Открытие: затемнение и окно одновременно, 220 мс ease-out (окно ещё и поднимается на 12px).
   Закрытие: обратная анимация 200 мс ease-in — класс .is-closing ставит closeDialog() в assets/js/main.js,
   после анимации окно закрывается. Ввод не блокируется: крестик и Esc работают сразу. */
.modal[open] {
  animation: modal-in 220ms ease-out;
}

.modal[open]::backdrop {
  animation: modal-backdrop-in 220ms ease-out;
}

.modal.is-closing {
  animation: modal-out 200ms ease-in forwards;
}

.modal.is-closing::backdrop {
  animation: modal-backdrop-out 200ms ease-in forwards;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes modal-out {
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes modal-backdrop-in {
  from {
    opacity: 0;
  }
}

@keyframes modal-backdrop-out {
  to {
    opacity: 0;
  }
}
