/* =====================================================================================
   TEMPLATES GALLERY (/templates/)
   Built on styles.css (tokens, sheet, .btn) and legal.css (page shell: header, footer line).
   Editorial header, category filters, and cards with live, scaled-down demo previews.
   ===================================================================================== */
.tg-page { flex: 1; padding-top: clamp(40px, 6vh, 72px); padding-bottom: clamp(56px, 8vh, 96px); }

/* ---------- Header ---------- */
.tg-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px clamp(32px, 5vw, 80px); align-items: end; }
.tg-eyebrow {
  display: inline-flex; align-items: center; gap: 12px;
  font: 500 12.5px var(--font-technical);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--red-bright);
}
.tg-eyebrow::before { content: ""; width: 26px; height: 1px; background: var(--red-bright); }
.tg-title {
  margin-top: 16px;
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  font-size: clamp(52px, 7vw, 112px);
  line-height: .95;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--ink);
}
.tg-title em { display: block; font-style: normal; color: var(--red-bright); }
.tg-lead { max-width: 560px; margin-top: 20px; font: 400 17px/1.65 var(--font-body); color: var(--ink-2); }
/* Collection strip: two figures between hairlines (counted from the data in gallery.js), and the
   way down to the gallery. Quieter than the title: small labels, mid-size figures, no box. */
.tg-stats { min-width: 300px; }
.tg-stats__figs {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}
.tg-stats__figs > div { display: flex; flex-direction: column; justify-content: space-between; padding: 14px 0 12px; }
.tg-stats__figs > div + div { padding-left: 22px; border-left: 1px solid var(--line); }
.tg-stats__figs dt {
  display: flex; align-items: center; gap: 8px;
  font: 500 10px var(--font-technical);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tg-stats__figs dt::before { content: ""; width: 10px; height: 1px; background: var(--red-bright); }
.tg-stats__figs dd {
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  font-size: 44px;
  line-height: 1;
  letter-spacing: .01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tg-stats__link {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 14px;
  font: 500 11px var(--font-technical);
  letter-spacing: .26em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
}
.tg-stats__link span { color: var(--red-bright); transition: transform .25s ease; }
.tg-stats__link:hover span { transform: translateY(3px); }
.tg-stats__link:hover, .tg-stats__link:focus-visible { color: var(--red-bright); }
.tg-stats__link:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 4px; }

/* ---------- Filters ---------- */
.tg-gallery { margin-top: clamp(36px, 6vh, 64px); }
.tg-tools { padding-top: 22px; border-top: 1px solid var(--line-strong); }
/* One row of keys; it scrolls sideways when the keys don't fit. The padding keeps the keys' drop
   shadows inside the scroll area, and the negative margin keeps the row aligned with the page. */
.tg-filters {
  position: relative;
  display: flex; flex-wrap: nowrap; gap: 10px;
  margin: 0 -14px; padding: 14px 14px 20px;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 20, 15, .35) transparent;
}
.tg-filters::-webkit-scrollbar { height: 6px; }
.tg-filters::-webkit-scrollbar-thumb { background: rgba(23, 20, 15, .3); border-radius: 3px; }
.tg-chip.tg-chip { flex: none; white-space: nowrap; }
/* Search */
.tg-search { display: flex; align-items: center; gap: 14px; max-width: 520px; }
.tg-search__label { flex: none; font: 500 11px var(--font-technical); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); }
.tg-search__input {
  flex: 1; min-width: 0;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: rgba(255, 252, 244, .6);
  font: 400 15px var(--font-body);
  color: var(--ink);
}
.tg-search__input::placeholder { color: var(--ink-3); }
.tg-search__input:focus { outline: none; border-color: var(--ink); }
.tg-search__input:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 3px; }
.tg-chip {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 0;
  background: rgba(255, 252, 244, .45);
  font: 500 12px var(--font-body);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.tg-chip:hover { color: var(--ink); border-color: var(--ink); }
.tg-chip[aria-pressed="true"] { color: #fff; background: var(--ink); border-color: var(--ink); }
.tg-chip__n { font-size: 10.5px; letter-spacing: .06em; color: var(--red-bright); }
.tg-chip[aria-pressed="true"] .tg-chip__n { color: #ff8b8b; }
.tg-status { margin: 4px 0 22px; font: 500 12px var(--font-technical); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- Category groups ---------- */
.tg-group + .tg-group { margin-top: clamp(40px, 6vh, 64px); }
.tg-group__title {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 18px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.05;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink);
}
.tg-group__n { font: 500 12px var(--font-technical); letter-spacing: .16em; color: var(--red-bright); }

/* ---------- Cards ---------- */
.tg-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: clamp(22px, 2.6vw, 36px); }
.tg-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); background: rgba(255, 252, 244, .5); }
/* Filtering hides cards with the hidden attribute: it must win over the display rules above. */
.tg-grid[hidden], .tg-groups[hidden], .tg-group[hidden], .tg-card[hidden], .tg-empty[hidden] { display: none; }
.tg-card__preview { display: block; padding: 12px 12px 0; }
/* The preview: a real demo page at 1440px wide, scaled by --s (set by gallery.js). */
.tg-frame {
  --s: .3;
  position: relative; display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid rgba(23, 20, 15, .3);
  background:
    repeating-linear-gradient(-45deg, rgba(23, 20, 15, .04) 0 8px, rgba(23, 20, 15, 0) 8px 16px),
    #f7f2e8;
  transition: box-shadow .35s ease, transform .35s cubic-bezier(.2, .7, .2, 1);
}
.tg-frame iframe {
  position: absolute; top: 0; left: 0;
  width: 1440px; height: 900px;
  border: 0;
  transform: scale(var(--s));
  transform-origin: 0 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
.tg-frame.is-loaded iframe { opacity: 1; }
/* Template websites: a screenshot captured from the finished site. */
.tg-frame--shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; opacity: 0; transition: opacity .4s ease; }
.tg-frame--shot.is-loaded img { opacity: 1; }
.tg-frame__wait {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 500 10.5px var(--font-technical); letter-spacing: .24em; text-transform: uppercase; color: var(--ink-3);
}
.tg-frame.is-loaded .tg-frame__wait { visibility: hidden; }
/* No live demo yet: a drawing-sheet placeholder instead of a preview. */
.tg-soon {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 16px; text-align: center;
}
.tg-soon__num { font: 500 11px var(--font-technical); letter-spacing: .28em; color: var(--red-bright); }
.tg-soon__name {
  font-family: var(--font-display); font-weight: var(--fw-display);
  font-size: clamp(26px, 3vw, 40px); line-height: 1; letter-spacing: .02em; text-transform: uppercase;
  color: rgba(23, 20, 15, .55);
  overflow-wrap: anywhere;
}
.tg-soon__label {
  margin-top: 4px; padding: 6px 10px;
  border: 1px dashed rgba(23, 20, 15, .45);
  font: 500 10.5px var(--font-technical); letter-spacing: .24em; text-transform: uppercase;
  color: var(--ink-2);
}
.tg-card:hover .tg-frame { box-shadow: 0 16px 36px rgba(23, 20, 15, .16); transform: translateY(-3px); }
.tg-card__body { display: flex; flex-direction: column; flex: 1; padding: 18px 20px 22px; }
.tg-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font: 500 11px var(--font-technical); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }
.tg-card__num { color: var(--red-bright); }
.tg-card__title {
  margin: 8px 0 8px;
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  font-size: clamp(28px, 2.4vw, 34px);
  line-height: 1.02;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink);
}
.tg-card__type { margin: -2px 0 10px; font: 600 12px var(--font-technical); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.tg-card__text { font: 400 15px/1.6 var(--font-body); color: var(--ink-2); }
.tg-badge { padding: 3px 7px; border: 1px dashed rgba(23, 20, 15, .45); font-size: 9.5px; letter-spacing: .2em; color: var(--ink-2); }
.tg-badge--live { border: 1px solid var(--red-bright); color: var(--red-bright); }
.tg-tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tg-tags li { padding: 4px 8px; border: 1px solid var(--line); background: rgba(255, 252, 244, .6); font: 500 10.5px var(--font-technical); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.tg-card__actions { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-top: auto; padding-top: 20px; }
.tg .tg-btn { padding: 13px 22px; font-size: 12px; text-transform: uppercase; text-align: center; }
.tg .tg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.tg-btn__icon { width: 15px; height: 15px; flex: none; }
.tg .btn:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 6px; }
.tg-chip:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 3px; }

