:root {
  /* Stepchange brand tokens — keep in sync with stepchange-website globals.css */
  --ink: #1a2332;          /* steel navy */
  --ink-soft: #4a5568;     /* concrete gray */
  --rule: #e2e8f0;         /* light concrete */
  --paper: #f8fafc;        /* clean white */
  --accent: #c5410d;       /* urgent copper */
  --link: #c5410d;
  --faint: #94a3b8;
  --sep: #cbd5e1;
  --disc-label: #94a3b8;
  --tip-bg: #fff;
  --tip-border: #e2e8f0;
  --field-bg: #fff;
  --err: #b3380b;
  --disc-x: #0f1419;
  --disc-bluesky: #0a7ea4;
  --disc-hn: #b35a1f;
  --disc-reddit: #a4341c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e2e8f0;
    --ink-soft: #94a3b8;
    --rule: #243042;
    --paper: #10161f;      /* deep steel navy */
    --accent: #e8632b;     /* copper, brightened for dark contrast */
    --link: #e8632b;
    --faint: #64748b;
    --sep: #3a4759;
    --disc-label: #64748b;
    --tip-bg: #1a2332;
    --tip-border: #2e3c52;
    --field-bg: #1a2332;
    --err: #f0825b;
    --disc-x: #c8cdd4;
    --disc-bluesky: #4fb3d9;
    --disc-hn: #d98a4f;
    --disc-reddit: #e07a5f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 17px;
  line-height: 1.4;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Two-column homepage layout: main stream + Newest rail. Reverts to single-column below 900px. */
.layout { max-width: 760px; }
@media (min-width: 900px) {
  .layout {
    max-width: 1040px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    column-gap: 32px;
    align-items: start;
  }
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.mast-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  padding-bottom: 12px;
}
/* Header shares the content stream's centered box so the logo can line up with
   the story column. .layout widens to 1040px at 900px; match it here. */
@media (min-width: 900px) {
  .mast-row,
  .mast-sub { max-width: 1040px; }
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-decoration: none;
  min-width: 0;
  margin-left: 36px; /* rank gutter: .story 26px col + 10px gap → aligns logo with headline text */
}
/* Stepchange logo lockup — replicates the main site's AnimatedLogo stack:
   six colored layer SVGs under the text layer, object-contain left-aligned. */
.brand-logo {
  position: relative;
  display: block;
  height: 60px;
  aspect-ratio: 4207 / 1909;
  flex: none;
}
.brand-logo img,
.brand-logo svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  pointer-events: none;
}
.brand-logo svg { color: #1F2B4C; }
@media (prefers-color-scheme: dark) {
  .brand-logo svg { color: var(--ink); }
}
.brand-news {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
  /* the wordmark sits at ~y 718-1195 of the 1909-tall lockup box, so pull
     News up into the empty band below the text */
  margin-top: -19px;
}
@media (max-width: 560px) {
  .mast-row {
    flex-wrap: wrap;
    row-gap: 6px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .brand-logo { height: 44px; }
  .brand-news { font-size: 14px; margin-top: -14px; }
  .topnav { font-size: 11px; }
}

.mast-sub {
  padding-top: 14px;
  margin-bottom: 4px;
  padding-left: 56px; /* 20px wrap + 36px rank gutter → align subtitle/stamp with headlines */
}
.mast-sub .subtitle {
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0 0 6px;
}
.mast-sub .stamp {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin: 0;
}

.story {
  display: grid;
  grid-template-columns: 26px 1fr;
  column-gap: 10px;
  padding: 7px 0 6px;
  border-bottom: 1px solid var(--rule);
}
.story:last-child {
  border-bottom: none;
}
.story .rank {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: right;
  padding-top: 4px;
  letter-spacing: 0.02em;
}
.story .rank a {
  color: var(--ink-soft);
  text-decoration: none;
}
.story .rank a:hover { color: var(--link); text-decoration: underline; }

.more .permalink {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  font-style: italic;
  color: var(--faint);
}
.more .permalink .permalink-arrow {
  display: inline-block;
  margin-left: 3px;
  transition: transform 0.18s ease;
}
.more .permalink:hover {
  color: var(--accent);
  text-decoration: none;
}
.more .permalink:hover .permalink-arrow { transform: translateX(2px); }
.story h2 {
  margin: 0 0 2px;
  font-size: 16.5px;
  line-height: 1.3;
  font-weight: 700;
}
.story h2 a {
  color: var(--ink);
  text-decoration: none;
}
.story h2 a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.story h2 .dek {
  font-weight: 400;
  font-size: 14.5px;
  color: var(--ink-soft);
  font-family: "IBM Plex Serif", Georgia, serif;
  line-height: 1.35;
}

/* TechMeme-style "More: outlet1, outlet2, …" comma-flow under each story.
   Native browser tooltips on each link give per-source headline previews. */
.more {
  margin: 1px 0 0;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.more-label {
  font-weight: 600;
  color: var(--accent);
  margin-right: 4px;
}
.more a {
  color: var(--link);
  text-decoration: none;
}
.more a:hover { text-decoration: underline; }
.more .src-ago {
  font-size: 10.5px;
  color: var(--faint);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* Right rail: "Newest" feed of recent articles, dedup'd against the curated stream. */
.rail {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  margin-top: 6px;
}
.rail-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--ink);
}
.rail-item {
  padding: 6px 0;
  border-bottom: 1px dotted var(--rule);
}
.rail-item:last-of-type { border-bottom: 1px solid var(--rule); }
.rail-meta {
  margin: 0 0 1px;
  font-size: 10.5px;
  color: var(--ink-soft);
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.rail-src {
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rail-ago { color: var(--faint); }
.rail-new {
  background: var(--accent);
  color: #fff;
  padding: 0 4px;
  border-radius: 2px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.rail-link {
  color: var(--ink);
  text-decoration: none;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 13.5px;
  line-height: 1.32;
  display: block;
}
.rail-link:hover {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 2px;
}
.rail-more {
  display: block;
  margin-top: 10px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.rail-more:hover { text-decoration: underline; }
@media (max-width: 899px) {
  .rail { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--rule); }
}

.sources {
  margin: 1px 0 0;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: baseline;
}
.sources .src-sep {
  color: var(--sep);
  user-select: none;
}

.src {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--link);
  text-decoration: none;
  padding: 1px 0;
}
.src:hover .src-name {
  text-decoration: underline;
}
.src-ago {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: none;
  width: 320px;
  max-width: calc(100vw - 40px);
  padding: 10px 12px;
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  z-index: 20;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  text-align: left;
  white-space: normal;
  pointer-events: none;
}
.src:hover .tip,
.src:focus-visible .tip {
  display: block;
}
.tip-source {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tip-title {
  display: block;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.32;
  margin-bottom: 4px;
}
.tip-dek {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.4;
}

/* Flip tooltip to right edge for sources near the right of their row */
.sources .src:nth-last-child(-n+2) .tip {
  left: auto;
  right: 0;
}

/* Social discussions — under the sources row, one line per platform. */
.disc-row {
  margin: 1px 0 0;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: baseline;
}
.disc-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--disc-label);
  margin-right: 2px;
}
.disc-x       .disc-label { color: var(--disc-x); }
.disc-bluesky .disc-label { color: var(--disc-bluesky); }
.disc-hn      .disc-label { color: var(--disc-hn); }
.disc-reddit  .disc-label { color: var(--disc-reddit); }

.disc {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--link);
  text-decoration: none;
  padding: 1px 0;
}
.disc:hover .disc-name {
  text-decoration: underline;
}
.disc-name {
  font-weight: 500;
}
/* Reuse the existing .tip styles for these chips */
.disc .tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: none;
  width: 320px;
  max-width: calc(100vw - 40px);
  padding: 10px 12px;
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  z-index: 20;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  text-align: left;
  white-space: normal;
  pointer-events: none;
}
.disc:hover .tip,
.disc:focus-visible .tip {
  display: block;
}
.disc-row .disc:nth-last-child(-n+2) .tip {
  left: auto;
  right: 0;
}

.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--ink-soft);
}

