/* News Discover UI — dark theme, iPad-portrait first.
   Targets 590px content column on iPad portrait (≈ Perplexity Discover).
   See docs/NEWS_DISCOVER_UI_DESIGN.md for the measured rhythm. */
:root {
  --bg: #0b0b0d;
  --surface: #131318;
  --surface-2: #1c1c22;
  --fg: #ededf0;
  --fg-mute: #a8a8b3;
  --fg-dim: #6a6a78;
  --accent: #4aa3ff;
  --bullet-bold: #f4d35e;
  --gap-card: 32px;
  --gap-internal: 16px;
  --radius: 14px;
  --content-w: 590px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.6; }

header.site {
  max-width: var(--content-w);
  margin: 24px auto 12px;
  padding: 0 16px;
}

header.site h1 {
  font-size: 28px; font-weight: 700; margin: 0 0 4px;
  letter-spacing: -0.01em;
}

header.site .date {
  color: var(--fg-mute); font-size: 14px;
}

main {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 16px;
}

/* Filter pill rows — sit above the feed, one row per filter kind
   (Sources, Topics). Single-select per row; active pill again to clear.
   Pills scroll horizontally on overflow so long source lists don't
   wrap into a tall block above the feed. */
nav.filters {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 8px 16px 0;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.filter-row-label {
  flex: 0 0 auto;
  color: var(--fg-mute);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: 60px;
}

.filter-row-pills {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.filter-row-pills::-webkit-scrollbar { display: none; }

.filter-pill {
  flex: 0 0 auto;
  background: var(--surface-2);
  color: var(--fg-mute);
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: rgba(74,163,255,0.10);
}

.filter-pill:hover { background: #2a2a32; color: var(--fg); }

.filter-pill.active {
  background: rgba(74,163,255,0.14);
  color: var(--accent);
  border-color: rgba(74,163,255,0.4);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: var(--gap-card);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04);
}

.hero {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-2);
  position: relative;
}

.hero.gradient {
  background: linear-gradient(135deg, var(--brand-1, #333) 0%, var(--brand-2, #555) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.55);
  border-radius: 4px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.hero.gradient .glyph {
  font-size: 52px; font-weight: 800; opacity: 0.4; color: white;
  letter-spacing: -0.02em;
}

.card .body { padding: var(--gap-internal); }

.card h2 {
  font-size: 22px; font-weight: 700; line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .description {
  /* Match bullet font color (var(--fg) bright white) — earlier this was
     dimmer (--fg-mute) which read as "less important" against the bullets
     below it. Lead is the most-information-dense line on the card; should
     read with the same prominence as bullets. */
  color: var(--fg);
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
  transition: -webkit-line-clamp 0.2s;
}

/* When the card is expanded, unclamp the description so the full lead
   shows in place. Keep the same font/color so there's no visual
   transition — just more text revealed. */
.card details[open] .description {
  -webkit-line-clamp: unset;
  display: block;
  margin-bottom: 0;  /* gap to first bullet handled by .body padding below */
}

/* Tighten body padding-bottom only when expanded — collapsed cards
   keep their normal padding for visual balance with the hero above,
   but when bullets are revealed below, that extra padding stacks with
   the description-to-bullets gap and reads as an extra empty line. */
.card details[open] .body { padding-bottom: 10px; }

/* The collapsed card shows hero + headline + lead only — no source
   pill, no date. Attribution lives inline at the end of bullets when
   the card is expanded, and a date pill sits at the bottom of the
   expanded block. Earlier the footer carried both source + date in
   the collapsed view; that was retired so the collapsed card reads
   as a clean summary, not metadata. */

/* Bottom of the expanded card carries tag chips + the date pill on the
   same line, separated by gap. Tags are LLM-derived from a controlled
   vocabulary (sports / entertainment / tech / ai / business /
   politics-world / crime / local / science-health / opinion / misc)
   and exist for future filter-chip UI; for now they read as topic
   metadata at the bottom of each expanded card. */
.card-footer {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.card-date {
  display: inline-block;
  background: var(--surface-2);
  color: var(--fg-dim);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
}

.tag-pill {
  display: inline-block;
  background: rgba(74,163,255,0.10);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

/* The entire collapsed card IS the summary — hero + headline + lead +
   footer. Tapping anywhere on it toggles expansion. */
.card details summary {
  cursor: pointer;
  list-style: none;
  display: block;
  -webkit-tap-highlight-color: rgba(255,255,255,0.04);
}
.card details summary::-webkit-details-marker { display: none; }
.card details summary::marker { display: none; }
.card details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Expanded content (bullets + citations) sits below the summary. */
.card .expanded {
  padding: 0 var(--gap-internal) var(--gap-internal);
}

.card ul.bullets {
  list-style: none; margin: 0; padding: 0;
}

.card ul.bullets li {
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 15px; line-height: 1.5;
}

/* No top border on the first bullet — the lead's bottom margin (8px)
   already provides separation from the headline/description above. */
.card ul.bullets li:first-child {
  border-top: none;
  padding-top: 0;
}

.card ul.bullets li strong {
  color: var(--bullet-bold);
  font-weight: 600;
}

/* Citation pill: lives INLINE at the end of the bullet sentence
   (Apple News Discover style), not as a separate row below. The
   pill flows as part of the text so a line wrap is natural and
   the visual treatment ("source · +N") reads as continuation of
   the sentence rather than a metadata block. */
.cit-pill {
  display: inline-block;
  background: var(--surface-2);
  color: var(--fg-mute);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  text-decoration: none;
  margin-left: 4px;
  vertical-align: 1px;  /* nudge baseline so pill sits inline with text */
  white-space: nowrap;  /* don't let "+N" wrap away from the source name */
}

.cit-pill .more { color: var(--fg-dim); margin-left: 4px; }

.cit-pill:hover { background: #2a2a32; }

footer.site {
  max-width: var(--content-w);
  margin: 24px auto 64px;
  padding: 0 16px;
  color: var(--fg-dim);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 620px) {
  :root { --content-w: 100vw; --gap-card: 28px; }
  header.site { margin: 16px auto 8px; }
}
