/* ==========================================================================
   News Update (newsupdate.ca) — viewer stylesheet
   --------------------------------------------------------------------------
   Plain CSS, no build step. Load order: this file only.
   Structure:
     1. Tokens (custom properties)      6. Story cards
     2. Dark-mode tokens                7. Tags, time, history
     3. Base / reset                    8. Footer
     4. Masthead (header top)           9. States: no-JS, reduced motion
     5. Control bar (header bottom)    10. Responsive breakpoints
   Every class and id the script reads (#list, .tag.brk, li.hot, li.flash,
   .ico, .offline, body.is-live, html.dark-mode …) is kept; only the look
   changed.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Brand */
  --ink-900: #0B1F4B;      /* primary: masthead navy */
  --ink-800: #142B6E;      /* masthead gradient end */
  --signal: #1F4FD8;       /* secondary: links, "New", focus on light */
  --red: #D90F1E;          /* breaking accent — use sparingly */
  --red-tint: #FFF6F6;     /* breaking card wash: barely there */
  --yellow: #FFC21A;       /* electric highlight: focus on dark, new-arrival flash */
  --yellow-tint: #FFF4CC;

  /* Surfaces and text */
  --bg: #EDF1F7;           /* page */
  --surface: #FFFFFF;      /* cards */
  --surface-2: #F6F8FB;    /* control bar, icon wells */
  --text: #121826;         /* body text, 16.9:1 on white */
  --muted: #4B5565;        /* meta text, 7.4:1 on white */
  --line: #D6DCE7;         /* hairlines and card borders */
  --on-ink: #FFFFFF;       /* text on masthead */
  --on-ink-muted: #B9C4E0; /* 8.4:1 on --ink-900 */

  /* Category stripes (left edge of each card; the footer counts use the same colours as a legend) */
  --cat-fire: #C2410C;
  --cat-police: #3346B5;
  --cat-transit: #0F766E;
  --cat-weather: #0369A1;
  --cat-hydro: #A16207;
  --cat-world: #64748B;
  --cat-local: #0B1F4B;

  /* Tag fills (all ≥ 4.5:1 with white text) */
  --tag-brk: var(--red);
  --tag-new: var(--signal);
  --tag-upd: #8A5300;
  --tag-act: #0F7B45;

  /* Type */
  --font-ui: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;     /* headlines, UI */
  --font-read: "Newsreader", Georgia, "Times New Roman", serif;              /* summaries, long text */
  --step--1: .8125rem;   /* 13px meta */
  --step-0: 1rem;        /* 16px */
  --step-1: 1.1875rem;   /* 19px headline, mobile */
  --step-2: 1.3125rem;   /* 21px headline, desktop */
  --step-3: 2.25rem;     /* clock */

  /* Shape and space */
  --radius-card: 10px;
  --radius-chip: 4px;
  --radius-btn: 6px;
  --gap: 12px;
  --page-max: 980px;
  --focus: 3px solid var(--signal);
}

/* 2. Dark mode: the class and storage key ('darkMode') are shared with gtaupdate.com ------ */
html.dark-mode {
  --ink-900: #08142F;
  --ink-800: #0F1E46;
  --bg: #0A1226;
  --surface: #111C38;
  --surface-2: #0E1830;
  --text: #E7ECF6;        /* 14.6:1 on surface */
  --muted: #A6B2CB;       /* 7.6:1 on surface */
  --line: #24325A;
  --red: #FF4B57;         /* brighter red so red text still passes on navy */
  --red-tint: #1C1A3A;
  --signal: #7FA2FF;
  --yellow-tint: #3A3110;
  --tag-brk: #C8101D;
  --tag-new: #2A55D6;
  --tag-upd: #8A5300;
  --tag-act: #0F7B45;
  --cat-local: #7FA2FF;
  --cat-world: #8A97B0;
  --focus: 3px solid var(--yellow);
  color-scheme: dark;
}

