body.modal-open { overflow: hidden; }

/* ═══════════════════════════════
   OVERLAY
═══════════════════════════════ */
.legal-modal {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,18,32,0.82); backdrop-filter: blur(6px);
  padding: 24px 16px;
  align-items: center;
  justify-content: center;
}
.legal-modal.modal-visible { display: flex; }
.modal-backdrop { position: absolute; inset: 0; z-index: 0; }

/* ═══════════════════════════════
   BOX — desktop: centred card
═══════════════════════════════ */
.modal-box {
  position: relative; z-index: 1;
  background: #fff; border-radius: 14px;
  max-width: 720px; width: 100%;
  margin: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,0.35);
  animation: modalIn 0.28s cubic-bezier(0.34,1.1,0.64,1) both;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}
@keyframes modalIn {
  from { transform: translateY(28px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ═══════════════════════════════
   STICKY HEADER
═══════════════════════════════ */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 40px;
  background: #1F5AA8;
  border-bottom: none;
  flex-shrink: 0;
  border-radius: 14px 14px 0 0;
}
.modal-header h2 {
  font-family: 'Poppins', sans-serif;
  font-size: 1.3rem; font-weight: 800;
  color: #fff; margin: 0;
}

/* ═══════════════════════════════
   SCROLLABLE BODY
═══════════════════════════════ */
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 40px;
  -webkit-overflow-scrolling: touch;
}
.modal-body h3 {
  font-family: 'Poppins', sans-serif; font-size: 1rem; font-weight: 700;
  color: #1A3A6B; margin: 24px 0 8px;
}
.modal-body h3:first-child { margin-top: 0; }
.modal-body p {
  font-size: 0.92rem; line-height: 1.75; color: #374151; margin-bottom: 12px;
}
.modal-body ul { padding-left: 20px; margin-bottom: 12px; }
.modal-body ul li {
  font-size: 0.92rem; line-height: 1.75; color: #374151; margin-bottom: 4px;
}

/* ═══════════════════════════════
   STICKY FOOTER
═══════════════════════════════ */
.modal-footer {
  padding: 16px 40px 24px;
  border-top: 2px solid #f3f4f6;
  flex-shrink: 0;
}

/* ═══════════════════════════════
   CLOSE × BUTTON (header)
═══════════════════════════════ */
.modal-close {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.75); font-size: 1.5rem; line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0; padding: 0;
}
.modal-close:hover { color: #fff; }

/* ═══════════════════════════════
   CLOSE BUTTON (legal footer)
═══════════════════════════════ */
.modal-close-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 28px;
  background: #f3f4f6; color: #1A3A6B;
  border: 1.5px solid #e5e7eb; border-radius: 6px;
  font-family: 'Poppins', sans-serif; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.modal-close-btn:hover { background: #1A3A6B; color: #fff; border-color: #1A3A6B; }


/* ═══════════════════════════════
   FORM INSIDE MODAL
═══════════════════════════════ */
.modal-box .contact-form-panel { background: transparent; padding: 0; box-shadow: none; }
.modal-box .form-row { grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-footer .btn-submit { width: 100%; }

/* ═══════════════════════════════
   ERROR / SUCCESS
═══════════════════════════════ */
.git-error, .git-success { display: none; }

/* ═══════════════════════════════
   TABLET (≤ 768px)
═══════════════════════════════ */
@media (max-width: 768px) {
  .modal-header { padding: 24px 28px 16px; }
  .modal-body   { padding: 20px 28px; }
  .modal-footer { padding: 14px 28px 20px; }
}

/* ═══════════════════════════════
   MOBILE BOTTOM SHEET (≤ 480px)
═══════════════════════════════ */
@media (max-width: 480px) {
  /* Overlay: sit at bottom, no centering */
  .legal-modal {
    padding: 0;
    align-items: flex-end;
    justify-content: center;
  }

  /* Box: full-width bottom sheet */
  .modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    margin: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.28);
    animation: modalSlideUp 0.32s cubic-bezier(0.34,1.05,0.64,1) both;
  }
  @keyframes modalSlideUp {
    from { transform: translateY(100%); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  /* Drag handle pill at top */
  .modal-header::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0 auto 16px;
    flex: none;
    order: -1;
    position: absolute;
    top: 12px; left: 50%; transform: translateX(-50%);
  }
  .modal-header {
    position: relative;
    padding: 28px 20px 18px;
    gap: 10px;
    border-radius: 20px 20px 0 0;
  }
  .modal-header h2 { font-size: 1.15rem; }
  .modal-body       { padding: 16px 20px; }
  .modal-footer     { padding: 12px 20px 20px; }

  /* Single-col form on mobile */
  .modal-box .form-row { grid-template-columns: 1fr; gap: 0; }
  .modal-close-btn  { width: 100%; padding: 12px; }
}

/* ═══════════════════════════════
   SMALL MOBILE (≤ 375px)
═══════════════════════════════ */
@media (max-width: 375px) {
  .modal-box    { max-height: 95vh; }
  .modal-header { padding: 30px 16px 14px; }
  .modal-body   { padding: 14px 16px; }
  .modal-footer { padding: 10px 16px 16px; }
  .modal-header h2 { font-size: 1.1rem; }

  /* Safe area for home bar */
  .modal-footer {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}
