:root {
  --loma-template-radius: 28px;
  --loma-template-shadow: 0 24px 70px rgba(32, 10, 17, 0.18);
}

.template-section {
  --template-section-bg: rgba(255, 255, 255, 0.1);
  --template-section-border: rgba(255, 255, 255, 0.18);
  --template-card-bg: rgba(255, 255, 255, 0.1);
  --template-card-border: rgba(255, 255, 255, 0.16);
  --template-title: #ffffff;
  --template-copy: rgba(255, 255, 255, 0.82);
  --template-muted: rgba(255, 255, 255, 0.68);
  --template-pill-bg: rgba(255, 255, 255, 0.14);
  --template-pill-border: rgba(255, 255, 255, 0.18);
  --template-pill-text: #ffffff;
  --template-primary-bg: #ffffff;
  --template-primary-text: #c2304c;
  --template-secondary-bg: rgba(255, 255, 255, 0.06);
  --template-secondary-border: rgba(255, 255, 255, 0.24);
  --template-secondary-text: #ffffff;
  position: relative;
  margin: 2rem 0;
  padding: clamp(1.2rem, 2vw, 2rem);
  border-radius: var(--loma-template-radius);
  border: 1px solid var(--template-section-border);
  background: var(--template-section-bg);
  box-shadow: var(--loma-template-shadow);
  color: var(--template-title);
}

.template-section--light {
  --template-section-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 247, 249, 0.98) 100%);
  --template-section-border: rgba(194, 48, 76, 0.12);
  --template-card-bg: rgba(194, 48, 76, 0.04);
  --template-card-border: rgba(194, 48, 76, 0.1);
  --template-title: #221419;
  --template-copy: rgba(34, 20, 25, 0.74);
  --template-muted: rgba(34, 20, 25, 0.58);
  --template-pill-bg: rgba(194, 48, 76, 0.08);
  --template-pill-border: rgba(194, 48, 76, 0.12);
  --template-pill-text: #7f2237;
  --template-primary-bg: #c2304c;
  --template-primary-text: #ffffff;
  --template-secondary-bg: rgba(194, 48, 76, 0.04);
  --template-secondary-border: rgba(194, 48, 76, 0.14);
  --template-secondary-text: #7f2237;
  box-shadow: 0 18px 52px rgba(40, 10, 19, 0.08);
}

