/* ==========================================================================
   templates.html: Pinterest-style masonry library.
   ========================================================================== */

.page-templates {
  background: var(--paper-2);
}

/* --- header -------------------------------------------------------------- */

.tpl-head {
  padding-top: 40px;
  padding-bottom: 72px;
}

.tpl-head__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tpl-head__back {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  transition:
    color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.tpl-head__back::before {
  content: "←";
  margin-right: 8px;
  color: var(--mint);
}

.tpl-head__back:hover {
  color: var(--ink);
  transform: translateX(-3px);
}

.tpl-head__title {
  margin-top: 88px;
  max-width: 640px;
}

.tpl-head__title .lead {
  margin-top: 18px;
}

/* --- filter chips --------------------------------------------------------- */

.tpl-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 48px;
}

.tpl-filter {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background-color 0.2s var(--ease),
    border-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

.tpl-filter:hover {
  border-color: var(--ink);
}

.tpl-filter.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* --- masonry -------------------------------------------------------------- */

.masonry {
  column-count: 4;
  column-gap: 16px;
}

.tcard {
  position: relative;
  display: block;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: var(--radius-2xl);
  background: var(--paper-4);
  break-inside: avoid;
  cursor: pointer;
}

.tcard img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s var(--ease);
}

.tcard:hover img {
  transform: scale(1.03);
}

/* Pinterest-ish hover: title rises in, arrow appears. */
.tcard__overlay {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 44px 14px 14px;
  background: linear-gradient(
    to top,
    rgba(20, 20, 20, 0.82) 8%,
    rgba(20, 20, 20, 0.35) 55%,
    transparent
  );
  color: var(--paper);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.tcard:hover .tcard__overlay,
.tcard:focus-within .tcard__overlay {
  opacity: 1;
  transform: translateY(0);
}

.tcard__name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.tcard__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--mint);
  transform: translateX(-4px);
  transition: transform 0.2s var(--ease);
}

.tcard:hover .tcard__arrow {
  transform: translateX(0);
}

@media (hover: none) {
  .tcard__overlay {
    opacity: 1;
    transform: none;
  }
}

.masonry__empty {
  margin-top: 60px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}

/* --- footer --------------------------------------------------------------- */

/* The templates page has no dark outro above it, so its footer stays light
   instead of inheriting the homepage's black band. */
.page-templates .footer {
  margin-top: 72px;
  border-top-color: var(--line);
  background: transparent;
}

.page-templates .footer__row,
.page-templates .footer__links a {
  color: var(--text-faint);
}

.page-templates .footer__links a:hover {
  color: var(--ink);
}

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 1000px) {
  .masonry {
    column-count: 3;
  }
}

@media (max-width: 720px) {
  .tpl-head {
    padding-top: 28px;
    padding-bottom: 48px;
  }

  .tpl-head__title {
    margin-top: 56px;
  }

  .masonry {
    column-count: 2;
    column-gap: 10px;
  }

  .tcard {
    margin-bottom: 10px;
    border-radius: var(--radius-xl);
  }

  .page-templates .footer {
    margin-top: 48px;
  }
}
