/* =============================================================================
 * Token Press — Styles
 * =============================================================================
 * Perplexity gradient: blue (certain) → purple (choosing) → red (uncertain)
 * Normalized to observed min/max — colors shift as the range evolves.
 * Uses --doppler-blue, --doppler-purple, --doppler-red from main.css.
 */

/* Container */
.tp-container {
  position: relative;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Base token */
.tp-token {
  position: relative;
  display: inline;
  padding: 1px 0;
  border-bottom: 3px solid var(--conf-color, transparent);
  cursor: default;
}

/* Trail tokens — active confidence fill with smooth fade transition on underline only */
.tp-token.tp-trail {
  background: linear-gradient(
    180deg,
    transparent 60%,
    color-mix(in srgb, var(--conf-color) calc(var(--trail-opacity, 1) * 25%), transparent) 100%
  );
  border-bottom-color: color-mix(in srgb, var(--conf-color) calc(var(--trail-opacity, 1) * 100%), transparent);
  transition: border-bottom-color 0.3s ease-out, background 0.3s ease-out;
}

/* Settled tokens — subtle confidence underline only */
.tp-token.tp-settled {
  border-bottom-width: 1.5px;
  border-bottom-width: 2px;
  border-bottom-color: color-mix(in srgb, var(--conf-color) 60%, transparent);
}

/* Hover: highlight token and show alternatives */
.tp-token.tp-has-alts:hover {
  background: color-mix(in srgb, var(--conf-color) 12%, transparent);
  border-bottom-color: var(--conf-color);
  border-bottom-width: 2px;
}

/* Alternatives tooltip */
.tp-alternatives {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--bg);
  color: var(--fg);
  border: var(--border-md) solid var(--fg);
  padding: var(--space-sm);
  font-size: var(--font-size-xs);
  line-height: var(--font-leading-snug);
  min-width: 180px;
  max-width: 280px;
  pointer-events: none;
}

.tp-token.tp-has-alts:hover > .tp-alternatives {
  display: block;
}

/* Perplexity header */
.tp-alt-header {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--font-tracking-label);
  opacity: var(--opacity-soft);
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-xs);
  border-bottom: var(--border-sm) solid var(--fg);
}

/* Alternative row */
.tp-alt-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 1px 0;
}

.tp-alt-row:first-child {
  font-weight: var(--font-weight-bold);
}

.tp-alt-text {
  flex: 0 0 auto;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
}

.tp-alt-bar {
  flex: 1 1 auto;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--fg) calc(var(--alt-prob) * 100%),
    color-mix(in srgb, var(--fg) 10%, transparent) calc(var(--alt-prob) * 100%)
  );
}

.tp-alt-pct {
  flex: 0 0 auto;
  min-width: 38px;
  text-align: right;
  font-size: var(--font-size-xs);
  opacity: var(--opacity-soft);
  font-variant-numeric: tabular-nums;
}

/* Controls bar */
.tp-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-size: var(--font-size-xs);
  user-select: none;
}

.tp-controls button {
  background: var(--bg);
  border: var(--border-md) solid var(--fg);
  color: var(--fg);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-size-xs);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.tp-controls button:hover {
  background: var(--fg);
  color: var(--bg);
}

.tp-controls button:active {
  background: var(--fg);
  color: var(--bg);
}

.tp-controls button:disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.tp-controls .tp-position {
  font-variant-numeric: tabular-nums;
  opacity: 0.5;
  min-width: 80px;
}

/* Prefill zone — prompt tokens shown at soft opacity with a gray underline */
.tp-prefill-zone {
  opacity: var(--opacity-soft, 0.5);
}

.tp-token.tp-prefill {
  border-bottom-width: 1.5px;
  border-bottom: 1.5px solid color-mix(in srgb, var(--fg) 45%, transparent);
  border-bottom-style: solid;
}

/* Trail zone — slight glow on the leading edge */
.tp-trail-zone .tp-token:last-child {
  border-bottom-width: 4px;
}

