/* ============================================================================
   Download popup — the ad-supported bridge between "your file is ready" and the
   file landing in the downloads folder.

   Deliberately honest by construction: the ad sits in its own labelled box, the
   real download button is visible and clickable from the first frame, and the bar
   is a disclosed short wait rather than a fake "processing" animation. An ad that
   impersonates a download button is what gets accounts banned, so the label and
   the separation are not optional.
   ========================================================================== */

.dlp {
  position: fixed;
  inset: 0;
  z-index: 400;               /* above the header (50) and the toasts (300) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dlp[hidden] { display: none; }

.dlp-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 26, 32, .5);
  animation: dlp-fade .18s ease both;
}

.dlp-box {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--surface, #fff);
  color: var(--ink, #1b2129);
  border-radius: var(--radius, 12px);
  box-shadow: var(--shadow-lg, 0 18px 44px rgba(20, 30, 35, .14));
  padding: 26px 26px 22px;
  animation: dlp-in .22s cubic-bezier(.2, .7, .25, 1) both;
}
@keyframes dlp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dlp-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.dlp-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2, #f7f8f9);
  color: var(--muted, #6b7280);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.dlp-x:hover { background: var(--brand-soft, #fdeceb); color: var(--brand, #e5322d); }

.dlp-kicker {
  margin: 0 0 6px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand, #e5322d);
}
.dlp-title {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.02em;
}
.dlp-sub {
  margin: 0 0 16px;
  color: var(--muted, #6b7280);
  font-size: .88rem;
  line-height: 1.5;
}

/* The wait: a real progress bar with the seconds written out. */
.dlp-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2, #f0f2f3);
  overflow: hidden;
}
.dlp-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--brand, #e5322d);
  transition: width .1s linear;
}
.dlp-count {
  margin: 8px 0 18px;
  font-size: .82rem;
  color: var(--muted, #6b7280);
}
.dlp.done .dlp-bar > span { width: 100% !important; }

/* The ad. Labelled, boxed, and never shaped like the download button. */
.dlp-ad {
  border: 1px solid var(--line, #e6e9ea);
  border-radius: var(--radius-sm, 9px);
  background: var(--surface-2, #f7f8f9);
  padding: 10px;
  margin-bottom: 18px;
}
.dlp-ad-label {
  margin: 0 0 8px;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
}
.dlp-ad-slot { min-height: 100px; display: flex; align-items: center; justify-content: center; }
.dlp-ad-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 100px;
  justify-content: center;
  border: 1px dashed var(--line-2, #d7dcdf);
  border-radius: 8px;
  background: #fff;
  color: var(--muted, #6b7280);
  font-size: .78rem;
  text-align: center;
  padding: 14px;
}
.dlp-ad-placeholder b { color: var(--ink-2, #3d4550); font-size: .82rem; }
.dlp-ad-placeholder code {
  font-family: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: .74rem;
  color: var(--ink-2, #3d4550);
}

.dlp-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dlp-actions .btn { flex: 1 1 auto; text-align: center; justify-content: center; }

.dlp-fallback {
  margin: 12px 0 0;
  font-size: .82rem;
  color: var(--muted, #6b7280);
}
.dlp-link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--brand, #e5322d);
  text-decoration: none;
  cursor: pointer;
}

/* Body scroll lock while the dialog is open. */
body.dlp-open { overflow: hidden; }

@media (max-width: 480px) {
  .dlp-box { padding: 22px 18px 18px; }
  .dlp-title { font-size: 1.15rem; }
  .dlp-actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .dlp-backdrop, .dlp-box { animation: none; }
  .dlp-bar > span { transition: none; }
}
