/* ========================================================
   DevSnips — Card Component Styles
   Used on the list page (index.html)
   ======================================================== */

/* ─── Card Grid ──────────────────────────────────────── */
.snip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 0;
  width: 100%;
}

@media (max-width: 900px) {
  .snip-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .snip-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ─── Full-card click overlay ────────────────────────── */
.card-fullink {
  position: absolute;
  inset: 0;
  z-index: 4;
  text-indent: -9999px;
  overflow: hidden;
}

/* ─── Card Base ──────────────────────────────────────── */
.snip-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--card-bg, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  contain: layout style paint;
}

.snip-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15);
  border-color: var(--accent, #6366f1);
}

/* ─── Card Preview Area ─────────────────────────────── */
.card-preview {
  position: relative;
  width: 100%;
  height: 200px;
  min-height: 200px;
  max-height: 200px;
  background: var(--surface, #0a0a1a);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* live_css preview */
.live-preview {
  --card-preview-width: calc(100% - 32px);
  --card-preview-height: calc(100% - 32px);
  width: 100%;
  height: 100%;
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  contain: strict;
  position: relative;
}

/* Ensure live_css content fills and clips inside the preview box */
.live-preview > [class^="lp-"] {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.live-preview > [class^="lp-"] > * {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}

.card-preview--inline style {
  display: none;
}

.live-preview--fallback > [class^="lp-"],
.live-preview--scoped > [class^="lp-"] {
  width: 100%;
  height: 100%;
  position: relative;
}

.live-preview--fallback > [class^="lp-"] > *,
.live-preview--scoped > [class^="lp-"] > * {
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}

.card-preview--inline .live-preview > [class^="lp-"] {
  pointer-events: none;
}

.snip-card--interactive-preview .card-fullink {
  top: 200px;
}

.snip-card--interactive-preview .card-preview {
  z-index: 5;
}

.card-preview--interactive {
  align-items: stretch;
  justify-content: stretch;
  padding: 16px;
  box-sizing: border-box;
}

.card-demo-inline__mount,
.card-demo-inline__content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-demo-inline__mount {
  overflow: hidden;
  --card-preview-width: 100%;
  --card-preview-height: 100%;
}

.card-demo-inline__content style {
  display: none;
}

.card-demo-inline__content > [class^="lp-"] {
  width: 100%;
  height: 100%;
}

.card-preview--interactive [class^="lp-"] > * {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}

.card-preview--interactive .demo-controls {
  display: none;
}

.card-preview--interactive .demo-controls button {
  padding: 8px 12px;
  font-size: 0.75rem;
  border-radius: 999px;
}

.card-preview :is(p, small, output, .control-row, [class*="controls"]) {
  display: none;
}

.card-preview :is([class*="chips"], [class*="chip-row"], [class*="pill-row"]) {
  display: none;
}

.card-preview :is(h1, h2, h3, h4, h5, h6) {
  margin-bottom: 0;
}

/* placeholder when no thumbnail */
.card-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99,102,241,0.15) 0%, rgba(167,139,250,0.08) 100%);
  z-index: 0;
}

.card-preview-placeholder span {
  font-family: 'Inter', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: rgba(129,140,248,0.4);
  letter-spacing: 0.05em;
}

/* real image sits above placeholder; hides on error via onerror */
.card-preview > img {
  position: relative;
  z-index: 1;
}

/* static_image */
.card-preview > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card-preview video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card-preview--video {
  background: #0b1020;
}

.card-preview-poster,
.card-preview-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-preview-poster {
  z-index: 1;
  transition: opacity 0.24s ease, transform 0.35s ease;
}

.card-preview-video {
  z-index: 2;
  opacity: 0;
  transition: opacity 0.24s ease;
  background: #0b1020;
}

.card-preview--video.video-loaded.is-playing .card-preview-video {
  opacity: 1;
}

.card-preview--video.video-loaded.is-playing .card-preview-poster {
  opacity: 0;
}

.snip-card:hover .card-preview-poster {
  transform: scale(1.03);
}

.card-preview iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.snip-card:hover .card-preview > img,
.snip-card:hover .card-preview > .card-preview-poster {
  transform: scale(1.05);
}

/* detail_only badge */
.card-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 4px 10px;
  background: rgba(99, 102, 241, 0.85);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  z-index: 3;
}

/* ─── Card Meta ──────────────────────────────────────── */
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 0;
}

.card-id {
  font-family: 'Inter', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-strong, #818cf8);
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

.card-category {
  font-size: 0.7rem;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Card Title & Tags ─────────────────────────────── */
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #f0f0f5);
  padding: 8px 16px 4px;
  margin: 0;
  line-height: 1.3;
}

.card-desc {
  font-size: 0.825rem;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  padding: 0 16px;
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 16px;
}

.card-tags span {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted, rgba(255, 255, 255, 0.5));
}

/* ─── Card Link ──────────────────────────────────────── */
.card-link {
  display: block;
  padding: 10px 16px 14px;
  margin-top: auto;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--accent-strong, #818cf8);
  text-decoration: none;
  transition: color 0.2s;
}

.card-link:hover {
  color: var(--accent-hover, #a78bfa);
}

.card-link::after {
  content: ' →';
}

/* ─── Premium Badge on Card ─────────────────────────── */
.card-premium-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 8px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 4px;
  z-index: 3;
  text-transform: uppercase;
}

/* ─── Reduced Motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .snip-card:hover {
    transform: none;
  }

  .snip-card:hover .card-preview img {
    transform: none;
  }

  .card-preview-video {
    display: none;
  }
}
