/* =============================================================================
 *  ui/news.css
 *  News, new look (html.nn on reader/code_inbetween.html). Stories come first,
 *  in a column that scrolls by itself (the news script keeps your place in it
 *  while headlines refresh). The globe, the chosen country and its regional
 *  map sit in a card beside it; on phones the card opens from the Map button.
 *  World voices, the news radio, is the bar at the bottom.
 * ========================================================================== */
html.nn { --nn-top: 68px; --nn-side: 420px; --nn-hit: #E07A2E; --nn-hit-dim: #F0B988; }
html.nn[data-style="night"] { --nn-hit: #F2A65A; --nn-hit-dim: #8A5A2E; }
html.nn, html.nn body { height: 100%; overflow: hidden; background: var(--page); color: var(--text); }

/* ---------- shared parts of the page ---------- */
html.nn .nn-app button, html.nn #world-radio button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  font: 500 14.5px/1.2 var(--ui); cursor: pointer; transition: border-color .15s, color .15s, background-color .15s;
}
html.nn .nn-app button:hover:not(:disabled), html.nn #world-radio button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
html.nn .nn-app button:disabled, html.nn #world-radio button:disabled { opacity: .45; cursor: default; }
html.nn .nn-app .icon-btn { width: 38px; padding: 0; }
html.nn .nn-app select, html.nn #world-radio select, html.nn #world-radio input[type="text"] {
  min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: 400 15px var(--ui);
}
html.nn input[type="checkbox"], html.nn input[type="radio"], html.nn input[type="range"] { accent-color: var(--brand); }
html.nn .muted, html.nn .nn-app small { color: var(--muted); font-size: 13px; line-height: 1.45; }
html.nn a { color: inherit; }

/* ---------- the two columns between the top bar and World voices ---------- */
html.nn .nn-app {
  position: fixed; left: 0; right: 0; top: var(--nn-top); bottom: var(--radio-height, 72px); /* the radio's own size note, measured by the page */
  display: grid; grid-template-columns: minmax(0, 1fr) var(--nn-side);
}
html.nn #geo-news-overlay {
  position: static; min-height: 0; height: 100%; max-height: none; width: auto; overflow-y: auto; overflow-x: hidden;
  padding: 30px max(24px, calc((100% - 780px) / 2)) 0; margin: 0; border: 0; border-radius: 0; background: transparent;
  box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; outline: none;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
html.nn #geo-news-overlay:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }

