/**
 * Crazy Master - Favorite Content Stylesheet
 *
 * Requirements:
 * - Center alignment
 * - Full-width responsive layout (width: 100%; max-width: 100%; margin: 0 auto;)
 * - Banner image width 100%, height auto, object-fit contain (no cropping, full banner visible)
 * - Clean modern card design (rounded, soft shadow, clean typography)
 * - Infinite scroll loader & animations
 * - Responsive CSS Grid (desktop: multi-column, tablet: 2-3 cols, mobile: 1 col)
 * - Mobile button tap targets
 */

:root {
  --cm-fav-primary: #f97316;
  --cm-fav-primary-hover: #ea580c;
  --cm-fav-heart-red: #ef4444;
  --cm-fav-bg-card: #ffffff;
  --cm-fav-text-title: #1e293b;
  --cm-fav-text-muted: #64748b;
  --cm-fav-border: #e2e8f0;
  --cm-fav-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  --cm-fav-shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.1);
  --cm-fav-radius: 14px;
}

/* ── Full Width Page Wrapper ── */
.cm-fav-page-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 30px 16px 80px 16px;
  box-sizing: border-box;
}

.cm-fav-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ── Center Aligned Header (Requirement 8) ── */
.cm-fav-header {
  text-align: center;
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cm-fav-header__icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 12px;
  animation: cmFavPulse 2s ease-in-out infinite;
}

.cm-fav-header__title {
  font-size: 32px;
  font-weight: 800;
  color: var(--cm-fav-text-title);
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
  text-align: center;
}

.cm-fav-header__subtitle {
  font-size: 18px;
  font-weight: 600;
  color: var(--cm-fav-primary);
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.cm-fav-header__meta {
  margin-top: 4px;
}

.cm-fav-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: #fff;
  border: 1px solid var(--cm-fav-border);
  border-radius: 30px;
  font-size: 15px;
  font-weight: 600;
  color: var(--cm-fav-text-title);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cm-fav-count__number {
  color: var(--cm-fav-primary);
  font-weight: 700;
}

/* ── Guest Sync Banner ── */
.cm-fav-guest-notice {
  margin-top: 18px;
  padding: 10px 20px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  font-size: 14px;
  color: #9a3412;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.cm-fav-guest-notice__link {
  font-weight: 700;
  color: #c2410c;
  text-decoration: underline;
  cursor: pointer;
}

/* ── Feedback Toast ── */
.cm-fav-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 99999;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.cm-fav-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Empty State ── */
.cm-fav-empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--cm-fav-bg-card);
  border: 1px dashed var(--cm-fav-border);
  border-radius: var(--cm-fav-radius);
  max-width: 540px;
  margin: 30px auto;
  box-shadow: var(--cm-fav-shadow);
}

.cm-fav-empty-state.is-hidden {
  display: none !important;
}

.cm-fav-empty-state__icon {
  font-size: 54px;
  margin-bottom: 16px;
}

.cm-fav-empty-state__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--cm-fav-text-title);
  margin: 0 0 8px 0;
}

.cm-fav-empty-state__desc {
  font-size: 15px;
  color: var(--cm-fav-text-muted);
  margin: 0 0 24px 0;
}

.cm-fav-empty-state__btn {
  display: inline-block;
  background: var(--cm-fav-primary);
  color: #fff;
  padding: 12px 28px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease;
}

.cm-fav-empty-state__btn:hover {
  background: var(--cm-fav-primary-hover);
  color: #fff;
  transform: translateY(-2px);
}

/* ── Responsive CSS Grid (Requirement 11) ── */
.cm-fav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  width: 100%;
  margin: 0 auto;
}

.cm-fav-grid.is-hidden {
  display: none !important;
}

/* Tablet (2 to 3 cards) */
@media (max-width: 1024px) {
  .cm-fav-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
  .cm-fav-header__title {
    font-size: 28px;
  }
}

