/* Feed page styles — extends theme.css */

/* === PAGE STRUCTURE === */
.feed-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px 64px;
  overflow-x: hidden;
}

.feed-page-header {
  padding: 32px 0 0;
  margin-bottom: 0;
}

.feed-page-desc {
  font-size: 0.88rem;
  color: var(--mid-gray);
  margin: 8px 0 20px;
  padding: 0;
}

/* === CATEGORY TABS === */
.category-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.cat-tab {
  background: none;
  border: 1px solid var(--border);
  padding: 7px 18px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dark-gray);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
}

.cat-tab:hover { border-color: var(--navy); color: var(--navy); }
.cat-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

/* === STATES === */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 0;
  gap: 16px;
  color: var(--mid-gray);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 0;
  gap: 12px;
  color: var(--dark-gray);
}

.empty-state .empty-icon { font-size: 3rem; }
.empty-state h3 { font-size: 1.3rem; color: var(--charcoal); }
.empty-state p { font-size: 0.9rem; max-width: 400px; line-height: 1.6; }

.error-state {
  padding: 60px 0;
  text-align: center;
  color: var(--red);
}

/* === FEATURED === */
.featured-section { margin-bottom: 28px; }
.featured-section .section-header { margin-bottom: 20px; }

.featured-card {
  background: var(--navy);
  color: var(--white);
  border-left: 4px solid var(--red);
  display: flex;
  flex-direction: row;
  overflow: hidden;
  text-decoration: none;
  transition: box-shadow 0.2s;
}

a.featured-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.25); }

.featured-img-wrap {
  flex: 0 0 280px;
  height: 220px;
  overflow: hidden;
}

.featured-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

.featured-body {
  flex: 1;
  padding: 32px 36px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.featured-card:hover .featured-headline { color: #f0c040; }

.featured-headline {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 10px;
  color: var(--white);
  transition: color 0.2s;
}

.featured-author {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
  margin: 0 0 10px;
}

.featured-excerpt {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.5;
  margin: 0;
}

.featured-card .card-footer { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* === FEED GRID === */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.feed-card {
  background: var(--white);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
}

.feed-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }

.feed-card a { text-decoration: none; }
.feed-card a:hover .card-headline { color: var(--red); }

.card-img-wrap {
  display: block;
  width: 100%;
  height: 160px;
  overflow: hidden;
  flex-shrink: 0;
}

.card-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

/* Proxy images — enforce 400px max per Fair Use requirement */
.card-img-wrap img,
.featured-img-wrap img {
  max-width: 100%;
  max-height: 100%;
}

/* Lazy-load placeholder — grey background while image is pending */
.lazy-img {
  background-color: var(--off-white, #f4f1ec);
  transition: opacity 0.3s ease;
  opacity: 0;
}

.lazy-img--loaded,
.lazy-img[src] {
  opacity: 1;
}

.card-category {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--red);
  margin: 16px 24px 6px;
}

.card-headline {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.0rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  margin: 0 24px 8px;
  transition: color 0.2s;
}

.card-author {
  font-size: 0.72rem;
  color: var(--mid-gray);
  margin: 0 24px 6px;
}

.card-excerpt {
  font-size: 0.82rem;
  color: var(--dark-gray);
  line-height: 1.5;
  margin: 0 24px 12px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 24px 18px;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.card-deeper {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 24px 16px;
  margin-top: 0;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  background: transparent;
}
.card-deeper-link {
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-deeper-link:hover { text-decoration: underline; color: var(--red); }

.source-tag {
  color: var(--type-source);
  font-weight: 600;
  text-decoration: none;
}
.source-tag:hover { text-decoration: underline; }

.card-time { color: var(--mid-gray); }

/* === TYPE TAGS (extended from theme.css) === */
.type-tag { text-decoration: none; }

/* === LOAD MORE === */
.load-more-container {
  text-align: center;
  padding: 16px 0 32px;
}

.load-more-btn {
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: 12px 40px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s;
}

.load-more-btn:hover { background: var(--red); }

/* Fetch button */
.btn-fetch {
  background: var(--red);
  color: var(--white);
  border: none;
  padding: 10px 28px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  margin-top: 12px;
  transition: background 0.2s;
}
.btn-fetch:hover { background: var(--red-dark); }
.btn-fetch:disabled { background: var(--mid-gray); cursor: default; }

/* Source type pills (legend) */
.source-types {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

/* === SEARCH PAGE === */
.search-page .search-form-inline {
  display: flex;
  gap: 6px;
  margin: 16px 0 24px;
  max-width: 480px;
}
.search-page .search-form-inline input[type=search] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  font: inherit;
  border-radius: 2px;
  background: var(--white);
  color: var(--charcoal);
}
.search-page .search-form-inline input[type=search]:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-color: var(--red);
}
.search-page .search-form-inline button {
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: 10px 22px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s;
}
.search-page .search-form-inline button:hover { background: var(--red); }
.search-page .search-form-inline button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.search-page .search-status {
  font-size: 0.88rem;
  color: var(--mid-gray);
  margin-bottom: 24px;
}
.search-page .card-snippet {
  font-size: 0.82rem;
  color: var(--dark-gray);
  line-height: 1.55;
  margin: 0 24px 12px;
}

/* === BOOKMARKS === */
.bookmark-btn {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--dark-gray);
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}

.bookmark-btn svg {
  fill: none;
  stroke: currentColor;
  width: 24px;
  height: 24px;
  display: block;
  transition: fill 0.2s, stroke 0.2s;
}

.featured-body .bookmark-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.8);
}

