/* ─── Feed Card — Mobile-first social card ───────────────────────────────────
 * Mobile default: full-width, edge-to-edge, no border-radius.
 * Desktop (≥ 600px): rounded card with max-width and spacing.
 * Touch targets: all interactive elements ≥ 48px tall.
 * No hover transforms — use active state for tactile feedback instead.
 * ─────────────────────────────────────────────────────────────────────────── */

/* ── Card container ────────────────────────────────────────────────────────── */
.feed-card {
  background: var(--white);
  border-bottom: 1px solid var(--cream-dark);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  /* Edge-to-edge on mobile — no radius, no side margins */
  border-radius: 0;
  /* Subtle active feedback on tap */
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.feed-card:active {
  background: var(--cream);
}

/* ── Image ─────────────────────────────────────────────────────────────────── */
.feed-card__image-link {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  /* Explicit max-height fallback for browsers where aspect-ratio alone
     doesn't constrain a very tall image */
  max-height: 320px;
  overflow: hidden;
  background: var(--cream-dark);
  flex-shrink: 0;
}

/* When image lives inside the padded body, give it rounded corners */
.feed-card__body .feed-card__image-link {
  border-radius: var(--radius-md);
  max-height: 240px;
}

.feed-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* GPU layer for smooth transitions */
  will-change: transform;
  transition: transform 0.4s ease;
}

/* ── Image placeholder (no image attached) ─────────────────────────────────── */
.feed-card__image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.12) 0%, rgba(26, 26, 46, 0.08) 100%);
}

/* Per-category placeholder gradients */
.feed-card__image-placeholder--animals    { background: linear-gradient(135deg, rgba(76, 175, 80, 0.15) 0%, rgba(26, 46, 26, 0.06) 100%); }
.feed-card__image-placeholder--food       { background: linear-gradient(135deg, rgba(255, 112, 67, 0.15) 0%, rgba(46, 26, 20, 0.06) 100%); }
.feed-card__image-placeholder--history    { background: linear-gradient(135deg, rgba(141, 110, 99, 0.15) 0%, rgba(30, 24, 22, 0.06) 100%); }
.feed-card__image-placeholder--science    { background: linear-gradient(135deg, rgba(66, 165, 245, 0.15) 0%, rgba(20, 30, 46, 0.06) 100%); }
.feed-card__image-placeholder--sports     { background: linear-gradient(135deg, rgba(236, 64, 122, 0.15) 0%, rgba(46, 20, 30, 0.06) 100%); }
.feed-card__image-placeholder--technology { background: linear-gradient(135deg, rgba(126, 87, 194, 0.15) 0%, rgba(30, 20, 46, 0.06) 100%); }
.feed-card__image-placeholder--geography  { background: linear-gradient(135deg, rgba(38, 166, 154, 0.15) 0%, rgba(20, 40, 38, 0.06) 100%); }
.feed-card__image-placeholder--entertainment { background: linear-gradient(135deg, rgba(255, 167, 38, 0.15) 0%, rgba(46, 38, 20, 0.06) 100%); }
.feed-card__image-placeholder--health     { background: linear-gradient(135deg, rgba(102, 187, 106, 0.15) 0%, rgba(26, 40, 26, 0.06) 100%); }
.feed-card__image-placeholder--politics   { background: linear-gradient(135deg, rgba(183, 28, 28, 0.12) 0%, rgba(40, 20, 20, 0.06) 100%); }
.feed-card__image-placeholder--showbiz    { background: linear-gradient(135deg, rgba(249, 168, 37, 0.15) 0%, rgba(46, 40, 20, 0.06) 100%); }
.feed-card__image-placeholder--miscellaneous { background: linear-gradient(135deg, rgba(120, 144, 156, 0.15) 0%, rgba(26, 30, 32, 0.06) 100%); }

.feed-card__placeholder-quote {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 900;
  color: rgba(245, 166, 35, 0.2);
  line-height: 1;
  user-select: none;
}