@media (max-width: 768px) {
  .cm-fav-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* Mobile (1 card per row, no horizontal scrolling) */
@media (max-width: 520px) {
  .cm-fav-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .cm-fav-page-wrapper {
    padding: 20px 12px 60px 12px;
  }
  .cm-fav-header__title {
    font-size: 24px;
  }
}

/* ── Clean Modern Favorite Card (Requirement 5, 6, 12) ── */
.cm-fav-card {
  background: var(--cm-fav-bg-card);
  border: 1px solid var(--cm-fav-border);
  border-radius: var(--cm-fav-radius);
  overflow: hidden;
  box-shadow: var(--cm-fav-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  text-align: center;
}

.cm-fav-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--cm-fav-shadow-hover);
}

.cm-fav-card__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Banner Image Display (Requirement 6 - MUST NOT CROP) ── */
.cm-fav-card__media {
  position: relative;
  width: 100%;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #f1f5f9;
  min-height: 160px;
}

.cm-fav-card__media-link {
  display: block;
  width: 100%;
  text-decoration: none;
}

/* CRITICAL: width 100%, height auto, object-fit contain */
.cm-fav-card__banner {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  transition: transform 0.3s ease;
}

.cm-fav-card:hover .cm-fav-card__banner {
  transform: scale(1.02);
}

/* 👑 Premium Badge (Requirement 21) */
.cm-fav-card__badge-premium {
  position: absolute;
  top: 10px;
  left: 10px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.4);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
}

/* Remove Button on Card (Requirement 15) */
.cm-fav-card__remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cm-fav-heart-red);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  z-index: 3;
}

.cm-fav-card__remove-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
  transform: scale(1.05);
}

.cm-fav-card__remove-icon {
  font-size: 13px;
  line-height: 1;
}

/* Content Title ONLY (Requirement 5) */
.cm-fav-card__content {
  padding: 16px 14px 20px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.cm-fav-card__title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
  color: var(--cm-fav-text-title);
  text-align: center;
  word-break: break-word;
}

.cm-fav-card__title-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.cm-fav-card__title-link:hover {
  color: var(--cm-fav-primary);
}

/* ── Infinite Scroll Sentinel & Loader (Requirement 9, 10) ── */
.cm-fav-scroll-footer {
  text-align: center;
  padding: 30px 16px;
  min-height: 60px;
}

.cm-fav-loader {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--cm-fav-bg-card);
  border: 1px solid var(--cm-fav-border);
  border-radius: 30px;
  color: var(--cm-fav-text-muted);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--cm-fav-shadow);
}

.cm-fav-loader.is-hidden {
  display: none !important;
}

.cm-fav-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--cm-fav-primary);
  border-radius: 50%;
  animation: cmFavSpin 0.75s linear infinite;
}

.cm-fav-end-message {
  font-size: 15px;
  color: var(--cm-fav-text-muted);
  font-weight: 500;
  margin-top: 10px;
}

.cm-fav-end-message.is-hidden {
  display: none !important;
}

/* ── Favorite Button Component (Sitewide On Cards & Single Content) ── */
.cm-fav-btn-wrap {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.cm-fav-btn-wrap--single {
  justify-content: flex-start;
  margin-top: 16px;
  margin-bottom: 16px;
}

.cm-fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  min-height: 40px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cm-fav-btn:hover {
  border-color: var(--cm-fav-heart-red);
  color: var(--cm-fav-heart-red);
  background: #fff5f5;
  transform: translateY(-1px);
}

.cm-fav-btn.is-favorited {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
}

.cm-fav-btn.is-favorited:hover {
  background: #fecaca;
  color: #b91c1c;
}

.cm-fav-btn.is-loading {
  opacity: 0.65;
  cursor: wait;
  pointer-events: none;
}

.cm-fav-btn__icon {
  font-size: 16px;
  line-height: 1;
}

/* Animations */
@keyframes cmFavSpin {
  to { transform: rotate(360deg); }
}

@keyframes cmFavPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
