/* Probability slider — tool-specific styles.
 * The shared design system in /style.css handles header, palette, layout.
 * This file does: the prompt chips, the live bar chart of next-token
 * probabilities, the temperature / top-K / top-P control panel, the
 * "set deterministic" button, and the explainer.
 * Colours come from the shared CSS variables — never hard-coded.
 */

[hidden] { display: none !important; }

.loading {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ── per-audience subtitle (swaps with the audience chip) ───── */
.aud-subtitle {
  font-size: 17px;
  line-height: 1.5;
  font-weight: 500;
  color: var(--text);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  margin: 0 0 22px;
  max-width: 760px;
}
.aud-subtitle:empty { display: none; }
@media (max-width: 640px) { .aud-subtitle { font-size: 15px; } }

/* ── illustrative-data note ────────────────────────────────── */

.data-note {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--accent-soft);
  border: 1px dashed rgba(245, 166, 35, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 18px;
  line-height: 1.5;
}
.data-note strong { color: var(--accent); }

/* ── live-model control bar ────────────────────────────────── */

.live-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 18px;
}
.btn-live {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-live:hover:not(:disabled) { background: var(--accent); color: var(--bg); }
.btn-live:disabled { opacity: 0.6; cursor: progress; }
.btn-live .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
  transition: background 0.2s ease;
}
.btn-live.loading .dot {
  background: var(--accent);
  animation: live-pulse 1s ease-in-out infinite;
}
.btn-live.on { background: var(--green); color: var(--bg); border-color: var(--green); }
.btn-live.on .dot { background: var(--bg); animation: none; }
@keyframes live-pulse { 50% { opacity: 0.3; } }

.live-note {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}
.live-status {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent);
}
.live-status.ok { color: var(--green); }
.live-status.warn { color: var(--yellow); }
.live-status.err { color: var(--red); }

/* when live is engaged, the "illustrative data" banner turns into a live badge */
.data-note.is-live {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.4);
}
.data-note.is-live strong { color: var(--green); }

/* ── prompt picker ─────────────────────────────────────────── */

.prompt-picker {
  margin-bottom: 16px;
}
.prompt-picker .label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.prompt-picker .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.prompt-picker .pchip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.prompt-picker .pchip:hover {
  color: var(--text);
  border-color: var(--accent);
  border-style: solid;
}
.prompt-picker .pchip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
}
.prompt-picker .pchip.cant-know::after {
  content: " ⚠";
  color: var(--red);
}

/* ── the live prompt line ──────────────────────────────────── */

.prompt-display {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.prompt-display .pd-kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.prompt-display .pd-text {
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
}
.prompt-display .pd-text .next {
  color: var(--accent);
  border-bottom: 2px dashed rgba(245, 166, 35, 0.5);
  padding: 0 2px;
  animation: blink 1.4s step-end infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }
.prompt-display .pd-cantknow {
  margin-top: 10px;
  font-size: 12px;
  color: var(--red);
  font-style: italic;
}

/* ── control panel (sliders) ───────────────────────────────── */

.controls {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
@media (max-width: 720px) {
  .controls { grid-template-columns: 1fr; }
}
.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.control .ctrl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.control .ctrl-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.control .ctrl-val {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
}
.control .ctrl-hint {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
  min-height: 30px;
}
.control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-elevated);
  outline: none;
  cursor: pointer;
}
.control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--accent);
}
.control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}
.control input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── action row ────────────────────────────────────────────── */

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.btn-det {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.btn-det:hover { background: var(--accent); color: var(--bg); }
.btn-det.active { background: var(--accent); color: var(--bg); }
.btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-reset:hover { color: var(--text); border-color: var(--text-muted); }
.action-row .det-caption {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* ── the bar chart ─────────────────────────────────────────── */

.chart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chart-head h2 {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.chart-head .legend {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 64px;
  gap: 12px;
  align-items: center;
  transition: opacity 0.3s ease;
}
@media (max-width: 560px) {
  .bar-row { grid-template-columns: 96px 1fr 54px; gap: 8px; }
}
.bar-row.filtered {
  opacity: 0.22;
}
.bar-tok {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  text-align: right;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-row.filtered .bar-tok { color: var(--text-dim); }
.bar-tok .ws { color: var(--text-dim); }
.bar-track {
  position: relative;
  height: 22px;
  background: var(--bg-elevated);
  border-radius: 5px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), #d97706);
  transition: width 0.45s cubic-bezier(0.2, 0.7, 0.3, 1),
    background 0.3s ease;
  min-width: 2px;
}
.bar-row.is-top .bar-fill {
  background: linear-gradient(90deg, var(--green), #16a34a);
}
.bar-row.filtered .bar-fill {
  background: var(--text-dim) !important;
}
.bar-pct {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  text-align: right;
  font-weight: 600;
}
.bar-row.filtered .bar-pct { color: var(--text-dim); }
.bar-row.is-top .bar-pct { color: var(--green); }

/* deterministic mode: one full green bar */
.chart.deterministic .bar-row:not(.is-top) { opacity: 0.18; }
.chart.deterministic .bar-row.is-top .bar-fill {
  background: linear-gradient(90deg, var(--green), #16a34a);
}

/* ── deterministic caption (the 98/2 punchline) ────────────── */

.det-punch {
  margin-top: 4px;
  margin-bottom: 18px;
  padding: 16px 18px;
  background: rgba(34, 197, 94, 0.06);
  border-left: 3px solid var(--green);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}
.det-punch strong { color: var(--text); }
.det-punch .accent { color: var(--accent); font-weight: 600; }

/* ── explainer (collapsible) — matches tokenizer convention ── */

.explainer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 22px;
}
.explainer summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.explainer summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--text-muted);
  font-size: 12px;
}
.explainer[open] summary::before { transform: rotate(90deg); }
.explainer .body {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}
.explainer .body h3 {
  color: var(--text);
  margin: 18px 0 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.explainer .body p { margin: 0 0 10px; }
.explainer .body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

/* ── under-the-hood: Poloclub embed (matches the explainer look) ── */

.mechanism {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 16px;
}
.mechanism summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mechanism summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--text-muted);
  font-size: 12px;
}
.mechanism[open] summary::before { transform: rotate(90deg); }
.mechanism .body {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}
.mechanism .body p { margin: 0 0 14px; }
.mechanism .body strong { color: var(--text); }

.mech-iframe {
  width: 100%;
  height: 640px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  display: block;
}
@media (max-width: 640px) {
  .mech-iframe { height: 520px; }
}
