/* ---------- Inter (self-hosted) ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter-latin-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/inter-latin-700.woff2") format("woff2");
}

/* ---------- Theme (Colors.png branding palette) ---------- */
:root {
  --bg: #1a1a1a;          /* Background Default */
  --panel: #252525;       /* Background Highlight */
  --line: #333333;        /* Lines / Dividers */
  --fg: #ffffff;          /* Font Default */
  --muted: #8a8a8a;       /* secondary text (time, chevrons) */
  --hover: #b2b2b2;       /* Font Hover */
  --dim: #4d4d4d;         /* Font Inactive */
  --accent: #ff4433;      /* Branding / Error */
  --accent-hover: #e53d2e;/* Red Hover */
  --link: #0000ee;        /* row action links — brand blue (#21) */
  --col: 760px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 20px;
}

a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--line);
}
.brand-link {
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  color: var(--fg);
  background: none;
  border: 0;
  /* Bigger tap target without shifting the visual position (#6). */
  padding: 8px 4px;
  margin: -8px -4px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.12s ease;
}
.brand-link:hover { color: var(--hover); }
.wordmark-home { color: inherit; text-decoration: none; }
.topnav { display: inline-flex; align-items: center; gap: 22px; }
.topbar .nav-btn,
.topbar .icon-btn,
.topbar .more-btn {
  background: none;
  border: 0;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  /* Enlarge the tap target (label + icon are one button, no dead gap) (#6). */
  padding: 8px 4px;
  margin: -8px -4px;
  transition: color 0.12s ease;
}
.topbar .nav-btn:hover { color: var(--hover); }
.topbar .icon { display: inline-flex; transition: transform 0.15s ease; }
.topbar button[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 56px 0 64px;
}
.wordmark {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  margin: 0;
  font-size: clamp(56px, 13vw, 124px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
}
/* The count badge is positioned out of flow as a top-right superscript so it no
   longer offsets the wordmark — "all.news" stays optically centred (#1). */
.count-badge {
  position: absolute;
  left: 100%;
  top: 0.1em;
  margin-left: 0.14em;
  background: var(--accent);
  color: #fff;
  font-size: 0.18em;
  font-weight: 500;
  line-height: 1;
  padding: 0.45em 0.7em;
  border-radius: 999px;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ---------- Search ---------- */
.search-wrap { position: relative; padding: 0 0 18px; }
#search {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  padding: 8px 30px 8px 2px; /* room for the magnifier / clear icon */
  outline: none;
}
#search::placeholder { color: var(--dim); }
#search:focus { border-color: var(--muted); }
/* Hide the browser's native search clear button — we draw our own (#25). */
#search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
.search-icon {
  position: absolute;
  right: 0;
  top: 8px;
  display: inline-flex;
  background: none;
  border: 0;
  padding: 4px;
  color: var(--fg); /* magnifier / clear icon are white */
  cursor: pointer;
  transition: color 0.12s ease;
}
.search-icon .ico-clear { display: none; }
/* While empty the magnifier is just a hint (not clickable); with a query it
   becomes a clickable ×. */
.search-wrap:not(.has-query) .search-icon { pointer-events: none; }
.search-wrap.has-query .ico-mag { display: none; }
.search-wrap.has-query .ico-clear { display: inline-flex; }
.search-wrap.has-query .search-icon:hover { color: var(--hover); }

/* Empty search state */
.no-results {
  list-style: none;
  padding: 24px 2px;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Day heading ---------- */
.day-heading {
  font-size: 28px;
  font-weight: 500;
  margin: 8px 0 6px;
}

/* ---------- Article list ---------- */
.feed-list { list-style: none; margin: 0; padding: 0; }

.article {
  position: relative;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 24px;
  align-items: center; /* center single-line headlines against the meta column (#5) */
  padding: 11px 0; /* tighter rows → more headlines per screen (#11) */
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 80px;
  cursor: pointer;
  /* Hover opens a strip of space above the row where Open/Share appear (#18). */
  transition: padding-top 0.18s ease;
}
.article.active { padding-top: 46px; }
/* Hover / shared-link card (States Sharing): row turns into a white card */
.article::before {
  content: "";
  position: absolute;
  inset: 4px -14px;
  border-radius: 14px;
  background: transparent;
  pointer-events: none;
  z-index: 0;
  transition: background 0.12s ease;
}
.article > * { position: relative; z-index: 1; }
.article.active::before,
.article.highlight::before { background: #fff; }
.article.active,
.article.highlight { border-bottom-color: transparent; }
.article.active .title,
.article.highlight .title { color: #000; }
.article.active .title:visited,
.article.highlight .title:visited { color: var(--dim); }
.article.active .time,
.article.highlight .time { color: var(--dim); }

/* Row actions: Open + Share. They live in the strip that opens above the row on
   hover and slide gently into place — no gradient fade over the headline (#18). */
.row-actions {
  position: absolute;
  top: 12px;
  right: 0;
  left: auto;
  bottom: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 22px;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease; /* subtle fade + slide */
  z-index: 2;
}
/* Reveal Open / Share immediately when the card opens (#9) — no dwell delay. */
.article.active .row-actions {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Pointer devices only: hovering a row opens its card. Touch devices have no
   real hover (browsers emulate a sticky one on first tap, which caused a
   two-stage reveal and left two rows looking selected), so there the card is
   driven solely by the .active class set on tap in script.js (#30). */
@media (hover: hover) {
  .article:hover,
  .article:focus-within { padding-top: 46px; }
  .article:hover::before { background: #fff; }
  .article:hover { border-bottom-color: transparent; }
  .article:hover .title { color: #000; }
  .article:hover .title:visited { color: var(--dim); }
  .article:hover .time { color: var(--dim); }
  .article:hover .row-actions,
  .article:focus-within .row-actions {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}
.row-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  /* Taller hit area for the action links; label + icon stay one target (#6). */
  padding: 8px 2px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--link);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.row-act:hover { text-decoration: none; }
.row-act svg { flex: none; }
.meta-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.source {
  align-self: flex-start;
  max-width: 100%;
  background: #888;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;        /* pill links to the source's portal home (#4) */
  cursor: pointer;
  transition: opacity 0.12s ease;
}
.source:hover { opacity: 0.82; }
.time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #6b6b6b; /* darker than --muted per #11 */
  font-size: 12.5px;
}
.time .ext { opacity: 0.7; flex: none; }
/* Eye toggle next to the time: hides this source from the feed (#4). */
.hide-src {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.hide-src:hover { opacity: 1; color: var(--accent); }

/* Confirm-hide popup (#4): white card on a dimmed backdrop. */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.confirm-modal {
  width: 100%;
  max-width: 340px;
  background: #fff;
  color: #111;
  border-radius: 16px;
  padding: 28px 28px 22px;
}
.confirm-modal h2 { font-size: 1.4rem; font-weight: 600; margin: 0 0 0.5em; }
.confirm-modal p { font-size: 0.95rem; line-height: 1.5; margin: 0 0 1.8em; color: #333; }
.confirm-modal .settings-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: #111;
  text-decoration: underline;
  cursor: pointer;
}
.confirm-modal .settings-link svg { vertical-align: -1px; }
.confirm-actions { display: flex; align-items: center; justify-content: space-between; }
.confirm-actions button { font: inherit; font-weight: 500; background: none; border: 0; padding: 0; cursor: pointer; }
.confirm-actions .cancel { color: var(--accent); }
.confirm-actions .cancel:hover { color: var(--accent-hover); }
.confirm-actions .confirm { color: #111; }
.confirm-actions .confirm:hover { color: #000; }
.title {
  display: block; /* fill the grid cell so the whole title area is one click target (#6) */
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0;
}
.title:hover { text-decoration: none; }
.title:visited { color: var(--dim); } /* Font Inactive — already-visited links */

/* Ad slot */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0d0d;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ---------- Older dates (link rows) ---------- */
.older-dates {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
}
.day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 28px;
  font-weight: 500;
  text-decoration: none;
  color: var(--fg);
}
.day-row .chev { color: var(--muted); }
/* day-row hover handled in the Hover states section (#3). */

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 48px 0 56px;
  color: var(--dim);
  font-size: 13px;
}

/* ---------- Panels (feed settings + more) ---------- */
.view[hidden] { display: none; }
.view { padding-top: 56px; min-height: 60vh; }

/* Feed settings: 4-column on desktop, accordions on mobile */
.feed-settings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}
.fs-group { min-width: 0; }
.fs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 0;
  color: var(--fg);
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  text-align: left;
  padding: 0;
  cursor: default; /* #23: column headers are labels, not clickable on desktop */
}
.fs-head .plus { display: none; }
.fs-archive {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  padding: 0;
  background: none;
  border: 0;
  cursor: default; /* #23: now a static label, not a link */
  font-family: inherit;
  text-align: left;
}
.fs-open-archive .ext { margin-left: 6px; vertical-align: -2px; }
/* Select all / Deselect all toggle under each filter group header (#2). Same font
   size as the rest of the menu; the space above is twice the space below. */
.fs-all {
  display: block;
  background: none;
  border: 0;
  margin: 0;
  padding: 48px 0 24px;
  font: inherit;
  text-decoration: none;
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: color 0.12s ease;
}
.fs-all:hover { color: var(--fg); }
/* Archive day list: "Today" (active) + recent days (deselected colour, open in a
   new tab) + a "more…" link to the full archive. */
.fs-days a {
  display: block;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--dim);
  text-decoration: none;
  padding: 2px 0;
  transition: color 0.12s ease;
}
.fs-days a:hover { color: var(--muted); }
.fs-days a.today {
  color: var(--fg); /* today's date is the active default — uniform row spacing */
}
.fs-days a.today:hover { color: var(--hover); }
.fs-days a.today::after {
  content: "✓";
  margin-left: 0.5em;
  color: var(--fg);
  font-weight: 600;
}
.fs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.fs-list li, .fs-list button {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--fg);
}
.fs-list .opt {
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  padding: 2px 0;
  cursor: pointer;
  color: var(--fg);
}
.fs-list .opt.off, .fs-list li.off { color: var(--dim); }
.fs-list .opt[aria-pressed="false"] { color: var(--dim); }

/* Trailing ✓ behind selected countries, languages and medias so it's obvious
   what's active (#8). */
.fs-list .opt[aria-pressed="true"]::after {
  content: "✓";
  margin-left: 0.5em;
  color: var(--fg);
  font-weight: 600;
}

/* Menu view: accordion rows. No rule above the first / below the last item (#7);
   only the dividers between items remain. */
.more-list { }
.more-item { border-bottom: 1px solid var(--line); }
.more-item:last-child { border-bottom: 0; }
.more-item > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
  padding: 18px 2px;
  font-size: 20px;
  font-weight: 600;
}
.more-item > summary::-webkit-details-marker { display: none; }
.more-item > summary .plus { color: var(--muted); font-size: 22px; line-height: 1; }
.more-item[open] > summary .plus { transform: rotate(45deg); }
.more-item .plus { transition: transform 0.15s ease; display: inline-block; }
.more-body {
  padding: 0 2px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 60ch;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .feed-settings { grid-template-columns: 1fr; gap: 0; }
  .fs-group { border-bottom: 1px solid var(--line); }
  .fs-head { padding: 18px 2px; cursor: pointer; }
  .fs-archive { display: block; padding: 18px 2px; }
  .fs-head .plus {
    display: inline-block;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    transition: transform 0.15s ease;
  }
  .fs-group.open .fs-head .plus { transform: rotate(45deg); }
  .fs-list { display: none; padding: 0 2px 18px; }
  .fs-group.open .fs-list { display: flex; }
  /* Select all / Deselect all (the toggle buttons) only show once the group is
     expanded; the Archive "Open Archive" link stays visible. */
  .fs-all { padding: 32px 2px 16px; }
  .fs-all[data-group] { display: none; }
  .fs-group.open .fs-all[data-group] { display: block; }
  /* Archive day list (no accordion header) stays visible. */
  .fs-days { display: flex !important; padding: 0 2px 18px; }
  .fs-archive { padding: 18px 2px 0; }
}

@media (max-width: 640px) {
  .article { grid-template-columns: 1fr; gap: 7px; padding: 10px 0; }
  .meta-col { flex-direction: row; align-items: center; gap: 10px; }
  .title { font-size: 17px; }
  .day-heading, .day-row { font-size: 22px; }
  .site-footer { flex-direction: column; gap: 6px; }
}

/* Touch devices have no hover: a row reveals nothing until tapped. The first tap
   turns it into the white card and slides Open/Share in (the .active state, set in
   script.js); links don't navigate until the card is open (#30). */
@media (hover: none) {
  .article { -webkit-tap-highlight-color: transparent; }
  /* Keep the initial list pure headlines — the hide-source eye is an option that
     appears with the others once the row is tapped open. */
  .article .hide-src { opacity: 0; pointer-events: none; }
  .article.active .hide-src { opacity: 0.6; pointer-events: auto; }
}

/* ---------- Archive page (month accordions) ---------- */
.archive { margin-top: 8px; }
.archive-month { border-bottom: 1px solid var(--line); }
.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
  padding: 22px 2px;
  font-size: 36px;
  font-weight: 600;
}
.month-head::-webkit-details-marker { display: none; }
.month-head .chev { color: var(--fg); transition: transform 0.15s ease; }
.archive-month[open] > .month-head .chev { transform: rotate(180deg); }
.month-days { padding: 4px 0 16px; }
.month-days .day-row { font-size: 20px; font-weight: 500; padding: 14px 2px; }

@media (max-width: 640px) {
  .month-head { font-size: 26px; padding: 18px 2px; }
  .month-days .day-row { font-size: 17px; }
}

/* Invisible scroll sentinel that triggers lazy-loading of more articles. */
.scroll-sentinel { list-style: none; height: 1px; margin: 0; padding: 0; }

/* Archive pagination */
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 24px 2px; }
.pager .pg {
  min-width: 38px; padding: 8px 10px; text-align: center;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--fg); text-decoration: none; font-weight: 500;
}
.pager a.pg:hover { border-color: var(--hover); }
.pager .pg-cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .pg-gap { color: var(--muted); padding: 0 2px; }

