/* Marcella · "Try her." — demo section shell.
 * Palette, type and card grammar from the approved Marcella page (Main.dc.html).
 * The instrument panel borrows the GIGI Builds dark stage (#141413).
 */

:root {
  --cream: #f6f2ea;
  --ink: #1d1a16;
  --ink-2: #514a41;
  --muted: #857c70;
  --placeholder: #a49b8e;
  --rule: #e3dccd;
  --rule-2: #ebe5d8;
  --line: #d9d1c2;
  --surface: #fcfaf5;
  --surface-2: #f9f6ef;
  --band: #efe9dd;
  --chip: #f1ebdf;
  --rose: #b8655a;
  --rose-deep: #8f4a41;
  --rose-soft: #f3e2dd;
  --sage: #6f8a76;
  --sage-soft: #dfe8df;

  --dark: #141413;
  --dark-line: #2e2d2b;
  --dark-ink: #e8e6e0;
  --dark-ink-2: #b5b2a8;
  --dark-ink-3: #85827a;

  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
.mono { font-family: var(--mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- section frame ---------- */
.demo {
  max-width: 1240px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.demo-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px 40px;
  flex-wrap: wrap;
}
.demo-head-text { display: flex; flex-direction: column; gap: 10px; }
.demo h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.lede {
  margin: 0;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 560px;
  text-wrap: pretty;
}
.tag { font-size: 12.5px; color: var(--muted); padding-bottom: 6px; }

/* ---------- the card ---------- */
.demo-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 22px;
  overflow: hidden;
}
.col-conv {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 32px 24px;
  min-width: 0;
}
.col-inst {
  order: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 28px 24px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule-2);
  min-width: 0;
}
/* direction words: below 1040px the instrument stacks ABOVE the conversation */
.wide-only { display: none; }
.stack-only { display: inline; }
@media (min-width: 1040px) {
  .demo-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
  .col-conv { order: 1; border-right: 1px solid var(--rule-2); }
  .col-inst { order: 2; border-bottom: 0; }
  .wide-only { display: inline; }
  .stack-only { display: none; }
}
@media (max-width: 560px) {
  .col-conv { padding: 22px 18px 20px; }
  .col-inst { padding: 22px 18px 20px; }
  .demo h2 { font-size: 34px; }
  /* the picture bleeds to the card edges and goes square (demo.js mounts it at
     width = height here), so the 9,134 points get the room the caption would take */
  .instrument { margin: 0 -18px; border-radius: 0; border-left: 0; border-right: 0; }
  .mount { aspect-ratio: 1 / 1; }
}

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.chip:hover { border-color: var(--muted); }
.chip:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}