.feed-card .bookmark-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.bookmark-btn:hover svg { stroke: var(--red); }

.bookmark-btn--saved svg {
  fill: var(--red);
  stroke: var(--red);
}

.bookmark-btn:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.bookmark-btn--just-saved {
  animation: bookmark-pop 200ms ease-out;
}

@keyframes bookmark-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.bookmark-count {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
}

.bookmark-count[hidden] { display: none; }

/* Soft "Upgrade to save" nudge shown to non-subscribers after a tap.
   Matches the feed-promo-bar palette (--mid-gray text, --navy hover) so the
   nudge reads as a follow-up to the rest of the page, not a hard error. */
.bookmark-upgrade-nudge {
  display: block;
  margin: 8px 0 12px;
  padding: 0;
  font-size: 0.78rem;
  color: var(--mid-gray);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.15s;
}

.bookmark-upgrade-nudge:hover {
  color: var(--navy);
}

/* Transient error toast shown when a subscriber's save/unsave fails so the
   button doesn't silently get stuck in the wrong state. */
.bookmark-error-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 10px 18px;
  font-size: 0.85rem;
  border-radius: 2px;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s;
}

.bookmark-error-toast--fading { opacity: 0; }

/* === SHARE BUTTONS === */
.share-group {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.share-btn {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--dark-gray);
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}

.share-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: none;
  display: block;
  transition: color 0.2s;
}

.featured-body .share-btn {
  position: absolute;
  top: 12px;
  right: 52px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.8);
}

.featured-body .share-btn:hover { color: var(--white); }

.feed-card .share-btn {
  position: absolute;
  top: 12px;
  right: 52px;
  z-index: 2;
}