/* 3. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--step-0)/1.45 var(--font-ui);
  font-feature-settings: "tnum" 0;
}
a { color: inherit; }
:focus-visible { outline: var(--focus); outline-offset: 2px; border-radius: 3px; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, p, figure { margin: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 10; padding: 8px 14px;
  background: var(--yellow); color: #111; font-weight: 700; border-radius: var(--radius-btn); text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* 4. Masthead -------------------------------------------------------------- */
header.masthead { position: sticky; top: 0; z-index: 5; }

.header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--gap);
  padding: 10px max(16px, calc((100% - var(--page-max)) / 2));
  color: var(--on-ink);
  /* Energy without noise: deep navy with a soft lift behind the clock; the red rule underneath does the shouting. */
  background:
    radial-gradient(60% 140% at 50% 0%, rgba(64, 108, 230, .35), transparent 70%),
    linear-gradient(180deg, var(--ink-800), var(--ink-900));
  border-bottom: 3px solid var(--red);
}

/* Wordmark: red "N" tile + name. The tile doubles as the favicon. */
.brand { justify-self: start; margin: 0; font-size: inherit; }
.brand a { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; border-radius: 6px; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--red); color: #fff;
  font: 900 26px/1 var(--font-ui); letter-spacing: -.04em;
  position: relative;
}
.brand-mark::after {            /* the live "signal" dot on the tile */
  content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--yellow);
}
.brand-text { display: flex; flex-direction: column; }
.logo-name { font: 800 1.5rem/1 var(--font-ui); letter-spacing: -.02em; white-space: nowrap; }
.logo-name small { font-weight: 500; font-size: .6em; color: var(--on-ink-muted); letter-spacing: 0; margin-left: 1px; }
.logo-tagline { font: 500 var(--step--1)/1.2 var(--font-ui); color: var(--on-ink-muted); margin-top: 4px; }

.clock {
  font: 700 var(--step-3)/1 var(--font-ui);
  font-variant-numeric: tabular-nums;   /* digits don't jiggle each second */
  letter-spacing: -.01em;
  min-width: 7.2ch; text-align: center;  /* reserved width: no layout shift as it ticks */
}

.header-right { justify-self: end; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill-btn {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px;
  font: 700 .9375rem/1 var(--font-ui); text-decoration: none; cursor: pointer;
  border-radius: var(--radius-btn); border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .08); color: var(--on-ink);
  transition: background-color .15s, border-color .15s;
}
.pill-btn:hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .6); }
.pill-btn-gold, .pill-btn-gray { /* old variants, kept so nothing breaks if reused */ }
.header-top :focus-visible { outline-color: var(--yellow); }