/* heading, search and where */
html.nn .nn-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
html.nn .nn-head h1 { margin: 0; color: var(--ink); font: 700 34px/1.1 var(--ui); letter-spacing: -.02em; }
html.nn .nn-map-btn { display: none !important; }
html.nn .nn-map-btn svg { width: 17px; height: 17px; }
html.nn #geo-directory-stats { margin: 6px 0 20px; color: var(--muted); font-size: 14px; }
html.nn .nn-find { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
html.nn .nn-search { position: relative; display: block; }
html.nn .nn-search svg { position: absolute; left: 14px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
html.nn #news-search {
  width: 100%; height: 46px; padding: 0 16px 0 42px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: 400 15.5px var(--ui);
}
html.nn #news-search::placeholder { color: var(--muted); }
html.nn #news-search:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
html.nn .nn-where { display: flex; gap: 8px; margin: 0; }
html.nn .nn-where select { height: 46px; max-width: 190px; border-radius: 12px; }
html.nn .nn-cross { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 14px; cursor: pointer; }
html.nn #geo-cross-language-status { margin: 4px 0 0; }
html.nn #geo-cross-language-status:empty { display: none; }

/* what to show: Top stories / Headlines / Sources */
html.nn .nn-tabrow { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; margin: 18px 0 6px; }
html.nn .nn-tabs { display: flex; gap: 4px; margin: 0; padding: 4px; border-radius: 12px; background: var(--surface-2); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
html.nn .nn-tabs::-webkit-scrollbar { display: none; }
html.nn .nn-app .nn-tabs button { flex: none; min-height: 36px; padding: 0 15px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font-weight: 500; }
html.nn .nn-app .nn-tabs button:hover:not(:disabled) { color: var(--brand); }
html.nn .nn-app .nn-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(36, 27, 61, .12); font-weight: 600; }
/* the long search note stays for screen readers and as the hover note of
   "Load all feeds in view" (ui/news.js), so stories come up the screen */
html.nn #geo-search-help { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html.nn #geo-feed-status { min-height: 20px; margin: 6px 0 4px; }

/* search: where the matching stories come from */
html.nn #geo-matching-locations { margin: 10px 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
html.nn #geo-matching-count { margin: 0 0 6px; color: var(--ink); font-weight: 600; }
html.nn #geo-matching-location-details summary { cursor: pointer; color: var(--brand); font-weight: 500; }
html.nn #geo-matching-location-list { padding-left: 20px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }

/* top stories */
/* heading and its time choice on one line, then one sliding row of topics */
html.nn #geo-trends:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; margin-top: 10px; }
html.nn #geo-trends > * { grid-column: 1 / -1; }
html.nn #geo-trends h2 { margin: 18px 0 8px; color: var(--ink); font: 600 18px/1.3 var(--ui); }
html.nn #geo-trends h2#geo-trend-heading { grid-column: 1; margin: 6px 0; }
html.nn #geo-trends .toolbar { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin: 6px 0; }
html.nn #geo-trends .toolbar label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
html.nn #geo-trends .toolbar select, html.nn .nn-app #geo-trends .toolbar button { height: 36px; min-height: 36px; font-size: 14px; }
html.nn #geo-trend-coverage { margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
html.nn #geo-trend-coverage:empty { display: none; }
html.nn #geo-trends h2:not(#geo-trend-heading) { margin: 14px 0 6px; color: var(--muted); font: 600 12.5px/1.3 var(--ui); letter-spacing: .1em; text-transform: uppercase; }
html.nn #geo-trend-terms { display: flex; flex-wrap: nowrap; gap: 8px; margin: 0 0 4px; padding: 2px 0 6px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
html.nn .nn-app #geo-trend-terms button { flex: none; }
html.nn .nn-app #geo-trend-terms button { min-height: 34px; padding: 0 13px; border-radius: 999px; font-size: 14px; font-weight: 400; }
html.nn .nn-app #geo-trend-terms button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--page); }
html.nn .nn-app #geo-trend-clear { margin-top: 6px; }

/* the stories */
html.nn #geo-news-results { margin: 0; padding: 0; list-style: none; }
html.nn #geo-news-results > li {
  margin: 0; padding: 18px 2px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; overflow-wrap: anywhere;
}
html.nn #geo-news-results > li:first-child { border-top: 1px solid var(--line); }
html.nn #geo-news-results a.headline { display: block; color: var(--ink); font: 500 19px/1.42 var(--read); text-decoration: none; }
html.nn #geo-news-results a.headline:hover { color: var(--brand); text-decoration: none; }
html.nn #geo-news-results > li > small { display: block; margin-top: 6px; }
html.nn #geo-news-results > li > strong { display: block; color: var(--ink); font: 600 16px/1.35 var(--ui); }
html.nn .source-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
html.nn .source-line small { margin: 0; }
html.nn .source-line a, html.nn .trend-coverage-row > a:last-child { flex: none; color: var(--brand); font-size: 13.5px; font-weight: 500; text-decoration: none; }
html.nn .source-line a:hover, html.nn .trend-coverage-row > a:last-child:hover { text-decoration: underline; }
html.nn .nn-app .source-line button { min-height: 34px; font-size: 13.5px; }
html.nn .feed-badge { color: var(--muted); }
html.nn #geo-news-results details { margin-top: 10px; font-size: 14px; }
html.nn #geo-news-results summary { cursor: pointer; color: var(--brand); font-weight: 500; }
html.nn .trend-coverage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; margin: 0 0 0 4px; padding: 10px 0 10px 14px; border-top: 0; border-left: 2px solid var(--line); }
html.nn .trend-coverage-row > a:first-child { grid-column: 1; color: var(--ink); font: 400 15px/1.45 var(--read); text-decoration: none; }
html.nn .trend-coverage-row > a:first-child:hover { color: var(--brand); }
html.nn .trend-coverage-row > small { grid-column: 1; }
html.nn .trend-coverage-row > a:last-child { grid-column: 2; grid-row: 1; }
html.nn #geo-news-results > li.radio-active, html.nn .radio-active {
  outline: 2px solid var(--brand) !important; outline-offset: 0; border-radius: 12px; background: var(--brand-soft) !important; padding-left: 14px; padding-right: 14px;
}
html.nn #geo-empty { margin: 14px 0; padding: 22px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; line-height: 1.5; }
html.nn .loadbar {
  position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 0; padding: 14px 0 18px;
  background: linear-gradient(to bottom, transparent, var(--page) 30%);
}
html.nn .loadbar button { flex: 1 1 160px; }

