/* ---------- Top news (Django: web/components/top_news*.html) ----------
 * The most read news of a scope in a measured window. One look, configured by the include:
 *   - scope: every news, one source (the rows leave out the source) or one topic;
 *   - window: the windows of the metrics (ADR 0016 of hirhanyo-pro): the last hour, today (local
 *     midnight to now), the rolling 24 hours and 7 days (the daily buckets);
 *   - size: the number of rows (3, 5 or 10).
 * The measure is the readers of a news on Hírhányó in the window (NewsRead, a reader counted once),
 * never the publisher's own figures. The bar is the share of the first place. Few readers and no
 * readers are their own states: missing data is not zero.
 * Every text is cut, never wrapped past its lines: titles in two lines, source and meta in one. */

/* The window switch: links (GET), the current one marked; shared by every top news block */
.tn-windows {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 10px var(--space-4) 0;
  list-style: none;
}

.tn-windows a {
  flex: 1 1 0;
  min-width: 0;
  padding: 5px 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .06em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-windows a:hover { border-color: var(--color-primary); color: var(--text); }
.tn-windows a[aria-current="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }

/* ---------- The list widget ---------- */

.top-news {
  container: top-news / inline-size;
  /* A size container does not grow to its content: it takes the width of its place */
  width: 100%;
  min-width: 0;
}

.tn-heading-mark { display: grid; place-items: center; flex-shrink: 0; width: 26px; height: 26px; }
.tn-heading-mark .source-avatar { width: 26px; height: 26px; }
.tn-heading-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }

.tn-list {
  margin: 0;
  padding: 2px var(--space-4) 4px;
  list-style: none;
}

/* One news: rank, title with source and time, readers; the bar runs below the text */
.tn-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  break-inside: avoid;
}

.tn-item:last-child { border-bottom: 0; }

.tn-rank {
  display: grid;
  place-items: center;
  height: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.tn-item:first-child .tn-rank { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

.tn-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.tn-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.tn-title:hover { color: var(--cyan); }

.tn-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.tn-source { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--cyan); font-family: var(--font-body); font-size: 10px; font-weight: 600; }
.tn-source > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.tn-source .source-avatar { width: 18px; height: 18px; font-size: 7px; }
.tn-source .source-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tn-meta time { flex-shrink: 0; }

.tn-count {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  padding-top: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .05em;
  white-space: nowrap;
}

.tn-count strong { color: var(--text); font-size: 12px; font-weight: 600; letter-spacing: 0; }

.tn-bar { position: relative; grid-column: 2 / -1; height: 3px; background: var(--track); }
.tn-bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--share); background: linear-gradient(90deg, var(--color-primary), var(--hud-transmission)); }

/* Rank movement against the same window one local day earlier (open decision) */
.tn-move { display: inline-flex; align-items: center; gap: 1px; font-family: var(--font-mono); font-size: 8px; font-weight: 600; letter-spacing: .04em; }
.tn-move .icon { width: 11px; height: 11px; font-size: 11px; }
.tn-move.is-up { color: var(--color-primary); }
.tn-move.is-down, .tn-move.is-same { color: var(--muted); }
.tn-move.is-new { padding: 0 4px; border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--line)); color: var(--accent); }

/* Read by the reader: the title muted, a check after the readers */
.tn-item.is-read .tn-title { color: var(--muted); }
.tn-item.is-read .tn-title:hover { color: var(--cyan); }
.tn-read { color: var(--color-success); }
.tn-read .icon { width: 12px; height: 12px; font-size: 12px; }

/* The first place with its photo above the list; a news without a photo stays a row */
.tn-lead { display: block; margin: 12px var(--space-4) 0; color: inherit; }
.tn-lead-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--line); background: var(--panel-hover); }
.tn-lead-media .media-fit { position: absolute; inset: 0; }
.tn-lead-rank { position: absolute; top: 8px; left: 8px; z-index: 2; display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; background: var(--accent); color: var(--accent-ink); font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.tn-lead .tn-title { margin-top: 10px; font-size: 15px; font-weight: 600; }
.tn-lead .tn-meta { margin-top: 6px; }
.tn-lead .tn-meta .tn-count { flex-direction: row; align-items: baseline; gap: 4px; margin-left: auto; padding: 0; }
.tn-lead .tn-meta .tn-count strong { font-size: 11px; }
.top-news--lead .tn-item:first-child .tn-rank { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: transparent; color: var(--accent); }

/* Compact: titles and readers only, for narrow places */
.top-news--compact .tn-item { grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; padding: 8px 0; }
.top-news--compact .tn-rank { height: 18px; font-size: 9px; }
.top-news--compact .tn-title { -webkit-line-clamp: 1; font-size: 12px; }
.top-news--compact .tn-meta { display: none; }
.top-news--compact .tn-count { flex-direction: row; align-items: baseline; gap: 3px; padding-top: 1px; }
.top-news--compact .tn-count strong { font-size: 10px; }

/* Nothing to rank: an empty state, never zeros */
.tn-empty { display: grid; justify-items: center; gap: 6px; padding: 26px var(--space-4) 24px; color: var(--muted); font-size: 12px; text-align: center; }
.tn-empty .icon { width: 26px; height: 26px; color: var(--line-bright); font-size: 26px; }
.tn-empty strong { color: var(--text); font-family: var(--font-heading); font-size: 13px; font-weight: 600; }

/* Wide: the window switch beside the heading and the rows in two columns (1–5 | 6–10) */
@container top-news (min-width: 640px) {
  .top-news .tn-windows { justify-content: flex-end; }
  .top-news .tn-windows a { flex: 0 0 auto; padding-inline: 12px; }
  .top-news:not(.top-news--compact) .tn-list.is-ten { columns: 2; column-gap: 32px; }
  .top-news .tn-list.is-ten .tn-item:nth-child(5) { border-bottom: 0; }
}

@container top-news (max-width: 300px) {
  .tn-item { grid-template-columns: 20px minmax(0, 1fr); }
  .tn-count { grid-column: 2; flex-direction: row; align-items: baseline; gap: 4px; padding: 0; }
  .tn-count strong { font-size: 10px; }
}

/* ---------- The strip: the first five side by side, for a wide column ---------- */

.top-news-strip { container: top-news-strip / inline-size; width: 100%; min-width: 0; }

.tn-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 14px var(--space-4) 16px;
  list-style: none;
}

