/* Popup opened from any [data-enroll-trigger] button — see
   assets/js/enroll-modal.js. No Figma frame exists for it: values not in
   tokens.css are PROPOSED (decisions.md, "Enroll popup"). */
.enroll-modal[hidden] { display: none; }

.enroll-modal {
  --enroll-error: #e5484d;
  --enroll-field-h: 56px;
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.enroll-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 28, 28, 0.5);
  animation: enroll-fade 0.25s ease-out;
}

/* Mobile: a bottom sheet; the submit button stays pinned to its bottom. */
.enroll-modal__panel {
  position: relative;
  width: 100%;
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-cards-bg);
  border-radius: var(--radius-big-mobile) var(--radius-big-mobile) 0 0;
  padding: 28px 20px 0;
  outline: none;
  animation: enroll-sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.enroll-modal__panel::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--color-text);
  opacity: 0.15;
}

@media (min-width: 700px) {
  .enroll-modal { align-items: center; }
  .enroll-modal__panel {
    max-width: 520px;
    max-height: 92dvh;
    border-radius: var(--radius-big);
    padding: 40px;
    animation-name: enroll-pop-in;
  }
  .enroll-modal__panel::before { content: none; }
}

@keyframes enroll-fade { from { opacity: 0; } }
@keyframes enroll-sheet-in { from { transform: translateY(100%); } }
@keyframes enroll-pop-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  .enroll-modal__backdrop, .enroll-modal__panel { animation: none; }
}

.enroll-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.enroll-modal__title {
  margin: 0 0 20px;
  padding-right: 52px;
  font-family: var(--font-primary);
  font-size: var(--font-size-h3-card-m);
  font-weight: 500;
  line-height: 1.15;
}

.enroll-modal__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.enroll-modal__form[hidden] { display: none; }
/* Lead-only vs checkout-only parts, switched on open. */
.enroll-modal [data-mode][hidden] { display: none; }

.enroll-modal__honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Floating label: the label must follow its input in the markup. 16px
   text: iOS zooms the page into any smaller field. */
.enroll-modal__control {
  position: relative;
  flex: 1;
  min-width: 0;
}
.enroll-modal__control input {
  width: 100%;
  height: var(--enroll-field-h);
  padding: 22px 16px 6px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-medium-mobile);
  background: var(--color-bg);
  font-family: var(--font-primary);
  font-size: 16px;
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}
.enroll-modal__control input::placeholder { color: inherit; opacity: 0.4; }
.enroll-modal__control input:not(:focus)::placeholder { color: transparent; }
.enroll-modal__control label {
  position: absolute;
  top: 50%;
  left: 17.5px;
  right: 16px;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: var(--opacity-secondary-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: top 0.15s, transform 0.15s, font-size 0.15s;
}
.enroll-modal__control input:focus + label,
.enroll-modal__control input:not(:placeholder-shown) + label {
  top: 8px;
  transform: none;
  font-size: 12px;
}
.enroll-modal__control input:focus,
.enroll-modal__country:focus-within { border-color: var(--color-text); }
.enroll-modal__field.is-invalid input,
.enroll-modal__field.is-invalid .enroll-modal__country { border-color: var(--enroll-error); }

.enroll-modal__phone {
  display: flex;
  gap: 8px;
}
/* The native select covers the chip invisibly: the phone's own picker. */
.enroll-modal__country {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: var(--enroll-field-h);
  padding: 0 12px 0 14px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-medium-mobile);
  background: var(--color-bg);
  font-size: 16px;
  white-space: nowrap;
}
.enroll-modal__country::after {
  content: '';
  width: 6px;
  height: 6px;
  margin: -3px 0 0 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: var(--opacity-secondary-text);
}
.enroll-modal__country select {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}

.enroll-modal__field-error {
  display: block;
  margin: 6px 0 0 4px;
  color: var(--enroll-error);
  font-size: 13px;
}
.enroll-modal__field-error[hidden] { display: none; }

.enroll-modal__group {
  margin: 8px 0 0;
  padding: 0;
  border: none;
  min-width: 0;
}
.enroll-modal__group-label {
  margin-bottom: 10px;
  padding: 0;
  font-size: var(--font-size-body-card-s);
  font-weight: 500;
}

/* Segmented control: one row at every width. */
.enroll-modal__channels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.enroll-modal__channel {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: var(--radius-label);
  background: var(--color-bg);
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.enroll-modal__channel input,
.enroll-modal__option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.enroll-modal__channel:has(input:checked) {
  background: var(--color-text);
  color: var(--color-cards-bg);
}

.enroll-modal__intent {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.enroll-modal__option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  border: 1.5px solid var(--color-bg);
  border-radius: var(--radius-medium-mobile);
  font-size: var(--font-size-body-card-s);
  cursor: pointer;
  transition: border-color 0.15s;
}
.enroll-modal__option::before {
  content: '';
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  opacity: 0.35;
}
.enroll-modal__option:has(input:checked) { border-color: var(--color-text); }
.enroll-modal__option:has(input:checked)::before {
  border-width: 6px;
  opacity: 1;
}
.enroll-modal__channel:has(input:focus-visible),
.enroll-modal__option:has(input:focus-visible) { outline: 2px solid var(--color-text); outline-offset: 2px; }

/* PROPOSED: the plan's terms under the options, in the checkbox type. */
.enroll-modal__hint {
  margin: 8px 0 0 4px;
  font-size: 13px;
  line-height: 1.4;
  opacity: var(--opacity-secondary-text);
}

.enroll-modal__consent { margin-top: 4px; }
.enroll-modal__checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}
.enroll-modal__checkbox input {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--color-text);
}
.enroll-modal__checkbox a { color: var(--color-text); text-decoration: underline; }
.enroll-modal__consent.is-invalid .enroll-modal__checkbox input { outline: 1.5px solid var(--enroll-error); outline-offset: 1px; }

.enroll-modal__error {
  margin: 0;
  color: var(--enroll-error);
  font-size: 14px;
}
.enroll-modal__error[hidden] { display: none; }

.enroll-modal__actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: 4px -20px 0;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--color-cards-bg);
  box-shadow: 0 -10px 12px -12px rgba(28, 28, 28, 0.25);
}
@media (min-width: 700px) {
  .enroll-modal__actions {
    position: static;
    margin: 8px 0 0;
    padding: 0;
    box-shadow: none;
  }
}

.enroll-modal__submit {
  width: 100%;
  height: var(--enroll-field-h);
  border: none;
  border-radius: var(--radius-label);
  background: var(--color-accent-buttons);
  color: var(--color-text);
  font-family: var(--font-primary);
  font-size: var(--font-size-button-l);
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s;
}
.enroll-modal__submit:active:not(:disabled) { transform: scale(0.98); }
.enroll-modal__submit:disabled { opacity: var(--opacity-secondary-text); cursor: default; }

.enroll-modal__success { padding: 8px 0 calc(28px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) {
  .enroll-modal__success { padding-bottom: 12px; }
}
.enroll-modal__success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--color-accent);
}
.enroll-modal__success h3 { margin: 0 0 8px; font-size: var(--font-size-h3-card-m); font-weight: 500; }
.enroll-modal__success p { margin: 0; opacity: var(--opacity-secondary-text); }

/* The page behind the popup shouldn't scroll or bounce on mobile while it's open. */
body.enroll-modal-open { overflow: hidden; }
