/* =========================================================
   sentiment-explore.css — Case 02.1, linked only from work/sentiment.html
   1. Method stepper (#method)
   2. Explorer, Fig. 2 (#sx): toolbar, chart frame, crosshair read-out, dividing line,
      zoom strip, split read-out, what-if
   3. Notes list wrapper
   Colour roles: --accent = responds to the visitor; --play = the visitor's what-if;
   --mark = the study's own split (static).
   ========================================================= */

/* ---------- Shared small button ---------- */
.sx-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--paper-2); color: var(--ink); font: 500 13px/1 var(--sans); cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease); }
.sx-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.sx-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sx-btn:disabled { opacity: .45; cursor: default; }

/* ---------- 1. Method ---------- */
.sx-method { margin-top: clamp(32px, 5vw, 56px); padding: clamp(16px, 2.4vw, 28px); border: 1px solid var(--rule); border-radius: 14px; background: var(--paper-2); --m: 0; }
.sx-method-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.sx-nodes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; position: relative; }
.sx-nodes li { position: relative; display: flex; }
/* connectors between steps */
.sx-nodes li + li::before { content: ""; position: absolute; right: 100%; top: 50%; width: 10px; height: 1px; background: var(--rule); }
.sx-node { all: unset; box-sizing: border-box; flex: 1; display: flex; flex-direction: column; gap: 4px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--rule);
  border-radius: 10px; background: var(--paper); cursor: pointer; transition: border-color .25s var(--ease), background .25s var(--ease); }
.sx-node-n { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.sx-node-t { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink); line-height: 1.25; }
.sx-node:hover { border-color: var(--accent); }
.sx-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sx-method.is-live .sx-node.is-past { border-color: color-mix(in srgb, var(--accent) 35%, var(--rule)); }
.sx-method.is-live .sx-node.is-past .sx-node-n { color: var(--accent); }
.sx-method.is-live .sx-node.is-on { border-color: var(--accent); background: var(--accent-soft); }
.sx-method.is-live .sx-node.is-on .sx-node-n, .sx-method.is-live .sx-node.is-on .sx-node-t { color: var(--accent); }
.sx-method.is-live .sx-nodes li + li::before { background: var(--rule); }

/* panels: all stacked in one cell so the tallest reserves the space (no shift) */
.sx-mpanels { margin-top: 20px; display: grid; gap: 22px; }
.sx-mpanel { display: flex; flex-direction: column; gap: 8px; max-width: 68ch; }
.sx-mpanel p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--ink-2); }
.sx-method.is-live .sx-mpanels { gap: 0; }
.sx-method.is-live .sx-mpanel { grid-area: 1 / 1; visibility: hidden; opacity: 0; transform: translateY(6px);
  transition: opacity .35s var(--ease), transform .45s var(--ease), visibility 0s linear .35s; }
.sx-method.is-live .sx-mpanel.is-on { visibility: visible; opacity: 1; transform: none; transition: opacity .35s var(--ease), transform .45s var(--ease), visibility 0s; }
.sx-mnav { display: none; }
.sx-method.is-live .sx-mnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--rule); }
@media (max-width: 800px) {
  .sx-nodes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sx-nodes li:nth-child(4)::before { display: none; }
}
@media (max-width: 420px) {
  .sx-node { padding: 8px; min-height: 58px; }
  .sx-node-t { font-size: 13px; }
  .sx-nodes { gap: 8px; }
  .sx-nodes li + li::before { width: 8px; }
}

/* ---------- 2. Explorer ---------- */
html:not(.js) .sx-fig { display: none; }
.sx-nojs { display: none; }
html:not(.js) .sx-nojs { display: block; }
.sx-chapter .cs-chapter-body { margin-bottom: 0; }
.sx-fig { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* Toolbar */
.sx-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; }
.sx-series { display: flex; flex-wrap: wrap; gap: 6px; }
.sx-chip { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 12px; border: 1px solid var(--rule);
  border-radius: 999px; font: 500 13px/1 var(--sans); color: var(--ink-3); cursor: pointer; transition: border-color .2s var(--ease), color .2s var(--ease), background .2s var(--ease); }
