/*
 * template-gallery.css — the /template gallery and /template/<category> pages
 * (approved Main design). Loads after assets/template-pages.css and reuses its
 * tokens (.tp-page) and pieces (.tp-hero, .tp-btn, .tp-faq, .tp-cta, .tp-types,
 * .tp-teams, .tp-search …). Markup: scripts/build-template-gallery.js and
 * scripts/generate-category-pages.js. Behaviour: assets/js/template-gallery.js.
 * Top-level blocks under <main> are divs (ai-agents.css zooms direct <section>s).
 */

/* the hidden attribute always wins over a display rule */
.tp-page [hidden] { display: none !important; }

/* ---------- hero ---------- */
.tp-hero__in--gal { padding-bottom: 72px; }
.tp-hero__in--gal .tp-gal-hero { padding-bottom: 0; }
.tp-hero__in--cat { padding-bottom: 64px; }
.tp-gal-eyebrow { margin: 0; font-size: 12px; letter-spacing: .18em; color: var(--tp-lav-2); }
.tp-search__box svg { flex: none; }
.tp-search__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tp-search__btn svg { flex: none; }
@media (max-width: 480px) {
  .tp-search__box { padding-left: 12px; gap: 8px; }
  .tp-search__btn { padding: 12px; }
  .tp-search__btn-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.tp-popular li { list-style: none; }
.tp-popular { margin: 0; padding: 0; }
/* category pages: subcategory chips under the lead, left-aligned like the hero copy */
.tp-popular--start { justify-content: flex-start; margin-top: 4px; }
.tp-page .tp-chip-link { display: inline-flex; align-items: center; }
.tp-cat-ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.tp-cat-ctas .tp-btn { font-size: 15px; }
@media (max-width: 640px) {
  .tp-hero__in--gal { padding-bottom: 56px; }
  .tp-gal-hero { padding-top: 24px; padding-bottom: 0; gap: 18px; }
  .tp-cat-ctas, .tp-cat-ctas .tp-btn { width: 100%; }
}

/* ---------- sections ---------- */
.tp-gsec { padding: 72px var(--tp-gut); }
.tp-gsec--tight { padding-top: 56px; }
.tp-gsec--flush { padding-top: 0; }
.tp-gsec .tp-wrap { display: flex; flex-direction: column; gap: 28px; }
.tp-ghead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; }
.tp-ghead > div { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 720px; }
.tp-gsub { margin: 0; color: var(--tp-ink-2); font-size: 15px; line-height: 1.55; max-width: 620px; }
.tp-ghead__aside { margin: 0; max-width: 380px; color: var(--tp-ink-2); font-size: 15px; line-height: 1.55; }
.tp-page .tp-gh2 { margin: 0; font-size: clamp(28px, 3.4vw, 40px); letter-spacing: -0.025em; line-height: 1.1; font-weight: 700; color: var(--tp-ink); }
.tp-tint .tp-wrap { display: flex; flex-direction: column; gap: 28px; }
@media (max-width: 640px) { .tp-gsec { padding-top: 48px; padding-bottom: 48px; } .tp-tint { padding-top: 48px; padding-bottom: 48px; } }

/* type tiles (buttons) */
.tp-types li { min-width: 0; }
.tp-type__icon { display: flex; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: 10px; margin-bottom: 2px; }