.share-btn[data-share-target="x"]:hover { color: #000; }
.share-btn[data-share-target="facebook"]:hover { color: #1877f2; }
.share-btn[data-share-target="copy"]:hover { color: var(--red); }

.share-btn:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.featured-body .share-btn:focus-visible {
  outline-color: var(--white);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .feed-page { padding: 0 20px 48px; }
  .feed-page-header { padding: 20px 0 0; }
  .category-tabs { gap: 6px; }
  /* Featured card: stack image above body on mobile */
  a.featured-card,
  .featured-card {
    flex-direction: column;
  }
  .featured-img-wrap {
    flex: none;
    width: 100%;
    height: 180px;
  }
  .featured-body {
    padding: 24px 20px 20px;
  }
  .featured-headline { font-size: 1.2rem; }
  /* Regular cards: image still shows */
  .card-img-wrap { height: 140px; }
}

/* Phone-first single-column feed grid (small tablets 641–768 keep 2-col) */
@media (max-width: 640px) {
  .feed-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .card-footer { flex-direction: column; align-items: flex-start; gap: 6px; }
  .type-tag { font-size: 0.55rem; }
  .featured-img-wrap { height: 150px; }
  .card-img-wrap { height: 120px; }
  .share-group { margin-left: 0; }

  /* Tighter side gutter at narrowest phone widths */
  .feed-page { padding-left: 12px; padding-right: 12px; }

  /* 44px touch targets on category filter pills */
  .cat-tab {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 14px;
    padding-right: 14px;
  }

  /* 44px touch targets on bookmark and share icon buttons */
  .bookmark-btn { width: 44px; height: 44px; }
  .share-btn    { width: 44px; height: 44px; }

  /* Shift share btn leftward so it clears the 44px bookmark btn */
  .feed-card .share-btn { right: 56px; }

  /* 44px touch targets on in-card links/CTAs that are wrapped in anchors */
  .card-img-wrap { min-height: 44px; }
  .card-alert-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .podcast-badge {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .section-cta-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* 44px tap target on Load More — current 12px vertical padding
     only clears 37px which is undersized for finger taps */
  .load-more-btn {
    min-height: 44px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  /* Tighten card internal horizontal padding to 16px on 360px screens */
  .card-category { margin-left: 16px; margin-right: 16px; }
  .card-headline { margin-left: 16px; margin-right: 16px; }
  .card-author   { margin-left: 16px; margin-right: 16px; }
  .card-excerpt  { margin-left: 16px; margin-right: 16px; }
  .card-footer   { padding-left: 16px; padding-right: 16px; }
  .card-deeper   { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 375px) {
  /* Hero / card images use aspect-ratio so they scale proportionally
     with the single-column width instead of a fixed-pixel height that
     dominates the iPhone-class viewport. Capped so landscape phones
     don't produce a giant image. */
  .featured-img-wrap { height: auto; aspect-ratio: 16 / 9; max-height: 180px; }
  .card-img-wrap      { height: auto; aspect-ratio: 16 / 9; max-height: 160px; }

  /* Tighter vertical rhythm so stacked single-column cards feel compact. */
  .feed-grid { gap: 16px; }

  /* Comfortable line-length gutter for the narrowest phones. */
  .feed-page { padding-left: 16px; padding-right: 16px; }

  /* Drop the duplicated horizontal margins so the card body itself
     becomes the line-length boundary. */
  .card-category,
  .card-headline,
  .card-author,
  .card-excerpt,
  .card-footer { margin-left: 0; margin-right: 0; padding-left: 16px; padding-right: 16px; }
  .card-deeper { margin-left: 0; margin-right: 0; padding-left: 16px; padding-right: 16px; }

  .featured-body { padding: 20px 18px 18px; }

  /* 44px tap targets — source-tag and type-tag are sometimes wrapped
     in anchors, so we hard-enforce the minimum on both. */
  .source-tag {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .type-tag {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .card-deeper-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* === PODCAST BADGE (inline card marker; podcast cards are NOT grouped separately anymore) === */
.podcast-badge {
  display: inline-block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a01b1b;
  background: rgba(160, 27, 27, 0.08);
  border: 1px solid rgba(160, 27, 27, 0.25);
  border-radius: 3px;
  padding: 2px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

/* === SUBSCRIBER-ONLY ALERT LINK (per-card discoverability) === */
.card-alert-link {
  display: inline-block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  background: transparent;
  border: 1px solid rgba(196, 30, 58, 0.35);
  border-radius: 3px;
  padding: 2px 6px;
  margin-left: 6px;
  vertical-align: middle;
  text-decoration: none;
}
.card-alert-link:hover { background: var(--red); color: #ffffff; }

/* === VIDEO EMBEDS SECTION === */
.video-section {
  margin: 0 0 36px;
  padding: 28px 0 0;
  border-top: 2px solid var(--red);
}

.video-section .section-header { margin-bottom: 20px; }

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 0;
}

.video-card {
  background: var(--white);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.video-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

.video-embed-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  background: var(--ink);
}

.video-embed-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.video-card-body {
  padding: 12px 16px 16px;
}

.video-creator {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--type-influencer);
  margin-bottom: 4px;
}

.video-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

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

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

/* === AD SLOTS === */
.ad-slot-wrap {
  margin: 0 0 28px;
  border: 1px solid var(--border);
  background: var(--off-white);
  border-radius: 2px;
  overflow: hidden;
  text-align: center;
}

.ad-slot-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--mid-gray);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--border);
}

.ad-slot-inner {
  padding: 12px;
  min-height: 0;
}

/* Hide wrapper entirely when inner slot is empty (before AdSense delivers) */
.ad-slot-wrap:has(.ad-slot-inner:empty) {
  display: none;
}

@media (max-width: 768px) {
  .ad-slot-wrap {
    margin: 0 0 20px;
  }
}