/* ==== БАЗОВАЯ МОДАЛКА ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.active { display: flex; }

/* Окно модалки */
.modal-content {
  background: #fff;
  border-radius: 1rem;
  max-width: 620px;
  width: 90%;
  padding: 1.5rem 1.75rem;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-size: 2.5rem;
  cursor: pointer;
  color: #888;
  transition: color 0.2s;
  line-height: 2.5rem;
}
.modal-close:hover { color: #333; }

/* Контент */
.modal-illustration { width: 200px; margin: 0 auto 1rem; }
.modal-title { font-size: 1.25rem; margin-bottom: 0.75rem; color: #333; }
.modal-text { font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; color: #555; }
.modal-text.small { margin-top: 1.25rem; margin-bottom: 0.5rem; }

.modal-download {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: #f6a623;
  color: #fff;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 700;
  transition: background 0.2s;
}
.modal-download:hover { background: #d68a1e; }

/* Форма */
.modal-form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.modal-form input[type="email"] {
  flex: 1 1 60%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  font-size: 0.9rem;
}
.modal-form button {
  flex: 1 1 30%;
  background: transparent;
  border: none;
  color: #0077cc;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.modal-form button:hover { text-decoration: underline; }

/* ==== CONTACT MODAL ======================================================= */
#contactModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#contactModal.active { display: flex; }

#contactModal .modal-content {
  background: #fff;
  border-radius: 0.75rem;
  width: 90%;
  max-width: 500px;
  padding: 2rem;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
#contactModal .modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  transition: color 0.2s;
}
#contactModal .modal-close:hover { color: #333; }
#contactModal h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  color: #2f3e46;
}
#contactModal form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
#contactModal input,
#contactModal textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s;
}
#contactModal input:focus,
#contactModal textarea:focus {
  border-color: #0077cc;
  outline: none;
}
#contactModal .btn--primary { align-self: flex-end; padding: 0.75rem 1.5rem; }

/* ==== SEARCH DIALOG (ЕДИНЫЙ БЛОК, БЕЗ ДУБЛЕЙ) ============================ */
#search-dialog {
  position: fixed;
  inset: 0;
  display: none;               /* по умолчанию скрыт */
  align-items: flex-start;     /* выезжает сверху */
  justify-content: center;
  background: rgba(0,0,0,.55); /* затемнение */
  z-index: 10000;              /* синхронно с contactModal */
  pointer-events: none;
}
#search-dialog[hidden] { display: none !important; }

#search-dialog.active,
#search-dialog.is-open {
  display: flex;               /* ВАЖНО: flex, не block */
  pointer-events: auto;
}

#search-dialog .search-dialog__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#search-dialog .search-dialog__panel {
  position: relative;
  z-index: 1;                  /* поверх подложки */
  margin-top: 8vh;
  width: min(920px, 92vw);
  max-height: 85vh;
  background: #fff;
  color: #111;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  overflow: auto;
  outline: none;

  /* Если тема внезапно прячет панель анимациями — держим видимой */
  display: block;
  opacity: 1;
  visibility: visible;
  transform: none;
}
#search-dialog .search-dialog__panel[hidden] { display: none !important; }
