/* ============================================================
   МОДАЛЬНІ ВІКНА + FAB — лід-форма, "1 клік", швидкий зв'язок
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal.is-open { display: flex; }

@media (min-width: 600px) {
  .modal { align-items: center; padding: 24px; }
}

.modal__overlay {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--c-ink) 50%, transparent);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.modal.is-open .modal__overlay { opacity: 1; }

@keyframes modal-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.modal__card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--c-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 28px 22px max(22px, env(safe-area-inset-bottom));
  animation: modal-in var(--t-med) var(--ease);
}
@media (min-width: 600px) {
  .modal__card { border-radius: var(--radius-md); padding: 32px; }
}

.modal__close {
  position: absolute; top: 10px; right: 10px;
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--c-muted);
}

.modal__ornament { display: none; }
.modal__dismiss { display: none; }

.modal__title { margin-bottom: 10px; }
.modal__lead { font-size: 14.5px; color: var(--c-muted); margin-bottom: 20px; }
.modal__agree-label { font-size: 12.5px; font-weight: 400; }
.modal__success { display: none; text-align: center; padding: 20px 0; }
.modal__success.is-visible { display: block; }
.modal__success-text { margin-top: 8px; color: var(--c-muted); }
.modal__form.is-hidden { display: none; }

/* --- Арка (автопоказ phone_modal) --- */
.modal--arch {
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.modal--arch .modal__overlay {
  background: transparent;
}

.modal--arch .modal__card {
  --arch-cream: #ffffff;
  --arch-ink: #2a3226;
  --arch-muted: #5c6658;
  --arch-btn: #3E5235;
  --arch-btn-hover: #33452c;
  --arch-line: #5a6b52;

  width: min(100%, 380px);
  max-height: min(92dvh, 720px);
  margin: 0 auto;
  padding: 36px 28px 40px;
  background-color: var(--arch-cream);
  background-image:
    linear-gradient(
      180deg,
      #ffffff 0%,
      #ffffff 56%,
      color-mix(in srgb, #ffffff 94%, transparent) 70%,
      color-mix(in srgb, #ffffff 60%, transparent) 86%,
      transparent 100%
    ),
    url("../img/modal/meadow-sunflowers.jpg");
  background-repeat: no-repeat;
  background-position: center top, center 128%;
  background-size: 100% 100%, 118% auto;
  border-radius: 190px 190px 28px 28px / 120px 120px 28px 28px;
  box-shadow: 0 22px 56px color-mix(in srgb, #2a3226 28%, transparent);
  text-align: center;
  overflow-x: hidden;
  isolation: isolate;
}

@media (min-width: 600px) {
  .modal--arch .modal__card {
    width: min(100%, 420px);
    padding: 44px 40px 48px;
    border-radius: 210px 210px 32px 32px / 140px 140px 32px 32px;
    background-size: 100% 100%, 112% auto;
    background-position: center top, center 130%;
  }
}

@media (max-width: 399px) {
  .modal--arch .modal__card {
    padding: 28px 20px 36px;
    border-radius: 160px 160px 24px 24px / 96px 96px 24px 24px;
    background-size: 100% 100%, 128% auto;
    background-position: center top, center 132%;
  }
}

.modal--arch .modal__close { display: none; }

.modal--arch .modal__dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 12px auto 0;
  padding: 10px 16px;
  min-height: 48px;
  border: 0;
  background: color-mix(in srgb, #ffffff 78%, transparent);
  border-radius: 999px;
  color: var(--arch-ink);
  font-family: var(--f-body);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.modal--arch .modal__dismiss:hover {
  color: var(--arch-btn);
  background: color-mix(in srgb, #ffffff 92%, transparent);
  text-decoration: underline;
}

.modal--arch .modal__ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 4px 0 18px;
  color: var(--arch-line);
}
.modal--arch .modal__ornament-line {
  display: block;
  width: 42px;
  height: 1px;
  background: currentColor;
  opacity: .55;
}
.modal--arch .modal__ornament-sprout {
  flex: 0 0 auto;
  color: var(--arch-line);
}

.modal--arch .modal__title {
  margin: 0 0 12px;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(26px, 6.2vw, 34px);
  line-height: 1.15;
  color: var(--arch-ink);
  text-wrap: balance;
}

.modal--arch .modal__lead {
  margin: 0 auto 22px;
  max-width: 32ch;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--arch-muted);
}

.modal--arch .modal__field-label {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.modal--arch .field {
  position: relative;
  margin-bottom: 12px;
  text-align: left;
}
.modal--arch .field input[type="text"],
.modal--arch .field input[type="tel"] {
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid color-mix(in srgb, var(--arch-ink) 22%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, #ffffff 92%, transparent);
  font-size: 15px;
  color: var(--arch-ink);
  -webkit-appearance: none;
  appearance: none;
}
.modal--arch .field input::placeholder {
  color: color-mix(in srgb, var(--arch-muted) 80%, transparent);
}
.modal--arch .field input:focus {
  border-color: var(--arch-btn);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--arch-btn) 18%, transparent);
}

.modal--arch .field--checkbox {
  margin: 14px 0 18px;
  align-items: flex-start;
  text-align: left;
}
.modal--arch .field--checkbox input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--arch-btn);
  border-radius: 3px;
}
.modal--arch .modal__agree-label {
  font-size: 12px;
  line-height: 1.4;
  color: var(--arch-muted);
  font-weight: 400;
}

.modal--arch .btn--primary {
  min-height: 50px;
  border-radius: 999px;
  background: var(--arch-btn);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.modal--arch .btn--primary:hover {
  background: var(--arch-btn-hover);
  color: #ffffff;
  filter: none;
}
.modal--arch .btn--primary:active:not(:disabled) {
  filter: none;
  transform: scale(.98);
}

.modal--arch .modal__success {
  padding: 28px 8px 12px;
}
.modal--arch .modal__success .h3 {
  color: var(--arch-ink);
}
.modal--arch .modal__success-text {
  color: var(--arch-muted);
}

@supports (-webkit-touch-callout: none) {
  .modal--arch .modal__card {
    max-height: min(92dvh, 720px);
  }
}

/* --- Кнопка швидкого зв'язку (FAB) --- */
.fab {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 45;
  width: 56px; height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--c-sage);
  color: #ffffff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-pop);
  transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.fab:hover { background: var(--c-sagehover); transform: translateY(-2px); }

@media (min-width: 900px) {
  .fab { right: 28px; }
}

/* --- Тост-повідомлення (напр. після заявки/додавання в кошик) --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: var(--z-toast);
  min-width: 220px;
  max-width: 90vw;
  padding: 14px 18px;
  background: var(--c-ink);
  color: var(--c-surface);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