/* ---------- the map card ---------- */
html.nn .nn-side {
  min-height: 0; overflow-y: auto; padding: 18px 20px 20px; border-left: 1px solid var(--line); background: var(--surface);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
html.nn .nn-side-head { display: none; }
html.nn .nn-globe-box {
  position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 48dvh; margin: 0 auto; overflow: hidden; border-radius: 16px;
  background: radial-gradient(circle at 50% 45%, var(--surface-2), var(--surface) 72%);
}
html.nn #geo-globe { position: absolute; inset: 0; }
html.nn #geo-region-controls {
  position: static; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; max-width: none; margin: 12px 0 0; padding: 0;
  border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 14px; line-height: 1.45;
}
html.nn .nn-app #geo-back-globe { min-height: 32px; padding: 0 12px; font-size: 13.5px; }
html.nn #geo-map-heading { margin: 18px 0 8px; color: var(--ink); font: 600 17px/1.3 var(--ui); }
html.nn #geo-focus-map { height: 220px; width: 100%; }
html.nn #geo-focus-map:empty { display: none; }
html.nn #geo-focus-map svg { display: block; width: 100%; height: 100%; }
html.nn #geo-map-caption { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
@keyframes nn-search-glow { 0%, 100% { fill: var(--nn-hit); } 50% { fill: var(--nn-hit-dim); } }
html.nn #geo-focus-map path.geo-search-match { animation: nn-search-glow 3s ease-in-out infinite; fill: var(--nn-hit); stroke: var(--surface); }
@media (prefers-reduced-motion: reduce) { html.nn #geo-focus-map path.geo-search-match { animation: none; } }
html.nn #geo-tooltip, html.nn .scene-tooltip, html.nn .float-tooltip-kap {
  padding: 5px 9px; border: 0; border-radius: 7px; background: var(--ink) !important; color: var(--page) !important;
  font: 500 13px/1.3 var(--ui) !important; text-shadow: none !important; box-shadow: var(--shadow);
}
html.nn #geo-tooltip { position: fixed; z-index: 60; pointer-events: none; display: none; }