.header-top select, .header-top input[type=date] {
  min-height: 36px; padding: 4px 8px;
  font: 600 .9375rem var(--font-ui);
  color: var(--on-ink); background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .35); border-radius: var(--radius-btn);
  color-scheme: dark;
}
.header-top select option { color: #111; background: #fff; }
select:disabled { opacity: .5; }
#histctl { display: inline-flex; gap: 8px; align-items: center; }
#histctl[hidden], #hours[hidden] { display: none; }

/* 5. Control bar ----------------------------------------------------------- */
.header-bottom {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px 16px;
  padding: 8px max(16px, calc((100% - var(--page-max)) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; font-size: var(--step--1); color: var(--muted); }
#status { flex: 1 1 0; min-width: 12ch; }
#offline:empty { display: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #9AA3B5; flex: none; }
body.is-live .dot { background: var(--red); animation: pulse 1.6s ease-out infinite; }
body.is-error .dot { background: var(--yellow); animation: none; box-shadow: 0 0 0 2px #8A5300 inset; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(217, 15, 30, .55); }
  80%  { box-shadow: 0 0 0 9px rgba(217, 15, 30, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 15, 30, 0); }
}
.offline {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-chip);
  background: var(--red-tint); color: var(--red); font-weight: 700;
}

/* Weather: quiet until hovered; small arrow says "opens elsewhere". */
.weather {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; min-width: 9rem;
  padding: 2px 12px 2px 6px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; white-space: nowrap; color: inherit; text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.weather img { width: 33px; height: 28px; }
.weather::after { content: "↗"; font-size: .75em; opacity: 0; transition: opacity .15s; }
.weather:hover, .weather:focus-visible { background: var(--surface-2); border-color: var(--line); }
.weather:hover::after, .weather:focus-visible::after { opacity: .7; }

/* Toggles */
.toggle-controls { display: flex; gap: 6px; align-items: center; justify-self: end; flex-wrap: wrap; border: 0; margin: 0; padding: 0; }
.pill-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px;
  padding: 4px 10px; border-radius: var(--radius-btn);
  background: var(--surface-2); border: 1px solid var(--line);
  font-weight: 600; font-size: .875rem; cursor: pointer; user-select: none;
}
.pill-toggle span:first-child::after { content: ""; }
.pill-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill-toggle .slider { position: relative; width: 30px; height: 18px; border-radius: 999px; background: #A3ACBD; transition: background-color .2s; }
.pill-toggle .slider::before {
  content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
.pill-toggle input:checked + .slider { background: var(--ink-900); }
html.dark-mode .pill-toggle input:checked + .slider { background: var(--signal); }
.pill-toggle input:checked + .slider::before { transform: translateX(12px); }
.pill-toggle input:focus-visible + .slider { outline: var(--focus); outline-offset: 2px; }

/* 6. Story cards ----------------------------------------------------------- */
main { max-width: var(--page-max); margin: 0 auto; padding: 16px 16px 32px; }
#list { display: grid; gap: 10px; }

#list > li {
  /* Off-screen cards skip layout and paint until scrolled near: big render/INP saving in History mode. */
  content-visibility: auto;
  contain-intrinsic-size: auto 140px;
}

.card {
  --stripe: var(--cat-local);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  padding: 12px 16px 12px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.card::before {                 /* category stripe */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--stripe);
}
.card > * { grid-column: 1; }

li[data-cat=fire]    .card { --stripe: var(--cat-fire); }
li[data-cat=police]  .card { --stripe: var(--cat-police); }
li[data-cat=transit] .card { --stripe: var(--cat-transit); }
li[data-cat=weather] .card { --stripe: var(--cat-weather); }
li[data-cat=hydro]   .card { --stripe: var(--cat-hydro); }
li[data-cat=world]   .card { --stripe: var(--cat-world); }

/* Breaking or a serious active incident: red stripe, red wash, red rule on top. */
#list > li.hot .card { --stripe: var(--red); background: var(--red-tint); }
#list > li.hot .card::before { width: 6px; }

/* Closed fires/outages in History: faded, still readable. */
#list > li.closed .card { opacity: .62; }
#list > li.closed .card::before { background: var(--line); }

/* New arrival on an incremental refresh: one yellow flash, then settles. */
#list > li.flash .card { animation: flash 3s ease-out; }
@keyframes flash { from { background: var(--yellow-tint); box-shadow: 0 0 0 2px var(--yellow); } to { box-shadow: 0 0 0 0 transparent; } }

/* Meta row: source on the left, time on the right */
.card-meta { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 4px; }
.ico {
  width: 28px; height: 28px; flex: none; object-fit: cover; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font: 800 8.5px/1 var(--font-ui); color: var(--muted); letter-spacing: .02em;
}
.source { flex: 1; min-width: 0; font-size: var(--step--1); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source .src { color: var(--text); font-weight: 700; }
.source .who { color: var(--muted); }

.title-text {
  font: 700 var(--step-2)/1.22 var(--font-ui);
  letter-spacing: -.012em;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.title-text a { text-decoration: none; background-image: linear-gradient(currentColor, currentColor); background-size: 0 2px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size .2s; }
.title-text a:hover { background-size: 100% 2px; }
.title-text a:visited { color: color-mix(in srgb, var(--text) 72%, var(--bg)); }

.summary {
  margin-top: 6px; max-width: 68ch;
  font: 400 1.0625rem/1.5 var(--font-read);
  color: color-mix(in srgb, var(--text) 85%, var(--surface));
  /* Teaser: clamp to 4 lines visually; the full text stays in the DOM for SEO. */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden;
}

/* Lead image: right column on wide screens, fixed box so nothing shifts when it loads. */
.thumb {
  grid-column: 2; grid-row: 1 / span 5; align-self: start;
  width: 220px; aspect-ratio: 16 / 9;
  border-radius: 6px; overflow: hidden; background: var(--surface-2);
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* 7. Tags, time, history --------------------------------------------------- */
/* Tags sit inline at the start of the headline, nudged to the headline's centre line. */
.title-text .tags { display: inline-flex; gap: 5px; margin-right: 8px; vertical-align: .18em; }
.title-text .tags .tag { height: 20px; font-size: .6875rem; line-height: 1; }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: var(--radius-chip);
  font: 700 .75rem/1 var(--font-ui); color: #fff; letter-spacing: .01em;
}
.tag.brk { background: var(--tag-brk); text-transform: uppercase; letter-spacing: .06em; }   /* the one all-caps word on the page */
.tag.new { background: var(--tag-new); }
.tag.upd { background: var(--tag-upd); }
.tag.act { background: var(--tag-act); }
.tag.act::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }

.card-meta time {
  flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  font-size: var(--step--1); line-height: 1.15; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: right;
}
.card-meta time b { color: var(--text); font-weight: 700; }
li.hot .card-meta time b { color: var(--red); }

.hist {
  margin-top: 8px; padding: 6px 0 0 12px;
  border-left: 2px solid var(--line);
  font-size: var(--step--1); color: var(--muted);
}
.hist li + li { margin-top: 2px; }

.empty {
  padding: 48px 16px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-card);
}

/* 8. Footer ---------------------------------------------------------------- */
/* Pinned one-line notice: the disclaimer stays on screen however far you scroll. */
.sticky-bar {
  position: sticky; bottom: 0; z-index: 4;
  padding: 6px 16px; text-align: center;
  background: var(--ink-900); color: var(--on-ink);
  border-top: 2px solid var(--red);
  font: 700 var(--step--1)/1.3 var(--font-ui);
}
/* End of page: one quiet line. */
footer.site-footer {
  max-width: var(--page-max); margin: 0 auto; padding: 14px 16px 18px;
  color: var(--muted); font-size: var(--step--1); text-align: center;
}
footer.site-footer a { color: var(--text); font-weight: 600; margin-left: 12px; white-space: nowrap; }

/* 9. States ---------------------------------------------------------------- */
/* No JavaScript: the server-rendered list still shows; controls that need the script are hidden. */
html:not(.js) .needs-js { display: none !important; }
.noscript-note { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
/* Before the script takes over, hide server-rendered rows the visitor has toggled off (prevents a jump). */
html.hide-world #list > li.ssr[data-group=world] { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .card::before, .tag { forced-color-adjust: none; }
}

/* 10. Responsive ----------------------------------------------------------- */
/* Tablet */
@media (max-width: 900px) {
  .header-top { grid-template-columns: 1fr auto; }
  .header-right { grid-column: 1 / -1; justify-content: flex-start; }
  .clock { font-size: 1.75rem; text-align: right; }
  .header-bottom { grid-template-columns: 1fr auto; }
  .status { grid-column: 1 / -1; order: 3; }
  .thumb { width: 168px; }
}

/* Phone: masthead scrolls away so stories get the screen; cards stack tighter. */
@media (max-width: 600px) {
  header.masthead { position: static; }
  .header-top { padding: 10px 12px; gap: 8px; }
  .brand-mark { width: 34px; height: 34px; font-size: 22px; }
  .logo-name { font-size: 1.2rem; }
  .logo-tagline { font-size: .75rem; }
  .clock { font-size: 1.3rem; min-width: 0; }
  .header-right { gap: 6px; }
  .pill-btn, .header-top select, .header-top input[type=date] { min-height: 34px; font-size: .875rem; padding: 4px 10px; }
  .header-bottom { grid-template-columns: minmax(0, 1fr) auto; padding: 6px 12px 8px; gap: 6px 8px; }
  .status { grid-column: 1; grid-row: 1; order: 0; }
  .weather { grid-column: 2; grid-row: 1; min-width: 0; padding-right: 6px; }
  .weather::after { display: none; }
  .toggle-controls { grid-column: 1 / -1; }
  .toggle-controls { justify-self: stretch; display: grid; grid-template-columns: repeat(3, 1fr); }
  .pill-toggle { justify-content: space-between; padding: 4px 8px; gap: 4px; font-size: .8125rem; }
  .pill-toggle .slider { width: 26px; height: 16px; }
  .pill-toggle .slider::before { width: 12px; height: 12px; }
  .pill-toggle input:checked + .slider::before { transform: translateX(10px); }

  main { padding: 10px 8px 24px; }
  #list { gap: 8px; }
  .card { padding: 12px 12px 12px 16px; column-gap: 12px; }
  .title-text { font-size: var(--step-1); }
  .summary { font-size: 1rem; }
  .thumb { width: 92px; aspect-ratio: 1; grid-row: 2 / span 4; }
  .card-meta { grid-column: 1 / -1; }
  .card-meta time { flex-direction: row; gap: 6px; }
}

/* Very narrow phones: four toggles become two rows of two. */
@media (max-width: 380px) {
  .toggle-controls { grid-template-columns: repeat(3, 1fr); }
}

/* 11. Desktop grid ---------------------------------------------------------
   Wide screens only: the two newest rows are 2 across (the lead stories), everything after is 3 across.
   Pure CSS on the same markup: a 6-column track, first four cards span 3 columns, the rest span 2.
   Order stays newest first, reading left to right, top to bottom. Below 1100px it's the single list above. */
@media (min-width: 1100px) {
  :root { --page-max: min(80%, 1920px); }

  #list { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
  #list > li { grid-column: span 2; display: grid; contain-intrinsic-size: auto 320px; }
  #list > li:nth-child(-n+4) { grid-column: span 3; }
  #list > li.empty { grid-column: 1 / -1; }

  /* Card becomes a column: full-bleed image on top, then source/time, tags, headline, summary. */
  .card { display: flex; flex-direction: column; padding: 14px 16px 16px 20px; }
  .card::before { z-index: 1; }
  .thumb {
    order: -1; width: auto; aspect-ratio: 16 / 9;
    margin: -14px -16px 12px -20px; border-radius: 0;
  }
  .card-meta { margin-bottom: 6px; }
  .title-text { font-size: 1.1875rem; line-height: 1.25; }
  .summary { font-size: 1rem; }
  .hist { margin-top: auto; padding-top: 8px; }
  .summary + .hist, .title-text + .hist { margin-top: 10px; }

  /* Lead stories with a photo: photo on the left, text on the right, so the top row stays short enough
     to show the second row on a laptop screen. */
  #list > li:nth-child(-n+4) .card:has(.thumb) {
    display: grid; grid-template-columns: 42% minmax(0, 1fr); column-gap: 18px; align-content: start;
  }
  #list > li:nth-child(-n+4) .card:has(.thumb) > * { grid-column: 2; }
  #list > li:nth-child(-n+4) .card:has(.thumb) > .thumb {
    grid-column: 1; grid-row: 1 / span 6; align-self: stretch;
    aspect-ratio: auto; min-height: 200px; margin: -14px 0 -16px -20px;
  }

  /* Lead stories: bigger headline, longer summary. */
  #list > li:nth-child(-n+4) .title-text { font-size: 1.5rem; line-height: 1.2; }
  #list > li:nth-child(-n+4) .summary { font-size: 1.0625rem; -webkit-line-clamp: 5; line-clamp: 5; }
}

/* 12. Trending in Canada ----------------------------------------------------
   Phones and tablets: one sideways-scrolling strip above the stories.
   Desktop (1100px+): a numbered sidebar beside the top two rows of stories. */
.trends[hidden] { display: none; }
.trends {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  overflow-x: auto; scrollbar-width: none;
}
.trends::-webkit-scrollbar { display: none; }
.trends h2 { flex: none; font: 800 var(--step--1)/1.1 var(--font-ui); color: var(--signal); white-space: nowrap; }
.trends-list { display: flex; gap: 6px; counter-reset: trend; }
.trends-list li { flex: none; counter-increment: trend; }
.trends-list a {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 10px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  text-decoration: none; white-space: nowrap;
}
.trends-list a::before { content: counter(trend); font: 700 .75rem/1 var(--font-ui); color: var(--muted); font-variant-numeric: tabular-nums; }
.trends-list a:hover { border-color: var(--signal); }
.t-term { font: 700 .875rem/1.2 var(--font-ui); }
.t-why, .trends-src { display: none; }

@media (min-width: 1100px) {
  /* 24-column track: trends take the right quarter of rows 1-2, the four lead stories share the rest,
     then three across as before. #list "dissolves" into this grid so its cards can flow around the panel. */
  html:not(.hide-trends) .layout.has-trends { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 16px; }
  html:not(.hide-trends) .layout.has-trends #list { display: contents; }
  html:not(.hide-trends) .layout.has-trends #list > li { grid-column: span 8; }
  html:not(.hide-trends) .layout.has-trends #list > li:nth-child(-n+4) { grid-column: span 9; }
  html:not(.hide-trends) .layout.has-trends #list > li.empty { grid-column: 1 / 19; }
  /* Narrower lead cards: slightly smaller headline so the photo-beside-text layout still breathes. */
  html:not(.hide-trends) .layout.has-trends #list > li:nth-child(-n+4) .title-text { font-size: 1.3125rem; }
  html:not(.hide-trends) .layout.has-trends #list > li:nth-child(-n+4) .card:has(.thumb) { grid-template-columns: 38% minmax(0, 1fr); }

  html:not(.hide-trends) .layout.has-trends .trends {
    grid-column: 19 / -1; grid-row: 1 / span 2;
    contain: size;                /* takes the height of the two rows; never stretches them */
    display: flex; flex-direction: column; align-items: stretch; gap: 0;
    margin: 0; padding: 14px 0 10px; overflow: hidden auto; scrollbar-width: thin;
    border-top: 3px solid var(--signal);
  }
  .trends h2 { padding: 0 16px 8px; font-size: 1rem; color: var(--text); }
  .trends-list { flex-direction: column; gap: 0; }
  .trends-list a {
    display: grid; grid-template-columns: 1.6em minmax(0, 1fr); column-gap: 8px; row-gap: 2px;
    padding: 7px 16px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; white-space: normal;
  }
  .trends-list a::before { grid-row: 1 / span 2; font-size: 1.25rem; line-height: 1.1; color: var(--signal); }
  .trends-list a:hover, .trends-list a:focus-visible { background: var(--surface-2); }
  .trends-list a:hover .t-term { text-decoration: underline; text-underline-offset: 2px; }
  .t-term { font-size: 1rem; }
  .t-why {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden;
    font-size: var(--step--1); line-height: 1.35; color: var(--muted);
  }
  .t-why b { color: var(--text); font-weight: 600; }
  .trends-src { display: block; margin-top: auto; padding: 10px 16px 0; font-size: .75rem; color: var(--muted); }
}

/* 13. Phones only ----------------------------------------------------------
   "Phone" = up to 600px wide (portrait), or a short touch screen (a phone held sideways; the touch test
   keeps a short desktop window out). No Trending strip, no weather chip, no "updated HH:MM": the
   stories get the room. The Live dot and the item count stay. Desktop and tablets are unchanged. */
@media (max-width: 600px), (max-height: 500px) and (pointer: coarse) {
  .layout .trends, .layout.has-trends .trends { display: none; }
  .weather { display: none; }
  .st-time { display: none; }
  .header-bottom .status { grid-column: 1 / -1; }
}
/* Phone held sideways: status on the left, the three toggles on the right, smaller, and free to wrap
   onto a second line instead of crowding into each other. */
@media (min-width: 601px) and (max-height: 500px) and (pointer: coarse) {
  .header-bottom { grid-template-columns: minmax(0, 1fr) auto; padding-top: 6px; padding-bottom: 6px; gap: 6px 10px; }
  .header-bottom .status { grid-column: 1; grid-row: 1; order: 0; }
  .toggle-controls { grid-column: 2; grid-row: 1; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
  .pill-toggle { min-height: 30px; padding: 2px 8px; gap: 6px; font-size: .8125rem; }
  .pill-toggle .slider { width: 26px; height: 16px; }
  .pill-toggle .slider::before { width: 12px; height: 12px; }
  .pill-toggle input:checked + .slider::before { transform: translateX(10px); }
}


/* 14. Incidents band and the Trending / Incidents toggles (desktop and tablet only) ----------------------
   Two marquee rows, fire on top, police below, from the same cache gtaupdate.com's incident page reads.
   Each row scrolls only if its calls don't fit; hovering the band pauses it. Fixed height: no layout shift. */
html.hide-trends .trends { display: none; }
html.hide-incidents .inc-band { display: none; }

/* Weather chip centred in the toolbar: equal side columns, so it sits in the middle whatever is beside it. */
@media (min-width: 901px) {
  .header-bottom { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .weather { justify-self: center; }
  .toggle-controls { justify-content: flex-end; }
}

.inc-band {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: stretch;
  margin: 0 0 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
}
.inc-h {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 0 14px;
  border-right: 1px solid var(--line); text-decoration: none; color: var(--text);
  font: 800 .9375rem/1.1 var(--font-ui);
}
.inc-h small { font-weight: 600; font-size: .75rem; color: var(--muted); }
.inc-h:hover { background: var(--surface-2); }
.inc-rows { display: grid; grid-template-rows: 34px 34px; min-width: 0; }
.inc-row { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); align-items: center; min-width: 0; }
.inc-row + .inc-row { border-top: 1px solid var(--line); }
.inc-kind {
  align-self: stretch; display: flex; align-items: center; justify-content: center;
  font: 800 .75rem/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: #fff;
}
.inc-row[data-kind=fire]   .inc-kind { background: var(--cat-fire); }
.inc-row[data-kind=police] .inc-kind { background: var(--cat-police); }
.inc-view { overflow: hidden; min-width: 0; height: 100%; display: flex; align-items: center; }
.inc-track { display: flex; width: max-content; }
.inc-track ul { display: flex; gap: 0; margin: 0; padding: 0; list-style: none; }
.inc-track li { flex: none; }
.inc-track a {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 0 16px; white-space: nowrap;
  border-right: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .875rem;
}
.inc-track a:hover b { text-decoration: underline; text-underline-offset: 2px; }
.inc-track time { font: 700 .8125rem/1 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--muted); }
.inc-track b { font-weight: 700; }
.inc-loc { color: var(--muted); }
.inc-track li.on time::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--tag-act); vertical-align: 1px; }
.inc-alarm { padding: 1px 6px; border-radius: var(--radius-chip); background: var(--red); color: #fff; font: 800 .6875rem/1.3 var(--font-ui); text-transform: uppercase; }
.inc-track li.alarm b { color: var(--red); }
.inc-none { padding: 0 16px; font-size: .875rem; color: var(--muted); }

/* Marquee: the list is in the track twice, so sliding left by exactly one copy loops without a seam.
   news.js adds .run only when a row overflows, and sets --dur from its width (a steady ~45px a second). */
.inc-track ul[aria-hidden] { display: none; }
.inc-row.run .inc-track ul[aria-hidden] { display: flex; }
.inc-row.run .inc-track { animation: inc-slide var(--dur, 60s) linear infinite; }
.inc-band.paused .inc-track, .inc-band:has(a:focus-visible) .inc-track { animation-play-state: paused; }
@keyframes inc-slide { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .inc-row.run .inc-track { animation: none; }
  .inc-row.run .inc-track ul[aria-hidden] { display: none; }
  .inc-view { overflow-x: auto; scrollbar-width: thin; }
}

/* Phones (same test as section 13): no band and no Trending / Incidents switches. */
@media (max-width: 600px), (max-height: 500px) and (pointer: coarse) {
  .inc-band, .desk-only { display: none !important; }
}
