/* ==========================================================================
   Template Gallery & Detail Styles (Stripe-inspired Modern Design System)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Hero Header & Filter Toolbar
   -------------------------------------------------------------------------- */
.templateHero {
  position: relative;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, var(--primary-soft) 0%, var(--background) 85%);
  border-bottom: 1px solid var(--border);
  padding: clamp(3.5rem, 6vw, 5rem) var(--space-5) clamp(2.5rem, 4vw, 3.5rem);
  text-align: center;
  overflow: hidden;
}

.templateHero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.35;
  pointer-events: none;
}

.templateHero .pageHeroInner {
  max-width: 860px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.templateHero .pageHeroHeading {
  text-align: center !important;
  max-width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.templateHero .pageHeroSub {
  text-align: center !important;
  max-width: 62ch !important;
  margin-left: auto !important;
  margin-right: auto !important;
  margin-bottom: 1.75rem !important;
}

/* Hero Specs Ticker Pills */
.templateHeroPills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.templateHeroPill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--foreground);
  backdrop-filter: blur(8px);
}

:root[data-theme="dark"] .templateHeroPill {
  background: rgba(23, 27, 24, 0.6);
}

.templateHeroPill svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

/* Filter & Search Bar */
.templateFilterSection {
  padding: 1.75rem 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.templateFilterInner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.templateFilterTabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.6rem 0.25rem;
  scrollbar-width: none;
}

.templateFilterTabs::-webkit-scrollbar {
  display: none;
}

.templateTabBtn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--motion-fast) var(--ease-standard);
}

.templateTabBtn:hover {
  color: var(--foreground);
  background: var(--muted);
}

.templateTabBtn.isActive {
  background: var(--card);
  color: var(--primary);
  border-color: var(--primary-soft-border);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.templateSearchWrap {
  position: relative;
  min-width: 260px;
  flex-grow: 0;
}

.templateSearchInput {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.templateSearchInput:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.templateSearchIcon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-foreground);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   2. Template Cards Grid
   -------------------------------------------------------------------------- */
.templateGridSection {
  padding: 3rem var(--space-5) 5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.templateGridHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.templateGridCount {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  font-weight: 500;
}

.templateGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.75rem;
}

/* Template Card Item */
a.templateCard,
a.templateCard:hover,
a.templateCard:focus,
a.templateCard:active,
.templateCard *,
.templateCard *:hover,
.templateCardTitle,
.templateCardTitle:hover,
.templateCardLink,
.templateCardLink:hover {
  text-decoration: none !important;
}

.templateCard {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  gap: 0 !important;
  align-items: stretch !important;
  padding: 0 !important;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform var(--motion-ui) var(--ease-standard),
              border-color var(--motion-ui) var(--ease-standard),
              box-shadow var(--motion-ui) var(--ease-standard);
  position: relative;
  text-decoration: none !important;
  color: inherit;
}

.templateCard:hover {
  transform: translateY(-6px);
  border-color: var(--primary-soft-border);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(31, 107, 69, 0.08);
}

.templateCardMedia {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 14;
  background: linear-gradient(135deg, var(--muted) 0%, var(--border) 100%);
  overflow: hidden;
}

.templateCardMedia img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--motion-story) var(--ease-standard);
}

.templateCard:hover .templateCardMedia img {
  transform: scale(1.04);
}

/* Fallback Abstract Gradient Header when thumbnail is missing */
.templateCardFallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: linear-gradient(145deg, var(--primary-soft) 0%, var(--muted) 100%);
  color: var(--primary);
  padding: 1.5rem;
  text-align: center;
  position: relative;
}

.templateCardFallbackIcon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  color: var(--primary);
}

.templateCardFallbackIcon svg {
  width: 24px;
  height: 24px;
}

/* Media Overlay Badges */
.templateCardBadges {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 2;
  pointer-events: none;
}

.templateCardTag {
  padding: 0.25rem 0.65rem;
  background: rgba(23, 25, 27, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  color: #ffffff;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.templateCardAspectBadge {
  padding: 0.25rem 0.6rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  color: #17191b;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 700;
}

:root[data-theme="dark"] .templateCardAspectBadge {
  background: rgba(23, 27, 24, 0.85);
  color: #eef2ef;
}

/* Play Hover Overlay Icon */
.templateCardPlayOverlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease-standard);
  z-index: 3;
}

.templateCard:hover .templateCardPlayOverlay {
  opacity: 1;
}

.templateCardPlayBtn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--card);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform: scale(0.85);
  transition: transform var(--motion-fast) var(--ease-standard);
}

.templateCard:hover .templateCardPlayBtn {
  transform: scale(1);
}

.templateCardPlayBtn svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
}

