/* Home (views/feed.js), Discover (views/discover.js) and Library (views/library.js), with the paged list they share
   (views/feed/pager.js). Tokens come from design.css, shared pieces from base.css. */

/* --- Paged lists ------------------------------------------------------------- */
.pager-item { min-width: 0; }
.pager-sentinel { height: 1px; }
.pager-foot { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 8px; }
.pager-foot:empty { display: none; }
.pager-foot .button { min-width: 180px; }
.pager-foot .button[aria-disabled="true"] { opacity: .6; cursor: progress; }
.pager-error { color: var(--danger); font-size: 13px; text-align: center; }
.pager-end { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 18px 0 6px; }
.pager > [data-pager-items] { margin-top: 0; }
.pager-lead + [data-pager-items] { margin-top: 44px; padding-top: 36px; border-top: 1px solid var(--rule); }

/* The first post of a list leads: picture and large title side by side. */
.pager-lead .entry-card { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 0 36px; align-items: stretch; }
.pager-lead .entry-cover { aspect-ratio: 3 / 2; }
.pager-lead .entry-details { padding-top: 4px; justify-content: center; }
.pager-lead .entry-title { font-size: clamp(26px, 3.2vw, 42px); line-height: 1.08; letter-spacing: -.045em; margin: 12px 0 14px; }
.pager-lead .entry-excerpt { font-size: 15px; -webkit-line-clamp: 4; line-clamp: 4; }
.pager-lead .entry-card-footer { padding-top: 22px; }

/* --- Home -------------------------------------------------------------------- */
.feed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: start; }
.feed-main { min-width: 0; }
.feed-list-head { margin-top: 8px; }
.feed-list-head h2 { color: var(--ink); }
.feed-list { min-height: 120px; }

.feed-controls { display: grid; gap: 18px; margin-bottom: 26px; }
.feed-controls .tabs { margin-bottom: 0; }
.feed-filters { display: grid; gap: 14px; min-width: 0; }

