/* ---------- Catalog pages: sources.html and topics.html ----------
 * Every source or every section as a card (or a row in the list view) with a few facts: articles
 * today and in 7 days, reads in 7 days, the last article, full-text share, feeds, a 7-day bar and
 * the main sections. The facts are a key-value grid, so more metrics fit in later. Facts only:
 * nothing here rates a source. Topics add the trending tags and an A–Z index of the tags. Builds
 * on lists.css (head, filters), story-widgets.css (columns) and select.css. */

.ct-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 16px; }

/* ---- Card ---- */
.ct-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px; color: var(--text); }
.ct-card-head { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
.ct-card-head .source-avatar, .ct-card-head .panel-icon { grid-row: span 2; width: 44px; height: 44px; font-size: 13px; }
.ct-card-head .panel-icon .icon { width: 22px; height: 22px; font-size: 22px; }
.ct-name { overflow: hidden; font-family: var(--font-heading); font-size: 17px; font-weight: 600; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
a.ct-card:hover .ct-name, .ct-name a:hover { color: var(--color-primary); }
.ct-name a { color: inherit; }
.ct-desc { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ct-status { display: inline-flex; align-items: center; gap: 5px; justify-self: start; color: var(--color-success); font-family: var(--font-mono); font-size: 9px; letter-spacing: .05em; }
.ct-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ct-status.is-error { color: var(--color-danger); }
.ct-status.is-quiet { color: var(--color-warning-text); }
.ct-status-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.ct-host { overflow: hidden; color: var(--muted); font-family: var(--font-mono); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

/* Facts: a key-value grid; a value may be missing ("–") */
.ct-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; border: 1px solid var(--line); background: var(--line); }
.ct-facts div { display: grid; gap: 2px; min-width: 0; padding: 7px 9px; background: var(--panel); }
.ct-facts dt { overflow: hidden; color: var(--muted); font-family: var(--font-mono); font-size: 8px; letter-spacing: .05em; text-overflow: ellipsis; white-space: nowrap; }
.ct-facts dd { margin: 0; overflow: hidden; font-family: var(--font-mono); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ct-facts dd small { color: var(--muted); font-size: 9px; font-weight: 500; }

.ct-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.ct-spark { display: grid; grid-template-columns: repeat(7, 7px); gap: 3px; align-items: end; height: 26px; }
.ct-spark i { display: block; min-height: 2px; height: calc(var(--n) / var(--max) * 100%); border-radius: 2px 2px 0 0; background: color-mix(in oklab, var(--color-primary) 45%, var(--track)); }
.ct-spark i:last-child { background: var(--color-primary); }
.ct-spark-label { display: grid; gap: 4px; color: var(--muted); font-family: var(--font-mono); font-size: 8px; letter-spacing: .05em; }
.ct-sections { display: flex; gap: 4px; }
.ct-sections .panel-icon { width: 24px; height: 24px; }
.ct-sections .panel-icon .icon { width: 13px; height: 13px; font-size: 13px; }
.ct-link { display: inline-flex; align-items: center; gap: 4px; color: var(--color-primary); font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .05em; white-space: nowrap; }
.ct-link:hover { color: var(--color-primary-hover); }

/* Subcategories of a section */
.ct-subs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ct-subs a, .ct-subs span { display: inline-flex; gap: 5px; padding: 2px 7px; border: 1px solid var(--line); color: var(--text); font-size: 11px; }
.ct-subs a small { color: var(--muted); font-family: var(--font-mono); font-size: 9px; }
.ct-subs a:hover { border-color: var(--color-primary); color: var(--color-primary); }
.ct-subs span { color: var(--muted); }

/* ---- List view: one row per source ---- */
.ct-rows { margin: 0; padding: 0 16px; list-style: none; }
.ct-row { display: grid; grid-template-columns: 30px minmax(0, 1.4fr) repeat(5, minmax(0, .7fr)) auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ct-row:last-child { border-bottom: 0; }
.ct-row .source-avatar { width: 30px; height: 30px; }
.ct-row-name { display: grid; gap: 2px; min-width: 0; }
.ct-row-name a { overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ct-row-name a:hover { color: var(--color-primary); }
.ct-row-fact { display: grid; gap: 2px; min-width: 0; }
.ct-row-fact small { color: var(--muted); font-family: var(--font-mono); font-size: 8px; letter-spacing: .05em; }
.ct-row-fact b { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.ct-rows-head { display: grid; grid-template-columns: 30px minmax(0, 1.4fr) repeat(5, minmax(0, .7fr)) auto; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: .05em; }

/* ---- Topics: trending tags and the A–Z index ---- */
.ct-trending { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 14px 16px; list-style: none; }
.ct-tag { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); color: var(--text); font-size: 13px; font-weight: 600; }
.ct-tag:hover { border-color: var(--color-primary); color: var(--color-primary); }
.ct-tag small { color: var(--muted); font-family: var(--font-mono); font-size: 9px; font-weight: 500; }
.ct-tag .icon { color: var(--color-primary); font-size: 14px; }
.ct-letters { display: flex; flex-wrap: wrap; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ct-letters a, .ct-letters span { display: grid; place-items: center; min-width: 28px; height: 28px; border: 1px solid var(--line); color: var(--text); font-family: var(--font-mono); font-size: 11px; }
.ct-letters a:hover { border-color: var(--color-primary); color: var(--color-primary); }
.ct-letters span { color: var(--muted); opacity: .4; }
.ct-az { columns: 3 220px; column-gap: 28px; column-rule: 1px solid var(--line); padding: 14px 16px; }
.ct-az section { break-inside: avoid; margin-bottom: 14px; }
.ct-az h3 { margin: 0 0 6px; color: var(--color-primary); font-family: var(--font-mono); font-size: 14px; font-weight: 600; scroll-margin-top: 16px; }
.ct-az ul { display: grid; margin: 0; padding: 0; list-style: none; }
.ct-az li a { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; color: var(--text); font-size: 13px; }
.ct-az li a:hover { color: var(--color-primary); }
.ct-az li small { color: var(--muted); font-family: var(--font-mono); font-size: 10px; }
/* The staff sees the tags that are no category (not checked) too, faded */
.ct-az li.is-unchecked { opacity: .45; }
.ct-az li.is-unchecked:hover { opacity: 1; }
.ct-az-note { display: flex; align-items: center; gap: 6px; margin: 0; padding: 10px 16px 0; color: var(--muted); font-size: 12px; }
.ct-filter { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); background: var(--panel); }
.ct-filter .icon { color: var(--muted); }
.ct-filter input { width: 180px; border: 0; background: transparent; color: var(--text); font-size: 12px; outline: none; }

/* With the column head the row repeats no labels; narrow, where the head hides columns, they return */
@media (min-width: 901px) {
  .ct-row .ct-row-fact small { display: none; }
}

@media (max-width: 1200px) {
  .ct-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ct-row, .ct-rows-head { grid-template-columns: 30px minmax(0, 1fr) repeat(2, minmax(0, .6fr)) auto; }
  .ct-row .is-wide, .ct-rows-head .is-wide { display: none; }
  .ct-rows-head { display: none; }
}

@media (max-width: 560px) {
  .ct-grid { grid-template-columns: minmax(0, 1fr); }
  .ct-row, .ct-rows-head { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .ct-row .ct-row-fact, .ct-rows-head .ct-row-fact { display: none; }
  .ct-filter input { width: 120px; }
}