.sx-chip i { width: 14px; height: 0; border-top: 2px solid currentColor; opacity: .5; }
.sx-chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink-3); background: var(--paper); }
.sx-chip[aria-pressed="true"] i { opacity: 1; }
.sx-chip:hover { border-color: var(--accent); }
.sx-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sx-chip.sx-r-bh[aria-pressed="true"] i { border-color: var(--ink); }
.sx-chip.sx-r-st[aria-pressed="true"] i { border-color: var(--accent); }
.sx-chip.sx-r-wi[aria-pressed="true"] i { border-top-style: dashed; border-color: var(--play); }
.sx-chip.sx-r-acc[aria-pressed="true"] i { border-top-width: 1.25px; border-color: var(--ink-2); }

.sx-scale { display: inline-flex; padding: 3px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); }
.sx-seg { all: unset; box-sizing: border-box; min-height: 28px; padding: 0 12px; display: inline-flex; align-items: center; border-radius: 999px;
  font: 500 12.5px/1 var(--sans); color: var(--ink-3); cursor: pointer; transition: background .2s var(--ease), color .2s var(--ease); }
.sx-seg[aria-checked="true"] { background: var(--accent); color: var(--paper-2); }
.sx-seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Chart frame: fixed height so nothing shifts while it loads */
.sx-frame { position: relative; overflow: hidden; height: 420px; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; border-radius: 8px; cursor: crosshair; }
.sx-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.sx-frame.is-brushing { cursor: ew-resize; }
.sx-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sx-over { pointer-events: none; }
.sx-status { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; text-align: center; padding: 16px; }
.sx-fig.is-ready .sx-status { display: none; }
.sx-fig:not(.is-ready) .sx-split, .sx-fig:not(.is-ready) .sx-under, .sx-fig:not(.is-ready) .sx-split-panel, .sx-fig:not(.is-ready) .sx-whatif { visibility: hidden; }

/* Crosshair read-out */
.sx-read { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; display: flex; flex-direction: column; gap: 3px; max-width: min(260px, calc(100% - 8px));
  padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: color-mix(in srgb, var(--paper-2) 94%, transparent);
  font: 11.5px/1.35 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .15s var(--ease); }
.sx-read.is-on { opacity: 1; }
.sx-read b { color: var(--ink); font-weight: 500; }
.sx-read span { display: flex; align-items: center; gap: 6px; }
.sx-read i, .sx-sides i { display: inline-block; width: 10px; height: 0; border-top: 2px solid var(--ink); flex: none; }
.sx-r-st i { border-color: var(--accent) !important; }
.sx-r-wi i { border-color: var(--play) !important; border-top-style: dashed !important; }
.sx-read .sx-r-h { display: block; color: var(--ink-3); margin-bottom: 2px; }

/* Dividing line */
.sx-split { position: absolute; left: 0; top: 0; z-index: 1; width: 44px; margin-left: -22px; cursor: ew-resize; touch-action: none; outline: none; }
.sx-split::before { content: ""; position: absolute; left: 21px; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .8; }
.sx-split-grip { position: absolute; left: 50%; top: 50%; width: 16px; height: 40px; margin: -20px 0 0 -8px; border-radius: 999px; background: var(--accent);
  box-shadow: 0 0 0 3px var(--paper-2); transition: transform .2s var(--ease); }
.sx-split-grip::after { content: ""; position: absolute; left: 5px; right: 5px; top: 14px; bottom: 14px; border-left: 1px solid var(--paper-2); border-right: 1px solid var(--paper-2); }
.sx-split:hover .sx-split-grip, .sx-split.is-drag .sx-split-grip { transform: scale(1.1); }
.sx-split:focus-visible .sx-split-grip { outline: 2px solid var(--accent); outline-offset: 3px; }
.sx-split.is-out { opacity: .4; }
.sx-split.is-out .sx-split-tag { display: none; }
.sx-split-tag { position: absolute; top: 4px; left: 50%; width: 0; pointer-events: none; font: 500 10.5px/1 var(--mono); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.sx-split-tag span { position: absolute; top: 0; }
.sx-split-tag span:first-child { right: 7px; color: var(--accent); }
.sx-split-tag span:first-child::after { content: " \2190"; }
.sx-split-tag span:last-child { left: 7px; color: var(--ink-3); }
.sx-split-tag span:last-child::before { content: "\2192  "; }

/* Under the chart: zoom strip */
.sx-under { display: flex; flex-direction: column; gap: 8px; }
.sx-strip { position: relative; height: 44px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); touch-action: none; cursor: crosshair; overflow: hidden; }
.sx-strip canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sx-win { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; box-sizing: border-box; border: 1.5px solid var(--accent); border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 9%, transparent); cursor: grab; outline: none; }
.sx-strip.is-drag .sx-win { cursor: grabbing; }
.sx-win:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.sx-h { position: absolute; top: 0; bottom: 0; width: 22px; margin-left: -11px; cursor: ew-resize; outline: none; z-index: 1; }
.sx-h::after { content: ""; position: absolute; left: 8px; top: 9px; bottom: 9px; width: 6px; border-radius: 3px; background: var(--accent); }
.sx-h:focus-visible::after { box-shadow: 0 0 0 2px var(--paper-2), 0 0 0 4px var(--accent); }
.sx-under-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sx-help { margin: 0; line-height: 1.55; }
.sx-scale-note { margin: 0; min-height: 1.5em; color: var(--ink-2); }