/* ---------- Welcome modal (first-visit primary-country prompt) ---------- */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: #fff;
  color: #111;
}
.welcome-modal { width: 100%; max-width: 360px; }
.welcome-modal h2 { font-size: 2.2rem; font-weight: 600; margin: 0 0 0.4em; }
.welcome-modal p { font-size: 1.15rem; line-height: 1.5; margin: 0 0 2.4em; }
.welcome-modal .country,
.welcome-modal .lang { text-decoration: underline; cursor: pointer; }
.welcome-actions { display: flex; align-items: center; justify-content: space-between; }
.welcome-actions button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.welcome-actions .change { color: var(--accent); }
.welcome-actions .change:hover { color: var(--accent-hover); }
.welcome-actions .continue { color: #111; font-weight: 500; }
.welcome-actions .continue:hover { color: #000; }
.welcome-modal .country:hover,
.welcome-modal .lang:hover { color: var(--accent); }

/* ---------- Hover states (#3) ----------
   Brand convention (Colors.png): white text dims to "Font Hover" (--hover) on
   hover; accent elements go to "Red Hover" (--accent-hover). Applied to every
   clickable element so hovering always gives feedback. */
/* #22: the big hero wordmark keeps its colour on hover (no dim). */
/* #23: filter column headers (.fs-head/.fs-archive) are static labels — no hover. */
.fs-list .opt:hover { color: var(--hover); }
.fs-list .opt[aria-pressed="false"]:hover { color: var(--muted); }
.more-item > summary:hover { color: var(--hover); }
.day-row:hover,
.day-row:hover .chev { color: var(--hover); }
.month-head:hover,
.month-head:hover .chev { color: var(--hover); }
.pager a.pg:hover { color: var(--hover); }
