/*
 * EHG public policy document modal repair.
 *
 * Applies only to dialogs containing .modal-content-scrollable.
 * Privacy Policy, SMS Privacy Policy, and Terms of Service share
 * this document viewer structure.
 */

[role="dialog"]:has(> .modal-content-scrollable) {
  display: flex;
  flex-direction: column;
  width: min(95vw, 48rem);
  max-width: 48rem;
  max-height: 90dvh;
  overflow: hidden;
}

[role="dialog"]:has(> .modal-content-scrollable) > :first-child {
  flex: 0 0 auto;
  padding-right: 2.5rem;
}

.modal-content-scrollable {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.75rem;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.modal-content-scrollable section + section {
  margin-top: 1.5rem;
}

.modal-section-title {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
}

.modal-section-title.mt-0 {
  margin-top: 0;
}

.modal-text {
  color: hsl(var(--muted-foreground));
  font-size: 1rem;
  line-height: 1.7;
}

.custom-scrollbar {
  scrollbar-color: hsl(var(--primary)) hsl(var(--muted));
  scrollbar-width: thin;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 10px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: hsl(var(--muted));
  border-radius: 999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: hsl(var(--primary));
  border: 2px solid hsl(var(--muted));
  border-radius: 999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--primary) / 0.8);
}

@media (max-width: 640px) {
  [role="dialog"]:has(> .modal-content-scrollable) {
    width: calc(100vw - 1rem);
    max-height: 94dvh;
    padding: 1rem;
  }

  [role="dialog"]:has(> .modal-content-scrollable) > :first-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-right: 2.5rem;
    padding-bottom: 0;
  }

  [role="dialog"]:has(> .modal-content-scrollable)
    [data-ehg-policy-download] {
    position: static !important;
    align-self: center;
    min-height: 2.5rem !important;
    margin: 1.25rem 0 1.5rem !important;
    padding: 0.55rem 1.1rem !important;
    transform: none !important;
    white-space: nowrap;
  }

  .modal-content-scrollable {
    padding-right: 0.4rem;
  }

  .modal-text {
    font-size: 0.95rem;
    line-height: 1.6;
  }
}
