/* Market Wire — modern editorial design.
   Contemporary sans-serif, generous white space, one accent color,
   hierarchy from size/weight/spacing rather than borders and rules.
   Light and dark themes via prefers-color-scheme. */

:root {
  --bg: #ffffff;
  --bg-soft: #f5f5f7;       /* chips, tiles, hovers */
  --text: #16181d;
  --text-2: #6b7180;        /* secondary text */
  --text-3: #9aa0ac;        /* quiet metadata */
  --accent: #4f46e5;        /* the one strong color */
  --accent-soft: #eef0fe;
  --up: #0e7a3c;
  --up-soft: #e5f4ea;
  --down: #c02d2d;
  --down-soft: #fceceb;
  --hairline: #ebecef;
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121317;
    --bg-soft: #1d1f25;
    --text: #eceef2;
    --text-2: #9ba2b0;
    --text-3: #6d7381;
    --accent: #8f88ff;
    --accent-soft: #262a45;
    --up: #4cc57e;
    --up-soft: #16311f;
    --down: #f27d72;
    --down-soft: #3a1d1a;
    --hairline: #24262d;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; }

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ---------- Sticky top nav ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 56px;
}

.logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.logo span { color: var(--accent); }

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* Let this flex child shrink below its content width so the link row
     scrolls inside the bar instead of stretching the page on phones. */
  min-width: 0;
  flex: 1;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
/* About is a utility link, not a content section: muted, pushed to the
   far right beside the search box (margin:auto is a no-op once the nav
   overflows on phones — there it just follows Curiosities). */
.nav a.nav-about { color: var(--text-3); margin-left: auto; }
.nav a.nav-about.active { color: var(--accent); }

/* ---------- Search form in topbar ---------- */

.search-form { flex-shrink: 0; }

.search-input {
  background: var(--bg-soft);
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  width: 140px;
  transition: width 0.2s, box-shadow 0.15s;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus {
  width: 200px;
  box-shadow: 0 0 0 2px var(--accent);
}

/* ---------- Page head: title + controls ---------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}

.page-title h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}
.page-title .quiet { font-size: 13px; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; }

.pills {
  display: flex;
  gap: 2px;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px;
}
.pills a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 999px;
}
.pills a.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ---------- Shared story elements ---------- */

.kicker {
  display: inline-block;
  font-size: 13px;
  font-weight: 650;
  color: var(--accent);
  text-decoration: none;
}
.kicker:hover { text-decoration: underline; }

.kicker-row { display: flex; align-items: center; gap: 8px; }

.source-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: auto;
  flex-shrink: 0;
}

.lead-kicker-row {
  position: relative;
  z-index: 1;
}

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.insight { color: var(--text-2); margin: 6px 0 12px; }
.insight.pending { color: var(--text-3); font-style: italic; }

.stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.chip {
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px 11px;
  color: var(--text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 700; }

.move {
  border-radius: 999px;
  padding: 3px 9px;
  font-weight: 650;
  font-size: 12.5px;
}
.move.up   { color: var(--up);   background: var(--up-soft); }
.move.down { color: var(--down); background: var(--down-soft); }
.move.sharp { font-weight: 700; box-shadow: 0 0 0 1.5px currentColor; }

.quiet { color: var(--text-3); }

.resolve-soon {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #7a5100;
  background: #fef3cc;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
  .resolve-soon { color: #f0c840; background: #2c2000; }
}

/* ---------- Lead story ---------- */

.lead {
  position: relative;            /* anchor for the stretched headline link */
  max-width: 760px;
  padding-bottom: 36px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--hairline);
}
.lead .kicker {
  font-size: 14px;
  position: relative;
  z-index: 1;                    /* stays its own link above the stretched one */
}
.lead h2 {
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.12;
  margin: 8px 0 12px;
}
.lead h2 a { text-decoration: none; }
/* Stretch the headline link over the whole story block, so everywhere reads
   (and clicks) as one big link. Hovering anywhere lights the headline up. */
.lead h2 a::after { content: ""; position: absolute; inset: 0; }
.lead:hover h2 a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}
.lead .insight { font-size: 18px; line-height: 1.55; margin-bottom: 16px; }

