.templates-page { margin-top: 5rem; }

.templates-hero {
  position: relative;
  overflow: hidden;
  padding-top: 5.5rem;
  padding-bottom: 4.2rem;
  background: linear-gradient(135deg, #faf5ff, #fdf2f8 50%, #fff7ed);
}
.templates-hero .section-title { margin: 1rem 0 1rem; }
.templates-hero p:not(.badge):not(.pill) { max-width: 43rem; font-size: 1.08rem; }
.templates-hero .hero-sub { margin-top: 0.4rem; font-size: 0.9rem; color: #9ca3af; }
.templates-hero .pill {
  font-size: 0.72rem;
  padding: 0.38rem 0.82rem;
}
.templates-hero .pill i {
  font-size: 0.74rem;
}
.btn-hero-alt {
  margin-top: 1rem;
  height: 2.95rem;
  padding-inline: 1.25rem;
  font-size: 0.86rem;
  font-weight: 800;
  gap: 0.45rem;
}
.btn-hero-alt-icon {
  width: 1.2rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-hero-alt-icon svg {
  width: 100%;
  height: 100%;
}

.nav-links .is-active { color: #db2777; font-weight: 800; }

.templates-stats {
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.templates-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  text-align: center;
}
.templates-stats-grid h2 { font-size: clamp(1.95rem, 4vw, 3rem); margin-bottom: 0.2rem; }
.templates-stats-grid article:nth-child(1) h2 { color: #7c3aed; }
.templates-stats-grid article:nth-child(2) h2 { color: #db2777; }
.templates-stats-grid article:nth-child(3) h2 { color: #f97316; }
.templates-stats-grid article:nth-child(4) h2 { color: #8b5cf6; }
.templates-stats-grid p {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.75rem;
  font-weight: 800;
}

.templates-filter-wrap {
  position: sticky;
  top: 5rem;
  z-index: 40;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.templates-filters {
  padding: 0.8rem 0;
  display: flex;
  gap: 0.5rem;
  overflow: auto;
}
.templates-filter-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  background: #f3f4f6;
  color: #4b5563;
}
.templates-filter-btn.active {
  color: #fff;
  background: var(--gradient-brand);
  box-shadow: var(--shadow-sm);
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 1.6rem;
  row-gap: 1.2rem;
}
.template-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.template-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.template-card.is-hidden { display: none; }
.template-head {
  height: 165px;
  display: grid;
  place-items: center;
  position: relative;
  color: #fff;
  overflow: hidden;
}
.template-head.has-template-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.05), rgba(17, 24, 39, 0.18));
  pointer-events: none;
}
.template-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.template-icon {
  width: 2.8rem;
  height: 2.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.92;
}
.template-icon svg {
  width: 100%;
  height: 100%;
}
.template-format {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #1f2937;
  padding: 0.24rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.template-head.has-template-image .template-format {
  z-index: 2;
}
.template-content { padding: 1rem; }
.template-tag {
  display: inline-block;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  margin-bottom: 0.7rem;
}
.tag-purple { background: #f3e8ff; color: #6d28d9; }
.tag-pink { background: #fce7f3; color: #be185d; }
.tag-orange { background: #ffedd5; color: #c2410c; }
.tag-teal { background: #ccfbf1; color: #0f766e; }

.template-content h3 { font-size: 1.04rem; line-height: 1.38; margin-bottom: 0.5rem; }
.template-content p { font-size: 0.9rem; line-height: 1.65; margin-bottom: 0.85rem; }
.template-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}
.template-downloads {
  font-size: 0.76rem;
  color: #9ca3af;
  font-weight: 700;
}
.download-btn {
  border: 0;
  border-radius: 999px;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(219, 39, 119, 0.22);
}
.download-btn:hover { opacity: 0.92; }
.templates-empty {
  grid-column: 1 / -1;
  color: #9ca3af;
  font-weight: 700;
  text-align: center;
  padding: 3rem 0;
}

.templates-cta {
  position: relative;
  overflow: hidden;
  background: linear-gradient(125deg, #7c3aed, #ec4899 52%, #fb923c);
}
.templates-cta-inner { text-align: center; position: relative; z-index: 2; }
.templates-cta .section-title,
.templates-cta p { color: #fff; }
.templates-cta p {
  max-width: 42rem;
  margin: 1rem auto;
  color: rgba(255, 255, 255, 0.85);
}
.hero-actions {
  margin-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}
.hero-actions .btn { min-width: 12.5rem; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}
.orb-a { width: 240px; height: 240px; top: 40px; left: -50px; background: rgba(196, 181, 253, 0.65); }
.orb-b { width: 240px; height: 240px; right: -50px; bottom: 10px; background: rgba(253, 186, 116, 0.6); }
.orb-c { width: 280px; height: 280px; left: -110px; top: -100px; background: rgba(255, 255, 255, 0.17); }
.orb-d { width: 280px; height: 280px; right: -110px; bottom: -120px; background: rgba(255, 255, 255, 0.17); }

@media (max-width: 980px) {
  .templates-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .templates-grid { grid-template-columns: 1fr; }
  .templates-stats-grid { grid-template-columns: repeat(2, 1fr); }

  .templates-stats-grid article {
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    padding: 0.9rem;
  }

  .template-foot {
    flex-direction: column;
    align-items: flex-start;
  }

  .download-btn {
    width: 100%;
    text-align: center;
  }

  .hero-actions .btn { width: 100%; }
}

/* ── Download popup modal ────────────────────────────────── */
.dl-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: dlOverlayIn 0.22s ease;
}
.dl-overlay[hidden] { display: none; }

@keyframes dlOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dl-modal {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 2.2rem 2rem 1.8rem;
  width: min(480px, 100%);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.22);
  animation: dlModalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 92vh;
  overflow-y: auto;
}

@keyframes dlModalIn {
  from { opacity: 0; transform: scale(0.88) translateY(20px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* Close button */
.dl-close {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f9fafb;
  color: #6b7280;
  font-size: 1rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.dl-close:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }

/* Header */
.dl-modal-head { text-align: center; margin-bottom: 1.6rem; }

.dl-icon-wrap {
  width: 4rem;
  height: 4rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #6a0dad, #e91e8c 55%, #f5a623);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: #fff;
  margin: 0 auto 1rem;
  box-shadow: 0 12px 28px rgba(233, 30, 140, 0.3);
}

.dl-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: #9ca3af;
  margin-bottom: 0.3rem;
}

.dl-template-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* Form fields */
.dl-form-shell[hidden] { display: none; }
.dl-form-shell form,
#dlForm { display: grid; gap: 1rem; }
.dl-form-shell .wpcf7 { width: 100%; }
.dl-form-shell .wpcf7-form-control-wrap { display: block; }
.dl-form-shell .wpcf7-spinner {
  display: block;
  margin: 0.6rem auto 0;
}

.dl-field { display: grid; gap: 0.32rem; }

.dl-field label {
  font-size: 0.84rem;
  font-weight: 700;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.dl-field label i { color: #7c3aed; font-size: 0.75rem; }

.dl-field input {
  height: 2.85rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 0 0.9rem;
  font-size: 0.93rem;
  color: #111827;
  background: #f9fafb;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  width: 100%;
}
.dl-field input:focus {
  outline: none;
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
  background: #fff;
}
.dl-field input.is-error {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.12);
}
.dl-field input.wpcf7-not-valid {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.12);
}

.dl-err,
.dl-form-shell .wpcf7-not-valid-tip {
  font-size: 0.78rem;
  color: #ef4444;
  font-weight: 600;
  min-height: 1rem;
  display: block;
  margin-top: 0.28rem;
}
.dl-form-shell .wpcf7-response-output {
  border: 0 !important;
  border-radius: 14px;
  margin: 0.2rem 0 0 !important;
  padding: 0.8rem 0.95rem !important;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.45;
}
.dl-form-shell form.sent .wpcf7-response-output {
  background: #ecfdf5;
  color: #047857;
}

/* Submit button */
.dl-submit {
  width: 100%;
  height: 3.1rem;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, #6a0dad, #e91e8c 55%, #f5a623);
  color: #fff;
  font-size: 0.97rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  box-shadow: 0 14px 32px rgba(233, 30, 140, 0.28);
  transition: filter 0.22s, transform 0.22s, box-shadow 0.22s;
}
.dl-submit:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(233, 30, 140, 0.38);
}
.dl-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}
.dl-form-shell .dl-submit + .wpcf7-spinner {
  justify-self: center;
}
.dl-submit-outline {
  background: transparent;
  border: 2px solid #e5e7eb;
  color: #374151;
  box-shadow: none;
  margin-top: 0.8rem;
}
.dl-submit-outline:hover {
  border-color: #a855f7;
  color: #7c3aed;
  filter: none;
  box-shadow: none;
}

/* Privacy note */
.dl-privacy {
  text-align: center;
  font-size: 0.76rem;
  color: #9ca3af;
  margin-top: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
.dl-privacy i { color: #10b981; font-size: 0.72rem; }

/* Success state */
.dl-success {
  text-align: center;
  padding: 1rem 0 0.5rem;
  animation: dlModalIn 0.3s ease;
}
.dl-success[hidden] { display: none; }

.dl-success-icon {
  font-size: 3.5rem;
  color: #10b981;
  margin-bottom: 0.9rem;
  animation: popIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.dl-success h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 0.5rem;
}
.dl-success p {
  color: #6b7280;
  font-size: 0.95rem;
  line-height: 1.65;
  margin-bottom: 0;
}

/* Mobile */
@media (max-width: 520px) {
  .dl-modal { padding: 1.8rem 1.3rem 1.4rem; border-radius: 20px; }
}
