/**
 * templates.css — per-template SEO landing pages (/templates/<slug>), plus
 * the .hub-* classes reused by the hand-written "Popular Templates" section
 * on landing.html (there is no standalone /templates hub page — browsing
 * lives at /app/templates, the in-app Library).
 *
 * Visually mirrors the in-app Template Library (css/template-library.css):
 * same card shape, premium badge, difficulty pills, and language flags, so a
 * visitor landing here from Google doesn't feel like a different product.
 *
 * Desktop-first: no @media queries here (see templates.responsive.css).
 * Colours come only from CSS variables in color-palette.css.
 */

.tp-page {
  background: var(--bg-primary);
  color: var(--text-body);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* ── Shared content width ─────────────────────────────────────────────────── */
.tp-hero,
.tp-main,
.hub-main {
  max-width: 920px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

/* ── Back bar (replaces the full marketing nav on template pages) ─────────── */
.tp-back-bar {
  padding: 20px 0 0 24px;
}

.tp-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
}

.tp-back-link:hover {
  text-decoration: underline;
}

/* ── Template page: hero ──────────────────────────────────────────────────── */
.tp-hero {
  padding-top: 24px;
  padding-bottom: 40px;
}

/* Optional hero background image — applied when seo.heroImage is set.
   ::before renders the image at low opacity; ::after adds a left→transparent
   gradient so the text area (left side) stays fully readable. */
.tp-hero--has-bg {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.tp-hero--has-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--tp-hero-bg);
  background-size: cover;
  background-position: right center;
  opacity: 0.92;
  z-index: 0;
  pointer-events: none;
}

.tp-hero--has-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, var(--bg-primary) 2%, transparent 22%);
  z-index: 1;
  pointer-events: none;
}

.tp-hero--has-bg > * {
  position: relative;
  z-index: 2;
}

/* Options picker gets a frosted-glass treatment when a hero image is present */
.tp-hero--has-bg .tp-options {
  background: rgba(255, 255, 255, 0.62);
  /* backdrop-filter: blur(8px); */
  /* -webkit-backdrop-filter: blur(8px); */
}

.tp-breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 20px;
}

.tp-breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
}

.tp-breadcrumb a:hover {
  text-decoration: underline;
}

.tp-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 16px;
}

.tp-hero-title {
  font-size: 2.75rem;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0;
}

.tp-hero-intro {
  font-size: var(--font-size-lg);
  line-height: 1.5;
  color: var(--text-body);
  max-width: 640px;
  margin: 0 0 24px;
}

/* ── Price badge: circular, mirrors .pricing-status-pill in the editor ────── */
.tp-price-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--font-size-lg);
  background: var(--success-lighter);
  border: 2px solid var(--success-color);
  box-shadow: 0 4px 12px var(--success-shadow);
  color: var(--text-primary);
}

.tp-price-badge.is-premium {
  background: var(--warning-lighter);
  border: 2px solid var(--warning-color);
  box-shadow: 0 4px 12px var(--warning-shadow);
  color: var(--text-heading);
}

/* ── Language / difficulty picker (click to select, drives the CTA href) ──── */
.tp-options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 28px;
  padding: 20px 24px;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.5));
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.tp-options-prompt {
  flex-basis: 100%;
  margin: 0 0 4px;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.tp-option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tp-option-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.tp-difficulty-description {
  flex-basis: 100%;
  margin: 4px 0 0;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--text-primary);
}

.tp-flag-buttons,
.tp-difficulty-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tp-flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tp-flag-btn:hover {
  background: var(--bg-primary);
  border-color: var(--border-medium);
}

.tp-flag-btn.is-selected {
  background: var(--primary-lightest);
  border-color: var(--primary-color);
}

.tp-flag {
  display: block;
  width: 22px;
  height: 15px;
  border-radius: 2px;
  border: 1px solid var(--border-default);
  object-fit: cover;
}

/* Toggle pills: a colored dot when unselected, an "X" + solid fill when
   selected — same interaction pattern as a checkbox chip. */
.tp-difficulty-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: var(--radius-xl);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
  cursor: pointer;
  background: var(--bg-primary);
  border: 2px solid var(--border-default);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tp-difficulty-pill:hover {
  transform: translateY(-1px);
}

.tp-difficulty-pill::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.tp-difficulty-pill.is-selected::before {
  content: "\2715";
  width: auto;
  height: auto;
  background: none;
  font-size: 10px;
  font-weight: 700;
  color: currentColor;
}

.tp-difficulty-easy {
  color: var(--difficulty-easy-text);
}

.tp-difficulty-easy.is-selected {
  background: var(--success-color);
  border-color: var(--success-color);
  color: var(--text-inverse);
}

.tp-difficulty-medium {
  color: var(--difficulty-medium-text);
}

.tp-difficulty-medium.is-selected {
  background: var(--warning-color);
  border-color: var(--warning-color);
  color: var(--text-heading);
}

.tp-difficulty-hard {
  color: var(--difficulty-hard-text);
}

.tp-difficulty-hard.is-selected {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: var(--text-inverse);
}

/* ── CTAs ─────────────────────────────────────────────────────────────────── */
.tp-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.tp-cta-primary {
  display: inline-block;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--font-size-md);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: var(--gradient-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-primary);
}

.tp-cta-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ── Template page: content sections ──────────────────────────────────────── */
.tp-main {
  padding-bottom: 64px;
}

.tp-main section {
  margin-top: 40px;
}

.tp-main h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 14px;
}

.tp-about p,
.tp-features-list li {
  font-size: var(--font-size-lg);
  line-height: 1.6;
  color: var(--text-body);
}

.tp-audience {
  color: var(--text-muted);
  font-style: italic;
}

.tp-stats-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 16px 0 0;
  padding: 0;
}

.tp-stats-list li {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.tp-features-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.tp-features-list li {
  padding-left: 8px;
}

.tp-features-list strong {
  color: var(--text-heading);
}

.tp-related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tp-related-list a {
  display: inline-block;
  padding: 10px 18px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tp-related-list a:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}


/* ── "Popular Templates" section on landing.html ──────────────────────────── */
.hub-main {
  padding-bottom: 64px;
}

.hub-category {
  margin-top: 40px;
}

.hub-category h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

/* Same shape/spacing/hover as .template-card in the in-app Library. */
.hub-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.hub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.hub-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.hub-card-title {
  font-weight: 600;
  font-size: var(--font-size-md);
  color: var(--text-heading);
  padding-right: 24px;
}

.hub-card-desc {
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--text-muted);
  flex: 1;
}
