/* ===================== Download — full-screen page ===================== */
/* Opened by a project's Download button (see download.js). Project at the top, a 7-second
   countdown ring, then the admin's ad fills the rest of the screen. */
.dl-page {
  background: var(--paper); bottom: 0; display: flex; flex-direction: column;
  left: 0; position: fixed; right: 0; top: 0; z-index: 125;
}
.dl-page.is-hidden { display: none; }

.dl-head {
  align-items: center; display: flex; flex: 0 0 auto; gap: 12px;
  padding: 12px 16px 6px; padding-top: max(12px, env(safe-area-inset-top));
}
.dl-back {
  align-items: center; background: #f2f3f7; border-radius: 9px; color: var(--ink);
  display: inline-flex; flex: 0 0 auto; height: 38px; justify-content: center; width: 38px;
}
.dl-back svg { fill: none; height: 17px; stroke: currentColor; stroke-width: 2; width: 17px; }
.dl-head-title { color: var(--ink); font-size: 15px; font-weight: 700; letter-spacing: -.02em; }

.dl-project { align-items: center; display: flex; flex: 0 0 auto; gap: 13px; padding: 8px 16px 14px; }
.dl-tile {
  background: linear-gradient(135deg, #7649f7, #3d83f5) center / cover no-repeat;
  border-radius: 16px; box-shadow: 0 8px 22px rgba(70,94,225,.25); flex: 0 0 auto; height: 60px; width: 60px;
}
.dl-project-text { flex: 1; min-width: 0; }
.dl-project-text h2 {
  color: var(--ink); font-size: 17px; letter-spacing: -.03em; line-height: 1.25; margin: 0 0 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dl-project-text p { color: #6b7385; font-size: 12px; margin: 0; }

.dl-ring { flex: 0 0 auto; height: 54px; position: relative; width: 54px; }
.dl-ring svg { height: 100%; transform: rotate(-90deg); width: 100%; }
.dl-ring circle { fill: none; stroke-width: 3.4; }
.dl-ring-track { stroke: rgba(118,73,247,.16); }
.dl-ring-fill { stroke: var(--purple); stroke-dasharray: 119.4; stroke-dashoffset: 0; stroke-linecap: round; }
.dl-ring span {
  align-items: center; color: var(--ink); display: flex; font-size: 19px; font-variant-numeric: tabular-nums;
  font-weight: 800; inset: 0; justify-content: center; position: absolute;
}
.dl-ring.is-done span { color: var(--purple); }
.dl-ring.is-done span svg { fill: none; height: 22px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.6; transform: none; width: 22px; }

.dl-bar { background: rgba(118,73,247,.12); flex: 0 0 auto; height: 3px; }
.dl-bar i { background: var(--purple); display: block; height: 100%; transform-origin: left; transform: scaleX(0); width: 100%; }

/* The ad: fills everything between the header and the footer. A blurred copy of the same image sits behind it
   so pictures of any shape look intentional, never letterboxed on a blank background. */
.dl-stage {
  align-items: center; background: #0f1220; display: flex; flex: 1; flex-direction: column; gap: 12px; justify-content: center;
  min-height: 0; overflow: hidden; padding: 14px; position: relative;
}
.dl-ad-bg {
  filter: blur(30px) saturate(1.2); height: 100%; inset: 0; object-fit: cover; opacity: 0; position: absolute;
  transform: scale(1.25); transition: opacity .5s ease; width: 100%;
}
/* The frame takes all the room the call-to-action bar leaves; the picture is centred inside it at its natural shape. */
.dl-ad-frame { flex: 1 1 0; min-height: 0; position: relative; width: 100%; }
.dl-ad {
  border-radius: 14px; bottom: 0; box-shadow: 0 18px 50px rgba(0,0,0,.45); left: 0; margin: auto; max-height: 100%; max-width: 100%;
  object-fit: contain; opacity: 0; position: absolute; right: 0; top: 0; transition: opacity .45s ease;
}
.dl-stage.has-ad .dl-ad, .dl-stage.has-ad .dl-ad-bg { opacity: 1; }
.dl-stage.has-ad .dl-ad-bg { opacity: .55; }
.dl-ad-tag {
  background: rgba(0,0,0,.55); border-radius: 6px; color: #fff; display: none; font-size: 10px; font-weight: 700;
  letter-spacing: .04em; padding: 3px 7px; position: absolute; right: 22px; text-transform: uppercase; top: 22px;
}
.dl-stage.has-ad .dl-ad-tag { display: block; }
.dl-stage:not(.has-ad) .dl-ad-frame { display: none; }
.dl-ad-empty { color: rgba(255,255,255,.78); display: none; max-width: 260px; text-align: center; }
.dl-stage:not(.has-ad) .dl-ad-empty { display: block; }
.dl-ad-empty strong { color: #fff; display: block; font-size: 17px; letter-spacing: -.02em; margin-bottom: 6px; }
.dl-ad-empty span { font-size: 12.5px; line-height: 1.5; }

.dl-foot {
  background: var(--paper); border-top: 1px solid var(--line); flex: 0 0 auto;
  padding: 13px 16px calc(13px + env(safe-area-inset-bottom)); text-align: center;
}
.dl-status { color: var(--ink); font-size: 14px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.dl-sub { color: #6b7385; font-size: 12px; line-height: 1.45; margin: 3px 0 0; }
.dl-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.dl-actions.is-hidden { display: none; }
.dl-btn {
  align-items: center; border-radius: 12px; display: inline-flex; font-size: 13px; font-weight: 700;
  gap: 7px; height: 42px; justify-content: center; padding: 0 18px;
}
.dl-btn-primary { background: var(--purple); color: #fff; }
.dl-btn-secondary { background: #f2f3f7; color: var(--ink); }
.dl-btn svg { fill: none; height: 16px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 16px; }
.dl-page.is-error .dl-ring, .dl-page.is-error .dl-bar { display: none; }
.dl-page.is-error .dl-status { color: #c23636; }

@media (min-width: 700px) {
  .dl-head, .dl-project, .dl-foot { margin: 0 auto; max-width: 720px; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .dl-ad, .dl-ad-bg { transition: none; }
}

body[data-theme="dark"] .dl-page { background: #181818; }
body[data-theme="dark"] .dl-head-title, body[data-theme="dark"] .dl-project-text h2,
body[data-theme="dark"] .dl-ring span, body[data-theme="dark"] .dl-status { color: #f2f2f2; }
body[data-theme="dark"] .dl-back, body[data-theme="dark"] .dl-btn-secondary { background: rgba(255,255,255,.07); color: #e2e5ee; }
body[data-theme="dark"] .dl-project-text p, body[data-theme="dark"] .dl-sub { color: #9aa1b2; }
body[data-theme="dark"] .dl-foot { background: #181818; border-color: rgba(255,255,255,.08); }
body[data-theme="dark"] .dl-ring-fill, body[data-theme="dark"] .dl-bar i { background: #a78bfa; stroke: #a78bfa; }
body[data-theme="dark"] .dl-bar i { background: #a78bfa; }
body[data-theme="dark"] .dl-page.is-error .dl-status { color: #ff8a8a; }

/* ===================== Admin → Ads ===================== */
.ad-admin-picks, .ad-admin-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin-top: 12px; }
.ad-admin-picks:empty { display: none; }
.ad-admin-picks img { aspect-ratio: 4 / 5; border-radius: 10px; object-fit: cover; width: 100%; }
.ad-admin-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-top: 14px; }
.ad-admin-form .settings-field { margin: 0; }
.ad-admin-form .settings-field select { background: #fafbfe; border: 1px solid #cdd3e3; border-radius: 8px; color: #303748; font-size: 12px; height: 39px; padding: 0 9px; }
body[data-theme="dark"] .ad-admin-form .settings-field select { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.14); color: #e2e5ee; }
.ad-admin-form .ad-admin-wide { grid-column: 1 / -1; }
.ad-admin-form small, .ad-admin-edit small { color: #7a8398; display: block; font-size: 11px; line-height: 1.4; margin-top: 4px; }
.ad-admin-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.ad-admin-card { border: 1px solid rgba(127,127,127,.28); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.ad-admin-card img { aspect-ratio: 4 / 3; background: #0f1220; object-fit: cover; width: 100%; }
.ad-admin-card.is-paused img { filter: grayscale(1); opacity: .45; }
.ad-admin-meta { align-items: center; display: flex; flex-wrap: wrap; font-size: 11px; gap: 6px; justify-content: space-between; padding: 9px 10px 0; }
.ad-admin-state { font-weight: 700; }
.ad-admin-card:not(.is-paused) .ad-admin-state { color: #17a34a; }
.ad-admin-card.is-paused .ad-admin-state { color: #8a93a6; }
.ad-admin-where { background: rgba(106,92,240,.14); border-radius: 99px; color: #6a5cf0; font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 3px 9px; text-transform: uppercase; }
body[data-theme="dark"] .ad-admin-where { color: #b3a8ff; }
.ad-admin-info { padding: 6px 10px 0; }
.ad-admin-info strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-admin-info span { color: #7a8398; display: block; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-admin-stats { color: #7a8398; display: flex; font-size: 11px; font-weight: 700; gap: 12px; padding: 6px 10px 0; }
.ad-admin-actions { display: flex; gap: 6px; padding: 9px 10px 10px; }
.ad-admin-actions button { background: rgba(127,127,127,.14); border-radius: 8px; flex: 1; font-size: 11.5px; font-weight: 700; height: 32px; }
.ad-admin-actions button[data-ad-delete] { color: #c23636; }
.ad-admin-edit { display: grid; gap: 8px; padding: 8px 10px 0; }
.ad-admin-edit.is-hidden { display: none; }
.ad-admin-edit label { color: #7a8398; display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; margin-bottom: 3px; text-transform: uppercase; }
.ad-admin-edit input, .ad-admin-edit select { background: rgba(127,127,127,.1); border: 1px solid rgba(127,127,127,.28); border-radius: 8px; box-sizing: border-box; color: inherit; font-size: 13px; height: 36px; padding: 0 10px; width: 100%; }

/* ===================== Daily download limit ===================== */
/* The Download button greys out once today's allowance is used up; tapping it opens the small popup below. */
body.dl-limit-hit .zip-button[data-download-project],
body.dl-limit-hit .feed-card-link-button.zip-button,
body.dl-limit-hit .pfs-secondary.zip-button { background: #eceef3 !important; border-color: transparent !important; box-shadow: none !important; color: #9aa1b2 !important; cursor: not-allowed; filter: grayscale(1); opacity: .75; }
body[data-theme="dark"].dl-limit-hit .zip-button[data-download-project] { background: rgba(255,255,255,.06) !important; color: #6f6f6f !important; }
.dl-limit { align-items: center; background: rgba(10,12,20,.55); bottom: 0; display: flex; justify-content: center; left: 0; padding: 24px; position: fixed; right: 0; top: 0; z-index: 140; animation: dlLimitFade .18s ease-out; }
.dl-limit.is-hidden { display: none; }
.dl-limit-card { background: var(--paper, #fff); border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.35); max-width: 300px; padding: 22px 20px 16px; text-align: center; width: 100%; animation: dlLimitPop .22s cubic-bezier(.2,.9,.3,1.2); }
body[data-theme="dark"] .dl-limit-card { background: #1b1b1b; border: 1px solid rgba(255,255,255,.08); }
.dl-limit-icon { align-items: center; background: rgba(240,90,70,.12); border-radius: 50%; color: #e5533d; display: inline-flex; height: 46px; justify-content: center; margin-bottom: 10px; width: 46px; }
.dl-limit-icon svg { fill: none; height: 22px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 22px; }
.dl-limit-card h3 { color: var(--ink); font-size: 16px; letter-spacing: -.02em; margin: 0 0 6px; }
.dl-limit-card p { color: #6b7488; font-size: 12.5px; line-height: 1.45; margin: 0 0 4px; }
body[data-theme="dark"] .dl-limit-card p { color: #a6a6a6; }
.dl-limit-reset { color: var(--ink); font-size: 12px; font-weight: 800; margin: 8px 0 14px !important; }
.dl-limit-ok { background: #6a5cf0; border-radius: 12px; color: #fff; font-size: 13px; font-weight: 800; padding: 11px 0; width: 100%; }
.dl-limit-more { color: #6a5cf0; display: block; font-size: 11.5px; font-weight: 800; margin: 10px auto 0; padding: 4px; }
@keyframes dlLimitFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dlLimitPop { from { opacity: 0; transform: scale(.92) translateY(8px); } to { opacity: 1; transform: none; } }
