/* Session B: hero + "the square sorts itself", platforms, how it works, report mock. Tokens + components.css classes. */

/* ---------- hero ---------- */
.hero { padding: clamp(32px, 3.4vw, 48px) 0 var(--section-y); background: var(--hero-glow), var(--ink); }
.hero-copy { max-width: 860px; margin: 0 auto; text-align: center; }
.hero .eyebrow { margin-bottom: 14px; }
.hero .h1 { max-width: 18ch; margin: 0 auto; }
.hero .lead { max-width: 620px; margin: 16px auto 0; }
.hero .input-search { margin: 24px auto 0; text-align: left; }
.hero .btn { padding: 0 22px; }
.hero-note { margin: 12px 0 0; color: var(--muted); font-size: var(--fs-small); }

/* caret: a transparent mirror of the input text, its ::after sits right after the last character */
.field { position: relative; flex: 1; min-width: 0; display: flex; }
.field input { width: 100%; }
.mirror { position: absolute; left: 0; top: 50%; transform: translateY(-50%); font: 500 18px var(--font); color: transparent; white-space: pre; pointer-events: none; display: none; }
.mirror::after { content: ""; display: inline-block; width: 2px; height: 22px; margin-left: 1px; vertical-align: middle; background: var(--violet); animation: caret 1s steps(1) infinite; }
.input-search.is-typing .mirror { display: block; }
@keyframes caret { 50% { opacity: 0; } }

/* ---------- caption rail: 1 Collecting, 2 Reading, 3 Counting ---------- */
.caps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 32px 0 0; padding: 0; list-style: none; }
.cap { position: relative; display: flex; gap: 12px; align-items: flex-start; padding-top: 12px; transition: opacity 300ms ease-out; }
.cap::before, .cap::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; border-radius: 2px; background: var(--line-strong); }
.cap::after { background: var(--violet); transform-origin: left; }
.cap-n { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--violet-tint); color: var(--violet); font: 500 13px var(--mono); transition: background-color 300ms, color 300ms, box-shadow 300ms; }
.cap-t { color: var(--muted); font-size: 14px; line-height: 1.5; }
.cap-t b { display: block; margin-bottom: 2px; color: var(--text); font-size: 15px; font-weight: 600; }
/* JS marks steps; with no classes (no JS / reduced motion) all three read as done */
.cap.is-todo .cap-t, .cap.is-todo .cap-t b { color: var(--muted); }
.cap.is-todo .cap-n { background: var(--panel-2); color: var(--muted); }
.cap.is-todo::after { transform: scaleX(0); }
.cap.is-active .cap-n { background: var(--grad-primary); color: var(--text); box-shadow: var(--glow); }
.cap.is-active::after { animation: cap-fill var(--dur, 1s) linear both; }
@keyframes cap-fill { from { transform: scaleX(0); } }

/* ---------- the wall ----------
   One DOM, two layouts. Default = sorted: three bottom-aligned columns whose heights are the split
   (a bar chart made of posts). JS adds .is-grid for steps 1-2 (columns become display:contents and
   tiles fall into a 4 x 4 grid by their inline `order`). Same height in both, so nothing below jumps. */
.wall {
  --row: 188px; --gap: 16px; --head: 40px;
  --wall-h: calc(4 * var(--row) + 3 * var(--gap));
  display: flex; align-items: flex-end; gap: var(--gap); height: var(--wall-h); margin-top: 20px;
}
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; height: calc(var(--head) + (100% - var(--head)) * var(--h)); }
.col-head {
  display: flex; align-items: baseline; justify-content: space-between; height: var(--head); margin: 0; padding-bottom: 12px;
  font-size: 12px; font-weight: 600; letter-spacing: var(--track-eyebrow); text-transform: uppercase;
  transition: opacity 300ms ease-out;
}
.col-head b { font: 500 15px var(--mono); letter-spacing: 0; }
.col-list { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }

.tile {
  --s: var(--neu);
  position: relative; isolation: isolate; overflow: hidden; min-width: 0; min-height: 0; flex: 1 1 0;
  display: grid; grid-template-columns: auto 1fr auto; align-content: center; align-items: start; gap: 8px 12px; padding: 12px 14px;
  container-type: size; /* tiles are always sized by their layout, so they can query their own height */
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-tile); color: var(--text);
  transition: opacity 380ms cubic-bezier(.2, .8, .2, 1), transform 380ms cubic-bezier(.2, .8, .2, 1), border-color 420ms ease-out;
}
.tile[data-s="pos"] { --s: var(--pos); }
.tile[data-s="neg"] { --s: var(--neg); }
.tile::before { /* sentiment wash from the top; a layer so it can fade in */
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity 420ms ease-out;
  background: linear-gradient(180deg, color-mix(in srgb, var(--s) 8%, var(--panel)) 0%, var(--panel) 70%);
}
.tile > * { transition: opacity 250ms ease-out; }
.tile-top { display: contents; }
.tile .pf { grid-column: 1; grid-row: 1; }
.dot { grid-column: 3; grid-row: 1; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--line-strong); transition: background-color 420ms ease-out, box-shadow 420ms ease-out; }
.tile-text {
  grid-column: 2; grid-row: 1; margin: 0; font-size: 14px; line-height: 1.45; font-weight: 500;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.tile-tags, .tile-meta { display: none; margin: 0; }
/* sorted strips tall enough for a second line get the emotion + theme back */
@container (min-height: 70px) { /* content box: 2 text lines + chip row */
  .wall:not(.is-grid) .tile-tags { display: flex; gap: 6px; grid-column: 2 / 4; grid-row: 2; min-width: 0; }
}

/* grid layout for steps 1-2 */
.wall.is-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: var(--row); align-items: stretch; }
.wall.is-grid .col, .wall.is-grid .col-list { display: contents; }
.wall.is-grid .col-head { display: none; }
.wall.is-grid .tile { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 16px; }
.wall.is-grid .tile-top { display: flex; align-items: center; justify-content: space-between; }
.wall.is-grid .dot { margin: 0; }
.wall.is-grid .tile-text { flex: 1; font-size: 15px; -webkit-line-clamp: 3; }
.wall.is-grid .tile-tags { display: flex; gap: 6px; min-width: 0; opacity: 0; transform: translateY(4px); transition: opacity 300ms ease-out, transform 300ms ease-out; }
.wall.is-grid .tile.on .tile-tags { opacity: 1; transform: none; }
.wall.is-grid .tile-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font: 500 12px/1.2 var(--mono); white-space: nowrap; }
.tile-tags span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.3; }
.t-emo { flex: none; background: var(--violet-tint); color: #c4b0ff; } /* emotions are violet, not sentiment (spec B 5.2) */
.t-thm { min-width: 0; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }

/* sequence states */
.wall.is-playing .tile { opacity: 0; transform: translateY(10px) scale(.98); }
.wall.is-playing .tile.in { opacity: 1; transform: none; }
.wall.is-leaving .tile { opacity: 0; transition-duration: 250ms; }
.wall.is-playing .col-head { opacity: 0; }
.wall.is-playing.is-headed .col-head { opacity: 1; }
/* labeled (step 2) and sorted: sentiment border, wash, dot */
.wall:not(.is-playing) .tile, .wall .tile.on { border-color: color-mix(in srgb, var(--s) 45%, transparent); }
.wall:not(.is-playing) .tile::before, .wall .tile.on::before { opacity: 1; }
.wall:not(.is-playing) .dot, .wall .tile.on .dot { background: var(--s); box-shadow: 0 0 0 4px color-mix(in srgb, var(--s) 15%, transparent); }
.wall.is-playing .tile.on .dot { animation: pulse 420ms ease-out; }
@keyframes pulse { 50% { transform: scale(1.6); } }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .wall:not(.is-playing):not(.is-leaving) .tile { transition-duration: 180ms; transition-timing-function: ease-out; }
  .wall:not(.is-playing):not(.is-leaving) .tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--s) 70%, transparent); }
}