.template-section--plain {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.template-section__header {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.template-section__eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.4rem 0.72rem;
  border-radius: 999px;
  background: var(--template-pill-bg);
  border: 1px solid var(--template-pill-border);
  color: var(--template-pill-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.template-section__title {
  margin: 0;
  color: var(--template-title);
  font-size: clamp(1.5rem, 2.5vw, 2.3rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.template-section__copy {
  margin: 0;
  max-width: 62ch;
  color: var(--template-copy);
  font-size: 0.98rem;
  line-height: 1.58;
}

.template-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.template-grid--compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.template-card {
  display: grid;
  gap: 0.9rem;
  min-height: 100%;
  padding: 1.1rem;
  border-radius: 22px;
  border: 1px solid var(--template-card-border);
  background: var(--template-card-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.template-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--template-card-border);
}

.template-card__media-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.template-card__media--placeholder {
  background: linear-gradient(135deg, rgba(194, 48, 76, 0.22), rgba(255, 255, 255, 0.06));
}

.template-card__media-tag {
  position: absolute;
  left: 0.7rem;
  top: 0.7rem;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  background: rgba(20, 8, 12, 0.6);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.template-card__eyebrow {
  color: var(--template-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.template-card__title {
  margin: 0;
  color: var(--template-title);
  font-size: 1.18rem;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.template-card__copy {
  margin: 0;
  color: var(--template-copy);
  font-size: 0.94rem;
  line-height: 1.55;
}

.template-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.template-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.66rem;
  border-radius: 999px;
  border: 1px solid var(--template-pill-border);
  background: var(--template-pill-bg);
  color: var(--template-pill-text);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
}

.template-card__list {
  display: grid;
  gap: 0.55rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.template-card__list li {
  position: relative;
  padding-left: 1rem;
  color: var(--template-copy);
  font-size: 0.88rem;
  line-height: 1.45;
}

.template-card__list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.48rem;
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.8;
}

.template-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: auto;
}

.template-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.78rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--template-primary-bg);
  color: var(--template-primary-text);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 10px 28px rgba(20, 8, 12, 0.18);
}

.template-btn:hover {
  /* Avoid `filter` here — it creates a new stacking context that, when
     nested inside `.template-card`'s backdrop-filter, can make Safari
     reflow the page on hover. Use background/opacity instead. */
  opacity: 0.94;
  box-shadow: 0 12px 30px rgba(20, 8, 12, 0.22);
}

.template-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.template-btn--secondary,
.template-btn--ghost {
  background: var(--template-secondary-bg);
  border-color: var(--template-secondary-border);
  color: var(--template-secondary-text);
  box-shadow: none;
}

.template-btn--ghost {
  background: transparent;
}

.template-microcopy {
  margin-top: 0.9rem;
  color: var(--template-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.template-kpis {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 1rem;
}

.template-kpi {
  padding: 0.95rem;
  border-radius: 20px;
  border: 1px solid var(--template-card-border);
  background: var(--template-card-bg);
}

.template-kpi strong {
  display: block;
  color: var(--template-title);
  font-size: 1.15rem;
  line-height: 1.05;
}

.template-kpi span {
  display: block;
  margin-top: 0.3rem;
  color: var(--template-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.inline-interest-card {
  margin-top: 1.4rem;
  padding: 1.2rem;
  border-radius: 24px;
  border: 1px solid var(--template-card-border);
  background: var(--template-card-bg);
}

.inline-interest-card h3 {
  margin: 0 0 0.45rem;
  color: var(--template-title);
  font-size: 1.15rem;
  line-height: 1.15;
}

.inline-interest-card p {
  margin: 0;
  color: var(--template-copy);
  font-size: 0.92rem;
  line-height: 1.55;
}

.inline-interest-form {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.inline-interest-form input,
.inline-interest-form textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--template-card-border);
  background: rgba(255, 255, 255, 0.92);
  color: #221419;
  font: inherit;
}

.inline-interest-form textarea {
  min-height: 120px;
  resize: vertical;
}

.inline-interest-form button {
  width: fit-content;
}

.inline-interest-note,
.inline-interest-status {
  margin-top: 0.75rem;
  color: var(--template-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.inline-interest-status {
  min-height: 1.2em;
}

.inline-interest-status.is-success {
  color: #1f8b58;
}

.inline-interest-status.is-error {
  color: #b3304b;
}

.template-empty {
  color: var(--template-muted);
  font-size: 0.92rem;
}

.templates-page-section {
  margin: 0 0 2.75rem;
}

.templates-page-section .template-section__header {
  margin-bottom: 1.35rem;
}

.templates-page-section .template-section__title {
  max-width: 18ch;
}

.templates-page-section .template-section__copy {
  max-width: 58ch;
}

.templates-page-section .template-grid {
  /* Row gap is intentionally larger than column gap: the cards share the
     solid pink page background with no outer borders, so a tight
     `gap: 1.2rem` made adjacent rows read as a single squished block
     (the row 1 "Read the guide" link sat right under the row 2 media).
     Explicit row/column gaps keep the columns aligned while giving rows
     real breathing room. */
  row-gap: 2.5rem;
  column-gap: 1.2rem;
  align-items: start;
}

.templates-page-section--featured .template-grid,
.templates-page-section--extended .template-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.templates-page-section .template-card {
  min-width: 0;
  gap: 0.8rem;
  padding: 1rem;
  border-radius: 24px;
}

.templates-page-section .template-card__eyebrow {
  display: none;
}

.templates-page-section .template-card__title {
  font-size: 1.1rem;
}

.templates-page-section .template-card__copy {
  font-size: 0.92rem;
}

.templates-page-section .template-card__list {
  gap: 0.45rem;
}

.templates-page-section .template-card__list li {
  font-size: 0.84rem;
  line-height: 1.38;
}

.templates-page-section .template-card__list li:nth-child(n + 3) {
  display: none;
}

.templates-page-section .template-card__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.55rem;
}

.templates-page-section .template-card__actions .template-btn {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  line-height: 1.15;
  box-shadow: none;
}

.templates-page-section .template-card__actions .template-btn:hover {
  opacity: 1;
  box-shadow: none;
}

.templates-page-section .template-card__actions .template-btn:not(.template-btn--secondary) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 243, 245, 0.96));
}

.templates-page-section .template-card__actions .template-btn:not(.template-btn--secondary):hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 235, 240, 0.92));
}

.templates-page-section .template-card__actions .template-btn--secondary {
  min-height: 0;
  justify-content: flex-start;
  padding: 0.15rem 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.86rem;
  font-weight: 600;
}

.templates-page-section .template-card__actions .template-btn--secondary::after {
  content: '\2192';
  margin-left: 0.45rem;
}

.templates-page-section .template-card__actions .template-btn--secondary:hover {
  background: transparent;
  color: #ffffff;
}

@media (max-width: 1100px) {
  .templates-page-section--featured .template-grid,
  .templates-page-section--extended .template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .template-section {
    border-radius: 24px;
  }

  .template-card {
    border-radius: 20px;
  }

  .template-card__actions {
    flex-direction: column;
  }

  .template-btn,
  .inline-interest-form button {
    width: 100%;
  }

  .templates-page-section--featured .template-grid,
  .templates-page-section--extended .template-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .templates-page-section .template-section__title {
    max-width: none;
  }

  .templates-page-section .template-card__actions .template-btn--secondary {
    padding: 0.2rem 0;
  }
}