/* Split read-out */
.sx-split-panel { padding-top: 14px; border-top: 1px solid var(--rule); }
.sx-split-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sx-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; min-height: 9.5em; }
.sx-side ul { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 4px; font: 13px/1.4 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sx-side li { display: flex; align-items: center; gap: 8px; }
.sx-side b { color: var(--ink); font-weight: 500; margin-left: auto; }
.sx-side p { margin: 0; }
.sx-side.is-empty p { margin-top: 8px; color: var(--ink-3); font-size: 14px; }
.sx-split-msg { grid-column: 1 / -1; margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }

/* What-if */
.sx-whatif { padding-top: 14px; border-top: 1px solid var(--rule); display: grid; gap: 16px; }
.sx-whatif-head { display: grid; gap: 6px; }
.sx-whatif-note { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); max-width: 72ch; }
.sx-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 28px; }
.sx-ctl { display: grid; gap: 6px; min-width: 0; }
.sx-ctl .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sx-ctl output { font: 14px var(--mono); color: var(--play); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sx-ctl .ends { display: flex; justify-content: space-between; gap: 8px; }
.sx-wsum { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; min-height: 5.2em; }
.sx-wsum div { display: flex; flex-direction: column; gap: 3px; }
.sx-wsum b { font: 500 22px/1.2 var(--mono); color: var(--play); font-variant-numeric: tabular-nums; }
.sx-wfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.sx-wmsg { margin: 0; min-height: 1.5em; max-width: 60ch; color: var(--ink-2); }

@media (max-width: 800px) {
  .sx-controls { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .sx-frame { height: 320px; }
  .sx-sides, .sx-wsum { grid-template-columns: 1fr; }
  .sx-sides { min-height: 16em; }
  .sx-read { font-size: 10.5px; padding: 6px 8px; max-width: min(200px, calc(100% - 8px)); }
  .sx-bar { align-items: flex-start; }
  .sx-split-tag { display: none; }
}

/* ---------- 3. Notes ---------- */
.cs-sent-notes { padding-bottom: clamp(64px, 8vw, 120px); max-width: min(var(--max), 100%); }
.cs-sent-notes > h2 { margin: 0 0 14px; padding-top: 18px; border-top: 1px solid var(--rule); }

/* ---------- 4. Final pass: method sketches, progress, key hints; the explorer's door; help chips; best gap ---------- */
.sx-mprog { display: none; }
.sx-method.is-live .sx-mprog { display: block; height: 3px; margin-top: 12px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.sx-mprog i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--mf, 0)); transition: transform .45s var(--ease); }
.sx-sk { display: block; width: 100%; max-width: 300px; height: 60px; margin: 2px 0 4px; overflow: visible; }
.sx-sk path, .sx-sk rect, .sx-sk circle { fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sx-sk .sk-ink { stroke: var(--ink); } .sx-sk .sk-ink3 { stroke: var(--ink-3); } .sx-sk .sk-ac { stroke: var(--accent); } .sx-sk .sk-rule { stroke: var(--rule); }
.sx-sk .sk-mark { stroke: var(--mark); stroke-dasharray: 3 3; }
.sx-sk .sk-box { stroke: var(--ink-3); fill: var(--paper); }
.sx-sk .sk-acf { fill: var(--accent); stroke: none; } .sx-sk .sk-inkf { fill: var(--ink); stroke: none; } .sx-sk .sk-ink3f { fill: var(--ink-3); stroke: none; }
.sx-sk text { font: 9.5px var(--mono); fill: var(--ink-3); letter-spacing: .02em; }
.sx-mcount { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 10px; text-align: center; }
.sx-keys { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-3); }
.sx-keys kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px;
  font: 11px/1 var(--mono); color: var(--ink-2); background: var(--paper); }