footer {
  margin-top: 40px;
  padding: 18px 0 40px;
  border-top: 1px solid var(--rule);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
}

/* Email-capture form in the footer. .hp is the spam honeypot — keep it visually
   gone but focusable-by-bots (no display:none, which some bots skip). */
.subscribe {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dotted var(--rule);
}
.subscribe label {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.subscribe-row { display: inline-flex; gap: 6px; }
.subscribe input[type="email"] {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--field-bg);
  color: var(--ink);
  min-width: 220px;
}
.subscribe button {
  font: inherit;
  font-weight: 600;
  padding: 5px 12px;
  border: none;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.subscribe button:hover { filter: brightness(1.1); }
.subscribe .hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.subscribe-thanks { font-weight: 600; color: var(--accent); }
.subscribe-err { display: block; margin-top: 5px; color: var(--err); }
footer a {
  color: var(--ink-soft);
  text-decoration: none;
}
footer a:hover { text-decoration: underline; }
.footer-legal { margin-top: 10px; color: var(--faint); }

@media (max-width: 500px) {
  body { font-size: 16px; }
  .story { grid-template-columns: 22px 1fr; column-gap: 8px; }
  .story h2 { font-size: 16.5px; }
  .story h2 .dek { font-size: 14px; }
  .sources { font-size: 12px; }
  .tip { width: 260px; }
}

/* /story/<id>/<slug> — persistent per-story page. */
.story-page { padding-top: 6px; }
.story-headline {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  margin: 10px 0 6px;
}
.story-dek {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin: 0 0 6px;
}
.story-meta {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin: 0 0 10px;
}
.story-section {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--ink);
  margin: 24px 0 6px;
  padding-bottom: 4px;
}
.story-editions {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 20px;
}
.story-editions a { color: var(--link); text-decoration: none; }
.story-editions a:hover { text-decoration: underline; }
.story-back {
  margin-top: 24px;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12.5px;
}
.story-back a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.story-back a:hover { text-decoration: underline; }

/* Topnav — shared by index and river. */
.topnav {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.topnav a {
  position: relative;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  padding-bottom: 3px;
}
.topnav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.topnav a:hover { color: var(--ink); }
.topnav a:hover::after { width: 100%; }
.topnav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}
.topnav a[aria-current="page"]::after { width: 100%; }

/* /river — reverse-chronological firehose. */
.river-day {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  margin: 22px 0 8px;
  padding-bottom: 4px;
}
.river-day:first-of-type { margin-top: 6px; }

.river-row {
  display: grid;
  grid-template-columns: 4.2rem 8.5rem 1fr;
  column-gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--rule);
  align-items: baseline;
  font-size: 15px;
  line-height: 1.4;
}
.river-time {
  color: var(--ink-soft);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.river-src {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.river-src .src-name { font-weight: 500; }
.river-via {
  color: var(--ink-soft);
  font-weight: 400;
}
.river-main {
  display: block;
  min-width: 0;
}
.river-title {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.river-title:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.river-dek {
  color: var(--ink-soft);
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 14px;
}

@media (max-width: 600px) {
  .river-row {
    grid-template-columns: 3.6rem 1fr;
    column-gap: 8px;
    row-gap: 2px;
    padding: 7px 0;
  }
  .river-src {
    grid-column: 2;
    font-size: 11.5px;
    white-space: normal;
  }
  .river-main { grid-column: 2; }
}
