/* ============================================================
   templates.php — Template Gallery Page
   Mobile-first: base rules target phones, min-width queries add
   breathing room for tablet/desktop. Uses the same CSS variables
   already established site-wide (--primary, --primary-dk, --accent,
   --accent-lt, --bg-white, --border, --radius, --shadow-sm, --text,
   --muted) so it matches contact.php and the rest of the site
   without introducing a new palette.
   ============================================================ */

/* ── Hero (same pattern as ct-hero) ── */
.tpl-hero{
  background: var(--primary-dk);
  padding: 110px 0 64px;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.tpl-hero::before{
  content: '';
  position: absolute; inset: 0;
  background: url('https://images.unsplash.com/photo-1519741497674-611481863552?w=1400&h=400&fit=crop') center/cover;
  opacity: 0.18;
}
.tpl-hero-inner{ position: relative; z-index: 1; padding: 0 16px; }
.tpl-hero h1{
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem,4vw,2.8rem);
  color: #fff;
  font-weight: 700;
}
.tpl-hero h1 em{ color: var(--accent); font-style: italic; }
.tpl-hero p{
  color: rgba(255,255,255,0.65);
  font-size: .95rem;
  max-width: 500px;
  margin: 10px auto 0;
}

/* ── Filter tabs ── */
.tpl-filterbar{
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px 0;
}
.tpl-tabs{
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px;
}
.tpl-tabs::-webkit-scrollbar{ display: none; }
.tpl-tab{
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tpl-tab-count{
  font-size: 0.68rem;
  background: rgba(0,0,0,0.06);
  padding: 1px 7px;
  border-radius: 20px;
}
.tpl-tab.active{
  background: var(--primary-dk);
  border-color: var(--primary-dk);
  color: #fff;
}
.tpl-tab.active .tpl-tab-count{ background: rgba(255,255,255,0.2); color: #fff; }

/* ── Section wrapper ── */
.tpl-section{ padding: 36px 0 8px; }
.tpl-empty{ text-align: center; padding: 60px 20px; color: var(--muted); }

/* ── Grid: 1 column on phones ── */
.tpl-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ── Card ── */
.tpl-card{
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius, 14px);
  overflow: hidden;
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(0,0,0,0.04));
  transition: transform .2s ease, box-shadow .2s ease;
}
.tpl-card:hover{
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(0,0,0,0.1);
}
.tpl-card-thumb{
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--tpl-s, #eee);
  overflow: hidden;
}
.tpl-card-thumb img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl-card-thumb-fallback{
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--tpl-p, #500707), var(--tpl-s, #C9A84C));
}
.tpl-badge{
  position: absolute; top: 10px; right: 10px;
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 10px; border-radius: 12px;
  background: #fff;
}
.tpl-badge-basic{ color: #B8860B; }
.tpl-badge-premium{ color: var(--primary-dk); }

/* Preview overlay — hidden by default on touch devices (tap-friendly),
   revealed on hover for devices that support it */
.tpl-card-preview-overlay{
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.85rem; font-weight: 600;
  text-decoration: none;
  opacity: 0;
  transition: opacity .2s ease;
}
@media (hover: hover){
  .tpl-card-thumb:hover .tpl-card-preview-overlay{ opacity: 1; }
}
@media (hover: none){
  /* On touch devices, show a small persistent preview chip instead of relying on hover */
  .tpl-card-preview-overlay{
    opacity: 1;
    inset: auto 8px 8px auto;
    top: auto; left: auto;
    background: rgba(0,0,0,0.55);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.7rem;
  }
}

.tpl-card-body{ padding: 16px; }
.tpl-card-name{
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  color: var(--primary-dk);
  margin-bottom: 4px;
}
.tpl-card-desc{
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
  display: -webkit-box;
  /* -webkit-line-clamp: 2; */
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tpl-card-footer{
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tpl-card-price{ font-weight: 700; color: var(--primary-dk); font-size: 1rem; }
.tpl-card-btn{
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--primary-dk);
  text-decoration: none;
  padding: 7px 14px;
  border: 1px solid var(--primary-dk);
  border-radius: 30px;
  transition: background .15s ease, color .15s ease;
}
.tpl-card-btn:hover{ background: var(--primary-dk); color: #fff; }

/* ── Bottom CTA ── */
.tpl-cta{
  background: var(--bg, #FBF6EC);
  padding: 48px 20px;
  margin-top: 40px;
}
.tpl-cta h2{
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.3rem, 5vw, 2rem);
  color: var(--primary-dk);
}
.tpl-cta h2 em{ color: var(--accent); font-style: italic; }
.tpl-cta p{
  color: var(--muted);
  max-width: 420px;
  margin: 10px auto 22px;
  font-size: 0.85rem;
}


/* ══════════════════════════════════════════════
   Small tablets and up (≥576px) — 2 columns
   ══════════════════════════════════════════════ */
@media (min-width: 576px){
  .tpl-grid{ grid-template-columns: repeat(2, 1fr); gap: 22px; }
}

/* ══════════════════════════════════════════════
   Tablets (≥768px) — 3 columns, roomier tabs
   ══════════════════════════════════════════════ */
@media (min-width: 768px){
  .tpl-grid{ grid-template-columns: repeat(3, 1fr); }
  .tpl-tabs{ justify-content: center; overflow: visible; }
  .tpl-tab{ padding: 9px 22px; font-size: 0.85rem; }
  .tpl-section{ padding: 48px 0 16px; }
  .tpl-card-body{ padding: 20px; }
  .tpl-cta{ padding: 64px 20px; }
}

/* ══════════════════════════════════════════════
   Desktop (≥1200px) — 4 columns, max width
   ══════════════════════════════════════════════ */
@media (min-width: 1200px){
  .tpl-grid{ grid-template-columns: repeat(4, 1fr); gap: 26px; }
}