/* ---------- recorded example walkthrough ---------- */
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.chips .chip { flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; height: auto; min-width: 0; min-height: 88px; padding: 14px; border-radius: 10px; text-align: left; line-height: 1.4; }
.question-kind { font-size: 12px; color: var(--muted); }
.question-text { font-size: 15px; }
.chip[aria-pressed="true"] .question-kind { color: #d9d1c2; }
.hint.demo-welcome { flex-direction: column; gap: 12px; padding: 28px 16px; text-align: center; font-family: var(--sans); font-style: normal; font-size: 15px; line-height: 1.6; animation: none; }
.demo-welcome > span { max-width: 330px; }
.demo-welcome-title { font-family: var(--serif); font-size: 28px; color: var(--ink); line-height: 1.15; }
.demo-navigation { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding-top: 20px; margin-top: auto; border-top: 1px solid var(--rule); }
.demo-navigation > div { flex: 1 1 160px; }
.example-progress { font-size: 12px; color: var(--ink-2); }
.demo-navigation p { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.demo-next { min-height: 44px; padding: 10px 16px; border: 1px solid var(--ink); border-radius: 8px; background: var(--ink); color: var(--cream); cursor: pointer; font-size: 14px; line-height: 1.4; }
.demo-next:hover { background: var(--ink-2); }
.demo-next:disabled { opacity: .5; cursor: wait; }
.demo-next:focus-visible, .source-detail summary:focus-visible, .sources button:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; }
.question-context { display: flex; flex-direction: column; gap: 8px; }
.question-mode { color: var(--muted); font-size: 12px; }
.question-context p { margin: 0; font-family: var(--serif); font-size: 25px; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.question-context .map-link { align-self: flex-start; color: var(--rose-deep); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.demo-outcome { padding: 16px 18px; background: var(--sage-soft); border-left: 3px solid var(--sage); border-radius: 0 8px 8px 0; }
.demo-outcome.outside { background: var(--rose-soft); border-color: var(--rose); }
.demo-outcome.self, .demo-outcome.unavailable { background: var(--band); border-color: var(--muted); }
.demo-outcome h3 { margin: 0 0 6px; color: var(--ink); font-size: 16px; font-weight: 600; line-height: 1.4; }
.demo-outcome p { margin: 0; padding-top: 6px; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.source-detail { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.source-detail summary { display: grid; grid-template-columns: minmax(0, 1fr) auto 12px; align-items: center; gap: 10px; padding: 13px 12px; list-style: none; cursor: pointer; }
.source-detail summary::-webkit-details-marker { display: none; }
.source-detail summary::after { content: '+'; color: var(--muted); text-align: center; }
.source-detail[open] summary::after { content: '−'; }
.source-detail[open] summary { border-bottom: 1px solid var(--rule-2); }
.source-detail .doc { font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.source-distance { font-size: 12px; color: var(--muted); white-space: nowrap; }
.source-detail .source-excerpt { margin: 0; padding: 14px 12px 8px; font-size: 14px; line-height: 1.6; color: var(--ink-2); overflow-wrap: anywhere; }
.source-note { display: block; padding: 0 12px 14px; font-size: 12px; color: var(--muted); }
.sources button.pill { cursor: pointer; min-height: 36px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.sources button.pill:hover { background: var(--band); border-color: var(--muted); }
.voice { flex-wrap: wrap; }
.voice .play { width: 44px; height: 44px; flex-shrink: 0; }
.voice-label { max-width: 100%; }
@media (max-width: 480px) {
  .chips { grid-template-columns: minmax(0, 1fr); }
  .chips .chip { min-height: 72px; }
  .demo-navigation { align-items: stretch; }
  .demo-next { width: 100%; }
  .source-detail summary { grid-template-columns: minmax(0, 1fr) 12px; }
  .source-detail summary::after { grid-column: 2; grid-row: 1; }
  .source-distance { grid-column: 1; grid-row: 2; }
}

/* ---------- thread ---------- */
.thread {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 300px;
}
.hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  color: var(--muted);
  pointer-events: none;
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.q-row { display: flex; justify-content: flex-end; animation: rise .32s ease both; }
.q-bubble {
  max-width: 420px;
  padding: 12px 16px;
  background: var(--band);
  border-radius: 16px 16px 4px 16px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
}

.m-row { display: flex; gap: 14px; align-items: flex-start; animation: rise .32s ease both; }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--rose-soft);
  color: var(--rose-deep);
  font-family: var(--serif);
  font-size: 18px;
  flex-shrink: 0;
}
.m-body { display: flex; flex-direction: column; gap: 14px; max-width: 520px; min-width: 0; }
.reply {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  text-wrap: pretty;
  min-height: 1.6em;
}
.reply.typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.15em;
  background: var(--rose);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  animation: rise .32s ease both;
}
.src-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.src-pills { display: contents; }
.pill {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice { display: flex; align-items: center; gap: 12px; animation: rise .32s ease both; }
.play {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.play svg { fill: var(--cream); }
.play .ic-pause { display: none; }
.voice.playing .play .ic-play { display: none; }
.voice.playing .play .ic-pause { display: block; }
.play:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.wave { display: flex; align-items: center; gap: 3px; height: 22px; }
.wave .bar {
  width: 3px;
  border-radius: 999px;
  background: var(--muted);
  transform-origin: center;
  transition: background .3s ease;
}
.voice.playing .wave .bar {
  background: var(--rose);
  animation: bounce .8s ease-in-out infinite alternate;
  animation-delay: var(--d, 0s);
}
@keyframes bounce { from { transform: scaleY(.45); } to { transform: scaleY(1.15); } }
.voice-label { font-size: 12.5px; color: var(--muted); }

/* ---------- input bar (disabled in the demo) ---------- */
.ask { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.ask-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 8px 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}
.ask-pill input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 15.5px;
  color: var(--ink);
  outline: none;
}
.ask-pill input::placeholder { color: var(--placeholder); opacity: 1; }
.ask-pill input:disabled { cursor: not-allowed; }
.send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--rose);
  flex-shrink: 0;
}
.helper { font-size: 12.5px; color: var(--muted); padding-left: 18px; }

/* ---------- instrument column ---------- */
.inst-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.inst-title { font-family: var(--serif); font-size: 22px; font-weight: 500; }
.status { font-size: 11.5px; white-space: nowrap; }
.status.waiting   { color: var(--muted); }
.status.measuring { color: var(--ink); animation: breathe 1.2s ease-in-out infinite; }
.status.measured  { color: var(--sage); }
.status.declined  { color: var(--rose); }
.status.self      { color: var(--sage); }

.instrument {
  background: var(--dark);
  border: 1px solid var(--dark-line);
  border-radius: 14px;
  overflow: hidden;
}
.mount {
  position: relative;
  width: 100%;
  aspect-ratio: 1120 / 640;
  background: var(--dark);
}
.mount.ready { aspect-ratio: auto; }
.mount canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}
.mount .notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--dark-ink-3);
  pointer-events: none;
}
.mount .notice.err { color: #e6a59d; pointer-events: auto; }
.caption {
  padding: 10px 14px 11px;
  border-top: 1px solid var(--dark-line);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--dark-ink-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.caption .hover { color: var(--dark-ink-2); min-height: 1.55em; overflow-wrap: anywhere; }
.caption .hover b { color: var(--dark-ink); font-weight: 500; }

/* families legend */
.legend-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.legend-label { font-size: 11.5px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.fam {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.fam:hover { background: var(--chip); }
.fam:focus-visible { outline: 2px solid var(--rose); outline-offset: 1px; }
.fam .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(29, 26, 22, .12);
  transition: opacity .18s ease;
}
.fam.off { color: var(--muted); text-decoration: line-through; }
.fam.off .dot { opacity: .22; }

/* readouts */
.readout { display: flex; flex-direction: column; gap: 10px; }
.readout .label { font-size: 13px; font-weight: 600; color: var(--ink); }

.scale { display: flex; flex-direction: column; gap: 6px; }
.track {
  /* --border-pct is the border's position on the 0.50–1.00 scale; demo.js
     sets it from meta.border (0.80 → 60%). Tick and colour split follow it. */
  --border-pct: 60%;
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--sage-soft) 0%,
    var(--sage-soft) calc(var(--border-pct) - 2%),
    var(--rose-soft) calc(var(--border-pct) + 4%),
    var(--rose-soft) 100%);
}
.tick {
  position: absolute;
  left: var(--border-pct);
  top: -5px;
  width: 1px;
  height: 20px;
  background: var(--rose);
}
.marker {
  position: absolute;
  top: -4px;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 999px;
  background: var(--ink);
  border: 3px solid var(--surface-2);
  /* .9s: the same tempo as the constellation's fly-in (flyMs 900), so the two
     markers land together and the reply starts after both */
  transition: left .9s cubic-bezier(.2, .7, .2, 1), background .3s ease;
}
.marker.out { background: var(--rose); }
.ring {
  position: absolute;
  top: -3px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  opacity: .4;
  transition: left .9s cubic-bezier(.2, .7, .2, 1);
}
.ticks { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.ticks .border { color: var(--rose); }
.reading { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.num { font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }
.num.out { color: var(--rose); }
.phrase { font-size: 13px; color: var(--sage); }
.phrase.out { color: var(--rose-deep); }
.phrase.self { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.phrase.none { color: var(--muted); }
.receipt { font-size: 11.5px; color: var(--muted); }

.rows { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: 10px;
  min-width: 0;
}
.row .doc {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .head {
  font-size: 12px;
  color: var(--muted);
  flex: 1 1 0;
  min-width: 0;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.none {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.foot { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  .hint, .status.measuring, .voice.playing .wave .bar, .reply.typing::after { animation: none; }
  .q-row, .m-row, .sources, .voice { animation: none; }
  .marker, .ring, .chip, .fam { transition: none; }
}