/* split bar + legend + themes */
.wall-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; margin-top: 28px; }
.split { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; background: var(--ink); }
.wall-foot .split { flex: 1 0 100%; width: 100%; }
.split > i { flex: 0 0 var(--w); background: currentColor; transition: flex-basis 300ms cubic-bezier(.2, .8, .2, 1); }
.split > i:nth-child(2) { transition-delay: 150ms; }
.split > i:nth-child(3) { transition-delay: 300ms; }
.is-reset .split > i { flex-basis: 0; transition-delay: 0s; }
.s-pos { color: var(--pos); }
.s-neu { color: var(--neu); }
.s-neg { color: var(--neg); }
.legend { margin: 0; font: 500 14px/1.4 var(--mono); }
.sep { color: var(--muted); }
.themes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; padding: 0; list-style: none; }
.label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: var(--track-eyebrow); text-transform: uppercase; }
.themes .label { margin-right: 4px; }
.theme { padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 14px; font-weight: 500; line-height: 1.3; }
.wall-foot .legend, .wall-foot .theme { transition: opacity 300ms ease-out 300ms; }
.wall-foot .theme + .theme { transition-delay: 360ms; }
.wall-foot .theme + .theme + .theme { transition-delay: 420ms; }
.wall-foot.is-reset .legend, .wall-foot.is-reset .theme { opacity: 0; transition-delay: 0s; transition-duration: 200ms; }

/* ---------- platforms ---------- */
.platforms { padding: 24px 0 var(--section-y); }
.platforms .wrap::before { content: ""; display: block; height: 1px; margin-bottom: 40px; background: var(--line); }
.platform-list { display: flex; justify-content: space-between; gap: 20px 14px; margin: 0; padding: 0; list-style: none; }
.platform-list li { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-small); font-weight: 500; }
.platforms-note { margin: 32px 0 0; text-align: center; color: var(--muted); font-size: var(--fs-small); }

/* ---------- how it works ---------- */
.how { padding: var(--section-y) 0; background: var(--section-fade); }
.how .h2, .report .h2 { max-width: 16ch; }
.how .h2 { margin: 0 0 56px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; margin: 0; padding: 0; list-style: none; }
.step { position: relative; }
.step-n { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--violet-tint); color: var(--violet); font: 500 16px var(--mono); }
.step .h3 { margin: 20px 0 8px; }
.step p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.step:not(:last-child)::after { content: ""; position: absolute; top: 22px; left: 56px; right: -20px; height: 1px; background: var(--line); }