/* ---------- Empty state, notes ---------- */
.tg-empty { padding: 40px 24px; text-align: center; border: 1px dashed var(--line-strong); }
.tg-empty__title { font: var(--fw-display) 28px/1.1 var(--font-display); text-transform: uppercase; color: var(--ink); }
.tg-empty p:not(.tg-empty__title) { max-width: 460px; margin: 10px auto 20px; font: 400 15px/1.6 var(--font-body); color: var(--ink-2); }
.tg-note { margin-top: 28px; max-width: 720px; font: 400 13.5px/1.6 var(--font-body); color: var(--ink-3); }
.tg-noscript { display: grid; gap: 8px; font: 400 16px var(--font-body); }

@media (max-width: 900px) {
  .tg-hero { grid-template-columns: minmax(0, 1fr); }
  .tg-stats { min-width: 0; max-width: 420px; }
}
@media (max-width: 600px) {
  .tg-title { font-size: min(56px, 14vw); }
  .tg-stats__figs dt { gap: 6px; font-size: 9.5px; letter-spacing: .16em; }
  .tg-stats__figs dd { font-size: 36px; }
  .tg-stats__figs > div + div { padding-left: 16px; }
  .tg-search { flex-direction: column; align-items: stretch; gap: 8px; max-width: none; }
  .tg-filters { gap: 8px; }
  .tg-lead { font-size: 15.5px; }
  .tg-chip { padding: 0 12px; letter-spacing: .1em; }
  .tg-card__actions { flex-direction: column; align-items: stretch; gap: 12px; }
  .tg .tg-btn { padding: 13px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .tg-frame, .tg-frame iframe, .tg-frame img, .tg-chip { transition: none; }
  .tg-card:hover .tg-frame { transform: none; }
}