/* ── Body ──────────────────────────────────────────────────────────────────── */
.feed-card__body {
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.feed-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.feed-card__title-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.feed-card__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.feed-card__summary {
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.65;
  /* Clamp to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* ── Action bar — lives in thumb zone ─────────────────────────────────────── */
.feed-card__actions {
  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--space-1) var(--space-3) var(--space-3);
  border-top: 1px solid var(--cream-dark);
  margin-top: var(--space-1);
}

/* Like / heart button */
.feed-card__like {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  /* Touch target: min 48px */
  min-height: 48px;
  min-width: 64px;
  padding: 0 var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-muted);
  transition:
    color var(--transition),
    background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.feed-card__like:active {
  background: rgba(232, 69, 60, 0.08);
}

.feed-card__like-icon {
  fill: currentColor;
  flex-shrink: 0;
  transition: fill var(--transition), transform 0.15s ease;
}

.feed-card__like--active {
  color: var(--red);
}

.feed-card__like--active .feed-card__like-icon {
  fill: var(--red);
}

/* Heart pop animation on like */
@keyframes heart-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.feed-card__like--pop .feed-card__like-icon {
  animation: heart-pop 0.35s ease forwards;
}

.feed-card__like-count {
  font-variant-numeric: tabular-nums;
  min-width: 1.5ch;
}

/* Share button */
.feed-card__share {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-muted);
  transition:
    color var(--transition),
    background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.feed-card__share:active {
  background: rgba(26, 26, 46, 0.06);
  color: var(--ink);
}

.feed-card__share-icon {
  fill: currentColor;
  flex-shrink: 0;
}

/* Read more — right-anchored */
.feed-card__read-more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 48px;
  padding: 0 var(--space-3);
  margin-left: auto;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--amber-dark);
  text-decoration: none;
  white-space: nowrap;
  transition:
    color var(--transition),
    gap var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.feed-card__read-more:active {
  color: var(--ink);
}

.feed-card__read-more svg {
  fill: currentColor;
  flex-shrink: 0;
  transition: transform var(--transition);
}

/* ── Share bottom sheet ────────────────────────────────────────────────────── */
.share-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26, 26, 46, 0);
  transition: background 0.3s ease;
}

.share-backdrop--open {
  background: rgba(26, 26, 46, 0.55);
}

.share-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-3) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  /* Max width so it doesn't span full desktop */
  max-width: 480px;
  margin-inline: auto;
}

.share-sheet--open {
  transform: translateY(0);
}

.share-sheet__handle {
  width: 40px;
  height: 4px;
  background: var(--cream-dark);
  border-radius: var(--radius-pill);
  margin: 0 auto var(--space-4);
}

.share-sheet__title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  margin-bottom: var(--space-4);
}

.share-sheet__options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.share-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 80px;
  padding: var(--space-3);
  background: var(--cream);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.share-option svg {
  fill: currentColor;
  flex-shrink: 0;
}

.share-option:active,
.share-option--copied {
  background: var(--amber-light);
  border-color: var(--amber);
  color: var(--ink);
}

.share-option--twitter { color: var(--ink-soft); }
.share-option--twitter:active { background: rgba(0, 0, 0, 0.05); color: #000; }

.share-option--facebook { color: var(--ink-soft); }
.share-option--facebook:active { background: rgba(24, 119, 242, 0.08); color: #1877f2; }

.share-sheet__close {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: var(--space-3);
  background: var(--cream);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-align: center;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.share-sheet__close:active {
  background: var(--cream-dark);
  color: var(--ink);
}

/* ── Feed spinner ──────────────────────────────────────────────────────────── */
.feed-sentinel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
}

.feed-sentinel__label {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.feed-sentinel--error .feed-sentinel__label {
  color: var(--red);
}

.feed-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.feed-spinner__ring {
  width: 32px;
  height: 32px;
  border: 3px solid var(--cream-dark);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ── Feed end state ────────────────────────────────────────────────────────── */
.feed-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  text-align: center;
}

.feed-end__text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.feed-end__link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--amber-dark);
}

/* ── Desktop enhancements (≥ 600px) ───────────────────────────────────────── */
@media (min-width: 600px) {
  .feed-card {
    border-radius: var(--radius-lg);
    border: 1px solid rgba(26, 26, 46, 0.06);
    box-shadow: var(--shadow-sm);
    /* No translateY hover — use a subtle shadow lift instead */
    transition:
      box-shadow var(--transition),
      background var(--transition);
  }

  .feed-card:hover {
    box-shadow: var(--shadow-md);
  }

  .feed-card:hover .feed-card__image {
    transform: scale(1.02);
  }

  .feed-card__title {
    font-size: 1.2rem;
  }

  .share-sheet {
    /* On desktop, show as a centered floating sheet, not bottom-anchored */
    top: 50%;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translate(-50%, -40%) scale(0.96);
    opacity: 0;
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    min-width: 360px;
    transition:
      transform 0.25s cubic-bezier(0.32, 0.72, 0, 1),
      opacity 0.25s ease;
  }

  .share-sheet--open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  .share-sheet__handle {
    display: none;
  }
}