/* ---------- World voices (the news radio) ---------- */
html.nn #world-radio {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px));
  border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--surface); box-shadow: none; backdrop-filter: none;
  color: var(--text); font: 400 14.5px/1.45 var(--ui);
}
html.nn #radio-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
html.nn #radio-top > strong { color: var(--ink); font-weight: 600; margin-right: 4px; }
html.nn #world-radio #radio-play { border-color: var(--brand); border-radius: 999px; padding: 0 18px; background: var(--brand); color: var(--brand-ink); font-weight: 600; }
html.nn #world-radio #radio-play:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-ink); }
html.nn #radio-status { flex: 1; min-width: 160px; color: var(--muted); }
html.nn #world-radio button:focus-visible, html.nn #world-radio input:focus-visible, html.nn #world-radio select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
html.nn #radio-now { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
html.nn #radio-now:empty { display: none; }
html.nn .radio-lane { flex: 1; min-width: 200px; padding: 4px 12px; border-left: 2px solid var(--brand); }
html.nn .radio-lane a { color: var(--ink); text-decoration: none; font-weight: 500; }
html.nn .radio-lane a:hover { color: var(--brand); }
html.nn .radio-lane small { display: block; color: var(--muted); }
html.nn #radio-menu { max-height: 55dvh; overflow: auto; padding-top: 14px; scrollbar-width: thin; }
html.nn .radio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
html.nn #world-radio fieldset { min-width: 0; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
html.nn #world-radio legend { padding: 0 4px; color: var(--ink); font-weight: 600; }
html.nn #radio-languages { display: flex; flex-wrap: wrap; gap: 10px; }
html.nn #world-radio label { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
html.nn #radio-menu p { margin: 8px 0; color: var(--muted); font-size: 13px; }

/* ---------- smaller windows ---------- */
@media (max-width: 1100px) { html.nn { --nn-side: 360px; } }
@media (max-width: 900px) {
  html.nn { --nn-top: 60px; }
  html.nn .nn-app { grid-template-columns: minmax(0, 1fr); }
  html.nn #geo-news-overlay { padding: 22px 16px 0; }
  html.nn .nn-head h1 { font-size: 28px; }
  html.nn .nn-map-btn { display: inline-flex !important; }
  html.nn .nn-find { grid-template-columns: minmax(0, 1fr); }
  html.nn .nn-where select { flex: 1 1 0; max-width: none; }
  html.nn #news-search, html.nn .nn-app select { font-size: 16px; }
  html.nn .nn-tabrow > #geo-search-all { flex: 1 1 auto; }
  html.nn #geo-news-results a.headline { font-size: 18px; }

  /* the map card opens over the stories */
  html.nn .nn-side { display: none; position: fixed; left: 0; right: 0; top: var(--nn-top); bottom: var(--radio-height, 100px); z-index: 40; border-left: 0; padding: 12px 16px 18px; }
  html.nn.nn-map-open .nn-side { display: block; }
  html.nn .nn-side-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; color: var(--ink); font-size: 17px; }
  html.nn .nn-globe-box { max-height: 42dvh; max-width: 42dvh; }

  html.nn #world-radio { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
  html.nn #radio-top { gap: 8px; }
  html.nn #world-radio button { min-height: 36px; padding: 0 12px; }
  html.nn #radio-settings { order: 8; }
  html.nn #radio-status { order: 9; flex: 1 1 0; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.nn #geo-trends:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
  html.nn #geo-trends h2#geo-trend-heading, html.nn #geo-trends .toolbar { grid-column: 1; justify-content: flex-start; }
  html.nn #geo-trend-coverage { display: none; }
  /* phones: time choice and refresh on one row, no small heading over the topics,
     and the load buttons wait at the end of the list instead of covering it */
  html.nn #geo-trends .toolbar label { font-size: 0; gap: 0; }
  html.nn #geo-trends .toolbar label select { font-size: 15px; }
  html.nn #geo-trends .toolbar { flex-wrap: nowrap; }
  html.nn #geo-trends h2:not(#geo-trend-heading):not(:last-child) { display: none; }
  html.nn #geo-directory-stats { font-size: 13px; margin-bottom: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.nn #geo-trends h2:last-child { display: none; } /* the tab above already says Top stories */
  html.nn .loadbar { position: static; background: none; padding-bottom: 22px; }
  html.nn #radio-now { max-height: 80px; overflow: auto; }
  html.nn #radio-menu { max-height: 40dvh; }
}
@media (max-width: 420px) { html.nn #radio-top > strong { display: none; } }
