/* =============================================================================
   zz_feed_layout.css — feed column + vertical density (UI redesign Phase 1c).
   Program doc: docs/ui_redesign_kickoff.md (§1c + 2026-07-13 density feedback).

   zz_ prefix = loads AFTER styles.css, so equal-specificity !important rules
   here win by cascade order. Feed and detail share the same card column;
   page controls and inter-post spacing below are specific to the main feed.
   FEED_MAIN_MAX_WIDTH in pages/feed/layout.py keeps the shared Container
   fallback; this desktop-only override sizes both card surfaces together.
   Reels video wrappers keep their own tighter spacing via the higher-
   specificity :has(.sp-reels-video-card) rules in styles.css — untouched.
   ============================================================================= */

/* Quiet introduction, aligned with the feed and its discovery controls. */
#main-feed-shell .feed-intro {
  padding: 28px 0 20px;
  margin: 0;
}

#main-feed-shell .feed-intro__title {
  max-width: 25ch;
  margin: 0;
  color: var(--feed-title, #f3f4f6);
  font-family: var(--sp-font-ui);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

#main-feed-shell .feed-intro__copy {
  margin: 10px 0 0;
  color: var(--feed-subtitle, #b6bac5);
  font-size: 0.875rem;
  line-height: 1.55;
  text-wrap: pretty;
}

@media (max-width: 767px), (max-height: 600px) and (pointer: coarse) {
  #main-feed-shell .feed-intro {
    padding: 22px 0 18px;
  }
}

/* ---- Desktop: 85% content column + tighter post rhythm --------------------- */
@media (min-width: 641px) {
  :is(#main-feed-shell.main-feed-page-shell, #detail-feed-shell.detail-page-shell) {
    /* 540px × 85% = 459px: reduce portrait video height proportionally,
       with the controls and loading skeleton aligned to the same column. */
    --feed-main-column-width: 459px;
  }

  #main-feed-shell.main-feed-page-shell #results-cards-container {
    gap: 10px !important;
  }

  /* The retired sort segment retains its compact layout. The active tabs'
     dimensions belong to zz_feed_controls.css. */
  #main-feed-shell.main-feed-page-shell .feed-order-segment .mantine-SegmentedControl-label {
    padding-inline: 9px !important;
    font-size: 0.8rem !important;
  }
}

/* Approved Clear treatment: align discovery text to the media's text inset.
   The desktop media remains 459 - 2*18 = 423px. */
#main-feed-shell.main-feed-page-shell .sp-discovery-hero {
  padding: 0 0 16px !important;
}

#main-feed-shell.main-feed-page-shell .sp-discovery-hero > .mantine-Container-root {
  padding-inline: 34px !important;
}

#main-feed-shell.main-feed-page-shell .sp-discovery-hero > .mantine-Container-root > .mantine-Stack-root {
  gap: 0 !important;
}

#main-feed-shell.main-feed-page-shell #feed-container {
  margin-top: 0 !important;
}

#main-feed-shell.main-feed-page-shell #results-cards-container:has(.sp-feed-post) {
  gap: 20px !important;
}

/* Gap has one owner; don't add a post margin to the stack's gap. */
#main-feed-shell.main-feed-page-shell #results-cards-container .sp-feed-post {
  margin-bottom: 0 !important;
}

/* No side gutters on phones, including landscape. The ratio is still owned
   by video metadata; neither card nor media gets a new height constraint. */
@media (max-width: 767px), (max-height: 600px) and (pointer: coarse) {
  #main-feed-shell.main-feed-page-shell {
    --feed-main-column-width: 100%;
    padding-inline: 0 !important;
  }

  #main-feed-shell.main-feed-page-shell #feed-container,
  #main-feed-shell.main-feed-page-shell .sp-feed {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
    padding-inline: 0 !important;
  }

  #main-feed-shell.main-feed-page-shell .sp-discovery-hero > .mantine-Container-root {
    padding-inline: 12px !important;
  }

  #main-feed-shell.main-feed-page-shell #results-cards-container:has(.sp-feed-post) {
    gap: 16px !important;
  }
}

/* ---- Mobile: tighten the inter-post gap (was 17px card top + 14px pad +
   16px margin ≈ 47px between posts; now ≈ 28px, divider kept) --------------- */
@media (max-width: 640px) {
  #main-feed-shell.main-feed-page-shell .feed-card-enter,
  #main-feed-shell.main-feed-page-shell #feed-initial-skeleton {
    padding-bottom: 8px !important;
    margin-bottom: 8px !important;
  }

  #main-feed-shell.main-feed-page-shell .sp-feed-card-shell,
  #main-feed-shell.main-feed-page-shell #feed-initial-skeleton > .mantine-Card-root {
    padding-top: 12px !important;
    padding-bottom: 10px !important;
  }
}

/* =============================================================================
   1d — controls row: sort select pill + topic chip row overflow fade
   ============================================================================= */

/* Sort select pill (dmc.Select, id select-order — replaced the 3-segment
   control; .feed-order-segment rules in zz_feed_controls.css are now unused). */
#main-feed-shell.main-feed-page-shell .feed-order-select .mantine-Select-input {
  height: 34px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid var(--feed-border, rgba(148, 163, 184, 0.28));
  background: color-mix(in srgb, var(--feed-input-bg, #ffffff) 88%, transparent);
  color: var(--feed-text, inherit);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}
#main-feed-shell.main-feed-page-shell .feed-order-select .mantine-Select-section {
  color: var(--feed-muted, var(--feed-subtitle, #6b7280));
}

/* One-row topic chips: fade out at the right edge instead of hard-clipping. */
#main-feed-shell.main-feed-page-shell .feed-topic-wrap {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent);
}

/* =============================================================================
   1e — states: post-shaped loading skeleton
   (#feed-initial-skeleton internals; the old card-skeleton CSS that targeted
   `#feed-initial-skeleton > .mantine-Card-root` is inert against the new DOM)
   ============================================================================= */

#main-feed-shell.main-feed-page-shell .feed-skel-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#main-feed-shell.main-feed-page-shell .feed-skel-reel {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: color-mix(in srgb, var(--feed-card-bg, #101826) 82%, transparent);
}

/* The sp-feed / sp-feed-post classes share the loaded cards' gutters, header
   spacing and corners. zz_statspoint.css shares their placeholder aspect. */
#main-feed-shell.main-feed-page-shell .feed-skel-author {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#main-feed-shell.main-feed-page-shell #feed-initial-skeleton {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

#main-feed-shell.main-feed-page-shell #feed-initial-skeleton::after {
  display: none !important;
}

@media (max-width: 640px) {
  #main-feed-shell.main-feed-page-shell .feed-skel-stack {
    gap: 0;
  }
}