/* ---------- Card grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px 20px;
}

.card {
  position: relative;            /* anchor for the stretched headline link */
  padding: 18px;
  margin: 0 -18px;               /* text stays aligned; hover bg extends out */
  border-radius: var(--radius);
  transition: background 0.12s;
}
@media (min-width: 700px) { .card { margin: 0; } }
.card:hover { background: var(--bg-soft); }

.card h3 {
  font-size: 18.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 6px 0 0;
}
.card h3 a { text-decoration: none; }
/* Whole card is the story link; hovering anywhere lights the headline up. */
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card:hover h3 a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.card .kicker-row { position: relative; z-index: 1; }  /* kicker stays its own link */
.card .insight { font-size: 14.5px; line-height: 1.5; }
.card .stats { font-size: 12.5px; }
.card .chip { padding: 2px 9px; }

.empty {
  text-align: center;
  padding: 100px 0;
  color: var(--text-2);
}
.empty h2 { color: var(--text); letter-spacing: -0.02em; }

/* ---------- Article page ---------- */

.article { max-width: 720px; margin: 8px auto 0; }

.article h1 {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.12;
  margin: 10px 0 14px;
}

.article .dek {
  font-size: 20px;
  line-height: 1.5;
  color: var(--text-2);
  margin: 0 0 14px;
}

.byline { font-size: 13.5px; color: var(--text-3); margin: 0 0 6px; }

/* The original market question, demoted to a small source line. */
.source-line { font-size: 13px; color: var(--text-3); margin: 0 0 24px; }
.source-line a { color: var(--text-2); }

/* Staleness notice: shown when the market has moved ≥10pp since the article was written */
.stale-notice {
  font-size: 13px;
  color: var(--text-2);
  margin: 8px 0 20px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
}

.opinion-crosslink {
  font-size: 14px;
  margin: 24px 0 0;
  padding: 10px 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
}
.opinion-crosslink a { color: var(--text); font-weight: 550; text-decoration: none; }
.opinion-crosslink a:hover { color: var(--accent); }

/* Stat tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 32px;
}
.tile {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile-label { font-size: 12px; font-weight: 550; color: var(--text-3); }
.tile-value {
  font-size: 15.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-value b { color: var(--accent); }
.tile-value.up { color: var(--up); }
.tile-value.down { color: var(--down); }
.tile-sub {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Body copy */
.body { font-size: 18.5px; line-height: 1.75; }
.body p { margin: 0 0 1.25em; }
.body .pending { color: var(--text-2); font-style: italic; font-size: 16px; }
.body code {
  background: var(--bg-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.85em;
}

/* Outcomes list with mini probability bars */
.outcomes { margin: 36px 0 8px; }
.outcomes h2 {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}
.outcome {
  display: grid;
  grid-template-columns: minmax(90px, 1.1fr) 2fr 52px 56px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.outcome-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}
.outcome-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}
.outcome-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  min-width: 2px;
}
.outcome-pct { text-align: right; font-weight: 700; }
.outcome-move { text-align: right; font-size: 12.5px; font-weight: 600; }
.outcome-move.up { color: var(--up); }
.outcome-move.down { color: var(--down); }
.outcome-move.flat { color: var(--text-3); }