/* ---------- report mock ---------- */
.report { padding: var(--section-y) 0; }
.report .lead { margin-top: 16px; }
.mock {
  margin-top: 48px; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 40px 120px -40px rgba(110, 40, 220, .35);
}
.mock-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.mock-title { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.3; }
.mock-meta { margin: 4px 0 0; color: var(--muted); font: 500 13px/1.4 var(--mono); }
.mock-actions { display: flex; gap: 8px; }
.fake-btn { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--r-control); font-size: 14px; font-weight: 600; }
.panels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; margin-top: 20px; }
.panel { grid-column: span 4; min-width: 0; display: flex; flex-direction: column; padding: 20px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; }
.panel-engaged { grid-column: span 7; }
.panel-trend { grid-column: span 5; }
.panel > .label, .panel-row { margin-bottom: 16px; }
.panel-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-note { margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.5; }
.panel > :nth-last-child(2) { margin-bottom: 18px; }
.big { display: block; color: var(--pos); font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.big + small { display: block; margin: 6px 0 18px; color: var(--muted); font-size: 14px; }
.panel .legend { margin-top: 10px; font-size: 13px; }
.n { color: var(--muted); font: 500 13px var(--mono); text-align: right; white-space: nowrap; }
.rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; }
.emo { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; font-size: 14px; }
.bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .05); }
.bar > i { display: block; width: var(--w); height: 100%; border-radius: inherit; background: var(--violet); }
.rows-themes { gap: 16px; }
.thm { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: 14px; font-weight: 500; }
.thm .split { grid-column: 1 / -1; grid-row: 2; height: 6px; gap: 1px; }
.engaged li { display: flex; align-items: center; gap: 12px; padding: 12px 0 12px 14px; border-left: 3px solid var(--s); font-size: 14px; line-height: 1.45; }
.engaged li + li { border-top: 1px solid var(--line); }
.engaged li[data-s="pos"] { --s: var(--pos); }
.engaged li[data-s="neu"] { --s: var(--neu); }
.engaged li[data-s="neg"] { --s: var(--neg); }
.engaged p { flex: 1; min-width: 0; margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.chip-follow { flex: none; padding: 3px 10px; border-radius: 999px; background: var(--violet-tint); color: #c4b5fd; font-size: 12px; font-weight: 600; line-height: 1.4; } /* 9:1 on the tint */
.trend { display: block; width: 100%; height: 140px; overflow: visible; }
.trend line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.trend polyline { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.trend .l-pos { stroke: var(--pos); }
.trend .l-neg { stroke: var(--neg); }
.trend .l-dot { fill: none; stroke: var(--pos); stroke-width: 8; stroke-linecap: round; vector-effect: non-scaling-stroke; } /* zero-length path + round cap = a dot that stays round when stretched */
.days { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font: 500 11px var(--mono); }
.trend-legend { margin: 12px 0 0; font: 500 13px/1.5 var(--mono); }

/* ---------- tablet ---------- */
@media (max-width: 1023px) {
  .wall { --row: 200px; --gap: 14px; }
  .wall.is-grid { grid-template-columns: repeat(3, 1fr); }
  .wall .t-tab { display: none !important; }
  .wall.is-grid .tile { padding: 14px; }
  .caps { gap: 14px; }
  .wall-foot { flex-direction: column; align-items: flex-start; }
  .wall-foot .split { flex: none; }
  .platform-list { display: grid; grid-template-columns: repeat(4, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); gap: 40px 32px; }
  .step::after { display: none; }
  .panel-sent, .panel-emo { grid-column: span 6; }
  .panel-themes, .panel-engaged, .panel-trend { grid-column: span 12; }
}

/* ---------- phone ---------- */
@media (max-width: 640px) {
  /* step 3 on phones: three narrow stacks of squares, one per post, logo only */
  .wall { --row: 184px; --gap: 10px; --head: 44px; --wall-h: 340px; margin-top: 24px; }
  .wall.is-grid { grid-template-columns: repeat(2, 1fr); height: auto; }
  .wall .t-ph { display: none !important; }
  .wall.is-grid .tile { padding: 12px; gap: 8px; }
  .wall.is-grid .tile-text { font-size: 13px; line-height: 1.4; }
  .wall.is-grid .tile-meta { font-size: 10.5px; justify-content: flex-end; }
  .wall.is-grid .tile-meta .handle { display: none; }
  .tile-tags span { padding: 2px 7px; font-size: 11px; }
  .wall.is-grid .tile-tags { flex-wrap: wrap; overflow: hidden; max-height: 20px; }
  .wall:not(.is-grid) .tile { grid-template-columns: 1fr; place-items: center; align-content: stretch; padding: 0; }
  .wall:not(.is-grid) .tile > :not(.tile-top), .wall:not(.is-grid) .dot { display: none; }
  .wall:not(.is-grid) .tile .pf { grid-area: 1 / 1; }
  .col-head { flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px; font-size: 10px; padding-bottom: 8px; }
  .col-head b { font-size: 14px; }
  /* rail = one row of 3 step pills; only the active step's sentence shows under it
     (no JS / reduced motion / stopped: no active class, so step 3's sentence shows) */
  .caps { position: relative; gap: 6px; margin-top: 32px; padding-bottom: 54px; } /* room for a 2-line sentence */
  .cap { position: static; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel-2); }
  .cap::before, .cap::after { display: none; }
  .cap.is-active { border-color: var(--violet); }
  .cap-n { width: 20px; height: 20px; border-radius: 6px; font-size: 11px; }
  .cap-t b { margin: 0; font-size: 13px; white-space: nowrap; }
  .cap-s { display: none; position: absolute; left: 0; right: 0; top: 44px; font-size: 13px; line-height: 1.45; text-align: center; }
  .cap.is-active .cap-s, .caps:not(:has(.is-active)) .cap:last-child .cap-s { display: block; }
  .legend { font-size: 12px; }
  .platform-list { gap: 20px 8px; }
  .platforms-note { text-align: left; }
  .steps { grid-template-columns: 1fr; gap: 28px; }
  .step { display: grid; grid-template-columns: 44px 1fr; column-gap: 16px; }
  .step-n { grid-row: span 2; }
  .step .h3 { margin: 9px 0 6px; }
  .step:not(:last-child)::after { display: block; top: 52px; bottom: -20px; left: 22px; right: auto; width: 1px; height: auto; }
  .mock { padding: 16px; }
  .panel { grid-column: span 12 !important; padding: 16px; }
  .engaged p { -webkit-line-clamp: 1; display: block; white-space: nowrap; text-overflow: ellipsis; }
}
