/* The Twitter sentiment tracker: noise flows in at the top and a brief comes out at the bottom. The three daily
   questions as a poster, the numbers as big type, the pipeline as a river that narrows at each stage, and the
   label words as bands. Teal is the raw stream, violet the finished brief. */

.post[data-accent="sentiment"] { --s-mid: color-mix(in oklab, var(--accent) 50%, var(--accent-2)); --s-neutral: var(--gray-500); }
/* A cool grey for "neutral" in light mode: the warm --gray-500 turns the band brown. 5.6 : 1 with the band's text. */
:root[data-theme="light"] .post[data-accent="sentiment"] { --s-neutral: #5d6068; }

.post[data-accent="sentiment"] .prose h2 { text-wrap: balance; }

/* The title fades from the text colour into the two accents. */
.post[data-accent="sentiment"] h1 {
  width: fit-content;
  background: linear-gradient(100deg, var(--text) 35%, var(--accent) 72%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@media (min-width: 640px) {
  .post[data-accent="sentiment"] h1 { font-size: 2.75rem; letter-spacing: -0.035em; }
}

/* The three questions: one ruled line each, the key word in its accent, a link down to the stage that answers it. */
.prose .s-asks { list-style: none; margin: 1.25em 0 0; padding: 0; counter-reset: s-ask; }
.prose .s-asks li {
  counter-increment: s-ask;
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: baseline;
  column-gap: 0.75rem;
  margin: 0;
  padding: 0.75rem 0 0.85rem;
  border-top: 1px solid var(--line);
}
.prose .s-asks li:last-child { border-bottom: 1px solid var(--line); }
.s-asks li::before { content: counter(s-ask, decimal-leading-zero); font: 400 0.8125rem/1 var(--mono); color: var(--gray-500); }
.s-asks li > span { text-wrap: balance; font: 600 clamp(1.5rem, 1.05rem + 1.7vw, 2.25rem)/1.15 var(--sans); letter-spacing: -0.025em; color: var(--text); }
.s-asks li:nth-child(1) { --c: var(--accent); }
.s-asks li:nth-child(2) { --c: var(--s-mid); }
.s-asks li:nth-child(3) { --c: var(--accent-2); }
.s-asks em { font-style: normal; color: var(--c); }
.prose .s-asks a { font: 400 0.8125rem/1.5 var(--mono); color: var(--gray-500); text-decoration: none; white-space: nowrap; transition: color 0.15s; }
.prose .s-asks a:hover, .prose .s-asks a:focus-visible { color: var(--c); }

/* The two headline numbers, the page's biggest type: big gradient numerals over a hairline, no boxes, teal for
   the accounts and violet for the posts. Under them, the small facts on one quiet line. */
.prose .s-hero { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 1.75rem; margin: 0; padding: 0; }
.prose .s-hero li {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 1.125rem;
  line-height: 1.4;
  color: var(--gray-600);
}
.s-hero li:nth-child(1) { --c1: var(--accent); --c2: var(--s-mid); }
.s-hero li:nth-child(2) { --c1: var(--s-mid); --c2: var(--accent-2); }
.s-hero b {
  display: block;
  width: fit-content;
  margin-bottom: 0.5rem;
  font: 600 clamp(4.25rem, 2.4rem + 6.4vw, 6.75rem)/0.95 var(--sans);
  letter-spacing: -0.055em;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.s-hero i { font-style: normal; font-weight: 400; font-size: 0.6em; vertical-align: 0.5em; }
.prose .s-quiet { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 0; margin: 1.5rem 0 0; padding: 0; font: 400 0.8125rem/1.5 var(--mono); color: var(--gray-500); }
.prose .s-quiet li { margin: 0; }
.s-quiet li:not(:last-child)::after { content: "·"; margin: 0 0.6rem; }

/* The river. Left: three streams join, the bed narrows at each stage, then it splits into the three groups.
   Right: the text of each stage, on a rule that continues the stage's gate. */
.prose .s-river { --r: 5rem; --gap: 1.25rem; margin: 2em 0 2.25em; }
.s-in, .s-out { display: grid; grid-template-columns: var(--r) 1fr; column-gap: var(--gap); font: 400 0.875rem/2rem var(--mono); color: var(--gray-600); }
.s-in { grid-template-rows: repeat(3, 2rem) 1.5rem; --c: var(--accent); }
.s-out { grid-template-rows: 1.5rem repeat(3, 2rem); --c: var(--accent-2); }
.s-in svg, .s-out svg { grid-column: 1; grid-row: 1 / -1; display: block; width: 100%; height: 100%; overflow: visible; }
.s-in span, .s-out span { position: relative; grid-column: 2; white-space: nowrap; }
.s-out span:nth-of-type(1) { grid-row: 2; }
.s-out span:nth-of-type(2) { grid-row: 3; }
.s-out span:nth-of-type(3) { grid-row: 4; }
.s-in span::before, .s-out span::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--gap) - 3px);
  top: calc(50% - 3px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c);
}
.s-river path { fill: none; stroke: var(--c); vector-effect: non-scaling-stroke; }
.s-ch { stroke-width: 3; opacity: 0.22; }
.s-fl { stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: 2 6; animation: s-dash 1.2s linear infinite; }
@keyframes s-dash { to { stroke-dashoffset: -8; } }

.prose .s-stages { list-style: none; margin: 0; padding: 0; counter-reset: s-stage; }
.prose .s-stages li {
  --c1: color-mix(in oklab, var(--accent) var(--p1), var(--accent-2));
  --c2: color-mix(in oklab, var(--accent) var(--p2), var(--accent-2));
  counter-increment: s-stage;
  display: grid;
  grid-template-columns: var(--r) 1fr;
  column-gap: var(--gap);
  margin: 0;
  scroll-margin-top: 6rem;
}
/* --a and --b: the bed's width at the top and the bottom of the stage, as a share of the river column. */
.s-stages li:nth-child(1) { --a: 1; --b: 0.84; --p1: 100%; --p2: 83%; }
.s-stages li:nth-child(2) { --a: 0.84; --b: 0.7; --p1: 83%; --p2: 67%; }
.s-stages li:nth-child(3) { --a: 0.7; --b: 0.57; --p1: 67%; --p2: 50%; }
.s-stages li:nth-child(4) { --a: 0.57; --b: 0.45; --p1: 50%; --p2: 33%; }
.s-stages li:nth-child(5) { --a: 0.45; --b: 0.34; --p1: 33%; --p2: 17%; }
.s-stages li:nth-child(6) { --a: 0.34; --b: 0.24; --p1: 17%; --p2: 0%; }
.s-stages li:nth-child(7) { --a: 0.24; --b: 0.16; --p1: 0%; --p2: 0%; }
.s-bed {
  position: relative;
  overflow: hidden;
  clip-path: polygon(calc(50% - var(--a) * 50%) 0, calc(50% + var(--a) * 50%) 0, calc(50% + var(--b) * 50%) 100%, calc(50% - var(--b) * 50%) 100%);
  background: linear-gradient(color-mix(in oklab, var(--c1) 18%, transparent), color-mix(in oklab, var(--c2) 18%, transparent));
}
/* The posts in the stream: three dot grids with one 24 px period, moved down one period per loop. */
.s-bed::before {
  content: "";
  position: absolute;
  inset: -24px 0 0;
  background:
    radial-gradient(circle, var(--c1) 0 1.3px, transparent 1.8px) 0 0 / 13px 24px,
    radial-gradient(circle, var(--c2) 0 1px, transparent 1.5px) 6px 9px / 19px 24px,
    radial-gradient(circle, var(--c1) 0 1px, transparent 1.5px) 3px 16px / 16px 24px;
  opacity: 0.8;
  animation: s-flow 2.4s linear infinite;
}
@keyframes s-flow { to { transform: translateY(24px); } }
/* The gate at the top of each stage, as wide as the bed there. */
.s-bed::after { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--c1); }
.s-stages li > div { padding: 0.9rem 0 1.25rem; border-top: 1px solid var(--line); font-size: 1.0625rem; line-height: 1.55; color: var(--gray-700); }
.s-stages b { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.2rem; font-size: 1.1875rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.s-stages b::after { content: counter(s-stage, decimal-leading-zero); font: 400 0.75rem/1 var(--mono); color: var(--c1); }
.s-stages li:target b { color: var(--c1); }

/* The label words as one spectrum per group, the word at the centre of its colour. "ignored" stays an empty,
   dashed segment at the end. */
.prose .s-moods { margin: 1.75em 0 0.75em; }
.prose .s-key { margin: 0 0 0.6rem; font: 400 0.8125rem/1.5 var(--mono); color: var(--gray-500); }
.s-key b { font-weight: 400; color: var(--text); }
.prose .s-band { list-style: none; display: flex; margin: 0 0 1.75rem; padding: 0; border-radius: 0.5rem; }
.s-band:first-of-type { background: linear-gradient(90deg, var(--accent) 16.7%, var(--s-neutral) 50%, var(--accent-2) 83.3%); }
.s-band:last-of-type { background: linear-gradient(90deg, var(--accent) 12.5%, var(--s-mid) 37.5%, var(--accent-2) 62.5% 75%, transparent 75%); }
.prose .s-band li { flex: 1 1 0; min-width: 0; margin: 0; padding: 1rem 0.25rem; color: var(--page); font: 400 0.9375rem/1 var(--mono); text-align: center; }
.prose .s-band:last-of-type li:nth-child(4) { color: var(--gray-600); outline: 1px dashed var(--line); outline-offset: -1px; border-radius: 0 0.5rem 0.5rem 0; }

/* The rules: a short statement and its line, on hairlines. */
.prose .s-rules { list-style: none; margin: 1.25em 0 2.25em; padding: 0; }
.prose .s-rules li { display: grid; grid-template-columns: 17rem 1fr; column-gap: 1.75rem; align-items: baseline; margin: 0; padding: 1.1rem 0 1.2rem; border-top: 1px solid var(--line); }
.prose .s-rules li:last-child { border-bottom: 1px solid var(--line); }
.s-rules b { text-wrap: balance; font: 600 1.3125rem/1.25 var(--sans); letter-spacing: -0.02em; color: var(--text); }
.s-rules span { font-size: 1rem; line-height: 1.55; color: var(--gray-600); }

/* The screenshot in a thin teal-to-violet frame. */
.post[data-accent="sentiment"] .shot img {
  border: 1px solid transparent;
  border-radius: 0.75rem;
  background: linear-gradient(var(--page), var(--page)) padding-box, linear-gradient(135deg, var(--accent), var(--accent-2)) border-box;
  box-shadow: 0 1.75rem 3.5rem -2.25rem color-mix(in srgb, var(--accent) 55%, transparent);
}

@media (max-width: 639px) {
  .prose .s-asks li { grid-template-columns: 2rem 1fr; }
  .prose .s-asks a { grid-column: 2; margin-top: 0.35rem; }
  .prose .s-hero { grid-template-columns: 1fr; gap: 1.5rem; }
  .s-hero b { font-size: clamp(4.5rem, 1rem + 18vw, 5.75rem); }
  .prose .s-quiet { flex-direction: column; }
  .s-quiet li:not(:last-child)::after { content: none; }
  .prose .s-river { --r: 3.25rem; --gap: 0.875rem; }
  .s-stages li > div { font-size: 1rem; }
  .s-stages b { font-size: 1.125rem; }
  .prose .s-band li { padding: 0.9rem 0.15rem; font-size: 0.8125rem; }
  .prose .s-rules li { grid-template-columns: 1fr; row-gap: 0.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .s-bed::before, .s-fl { animation: none; }
}
@media (forced-colors: active) {
  .post[data-accent="sentiment"] h1, .s-hero b { background: none; color: CanvasText; }
}
