/**
 * Marketplace Feed — FR-017.2
 *
 * Additive CSS for the Live Marketplace Feed.
 * NO overrides of existing ep12-* or dlc-* classes.
 * New class prefix: mp- (marketplace)
 *
 * RULES:
 *   RULE 13 — Route is hero (20px bold)
 *   RULE 15 — Feed is NOT Facebook (no avatar, no status)
 *   RULE 16 — 5 questions in 2s
 *   RULE 22 — Stable Layout (no CLS)
 *   RULE 23 — One story per card
 *
 * @package XOS_Lite
 * @version 1.0.0 — FR-017.2
 * @since   FR-017.2
 */

/* ===========================================================
   1. FEED CONTAINER — Stable Layout (RULE 22)
   =========================================================== */

.mp-feed-section {
  position: relative;
  min-height: 400px;
  overflow: hidden;
}

.mp-feed-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 2px;
}

.mp-feed-label {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.mp-feed-count {
  font-weight: 700;
  color: #2563EB;
  font-size: 0.9375rem;
}

.mp-feed-unit {
  font-size: 0.75rem;
  color: #6B7280;
  margin-left: 2px;
}

.mp-freshness-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  flex-shrink: 0;
  transition: background-color 300ms ease;
}

.mp-freshness-dot--active {
  animation: mp-dot-pulse 1.2s ease-in-out infinite;
}

@keyframes mp-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

.mp-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 370px;
}

.mp-feed .mp-card {
  flex-shrink: 0;
}

/* ===========================================================
   2. BASE CARD — RULE 23: One story per card
   =========================================================== */

.mp-card {
  contain: layout style paint;
  content-visibility: auto;
  contain-intrinsic-size: auto 118px;

  position: relative;
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid #E7EEF7;
  margin-bottom: 6px;
  overflow: hidden;
  transition: box-shadow 150ms ease, transform 100ms ease;
  animation: mp-card-enter 250ms ease-out both;
  animation-delay: calc(var(--mp-index, 0) * 30ms);
}

.mp-card:active {
  transform: scale(0.99);
}

.mp-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

@keyframes mp-card-enter {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Card Link === */

.mp-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 8px;
  height: auto;
  min-height: 110px;
}

/* ===========================================================
   3. CARD LAYOUT — Visual Hierarchy (RULE 13, 16)
   =========================================================== */

/* ── Header: Badge + Meta ── */

.mp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}

.mp-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1.5;
  white-space: nowrap;
  flex-shrink: 0;
}

.mp-header-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.mp-source-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.5;
  white-space: nowrap;
}

.mp-source-badge--ai {
  color: #4338CA;
  background: #EEF2FF;
  font-size: 0.625rem;
}

.mp-time-ago {
  font-size: 0.6875rem;
  color: #9CA3AF;
  white-space: nowrap;
}

/* ── Route Row — RULE 13: Route is hero (20px bold) ── */

.mp-route {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 1.125rem;
  font-weight: 700;
  color: #1F2937;
  line-height: 1.25;
  overflow: hidden;
  margin-bottom: 3px;
}

.mp-route--compact {
  font-size: 0.9375rem;
}

.mp-route-origin,
.mp-route-dest {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.mp-route-arrow {
  flex-shrink: 0;
  color: #9CA3AF;
  min-width: 16px;
}

/* ── Info Row — RULE 16: 5 questions answered ── */

.mp-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.mp-info-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.8125rem;
  color: #4B5563;
  line-height: 1.4;
}

.mp-info-fomo {
  font-weight: 700;
  font-size: 0.8125rem;
}

.mp-info-price {
  font-weight: 700;
  color: #DC2626;
  font-size: 1.125rem;
  margin-left: auto;
  flex-shrink: 0;
}

.mp-info-time svg {
  flex-shrink: 0;
}

/* ── Bottom Row: Author (metadata) + CTA ── */

.mp-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 2px;
}

.mp-driver-name {
  font-size: 0.625rem;
  color: #9CA3AF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.7;
}

.mp-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ── CTA Buttons (RULE 14) ── */

.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 8px;
  line-height: 1.3;
  transition: all 120ms ease;
  white-space: nowrap;
  touch-action: manipulation;
  min-height: 30px;
}

.mp-btn--outline {
  border: 1.5px solid #D1D5DB;
  color: #374151;
  background: rgba(255, 255, 255, 0.85);
}

.mp-btn--outline:active {
  background: #F3F6FA;
  border-color: #9CA3AF;
}

.mp-btn--primary {
  border: 1.5px solid #2563EB;
  color: #FFFFFF;
  background: #2563EB;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.mp-btn--primary:active {
  background: #1D4ED8;
  border-color: #1D4ED8;
}

