/* ============================================================
 * Download-modal — shared email-gate modal used on Sample Report
 * posts and Guide posts. Triggered by [data-modal-open] buttons,
 * dismissed via [data-modal-close], the backdrop, or Esc.
 * ============================================================ */

.pi-dl-modal-bd {
  position: fixed; inset: 0;
  background: rgba(15, 17, 21, 0.62);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 200ms;
}
.pi-dl-modal-bd.open { display: flex; opacity: 1; }

.pi-dl-modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(15, 17, 21, 0.32);
  position: relative;
  transform: translateY(20px);
  transition: transform 200ms;
}
.pi-dl-modal-bd.open .pi-dl-modal { transform: translateY(0); }

.pi-dl-modal-head {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--color-border);
}
.pi-dl-modal-head h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--anthracite-100);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.pi-dl-modal-head p {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}
.pi-dl-modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-subtle);
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms;
}
.pi-dl-modal-close:hover { background: var(--off-white-100); color: var(--color-text); }
.pi-dl-modal-close svg { width: 18px; height: 18px; }

.pi-dl-modal-body { padding: 24px 32px 28px; }
.pi-dl-fg { margin-bottom: 16px; }
.pi-dl-fg label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}
.pi-dl-fg label .req { color: var(--color-accent-hover); margin-left: 2px; }
.pi-dl-fg label .opt { font-weight: 400; color: var(--color-text-subtle); margin-left: 4px; font-size: 12px; }
.pi-dl-fg input[type="text"],
.pi-dl-fg input[type="email"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: #fff;
  transition: border-color 150ms, box-shadow 150ms;
  box-sizing: border-box;
}
.pi-dl-fg input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.14);
}

.pi-dl-checkbox-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.45;
  margin: 18px 0 8px;
}
.pi-dl-checkbox-row input { margin-top: 2px; accent-color: var(--color-accent); flex-shrink: 0; }

.pi-dl-modal-foot {
  border-top: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  /* When embedded inside CF7's form (which sits inside .pi-dl-modal-body),
   * extend to the modal's full width via negative horizontal margins, then
   * re-pad to reset the inner gutter. The 24px top margin offsets the
   * checkbox row above. */
  margin: 24px -32px 0;
  padding: 18px 32px 28px;
}
.pi-dl-modal-foot .btn { padding: 11px 22px; }

/* ───────────── CF7 form embed shims ─────────────
 * The modal body wraps a CF7 [contact-form-7] shortcode. CF7 renders its own
 * <form> + wrapping <span class="wpcf7-form-control-wrap"> around inputs.
 * These rules normalise CF7's defaults so the rendered form matches the
 * modal's hand-styled design. */

.pi-dl-modal-body .wpcf7,
.pi-dl-modal-body .wpcf7 form { margin: 0; padding: 0; }

/* Make CF7's input wrapper a transparent block so .pi-dl-fg input width:100% works. */
.pi-dl-modal-body .wpcf7-form-control-wrap {
  display: block;
  width: 100%;
}

/* CF7 adds .wpcf7-text / .wpcf7-email / .wpcf7-validates-as-required to inputs.
 * Reset margins/sizes so they pick up our .pi-dl-fg styling. */
.pi-dl-modal-body .wpcf7-form-control.wpcf7-text,
.pi-dl-modal-body .wpcf7-form-control.wpcf7-email {
  width: 100%;
  margin: 0;
}

/* Submit button: CF7 outputs <input type="submit" class="wpcf7-form-control wpcf7-submit …">.
 * Strip CF7's inline-block/native-button look so our .btn styling shows through. */
.pi-dl-modal-body .wpcf7-form-control.wpcf7-submit {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

/* Checkbox layout — CF7 renders [checkbox] as a list item. Our .pi-dl-checkbox-row
 * label wraps it; flatten CF7's <span class="wpcf7-form-control-wrap"> + <span class="wpcf7-list-item"> chain. */
.pi-dl-modal-body .pi-dl-checkbox-row .wpcf7-form-control-wrap,
.pi-dl-modal-body .pi-dl-checkbox-row .wpcf7-list-item {
  display: contents;
}
.pi-dl-modal-body .pi-dl-checkbox-row .wpcf7-list-item-label { font: inherit; color: inherit; }

/* CF7 spinner — small loader to the right of the submit button while AJAXing. */
.pi-dl-modal-body .wpcf7-spinner {
  background-color: var(--color-text-muted);
}

/* Validation errors — CF7 prints these inline below the field. */
.pi-dl-modal-body .wpcf7-not-valid-tip {
  color: #b3261e;
  font-size: 12px;
  margin-top: 6px;
  display: block;
}
.pi-dl-modal-body input.wpcf7-not-valid {
  border-color: #b3261e;
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.10);
}

/* Response output — CF7's catch-all message area below the form. */
.pi-dl-modal-body .wpcf7-response-output {
  margin: 16px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}
.pi-dl-modal-body .wpcf7-form.invalid .wpcf7-response-output,
.pi-dl-modal-body .wpcf7-form.unaccepted .wpcf7-response-output {
  background: #fef2f0;
  border: 1px solid #f5c6c0;
  color: #6b1410;
}
.pi-dl-modal-body .wpcf7-form.failed .wpcf7-response-output,
.pi-dl-modal-body .wpcf7-form.aborted .wpcf7-response-output,
.pi-dl-modal-body .wpcf7-form.spam .wpcf7-response-output {
  background: #fff7e6;
  border: 1px solid #f5d289;
  color: #5b3d08;
}
/* Hide the success message from CF7 — we show our own success state instead. */
.pi-dl-modal-body .wpcf7-form.sent .wpcf7-response-output {
  display: none;
}

/* Success state */
.pi-dl-success {
  padding: 40px 32px 32px;
  text-align: center;
  display: none;
}
.pi-dl-success.shown { display: block; }
.pi-dl-success .check {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(127, 212, 142, 0.18);
  margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
}
.pi-dl-success .check svg { width: 30px; height: 30px; fill: none; stroke: #2A8F46; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pi-dl-success h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--anthracite-100);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.pi-dl-success p {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.55;
  max-width: 360px;
  margin: 0 auto;
}
