/* /templates — the public template gallery. Builds on seo-page.css (same tokens, nav, footer, .cta);
   the cards follow the dashboard's template manager (.tpl-card in main.css): 16:9 preview on top,
   name, pill badges, description, actions pinned to the bottom. */

.tg-page { max-width: 1200px; margin: 0 auto; padding: 120px 24px 40px; }
/* seo-page.css fixes every <nav> to the top; the breadcrumb is one, and outside .article here. */
.tg-page .breadcrumb { position: static; background: none; backdrop-filter: none; border: 0; z-index: auto; }
.tg-hero { max-width: 820px; margin-bottom: 28px; }
.tg-hero h1 { font-size: 40px; line-height: 1.15; margin-bottom: 16px; }
.tg-hero .lead { font-size: 19px; color: var(--muted); margin-bottom: 12px; }
.tg-sub { font-size: 14px; color: var(--dim); }

.tg-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.tg-filter { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 7px 16px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.tg-filter:hover { color: var(--text); border-color: var(--muted); }
.tg-filter.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.tg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-bottom: 56px; }
.tg-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: border-color 0.2s, transform 0.2s; }
.tg-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tg-card[hidden] { display: none; }
.tg-thumb { aspect-ratio: 16 / 9; background: #0b1220; display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.tg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tg-thumb-empty { color: var(--dim); font-weight: 600; padding: 16px; text-align: center; }
.tg-body { flex: 1; padding: 16px 18px 8px; }
.tg-body h3 { font-size: 17px; margin: 0 0 8px; }
.tg-body p { font-size: 14px; color: var(--muted); line-height: 1.55; margin: 10px 0 8px; }
.tg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tg-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.tg-chip-slide { color: var(--accent); border-color: #1e40af; }
.tg-chip-code { color: #c084fc; border-color: #7e22ce; }
.tg-chip-data { color: #22c55e; border-color: #166534; }
.tg-cats { font-size: 12px; color: var(--dim); }
.tg-actions { padding: 8px 18px 18px; }
.tg-actions .btn { width: 100%; justify-content: center; }
.tg-fallback { grid-column: 1 / -1; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 28px; color: var(--muted); }
.tg-empty { grid-column: 1 / -1; color: var(--muted); }

.tg-how { padding-top: 0; }

/* Preview modal: the template is rendered at a real screen size and scaled to fit. */
.tg-modal { position: fixed; inset: 0; z-index: 200; background: rgba(2, 6, 23, 0.85); display: flex; align-items: center; justify-content: center; padding: 24px; }
.tg-modal[hidden] { display: none; }
.tg-modal-box { width: min(1200px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tg-modal-head { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tg-modal-head h2 { font-size: 17px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-shapes { display: flex; gap: 6px; }
.tg-shape { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.tg-shape.is-active { color: #fff; background: var(--accent); border-color: var(--accent); }
.tg-close { background: transparent; border: none; color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }
.tg-close:hover { color: var(--text); }
.tg-stage { position: relative; flex: 1 1 auto; min-height: 240px; height: 70vh; background: #020617; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tg-screen { position: absolute; left: 50%; top: 50%; transform-origin: 0 0; box-shadow: 0 0 0 1px var(--border); background: #000; }
.tg-screen iframe { width: 100%; height: 100%; border: 0; display: block; }
.tg-modal-note { font-size: 12px; color: var(--dim); padding: 10px 16px; margin: 0; }

@media (max-width: 768px) {
  .tg-hero h1 { font-size: 30px; }
  .tg-grid { grid-template-columns: 1fr; }
  .tg-modal { padding: 0; }
  .tg-modal-box { height: 100%; border-radius: 0; }
  .tg-modal-head { flex-wrap: wrap; }
  .tg-stage { height: auto; }
  .nav-links a:not(.btn) { display: none; }
}