.tn-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tn-card-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--line); background: var(--panel-hover); }
.tn-card-media .media-fit { position: absolute; inset: 0; }
.tn-card-media.is-empty { display: grid; place-items: center; color: var(--line-bright); }
.tn-card-media.is-empty .icon { width: 28px; height: 28px; font-size: 28px; }
.tn-card-rank { position: absolute; top: 0; left: 0; z-index: 2; display: grid; place-items: center; width: 26px; height: 26px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel); color: var(--accent); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.tn-card:first-child .tn-card-rank { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.tn-card .tn-title { font-size: 12px; -webkit-line-clamp: 3; }
.tn-card .tn-meta { margin-top: auto; }
.tn-card .tn-count { flex-direction: row; align-items: baseline; gap: 3px; margin-left: auto; padding: 0; }
.tn-card .tn-count strong { font-size: 10px; }

/* Narrower: a row that scrolls sideways, one card snapping after the other */
@container top-news-strip (max-width: 760px) {
  .tn-strip { grid-template-columns: none; grid-auto-columns: minmax(150px, 46%); grid-auto-flow: column; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--space-4); scrollbar-width: thin; }
  .tn-card { scroll-snap-align: start; }
}

/* ---------- The table: the ranking of a top news page ---------- */

.top-news-table { container: top-news-table / inline-size; width: 100%; min-width: 0; }
.tn-table-wrap { position: relative; overflow-x: auto; padding: 4px var(--space-4) 6px; }

.tn-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 12px;
}

.tn-table th {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .07em;
  text-align: left;
  white-space: nowrap;
}

.tn-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tn-table tr:last-child td { border-bottom: 0; }
.tn-table .is-num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.tn-table td.is-num { color: var(--text); font-size: 11px; }
.tn-table .tn-col-rank { width: 34px; }
.tn-table .tn-col-share { width: 22%; }
.tn-table .tn-col-move { width: 52px; }
.tn-table .tn-title { -webkit-line-clamp: 1; }
.tn-table .tn-meta { margin-top: 4px; }
.tn-table .tn-bar { display: block; grid-column: auto; }
.tn-table tbody tr:first-child .tn-rank { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.tn-table tbody tr:not(:first-child) .tn-rank { background: transparent; color: var(--accent); }
.tn-table .tn-share { display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; gap: 8px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; text-align: right; }
.tn-table time { color: var(--muted); font-family: var(--font-mono); font-size: 9px; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .tn-strip { scroll-behavior: auto; }
}

/* Fewer readers than the minimum: the stories with the most independent sources (their marks) */
.tn-marks { display: inline-flex; align-items: center; gap: 3px; }
.tn-marks .source-avatar { width: 18px; height: 18px; font-size: 7px; }
.tn-marks .source-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Most read (Django: web/components/most_read.html) ----------
 * The most read fresh news, right under the hero across the news grid of the home page, with no
 * heading: the photo on the left (none: the text takes the width), the tags, the title, the lead,
 * the source and the link. A .pw panel: the tags, the excerpt, the marks and the link come from
 * press-review-widgets.css. */
.news-grid > .mr-card { grid-column: 1 / -1; }
.mr-card { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.mr-card:not(:has(.mr-photo)) { grid-template-columns: minmax(0, 1fr); }
.mr-photo { position: relative; display: block; min-height: 220px; overflow: hidden; border-right: 1px solid var(--line); background: var(--panel-hover); }
.mr-body { display: grid; gap: 10px; align-content: start; min-width: 0; padding: 18px; }
.mr-body h3 { display: -webkit-box; overflow: hidden; margin: 0; font-size: 21px; font-weight: 600; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.mr-body h3 a { color: var(--text); }
.mr-body h3 a:hover { color: var(--color-primary); }

@media (max-width: 700px) {
  .mr-card { grid-template-columns: minmax(0, 1fr); }
  .mr-photo { min-height: 0; aspect-ratio: 16 / 9; border-right: 0; border-bottom: 1px solid var(--line); }
}
