/* ============================================================
   POSTIQUE — Templates Page Styles
   ============================================================ */

/* ── Page Hero ─────────────────────────────────────────────── */
.page-hero {
  padding-top: calc(var(--nav-h) + var(--space-4xl));
  padding-bottom: var(--space-2xl);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.page-hero::before {
  content: '';
  position: absolute;
  top: -200px; right: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(29,185,84,0.07) 0%, transparent 70%);
  pointer-events: none;
}
.page-hero .eyebrow { margin-bottom: var(--space-md); }
.page-hero h1 { margin-bottom: var(--space-lg); }
.page-hero p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 560px;
  line-height: 1.75;
}

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
  background: rgba(10,12,15,0.94);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding-block: var(--space-md);
  z-index: 80;
}
.sticky-bar {
  position: sticky;
  top: var(--nav-h);
}
.filter-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
}
.filter-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.filter-tab {
  padding: 0.4rem 1rem;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--t-fast);
  cursor: pointer;
}
.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active {
  background: var(--green-pale);
  color: var(--green);
  border-color: rgba(29,185,84,0.25);
}
.filter-price-group {
  display: flex;
  gap: 4px;
}
.filter-price {
  padding: 0.4rem 0.85rem;
  border-radius: var(--r-full);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--t-fast);
}
.filter-price:hover { color: var(--text-primary); border-color: var(--border-light); }
.filter-price.active {
  background: var(--ink-soft);
  color: var(--text-primary);
  border-color: var(--border-light);
}

/* ── Templates Section ─────────────────────────────────────── */
.templates-section { padding-top: var(--space-2xl); }
.templates-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}
.templates-meta span {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}
.sort-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.sort-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.sort-group select {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  outline: none;
  cursor: pointer;
}

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

/* Template card (inherits from global, extended here) */
.tpl-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--t-base);
  display: flex;
  flex-direction: column;
}
.tpl-card:hover {
  border-color: rgba(29,185,84,0.3);
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(29,185,84,0.1);
}

.tpl-preview {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: #0a0c0f;
  cursor: zoom-in;
}
.tpl-preview-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.tpl-preview-inner {
  width: 65%; height: 75%;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-mock-header {
  height: 10px;
  border-radius: 3px;
  background: var(--green);
  opacity: 0.7;
  width: 50%;
}
.tpl-mock-img {
  flex: 1;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
}
.tpl-mock-lines { display: flex; flex-direction: column; gap: 4px; }
.tpl-mock-line {
  height: 5px; border-radius: 3px;
  background: rgba(255,255,255,0.1);
}
.tpl-mock-btn {
  height: 14px; width: 50px;
  border-radius: 7px;
  margin-top: 2px;
}

.tpl-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,12,15,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  opacity: 0;
  transition: opacity var(--t-base);
  backdrop-filter: blur(3px);
}
.tpl-card:hover .tpl-overlay { opacity: 1; }
.tpl-overlay-btn {
  background: var(--green);
  color: var(--ink);
  padding: 0.55rem 1.4rem;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast);
}
.tpl-overlay-btn:hover { background: var(--green-dim); }
.tpl-overlay-label {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.08em;
}

.tpl-meta {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  flex: 1;
}
.tpl-meta-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.tpl-meta-top h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}
.tpl-price-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}
.tpl-price-badge.free {
  background: rgba(29,185,84,0.1);
  color: var(--green);
  border: 1px solid rgba(29,185,84,0.2);
}
.tpl-price-badge.paid {
  background: rgba(201,168,76,0.08);
  color: var(--gold);
  border: 1px solid rgba(201,168,76,0.2);
}

.tpl-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: var(--space-md);
  flex: 1;
}

.tpl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}
.tpl-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tpl-get-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green);
  transition: color var(--t-fast);
  text-decoration: none;
}
.tpl-get-btn:hover { color: var(--green-dim); }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-4xl) var(--space-lg);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}
.empty-state p { font-size: 1rem; color: var(--text-secondary); }
.empty-state button {
  color: var(--green);
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
}

/* ── Preview Modal ─────────────────────────────────────────── */
.preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
.preview-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.preview-modal {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(16px);
  transition: transform var(--t-spring);
}
.preview-modal-overlay.open .preview-modal {
  transform: scale(1) translateY(0);
}
.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
  gap: var(--space-lg);
  flex-wrap: wrap;
}
.preview-modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.preview-meta-line {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.preview-modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.device-toggle {
  display: flex;
  background: var(--ink-soft);
  border-radius: var(--r-full);
  padding: 3px;
  border: 1px solid var(--border);
}
.dev-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.35rem 0.9rem;
  border-radius: var(--r-full);
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: all var(--t-fast);
  cursor: pointer;
}
.dev-btn.active {
  background: var(--white);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.preview-frame-wrap {
  flex: 1;
  overflow: auto;
  background: #d0cfc9;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-xl);
  min-height: 0;
}
.preview-frame-container {
  background: white;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: width var(--t-slow);
  width: 100%;
  max-width: 640px;
}
.preview-frame-container.mobile-view {
  width: 375px;
  max-width: 375px;
}
#previewIframe {
  width: 100%;
  height: 600px;
  border: none;
  display: block;
  /* Prevent JS inspection via iframe CSP attribute + sandbox */
  pointer-events: none;
}

/* ── Custom CTA ────────────────────────────────────────────── */
.custom-cta-section {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding-block: var(--space-4xl);
}
.custom-cta-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4xl);
  align-items: center;
}
.custom-cta-text .eyebrow { margin-bottom: var(--space-md); }
.custom-cta-text .display-md { margin-bottom: var(--space-md); }
.custom-cta-text p { color: var(--text-secondary); line-height: 1.75; }
.custom-feature-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
.custom-feature {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: var(--space-md) var(--space-lg);
  background: var(--ink-soft);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .tpl-grid { grid-template-columns: repeat(2, 1fr); }
  .custom-cta-box { grid-template-columns: 1fr; gap: var(--space-2xl); }
}
@media (max-width: 768px) {
  .tpl-grid { grid-template-columns: 1fr; }
  .filter-inner { flex-direction: column; align-items: flex-start; }
  .preview-modal { max-height: 95vh; border-radius: 14px; }
  .preview-modal-header { flex-direction: column; align-items: flex-start; }
  .preview-frame-container.mobile-view { width: 100%; max-width: 375px; }
}
