/* ========================================
   ОКНО ОФОРМЛЕНИЯ ПОКУПКИ
======================================== */

.checkout-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px #0004;
}

.checkout-dialog::backdrop {
  background: #101812b3;
  backdrop-filter: blur(5px);
}

html:has(#checkout-dialog[open]) {
  overflow: hidden;
}

/* ========================================
   ЗАГОЛОВОК И КНОПКА ЗАКРЫТИЯ
======================================== */

.checkout-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.checkout-dialog__header h2 {
  font-size: clamp(29px, 5vw, 34px);
}

.checkout-dialog__close {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 0;
  cursor: pointer;
  transition: background 0.2s;
}

.checkout-dialog__close:hover {
  background: var(--sage);
}

/* Геометрически центрированный крестик */

.checkout-dialog__close::before,
.checkout-dialog__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.checkout-dialog__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.checkout-dialog__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ========================================
   ИНФОРМАЦИЯ О ПРОДУКТЕ
======================================== */

.checkout-dialog__product {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 24px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--section-tint);
}

.checkout-dialog__image {
  flex-shrink: 0;
  width: 76px;
  height: 100px;
  object-fit: contain;
}

.checkout-dialog__info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.checkout-dialog__name {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
}

.checkout-dialog__description {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.checkout-dialog__price {
  color: var(--terracotta);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
}

/* ========================================
   ФОРМА ПОКУПАТЕЛЯ
======================================== */

#checkout-form {
  display: flex;
  flex-direction: column;
}

#checkout-form > label:not(.checkout-dialog__agreement) {
  margin-bottom: 7px;
  font-size: 16px;
  font-weight: 650;
}

#checkout-form > input {
  width: 100%;
  height: 56px;
  margin-bottom: 20px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--paper);
  font: 17px var(--sans);
  transition: border-color 0.2s;
}

#checkout-form > input:focus {
  border-color: var(--terracotta);
  outline: 2px solid var(--terracotta);
  outline-offset: 1px;
}

.checkout-dialog__hint {
  margin: -12px 0 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

/* ========================================
   СОГЛАСИЕ С УСЛОВИЯМИ
======================================== */

.checkout-dialog__agreement {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 15px;
  line-height: 1.6;
  cursor: pointer;
}

.checkout-dialog__agreement input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--terracotta);
  cursor: pointer;
}

.checkout-dialog__agreement a {
  color: var(--terracotta);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.checkout-dialog__agreement a:hover {
  color: var(--terracotta-hover);
}

/* ========================================
   КНОПКА ПЕРЕХОДА К ОПЛАТЕ
======================================== */

#checkout-form > .button {
  width: 100%;
  min-height: 56px;
  font-size: 17px;
  cursor: pointer;
}

.checkout-dialog__status {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ========================================
   ОШИБКИ ВАЛИДАЦИИ
======================================== */

.checkout-dialog__error {
  margin: -12px 0 18px;
  color: var(--terracotta);
  font-size: 14px;
  line-height: 1.5;
}

.checkout-dialog__agreement + .checkout-dialog__error {
  margin: -16px 0 18px;
}

#checkout-form input[aria-invalid="true"] {
  border-color: var(--terracotta);
}

/* ========================================
   ПОДСКАЗКА ОБ ОПЕЧАТКЕ EMAIL
======================================== */

.checkout-dialog__email-suggestion {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  margin: -8px 0 18px;
  padding: 16px;
  border: 1px solid var(--terracotta);
  border-radius: 12px;
  background: color-mix(in srgb, var(--terracotta) 12%, var(--surface));
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.checkout-dialog__email-suggestion[hidden] {
  display: none;
}

.checkout-dialog__suggestion-title {
  grid-column: 1 / -1;
  font-size: 17px;
  font-weight: 750;
}

.checkout-dialog__email-suggestion span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.checkout-dialog__email-suggestion button {
  padding: 10px 14px;
  border: 1px solid var(--terracotta);
  border-radius: 8px;
  background: var(--terracotta);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s;
}

.checkout-dialog__email-suggestion button:hover {
  background: var(--terracotta-hover);
}

/* ========================================
   МОБИЛЬНАЯ ВЕРСИЯ
======================================== */

@media (max-width: 580px) {
  .checkout-dialog {
    padding: 22px;
  }

  .checkout-dialog__product {
    gap: 14px;
    padding: 12px;
  }

  .checkout-dialog__image {
    width: 65px;
    height: 86px;
  }
}

@media (max-width: 480px) {
  .checkout-dialog__email-suggestion {
    grid-template-columns: 1fr;
  }

  .checkout-dialog__email-suggestion button {
    width: 100%;
  }
}