@media (hover: none) { .sx-keys { display: none; } }
.sx-method.is-live .sx-node.is-hint { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sx-method.is-flash { animation: sx-flash 1.1s var(--ease); }
@keyframes sx-flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }

/* The explorer's door. Without JavaScript the figure's no-JS note stands in and the door is not drawn. */
.sx-open { all: unset; box-sizing: border-box; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-height: 48px; margin-top: 6px; padding: 10px 18px;
  border: 1px solid var(--ink-3); border-radius: 999px; background: var(--paper-2); cursor: pointer; font: 500 15px/1.3 var(--sans); color: var(--ink);
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease); }
.sx-open-q { color: var(--ink-2); font-weight: 400; }
.sx-open-a { color: var(--accent); white-space: nowrap; }
.sx-open-i { display: inline-block; transition: transform .3s var(--ease); }
.sx-open:hover { border-color: var(--accent); background: var(--accent-soft); }
.sx-open:hover .sx-open-i { transform: translateY(2px); }
.sx-open[aria-expanded="true"] .sx-open-i { transform: none; }
.sx-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
html:not(.js) .sx-open { display: none; }
html.js .sx-box:not(.is-open) { display: none; }
.sx-box.is-open { animation: sx-box-in .4s var(--ease); }
@keyframes sx-box-in { from { opacity: 0; transform: translateY(-6px); } }

/* Help: three chips, the full text one press away */
.sx-help { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.sx-hchips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.sx-hchips li { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px 0 8px; border: 1px solid var(--rule); border-radius: 999px;
  font: 12.5px/1 var(--sans); color: var(--ink-2); background: var(--paper); }
.sx-hchips svg { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.sx-hmore summary { display: inline-flex; align-items: center; min-height: 36px; padding: 0 6px; cursor: pointer; list-style: none; font: 500 12.5px/1 var(--sans); color: var(--accent); }
.sx-hmore summary::-webkit-details-marker { display: none; }
.sx-hmore summary::after { content: "+"; margin-left: 5px; font-family: var(--mono); }
.sx-hmore[open] summary::after { content: "−"; }
.sx-hmore summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sx-hmore p { margin: 4px 0 0; line-height: 1.55; max-width: 72ch; }
.sx-hmore[open] { flex-basis: 100%; }

/* The read-out says it is approximate */
.sx-read .sx-r-n { display: block; margin-top: 3px; padding-top: 3px; border-top: 1px solid var(--rule); color: var(--ink-3); font-size: 10.5px; }

/* The visitor's best what-if gap, in plum */
.sx-best { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 12px; border: 1px dashed color-mix(in srgb, var(--play) 55%, var(--rule));
  border-radius: 10px; background: color-mix(in srgb, var(--play) 7%, transparent); }
.sx-best[hidden] { display: none; }
.sx-best .label { color: var(--play); }
.sx-best b { font: 500 20px/1.2 var(--mono); color: var(--play); font-variant-numeric: tabular-nums; }
.sx-best .note { flex-basis: 100%; margin: 0; }
.sx-best.is-new { animation: sx-best .8s var(--ease); }
@keyframes sx-best { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--play) 40%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

/* Zoom handles: at least 36px wide wherever fingers are the pointer */
@media (pointer: coarse) {
  /* 40px hit area on a 36px button: the extra 3px each side is invisible and moves nothing */
  .sx-btn, .sx-hmore summary { position: relative; }
  .sx-btn::before, .sx-hmore summary::before { content: ""; position: absolute; left: 0; right: 0; top: -3px; bottom: -3px; }
}
@media (pointer: coarse), (max-width: 600px) {
  .sx-h { width: 36px; margin-left: -18px; }
  .sx-h::after { left: 15px; }
  .sx-chip, .sx-seg { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .sx-node, .sx-chip, .sx-seg, .sx-read, .sx-split-grip, .sx-btn { transition: none; }
  .sx-method.is-live .sx-mpanel, .sx-method.is-live .sx-mpanel.is-on { transition: none; transform: none; }
  .sx-mprog i, .sx-open, .sx-open-i { transition: none; }
  .sx-method.is-flash, .sx-box.is-open, .sx-best.is-new { animation: none; }
}