/* A segmented control (post type) and a row of topics. Square, fine rules, the chosen one inked in. */
.seg { display: inline-flex; max-width: 100%; border: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.seg-button { flex: 0 0 auto; min-height: 38px; padding: 0 18px; border: 0; border-left: 1px solid var(--rule); background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.seg-button:first-child { border-left: 0; }
.seg-button:hover { color: var(--ink); background: var(--wash); }
.seg-button.is-active, .seg-button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg-button:focus-visible { outline-offset: -3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 22px; min-width: 0; }
.chip { flex: 0 0 auto; min-height: 32px; padding: 0 0 2px; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.chip:hover { color: var(--ink); }
.chip.is-active, .chip[aria-pressed="true"] { color: var(--bronze); border-bottom-color: var(--bronze); }

.feed-notice-region:empty { display: none; }
.feed-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-bottom: 20px; padding: 12px 16px; background: var(--wash); border-left: 2px solid var(--bronze); font-size: 13px; line-height: 1.5; }
.feed-notice .text-button { font-weight: 600; }
.feed-suggest { margin-top: 36px; }

/* The welcome and the invitation to join. */
.welcome-card, .join-card { display: flex; gap: 20px; margin-bottom: 36px; padding: 26px 28px; border: 1px solid var(--rule); background: var(--white); }
.welcome-card { align-items: flex-start; justify-content: space-between; border-left: 2px solid var(--bronze); }
.welcome-text { max-width: 60ch; }
.welcome-text h2, .join-card h2 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -.04em; margin: 8px 0 10px; }
.welcome-text p:not(.eyebrow), .join-card p:not(.eyebrow) { color: var(--muted); font-size: 14px; line-height: 1.65; }
.welcome-text .row { margin-top: 18px; gap: 14px 22px; }
.join-card { align-items: center; justify-content: space-between; flex-wrap: wrap; }
.join-card > div:first-child { max-width: 62ch; flex: 1 1 320px; }

/* The rail: your circle, what they said lately, who to follow. */
.feed-rail { display: grid; gap: 36px; position: sticky; top: calc(var(--topbar-h) + 28px); min-width: 0; }
.rail-section { min-width: 0; }
.rail-section .section-head { margin-bottom: 14px; }
.rail-list { display: grid; gap: 4px; margin-bottom: 14px; }
.rail-person { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px 0; }
.rail-person-text { flex: 1; min-width: 0; }
.rail-person-name { display: block; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-person-name:hover { color: var(--bronze); }
.rail-person-text .eyebrow { font-size: 9px; letter-spacing: .12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-more, .rail-empty { font-size: 13px; line-height: 1.6; margin-bottom: 14px; }
.rail-notes { display: grid; gap: 18px; }
.rail-note { padding-left: 14px; border-left: 1px solid var(--rule); }
.rail-note-text { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.rail-note .eyebrow { margin-top: 6px; font-size: 9px; }
.rail-note .eyebrow a { text-decoration: underline; text-underline-offset: 3px; }
.rail-footer { font-size: 12px; line-height: 1.7; padding-top: 22px; border-top: 1px solid var(--rule); }

/* --- Discover ---------------------------------------------------------------- */
.discover-search { position: relative; display: flex; align-items: stretch; gap: 12px; max-width: 720px; }
.discover-search > svg { position: absolute; left: 15px; top: 23px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.discover-search input { flex: 1; min-width: 0; min-height: 46px; padding-left: 44px; font-size: 15px; }
.discover-search input::-webkit-search-cancel-button { appearance: none; }
.discover-search .button { flex-shrink: 0; }
.discover-filters { align-items: flex-end; gap: 14px 18px; margin: 22px 0 0; padding-bottom: 20px; border-bottom: 1px solid var(--rule); }
.discover-field { flex: 0 1 190px; min-width: 150px; }
.discover-field label { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.discover-filters .discover-field select { width: 100%; min-width: 0; min-height: 42px; padding-top: 10px; padding-bottom: 10px; font-size: 14px; }
.discover-clear { align-self: center; padding-top: 18px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.discover-results { min-height: 160px; }
.discover-section:first-child { margin-top: 32px; }
.discover-hint { margin-top: 28px; font-size: 13px; }
.discover-results .empty { margin-top: 32px; }

/* --- Library ----------------------------------------------------------------- */
.library-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.library-list { min-height: 120px; }
.library-actions { display: flex; justify-content: flex-start; padding-top: 8px; }
.library-remove { font-size: 12px; color: var(--muted); }
.library-remove:hover { color: var(--danger); }
.library-remove[aria-busy="true"] { opacity: .6; cursor: progress; }

/* --- Smaller screens ----------------------------------------------------------- */
@media (max-width: 1180px) {
  .feed-layout { grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; }
  .pager-lead .entry-card { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .pager-lead .entry-details { padding-top: 14px; }
}

/* Tablets and phones: the rail moves above the list as a short strip, since a list that never ends has no bottom. */
@media (max-width: 1020px) {
  .feed-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .feed-rail { position: static; order: -1; gap: 22px; }
  .feed-rail.is-guest, [data-rail-suggested], .rail-footer, .rail-section .text-link { display: none; }
  .rail-section .section-head { margin-bottom: 10px; }
  .rail-list { display: flex; gap: 22px; margin-bottom: 0; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .rail-person { flex: 0 0 auto; max-width: 220px; }
  .rail-more { display: none; }
  .rail-notes { gap: 12px; }
  .rail-note:nth-child(n+3) { display: none; }
}

@media (max-width: 760px) {
  .welcome-card, .join-card { padding: 20px 18px; margin-bottom: 28px; }
  .welcome-card { gap: 10px; }
  .discover-search { gap: 8px; }
  .discover-search .button { padding-left: 14px; padding-right: 14px; }
  .discover-field { flex: 1 1 140px; }
  .discover-clear { padding-top: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; gap: 6px 20px; }
  .seg { display: flex; }
  .seg-button { flex: 1 1 0; padding: 0 10px; }
  .feed-notice { padding: 12px; }
  .pager-lead + [data-pager-items] { margin-top: 32px; padding-top: 28px; }
}

@media (pointer: coarse) {
  .seg-button, .chip, .library-remove, .feed-notice .text-button, .discover-clear { min-height: 44px; }
  .chip { display: inline-flex; align-items: center; }
  .library-remove, .feed-notice .text-button, .discover-clear { display: inline-flex; align-items: center; }
  .rail-person-name, .rail-person { min-height: 44px; }
  .discover-search input { min-height: 46px; }
  .discover-search > svg { top: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  .pager-foot .button { transition: none; }
}