/* ---------- template cards (Main design) ---------- */
.tp-ggrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 24px; }
.tp-ggrid > li { min-width: 0; }
.tp-ggrid > li.tp-gl-rest { display: none; }
.tp-ggrid[aria-busy="true"] { min-height: 320px; }
.tp-gcard { height: 100%; background: #fff; border: 1px solid var(--tp-line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; box-sizing: border-box; }
.tp-gcard:hover { border-color: #C7C9D1; }
.tp-gcard__img { position: relative; background: var(--tp-frame); padding: 12px 12px 0; }
.tp-gcard__img img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; border-radius: 10px 10px 0 0; border: 1px solid var(--tp-line); border-bottom: 0; background: #fff; box-sizing: border-box; }
/* forms, email: the thumbnail carries its own grey margin + white page; no second frame */
.tp-gcard--flush .tp-gcard__img { padding: 0; overflow: hidden; }
.tp-gcard--flush .tp-gcard__img img { border: 0; border-radius: 0; }
/* form captures have a 2% white strip + hairline along the top: scale from the bottom to crop it */
.tp-gcard--croptop .tp-gcard__img img { transform: scale(1.045); transform-origin: 50% 100%; }
.tp-gcard__actions { position: absolute; inset: 12px 12px 0; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 8px; background: rgba(13,11,30,.55); border-radius: 10px 10px 0 0; opacity: 0; transition: opacity .15s; }
.tp-gcard--flush .tp-gcard__actions { inset: 0; border-radius: 0; }
.tp-gcard:hover .tp-gcard__actions, .tp-gcard:focus-within .tp-gcard__actions { opacity: 1; }
.tp-page .tp-gcard__btn { background: #fff; color: var(--tp-ink); font-size: 14px; font-weight: 600; padding: 11px 16px; border-radius: 10px; min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center; }
.tp-page .tp-gcard__btn:hover { color: var(--tp-ink); background: #ECEAFF; }
.tp-page .tp-gcard__btn--brand { background: var(--tp-brand); color: #fff; }
.tp-page .tp-gcard__btn--brand:hover { background: var(--tp-brand-dk); color: #fff; }
@media (hover: none) { .tp-gcard__actions { display: none; } }
@media (prefers-reduced-motion: reduce) { .tp-gcard__actions { transition: none; } }
.tp-gcard__body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tp-gcard__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tp-gcard__new { font-size: 12px; font-weight: 600; color: #3F7D20; }
.tp-page .tp-gcard__title { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.tp-page .tp-gcard__title a { color: var(--tp-ink); }
.tp-page .tp-gcard__title a:hover { color: var(--tp-brand); }
.tp-gcard__title a::after { content: ""; position: absolute; inset: 0; }
.tp-gcard { position: relative; }
.tp-gcard__actions { z-index: 2; }
.tp-gcard__desc { margin: 0; font-size: 14px; line-height: 1.5; color: var(--tp-ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tp-gmore { align-self: center; }
.tp-page .tp-btn--outline { background: #fff; color: var(--tp-ink); border: 1px solid var(--tp-line-2); font-size: 15px; }
.tp-page .tp-btn--outline:hover { border-color: #9C95F5; color: var(--tp-ink); }
.tp-gempty { margin: 0; padding: 32px; text-align: center; color: var(--tp-ink-2); background: var(--tp-soft); border: 1px dashed var(--tp-line-2); border-radius: 16px; }

/* teams list */
.tp-teams li { min-width: 0; }
.tp-page .tp-team { min-height: 24px; }
.tp-page .tp-team:hover { color: var(--tp-brand); }

/* uses (check list) reuse .tp-inside; category body copy */
.tp-prose { max-width: 820px; font-size: 16px; line-height: 1.7; color: var(--tp-ink-2); overflow-wrap: break-word; }
.tp-prose > :first-child { margin-top: 0; }
.tp-page .tp-prose h2 { margin: 36px 0 12px; font-size: clamp(22px, 2.4vw, 28px); letter-spacing: -0.02em; line-height: 1.2; font-weight: 700; color: var(--tp-ink); }
.tp-page .tp-prose h3 { margin: 24px 0 8px; font-size: 18px; font-weight: 600; color: var(--tp-ink); }
.tp-prose p { margin: 0 0 14px; }
.tp-prose ul, .tp-prose ol { margin: 0 0 16px; padding-left: 22px; }
.tp-prose li { margin: 0 0 8px; }
.tp-prose strong { color: var(--tp-ink); }
.tp-prose img { max-width: 100%; height: auto; }
.tp-prose table { display: block; max-width: 100%; }
.tp-faq summary h3 { display: inline; margin: 0; font: inherit; color: inherit; }

/* A–Z index of every template page (internal links) */
.tp-az { list-style: none; margin: 0; padding: 0; columns: 4 220px; column-gap: 32px; }
.tp-az li { break-inside: avoid; }
.tp-page .tp-az a { display: inline-block; padding: 3px 0; font-size: 14px; line-height: 1.5; color: var(--tp-ink-2); }
.tp-page .tp-az a:hover { color: var(--tp-brand); }
@media (max-width: 640px) { .tp-az { columns: 2 140px; column-gap: 16px; } .tp-page .tp-az a { font-size: 13px; } }

/* tap targets: at least 24px tall (playbook) */
.tp-page .tp-gcard__title a, .tp-page .tp-az a { display: inline-flex; align-items: center; min-height: 24px; }
.tp-hero__in--cat .tp-crumbs a { display: inline-flex; align-items: center; min-height: 24px; }
