/* ══════════════════════════════════════════════════════════
   widgets.css — Homepage Widget System
   Trending Study Cards + future widget container
   ══════════════════════════════════════════════════════════ */

/* ── Widget Section ── */
.widget-section {
  position: relative;
  padding: 4rem 1.5rem;
}

.widget-section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

/* ── Widget Grid ── */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  max-width: 72rem;
  margin: 0 auto;
}

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

@media (max-width: 640px) {
  .widget-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 1rem;
    padding-bottom: 1rem;
    scrollbar-width: none;
  }
  .widget-grid::-webkit-scrollbar {
    display: none;
  }
  .widget-grid > * {
    flex: 0 0 80%;
    scroll-snap-align: start;
  }
}

/* ── Widget Card ── */
.widget-card {
  background: var(--kv-glass-bg);
  border: 1px solid var(--kv-glass-border);
  border-radius: 16px;
  padding: 1.25rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  min-height: 180px;
}

.widget-card:hover {
  transform: translateY(-4px);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 16px 40px var(--kv-shadow);
}

/* ── Card Header (badge + views) ── */
.widget-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

/* ── Source Badge ── */
.widget-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
}

.widget-source-badge.badge-camera {
  background: rgba(16, 185, 129, 0.12);
  color: #10B981;
}
.widget-source-badge.badge-audio {
  background: rgba(139, 92, 246, 0.12);
  color: #8B5CF6;
}
.widget-source-badge.badge-text {
  background: rgba(236, 72, 153, 0.12);
  color: #EC4899;
}

/* ── View Count ── */
.widget-views {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  color: var(--kv-text-dim);
}

/* ── Card Title ── */
.widget-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--kv-text);
  margin-bottom: 0.6rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Key Points (V1) ── */
.widget-preview-kp {
  list-style: none;
  padding: 0;
  margin: 0 0 auto;
  font-size: 0.8rem;
  color: var(--kv-text-sub);
  line-height: 1.5;
}

.widget-preview-kp li {
  position: relative;
  padding-left: 14px;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.widget-preview-kp li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--kv-primary-dark);
  opacity: 0.6;
}

/* ── Tags (V2) ── */
.widget-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: auto;
}

.widget-tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--kv-btn-ghost-bg);
  color: var(--kv-text-sub);
}

/* ── Study Link ── */
.widget-study-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--kv-primary-dark);
  margin-top: 0.75rem;
  transition: gap 0.25s ease;
}

.widget-card:hover .widget-study-link {
  gap: 8px;
}

/* ── Skeleton Loader ── */
.widget-card-skeleton {
  background: var(--kv-glass-bg);
  border: 1px solid var(--kv-glass-border);
  border-radius: 16px;
  padding: 1.25rem;
  min-height: 180px;
  overflow: hidden;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--kv-btn-ghost-bg) 25%,
    var(--kv-hover-tint) 50%,
    var(--kv-btn-ghost-bg) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-badge {
  width: 60px;
  height: 18px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.skeleton-title {
  width: 75%;
  height: 16px;
  margin-bottom: 10px;
}

.skeleton-text {
  width: 90%;
  height: 10px;
  margin-bottom: 6px;
}

.skeleton-text-short {
  width: 60%;
  height: 10px;
  margin-bottom: 6px;
}

.skeleton-link {
  width: 50px;
  height: 12px;
  margin-top: auto;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty State ── */
.widget-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--kv-text-sub);
  grid-column: 1 / -1;
}

.widget-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.widget-empty-text {
  font-size: 0.95rem;
  line-height: 1.5;
}
