/* ==========================================================================
   Vidzy Template Gallery
   Tab-based categories with horizontal scroll rows and edge gradients.
   Consumes design-system.css tokens.
   ========================================================================== */

/* Showcase container */
.vidzy-showcase {
  padding: var(--space-xl) 0 var(--space-xxxl);
}

/* Section header */
.vidzy-showcase > .section-inner > .showcase-header {
  margin-bottom: var(--space-lg);
}

.showcase-title {
  font-size: var(--text-heading-large);
  line-height: var(--text-heading-large-lh);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-xxs);
}

.showcase-subtitle {
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
  color: var(--color-text-tertiary);
  margin: 0;
}

/* --------------------------------------------------------------------------
   Category tabs
   -------------------------------------------------------------------------- */

.showcase-tabs {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.showcase-tabs::-webkit-scrollbar {
  display: none;
}

.showcase-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  padding: var(--space-xs) var(--space-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-family);
  font-size: var(--text-body-small);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.showcase-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

.showcase-tab.is-active {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--color-border);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

.tab-emoji {
  font-size: 1em;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Tab panels
   -------------------------------------------------------------------------- */

.showcase-panel {
  display: none;
}

.showcase-panel.is-active {
  display: block;
}

/* --------------------------------------------------------------------------
   Horizontal scroll row with edge fade gradients
   -------------------------------------------------------------------------- */

.template-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--screen-padding));
  padding: 0 var(--screen-padding);

  /* Hide scrollbar but keep scrollable */
  scrollbar-width: none;
  -ms-overflow-style: none;

  /* Mask-based edge fade — works on the scroll container itself */
  --fade-size: 60px;
  mask-image: linear-gradient(
    to right,
    transparent 0px,
    black var(--fade-size),
    black calc(100% - var(--fade-size)),
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0px,
    black var(--fade-size),
    black calc(100% - var(--fade-size)),
    transparent 100%
  );
}

.template-scroll::-webkit-scrollbar {
  display: none;
}

.template-row {
  display: flex;
  gap: var(--space-md);
  padding-bottom: var(--space-xs); /* Space for hover lift */
}

/* --------------------------------------------------------------------------
   Template card — fixed size, uniform
   -------------------------------------------------------------------------- */

.template-card {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease;
  cursor: pointer;
}

.template-card:hover {
  transform: translateY(-4px);
}

/* Featured cards — same size in showcase, slightly larger in standalone grid */
.template-grid .template-card--featured {
  /* Grid layout only — showcase uses uniform sizing */
}

/* Media container — fixed 9:16 portrait ratio, always same size */
.template-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: var(--corner-radius-lg);
  overflow: hidden;
  background: var(--color-surface-elevated);
  flex-shrink: 0;
}

/* Images & videos — fill the container, center-crop */
.template-card-thumb,
.template-card-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Play button overlay */
.template-card-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  color: rgba(255, 255, 255, 0.9);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.template-card:hover .template-card-play {
  opacity: 1;
}

/* Placeholder for templates without thumbnails */
.template-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--color-surface) 0%,
    var(--color-surface-elevated) 50%,
    var(--color-surface) 100%
  );
  font-size: 40px;
  opacity: 0.5;
}

/* Card info */
.template-card-info {
  padding: var(--space-sm) var(--space-xxs) 0;
}

.template-card-name {
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-card-desc {
  font-size: var(--text-caption);
  line-height: var(--text-caption-lh);
  color: var(--color-text-tertiary);
  margin: var(--space-xxs) 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Grid layout (for shortcode/standalone pages)
   -------------------------------------------------------------------------- */

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

/* --------------------------------------------------------------------------
   Category chips (shortcode)
   -------------------------------------------------------------------------- */

.vidzy-categories {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.vidzy-category-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  padding: var(--space-xs) var(--space-md);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  font-size: var(--text-body-small);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  transition: background 0.2s ease, color 0.2s ease;
  cursor: default;
}

.vidzy-category-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

.chip-emoji {
  font-size: 1em;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (min-width: 768px) {
  .template-card {
    flex: 0 0 180px;
  }

  .showcase-title {
    font-size: var(--text-heading-large);
  }

  .template-scroll {
    --fade-size: 80px;
  }
}

@media (min-width: 1024px) {
  .template-card {
    flex: 0 0 200px;
  }
}

/* --------------------------------------------------------------------------
   Video hover play (JS enhancement)
   -------------------------------------------------------------------------- */

.template-card-video[data-playing] + .template-card-play {
  opacity: 0 !important;
}