/* Card Body */
.templateCardBody {
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.templateCardCategory {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.templateCardTitle {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--foreground);
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.templateCardBlurb {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  line-height: 1.5;
  margin: 0 0 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.templateCardMetaChips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.templateMetaChip {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 0.2rem 0.55rem;
  background: var(--muted);
  border-radius: var(--radius-sm);
  color: var(--muted-foreground);
  font-weight: 500;
}

/* Card Footer */
.templateCardFooter {
  margin-top: auto;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: var(--text-xs);
  line-height: 1;
  width: 100%;
  box-sizing: border-box;
}

.templateCardCredit {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1;
  white-space: nowrap;
}

.templateCardCredit svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
  flex-shrink: 0;
  display: block;
}

.templateCardLink {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1;
  white-space: nowrap;
  transition: gap var(--motion-fast) var(--ease-standard);
}

.templateCardLink svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}

.templateCard:hover .templateCardLink {
  gap: 0.55rem;
}

/* Empty State */
.templateEmptyState {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-xl);
}

.templateEmptyState h3 {
  font-size: var(--text-xl);
  margin: 0 0 0.5rem;
  color: var(--foreground);
}

.templateEmptyState p {
  color: var(--muted-foreground);
  margin: 0;
}

/* --------------------------------------------------------------------------
   3. Template Detail Page Styles
   -------------------------------------------------------------------------- */
.templateDetailHero {
  background: var(--background);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem var(--space-5) 2rem;
}

.templateBreadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.templateBreadcrumbs a {
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color var(--motion-fast);
}

.templateBreadcrumbs a:hover {
  color: var(--primary);
}

.templateBreadcrumbs span {
  color: var(--foreground);
  font-weight: 600;
}

.templateDetailContainer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem var(--space-5) 5rem;
}

.templateDetailLayout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 3rem;
  align-items: start;
}

@media (max-width: 960px) {
  .templateDetailLayout {
    grid-template-columns: 1fr;
  }
}

/* Phone Mockup Preview */
.templatePreviewSticky {
  position: sticky;
  top: 5rem;
}

.templatePhoneFrame {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  border-radius: 36px;
  background: #000000;
  padding: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.templatePhoneNotch {
  width: 120px;
  height: 20px;
  background: #000000;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.templatePhoneScreen {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 26px;
  overflow: hidden;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

.templatePhoneScreen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.templatePhoneOverlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, transparent 20%, transparent 70%, rgba(0,0,0,0.6) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem;
  color: #fff;
}

.templatePhoneTopBadge {
  align-self: flex-end;
  padding: 0.25rem 0.6rem;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-family: var(--font-mono);
}

.templatePhoneCenterPlay {
  align-self: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: transform var(--motion-fast) var(--ease-standard);
}

.templatePhoneCenterPlay:hover {
  transform: scale(1.1);
}

.templatePhoneCenterPlay svg {
  width: 24px;
  height: 24px;
  margin-left: 3px;
}

.templatePhoneBottomInfo {
  font-size: var(--text-xs);
}

.templatePhoneBottomInfo h4 {
  margin: 0 0 0.2rem;
  font-size: var(--text-sm);
  color: #ffffff;
}

.templatePhoneBottomInfo p {
  margin: 0;
  opacity: 0.8;
}

/* Detail Spec Content */
.templateDetailMainHeader {
  margin-bottom: 2rem;
}

.templateDetailCategory {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.templateDetailTitle {
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--foreground);
  margin: 0 0 0.85rem;
  line-height: 1.15;
}

.templateDetailBlurb {
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  color: var(--muted-foreground);
  line-height: 1.55;
  margin: 0 0 1.5rem;
}

/* Primary Action Bar */
.templateActionRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.btnTemplatePrimary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
  font-size: var(--text-base);
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(31, 107, 69, 0.25);
  transition: all var(--motion-fast) var(--ease-standard);
}

.btnTemplatePrimary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(31, 107, 69, 0.35);
}

.btnTemplateSecondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: all var(--motion-fast) var(--ease-standard);
}

.btnTemplateSecondary:hover {
  background: var(--muted);
  border-color: var(--input);
}

/* Specification Grid Box */
.templateSpecsCard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-md);
}

.templateSpecsTitle {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--foreground);
  margin: 0 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.templateSpecsTitle svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.templateSpecsList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
}

.templateSpecItem {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.templateSpecLabel {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.templateSpecValue {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--foreground);
}

/* Use-Cases Tags */
.templateUseCasesBox {
  margin-bottom: 2.5rem;
}

.templateSectionLabel {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 0.85rem;
}

.templateUseCasePills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.templateUseCasePill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--radius-full);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Shot Breakdown Timeline */
.templateShotSection {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 3rem;
}

.templateShotTimeline {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.25rem;
  position: relative;
}

.templateShotTimeline::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
}

.templateShotStep {
  display: flex;
  gap: 1.25rem;
  position: relative;
  z-index: 1;
}

.templateShotNum {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 700;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px var(--card);
}

.templateShotContent {
  flex-grow: 1;
  background: var(--muted);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
}

.templateShotHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.templateShotTitle {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--foreground);
  margin: 0;
}

.templateShotDuration {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
  background: var(--card);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.templateShotDesc {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin: 0;
  line-height: 1.5;
}

/* Related Templates Section */
.templateRelatedSection {
  border-top: 1px solid var(--border);
  padding-top: 4rem;
  margin-top: 4rem;
}

.templateRelatedTitle {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--foreground);
  margin: 0 0 0.5rem;
}

.templateRelatedSub {
  color: var(--muted-foreground);
  font-size: var(--text-base);
  margin: 0 0 2rem;
}
