/* Topic pages, topic links, the monthly review, and dark-mode colour fixes.
   Loaded after styles.css. Do not fold this into the minified stylesheet. */

.topic-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 12px;
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}
.topic-link:hover { background: var(--hover); }
.topic-link:focus-visible,
.topic-card:focus-visible,
.topic-entry h2 a:focus-visible,
.topic-day:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.topic-index {
  list-style: none;
  margin: 8px 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.topic-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.topic-card.has-cover { padding: 0 0 12px; }
.topic-body { display: block; }
.topic-card.has-cover .topic-body { padding: 12px 16px 0; }
.topic-cover {
  margin: 0;
  background: var(--chip);
}
.topic-cover img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--chip);
}
.topic-cover figcaption {
  margin: 0;
  padding: 4px 16px 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--faint);
  text-align: right;
}
.theme-dark .topic-cover img,
.theme-dark .topic-entry .pic a,
.theme-dark .mo-story .pic a {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.topic-card:hover { background: var(--hover); }
.topic-card h2 {
  margin: 8px 0 4px;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.topic-now {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}
.topic-meta {
  margin-top: 8px;
  color: var(--faint);
  font-size: 12.5px;
}
.topic-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--chip);
  border-radius: 999px;
  padding: 2px 8px;
}

ol.topic-rail.stories {
  position: relative;
  list-style: none;
  margin: 16px 0 8px;
  padding: 0;
}
.topic-rail::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 28px;
  bottom: 28px;
  width: 2px;
  border-radius: 2px;
  background: var(--border-strong);
}
.topic-entry {
  position: relative;
  margin-left: 26px;
}
.topic-entry .pic { margin: -4px -4px 10px; }
.topic-dot {
  position: absolute;
  left: -26px;
  top: 22px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--btn);
  box-shadow: 0 0 0 3px var(--surface);
}
.topic-entry h2 a {
  color: inherit;
  text-decoration: none;
}
.topic-entry h2 a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.topic-day { margin-left: auto; }

@media (max-width: 600px) {
  header .bar nav {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }
  .topic-day { margin-left: 0; flex-basis: 100%; }
  .topic-card h2 { font-size: 16.5px; }
  .topic-entry { margin-left: 22px; }
  .topic-dot { left: -22px; }
  .topic-rail::before { left: 5px; }
}