.mp-btn--opportunity {
  background: #F59E0B;
  border-color: #F59E0B;
  color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

.mp-btn--opportunity:active {
  background: #D97706;
  border-color: #D97706;
}

/* ===========================================================
   4. CARD TYPE: TRANSACTION (default)
   =========================================================== */

.mp-card--transaction {
  border: 1px solid #E7EEF7;
}

/* ===========================================================
   5. CARD TYPE: HERO (RULE 19 — Every ~20 cards)
   =========================================================== */

.mp-card--hero {
  border: 2px solid #F59E0B;
  background: linear-gradient(135deg, #FFFBEB 0%, #FFFFFF 100%);
}

.mp-card--hero .mp-route {
  font-size: 1.25rem;
}

.mp-card--hero .mp-info-price {
  font-size: 1.25rem;
}

.mp-card--hero .mp-badge {
  background: #FEF3C7 !important;
  color: #92400E !important;
  border: 1px solid #FDE68A;
}

/* ===========================================================
   6. CARD TYPE: OPPORTUNITY (🔥 CƠ HỘI HÔM NAY)
   =========================================================== */

.mp-card--opportunity {
  border: 1.5px solid #F59E0B;
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
}

.mp-badge--opportunity {
  background: #FEF3C7 !important;
  color: #C2410C !important;
  border: 1px solid #FDE68A;
}

.mp-opportunity-body {
  padding: 2px 0 4px 0;
}

.mp-opportunity-text {
  font-size: 0.8125rem;
  color: #92400E;
  font-weight: 600;
  margin: 0 0 2px 0;
  line-height: 1.4;
}

.mp-opportunity-reason {
  font-size: 0.75rem;
  color: #B45309;
  margin: 0;
  line-height: 1.4;
}

/* ===========================================================
   7. CARD TYPE: INSIGHT (📊 THỊ TRƯỜNG / 🔥 TUYẾN PHỔ BIẾN)
   =========================================================== */

.mp-card--insight {
  border: 1px solid #E5E7EB;
  background: #F9FAFB;
}

.mp-card--insight .mp-header {
  margin-bottom: 4px;
}

.mp-badge--insight {
  background: #F3F4F6 !important;
  color: #374151 !important;
  font-size: 0.6875rem;
}

.mp-insight-body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 2px 0;
}

.mp-insight-stat {
  font-size: 0.8125rem;
  color: #4B5563;
  font-weight: 600;
}

.mp-insight-growth {
  font-size: 0.75rem;
  color: #059669;
  font-weight: 600;
}

/* ===========================================================
   8. CARD TYPE: ACTIVITY (low-priority fallback)
   =========================================================== */

.mp-card--activity {
  border: 1px solid #E5E7EB;
  background: #F9FAFB;
  min-height: 48px;
}

.mp-card--activity .mp-card-link {
  min-height: 48px;
  padding: 8px 12px;
}

.mp-activity-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-activity-text {
  font-size: 0.75rem;
  color: #6B7280;
}

.mp-activity-time {
  font-size: 0.6875rem;
  color: #9CA3AF;
  margin-left: auto;
}

/* ===========================================================
   9. CARD TYPE: SIMULATION (RULE 20 — clearly labeled)
   =========================================================== */

.mp-card--simulation {
  border: 1px dashed #D1D5DB;
}

/* ===========================================================
   10. EMPTY STATE
   =========================================================== */

.mp-empty-state {
  text-align: center;
  padding: 32px 16px;
}

.mp-empty-icon {
  margin-bottom: 8px;
  opacity: 0.6;
}

.mp-empty-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #374151;
  margin: 0 0 4px;
}

.mp-empty-text {
  font-size: 0.75rem;
  color: #9CA3AF;
  margin: 0 0 12px;
  line-height: 1.5;
}

.mp-empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #FFFFFF;
  background: #2563EB;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 120ms ease;
}

.mp-empty-btn:active {
  background: #1D4ED8;
}

/* ===========================================================
   11. HERO CARD EXTRA STYLES (desktop only, RULE 19)
   =========================================================== */

@media (min-width: 640px) {
  .mp-card--hero {
    min-height: 150px;
  }

  .mp-card--hero .mp-card-link {
    min-height: 150px;
  }

  .mp-card--hero .mp-route {
    font-size: 1.375rem;
  }

  .mp-card--hero .mp-info-price {
    font-size: 1.375rem;
  }
}

/* ===========================================================
   12. RESPONSIVE
   =========================================================== */

@media (min-width: 640px) {
  .mp-card {
    border-radius: 14px;
    margin-bottom: 8px;
  }

  .mp-card-link {
    padding: 10px 12px;
  }

  .mp-badge {
    font-size: 0.8125rem;
  }

  .mp-route {
    font-size: 1.25rem;
  }

  .mp-info-item {
    font-size: 0.875rem;
  }

  .mp-info-price {
    font-size: 1.25rem;
  }

  .mp-btn {
    font-size: 0.875rem;
    padding: 5px 12px;
  }

  .mp-driver-name {
    font-size: 0.75rem;
  }
}

@media (min-width: 1024px) {
  .mp-container {
    max-width: 768px;
    margin: 0 auto;
  }
}

/* ===========================================================
   13. REDUCED MOTION
   =========================================================== */

@media (prefers-reduced-motion: reduce) {
  .mp-card {
    animation: none;
  }

  .mp-card--new {
    animation: none;
  }

  .mp-card--removing {
    animation: none;
    display: none;
  }

  .mp-freshness-dot--active {
    animation: none;
  }
}

/* ===========================================================
   14. PERFORMANCE: GPU acceleration
   =========================================================== */

.mp-card,
.mp-card-link {
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

.mp-card:active,
.mp-btn:active {
  transform: scale(0.97);
  transition: transform 80ms ease;
}