/* Source markets (the cluster) at the foot of an article */
.sources { margin: 36px 0 8px; }
.sources h2 {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
.source-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 7px 0;
  border-top: 1px solid var(--hairline);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.source-row a {
  color: var(--text-2);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-row a:hover { color: var(--accent); }
.source-row .quiet { white-space: nowrap; }
.source-row .quiet b { color: var(--text); }

.article-links {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 999px;
  transition: opacity 0.12s;
}
.button:hover { opacity: 0.88; color: #fff; }
button.button { border: none; cursor: pointer; font-family: inherit; }
.back { font-size: 14px; color: var(--text-2); text-decoration: none; }
.back:hover { color: var(--text); }

/* ---------- Crypto Positioning widget (Finance section) ---------- */

.crypto-widget {
  margin-bottom: 28px;
  padding: 14px 16px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
}
.crypto-widget-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.crypto-widget-sublabel { margin-top: 14px; }
.crypto-rows { display: flex; flex-direction: column; gap: 6px; }
.crypto-row {
  display: grid;
  grid-template-columns: 40px 90px 58px 110px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}
.crypto-asset { font-weight: 700; color: var(--text); }
.crypto-price { color: var(--text); font-variant-numeric: tabular-nums; }
.crypto-change,
.crypto-funding { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.crypto-change.up,  .crypto-funding.up   { color: var(--up); }
.crypto-change.down,.crypto-funding.down  { color: var(--down); }
.crypto-change.flat,.crypto-funding.flat  { color: var(--text-3); }
.crypto-lean {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lean-long    { color: var(--up); }
.lean-short   { color: var(--down); }
.lean-neutral { color: var(--text-3); }
.crypto-widget-footer {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-3);
}
.crypto-digest {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  font-style: italic;
}

@media (max-width: 480px) {
  .crypto-row { grid-template-columns: 40px 80px 56px 1fr; }
  .crypto-funding { display: none; }
}

/* ---------- Footer ---------- */

footer {
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-3);
}
footer strong { color: var(--text-2); }
footer a { color: var(--text-2); }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  main { padding-top: 20px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .lead { padding-bottom: 26px; margin-bottom: 26px; }
  .lead .insight { font-size: 16.5px; }
  .body { font-size: 17.5px; }
  .card h3 { font-size: 17px; }
  .article .dek { font-size: 18px; }
  .outcome { grid-template-columns: minmax(80px, 1fr) 1.2fr 48px 50px; gap: 8px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  /* 44px tap target for the article CTA button */
  .button { padding: 11px 20px; }
}

/* ---------- Narrow phones: two-row topbar ---------- */
/* On phones (≤560px) the single-row topbar leaves only ~40px for the
   nav, which is nearly unusable. Reflow into two rows: logo + search on
   top, nav scrolls full-width below. CSS `order` resequences the items
   visually without touching the DOM (screen-reader order unchanged). */

@media (max-width: 560px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 0;
    min-height: auto;
    padding: 0 16px;
  }
  /* Row 1: logo (stretches left) + search (right) */
  .logo  { order: 1; flex: 1; padding: 12px 0; }
  .search-form { order: 2; padding: 10px 0; }
  .search-input { width: 120px; }
  .search-input:focus { width: 150px; }
  /* Row 2: nav scrolls full-width */
  .nav {
    order: 3;
    flex-basis: 100%;
    border-top: 1px solid var(--hairline);
    padding: 2px 0;
    gap: 2px;
  }
  /* 44px tap targets for nav links */
  .nav a { padding: 11px 10px; font-size: 13.5px; }
}

/* Very narrow phones (<380px): drop the visual outcome bar to recover label space */
@media (max-width: 380px) {
  .outcome { grid-template-columns: 1fr 52px 54px; gap: 6px; }
  .outcome-bar { display: none; }
}

/* ---------- Related stories (IDEAS.md #33) ---------- */

.related {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--hairline);
}

.related h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 20px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* ---------- Email signup box (IDEAS.md #25) ---------- */

.signup-box {
  margin: 56px 0 0;
  padding: 32px 24px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  text-align: center;
}

/* Mid-page placement on the front page: cards continue below the box. */
.signup-box.mid { margin: 40px 0 44px; }

.signup-pitch {
  margin: 0 0 20px;
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
}

.signup-form {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.signup-input {
  padding: 10px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  width: 280px;
  max-width: 100%;
  outline: none;
}

.signup-input:focus { border-color: var(--accent); }

.signup-btn {
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.signup-btn:hover { opacity: 0.88; }

/* ---------- Post-subscribe / confirm notice banners ---------- */

.notice {
  margin: 0 0 24px;
  padding: 14px 18px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--accent);
}

.notice.notice-ok {
  background: var(--up-soft);
  color: var(--up);
}