/* Category chips, search highlights, and loaded-term marks stay readable
   when the OS is dark and no theme class has been applied yet.
   .theme-dark rules live in styles.css and win when that class is set. */
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light):not(.theme-dark) .cat-conflict { background: #f052482e; color: #ff9c94; }
  :root:not(.theme-light):not(.theme-dark) .cat-economy { background: #32d58326; color: #6ce9a6; }
  :root:not(.theme-light):not(.theme-dark) .cat-tech { background: #538aff2e; color: #a4c1ff; }
  :root:not(.theme-light):not(.theme-dark) .cat-health { background: #ee46bc29; color: #f9a8df; }
  :root:not(.theme-light):not(.theme-dark) .cat-climate,
  :root:not(.theme-light):not(.theme-dark) .cat-science { background: #2eaadc2b; color: #7cd4fd; }
  :root:not(.theme-light):not(.theme-dark) .cat-politics { background: #7a5af833; color: #c3b5fd; }
  :root:not(.theme-light):not(.theme-dark) .cat-world,
  :root:not(.theme-light):not(.theme-dark) .cat-society { background: #353535; color: #d0d0d0; }
  :root:not(.theme-light):not(.theme-dark) mark.hit { background: #f5c518; color: #141000; box-shadow: none; }
  :root:not(.theme-light):not(.theme-dark) mark.loaded { background: #fab02842; color: #ffe2a8; box-shadow: inset 0 -1.5px #fab028b3; }
  :root:not(.theme-light):not(.theme-dark) .topic-cover img,
  :root:not(.theme-light):not(.theme-dark) .topic-entry .pic a,
  :root:not(.theme-light):not(.theme-dark) .mo-story .pic a { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
}

/* Monthly review. Category chips keep the colours from styles.css. */
.mo-head > .r-back { margin-top: 0 !important; margin-bottom: 12px; }
.mo-groups { display: flex; flex-direction: column; gap: 22px; margin: 8px 0 4px; }
.mo-cat .stories { margin: 0; }
.mo-h { display: flex; align-items: center; margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.mo-h .cat { font-size: 13px; }
.mo-story .topic-link { margin-bottom: 10px; }
.mo-block {
  margin: 16px 0 8px;
  padding: 14px 16px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.mo-block h2 { margin: 0 0 4px; font-size: 16px; letter-spacing: -0.01em; }
.mo-note { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.mo-topics { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mo-topic {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.mo-topic:hover { background: var(--hover); }
.mo-topic .cat { flex: none; }
.mo-topic-name { flex: 1 1 160px; min-width: 0; font-weight: 700; font-size: 15px; line-height: 1.35; }
.mo-topic .topic-count { flex: none; }
.mo-weeks { display: flex; flex-direction: column; gap: 8px; }
.mo-week {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
}
.mo-week:hover { background: var(--hover); }
.mo-week-id { font-variant-numeric: tabular-nums; font-size: 12.5px; letter-spacing: 0.04em; color: var(--faint); }
.mo-week-when { flex: 1 1 140px; font-size: 14.5px; }
.mo-go { color: var(--faint); }
.mo-topic:focus-visible,
.mo-week:focus-visible,
.mo-head .r-back a:focus-visible,
.topic-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (max-width: 420px) {
  .mo-block { padding: 12px 12px 14px; }
  .mo-topic-name { flex-basis: 100%; }
  .mo-week-when { flex-basis: 100%; }
}
/* Homepage lead story and daily sections. Map and subscribe keep their styles from styles.css. */
.story.lead {
  margin-top: 12px;
  padding: 0 0 4px;
  overflow: hidden;
  border-radius: 18px;
  border-color: color-mix(in srgb, #e5484d 42%, var(--border));
}
.story.lead .pic { margin: 0; }
.story.lead .pic a { border-radius: 18px 18px 0 0; }
.story.lead .pic figcaption { padding: 4px 18px 0; }
.story.lead .lead-body { padding: 12px 18px 16px; }
.story.lead .num { display: none; }
.story.lead h2 {
  margin: 2px 0 10px;
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1.16;
  letter-spacing: -0.024em;
  text-wrap: balance;
}
.lead-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e5484d;
}
.theme-dark .lead-kicker { color: #ff8b8f; }
.sec-jump {
  display: flex;
  gap: 8px;
  margin: 16px 0 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sec-jump::-webkit-scrollbar { display: none; }
.sec-jump a {
  flex: none;
  text-decoration: none;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13.5px;
  font-weight: 650;
}
.sec-jump a:hover { background: var(--hover); }
.sec { margin-top: 22px; }
.sec-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 8px;
}
.sec-h h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.sec-more { flex: none; font-size: 13.5px; font-weight: 650; color: var(--muted); text-decoration: none; }
.sec-more:hover { color: var(--text); }
.sec .stories { margin-top: 0; }
.sec-head { border-top: 0; margin-top: 0; }
.cat-gaming { background: #fff4ed; color: #c4320a; }
.theme-dark .cat-gaming { background: #ff692e2b; color: #ffb088; }
@media (max-width: 420px) {
  .story.lead .lead-body { padding: 12px 14px 14px; }
  .story.lead h2 { font-size: 26px; }
  .sec-h { align-items: flex-start; flex-direction: column; gap: 2px; }
}
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light):not(.theme-dark) .lead-kicker { color: #ff8b8f; }
  :root:not(.theme-light):not(.theme-dark) .cat-gaming { background: #ff692e2b; color: #ffb088; }
  :root:not(.theme-light):not(.theme-dark) .story.lead { border-color: color-mix(in srgb, #ff8b8f 45%, var(--border)); }
}
