/* ============================================================================
   screen-5-streaming.css -- Beast P8
   Live streaming UX for Screen 5: reveal animations, document highlighting,
   compound-claim cards, cost-meter count-up.

   PREFIX: .s5cc-   (screen-5 compound card)
           .s5-stream-   (streaming-specific states)

   Animations respect prefers-reduced-motion.
   Desktop-first: no mobile breakpoints (feedback_desktop_first.md).
   ASCII-only source.
   ============================================================================ */


/* ============================================================================
   0. VERDICT COLOR TOKENS
   These supplement design-tokens.css with the two verdicts not yet tokenized
   at the time of writing (DISTORTED, CONTRADICTED).
   ============================================================================ */

:root {
  --s5-distorted:          #DC2626;
  --s5-distorted-dim:      rgba(220, 38, 38, 0.15);
  --s5-contradicted:       #A21CAF;
  --s5-contradicted-dim:   rgba(162, 28, 175, 0.15);
}


/* ============================================================================
   1. CARD REVEAL ANIMATION
   200ms cubic-bezier(0.4, 0, 0.2, 1) opacity 0->1 + translateY(8px)->0.
   Applied to .s5cc-reveal and also to ordinary claim cards that arrive
   via the streaming path (use class s5-stream-reveal instead of s5cc-reveal
   when targeting existing card HTML).
   ============================================================================ */

@keyframes s5-card-reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.s5cc-reveal,
.s5-stream-reveal {
  animation: s5-card-reveal 200ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .s5cc-reveal,
  .s5-stream-reveal {
    animation: none;
    opacity: 1;
    transform: none;
  }
}


/* ============================================================================
   2. DOCUMENT HIGHLIGHT COLOR TRANSITIONS
   Claim spans start as neutral grey, then transition to their verdict color
   as each verdict lands.  The transition targets background-color and
   border-left-color.
   ============================================================================ */

.s5r-claim-hl {
  transition: background-color 400ms ease, border-left-color 400ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .s5r-claim-hl {
    transition: none;
  }
}

/* Neutral state -- claim extracted but not yet verified */
.s5r-claim-hl[data-verdict="pending"] {
  background-color: rgba(180, 180, 190, 0.15);
  border-left: 3px solid rgba(180, 180, 190, 0.4);
}

/* Verdict color overrides for the streaming path.
   The existing screen-5-redesign.css already handles
   data-verdict="supported" etc. via background-color.
   We add the transition above to make them animate. */

/* Distorted -- dark red (not in base tokens) */
.s5r-claim-hl[data-verdict="distorted"] {
  background-color: var(--s5-distorted-dim);
  border-left: 3px solid var(--s5-distorted);
}

/* Contradicted -- magenta/purple */
.s5r-claim-hl[data-verdict="contradicted"] {
  background-color: var(--s5-contradicted-dim);
  border-left: 3px solid var(--s5-contradicted);
}


/* ============================================================================
   3. CHART SEGMENT GROWTH ANIMATION
   Applied to verdict-bar segments (class .s5r-claims-bar-seg) when they are
   re-rendered as new verdicts land.
   ============================================================================ */

.s5r-claims-bar-seg {
  transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  .s5r-claims-bar-seg {
    transition: none;
  }
}


/* ============================================================================
   4. COST METER COUNT-UP TRANSITION
   The credit total number in .vcm-total gets a 250ms color flash when updated.
   ============================================================================ */

@keyframes s5-credit-pulse {
  0%   { color: var(--vc-accent, #7268D8); }
  100% { color: inherit; }
}

.vcm-total--updated strong {
  animation: s5-credit-pulse 250ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .vcm-total--updated strong {
    animation: none;
  }
}


/* ============================================================================
   5. COMPOUND CLAIM CARD -- .s5cc-*
   ============================================================================ */

/* ---- 5.1 Card wrapper ---- */
.s5cc-card {
  background: var(--vc-bg-surface, #161820);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.s5cc-card:focus-visible {
  outline: 2px solid var(--vc-accent, #7268D8);
  outline-offset: 2px;
}

/* Left accent stripe keyed to parent verdict */
.s5cc-card[data-verdict="SUPPORTED"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--vc-status-supported, #22c55e);
  border-radius: 10px 0 0 10px;
}
.s5cc-card[data-verdict="PARTIALLY_SUPPORTED"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--vc-status-partial, #f59e0b);
  border-radius: 10px 0 0 10px;
}
.s5cc-card[data-verdict="UNSUPPORTED"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--vc-status-unsupported, #ef4444);
  border-radius: 10px 0 0 10px;
}
.s5cc-card[data-verdict="DISTORTED"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--s5-distorted, #DC2626);
  border-radius: 10px 0 0 10px;
}
.s5cc-card[data-verdict="CONTRADICTED"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--s5-contradicted, #A21CAF);
  border-radius: 10px 0 0 10px;
}
.s5cc-card[data-verdict="UNVERIFIABLE"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--vc-status-unverifiable, #6B7280);
  border-radius: 10px 0 0 10px;
}

/* ---- 5.2 Parent claim text ---- */
.s5cc-parent-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--vc-t1, #E8E4F0);
  margin-bottom: 10px;
  padding-left: 8px;
}

/* ---- 5.3 Badge row ---- */
.s5cc-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-left: 8px;
}

.s5cc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.s5cc-badge--supported {
  background: var(--vc-status-supported-bg, rgba(34, 197, 94, 0.15));
  color: var(--vc-status-supported, #22c55e);
}
.s5cc-badge--partial {
  background: var(--vc-status-partial-bg, rgba(245, 158, 11, 0.15));
  color: var(--vc-status-partial, #f59e0b);
}
.s5cc-badge--unsupported {
  background: var(--vc-status-unsupported-bg, rgba(239, 68, 68, 0.15));
  color: var(--vc-status-unsupported, #ef4444);
}
.s5cc-badge--unverifiable {
  background: var(--vc-status-unverifiable-bg, rgba(107, 114, 128, 0.15));
  color: var(--vc-status-unverifiable, #6B7280);
}
.s5cc-badge--distorted {
  background: var(--s5-distorted-dim);
  color: var(--s5-distorted, #DC2626);
}
.s5cc-badge--contradicted {
  background: var(--s5-contradicted-dim);
  color: var(--s5-contradicted, #A21CAF);
}

.s5cc-compound-label {
  font-size: 11px;
  color: var(--vc-t3, #8280A0);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---- 5.4 Sub-claim list ---- */
.s5cc-sub-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
}

.s5cc-sub-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background-color 120ms ease;
}

.s5cc-sub-row[role="button"] {
  cursor: pointer;
}

.s5cc-sub-row[role="button"]:hover {
  background: rgba(255, 255, 255, 0.04);
}

.s5cc-sub-row[role="button"]:focus-visible {
  outline: 2px solid var(--vc-accent, #7268D8);
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .s5cc-sub-row {
    transition: none;
  }
}

/* Sub-row verdict colors */
.s5cc-sub-row--supported   { border-left: 2px solid var(--vc-status-supported, #22c55e); }
.s5cc-sub-row--partial     { border-left: 2px solid var(--vc-status-partial, #f59e0b); }
.s5cc-sub-row--unsupported { border-left: 2px solid var(--vc-status-unsupported, #ef4444); }
.s5cc-sub-row--unverifiable{ border-left: 2px solid var(--vc-status-unverifiable, #6B7280); }
.s5cc-sub-row--distorted   { border-left: 2px solid var(--s5-distorted, #DC2626); }
.s5cc-sub-row--contradicted{ border-left: 2px solid var(--s5-contradicted, #A21CAF); }

.s5cc-sub-symbol {
  font-size: 11px;
  font-family: monospace;
  color: var(--vc-t3, #8280A0);
  flex-shrink: 0;
  padding-top: 1px;
  min-width: 24px;
}

.s5cc-sub-text {
  font-size: 13px;
  color: var(--vc-t2, #C8C3D2);
  flex: 1;
  line-height: 1.45;
}

.s5cc-sub-verdict-label {
  font-size: 11px;
  color: var(--vc-t3, #8280A0);
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.s5cc-sub-expand-icon {
  font-size: 10px;
  color: var(--vc-t4, #6B6580);
  flex-shrink: 0;
  transition: transform 150ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .s5cc-sub-expand-icon {
    transition: none;
  }
}

/* ---- 5.5 Evidence pane (toggled by clicking sub-row) ---- */
.s5cc-sub-pane {
  padding: 8px 10px 8px 24px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0 0 6px 6px;
  margin-bottom: 4px;
}

.s5cc-passages-group {
  margin-bottom: 10px;
}

.s5cc-passages-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--vc-t3, #8280A0);
  margin-bottom: 5px;
}

.s5cc-passage {
  font-size: 12px;
  line-height: 1.5;
  color: var(--vc-t2, #C8C3D2);
  border-left: 3px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  margin: 0 0 6px 0;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}

.s5cc-passage--supporting {
  border-left-color: var(--vc-status-supported, #22c55e);
}

.s5cc-passage--refuting {
  border-left-color: var(--vc-status-unsupported, #ef4444);
}

/* ---- 5.6 No-breakdown fallback ---- */
.s5cc-no-breakdown {
  font-size: 12px;
  color: var(--vc-t3, #8280A0);
  padding: 8px;
  font-style: italic;
}


/* ============================================================================
   6. STREAMING STATE INDICATORS
   ============================================================================ */

/* "Verifying..." placeholder on a claim card before its verdict lands */
.s5-claim-pending {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}

.s5-claim-pending::after {
  content: 'Verifying...';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--vc-t4, #6B6580);
  font-style: italic;
  animation: s5-blink 1.2s ease-in-out infinite;
}

@keyframes s5-blink {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .s5-claim-pending::after {
    animation: none;
    opacity: 1;
  }
}


/* ============================================================================
   EARLY-TRANSITION VERDICT FLASH (2026-05-12)
   When a Phase 2 verdict arrives for a claim, the corresponding
   .s5-claim-highlight span gets .s5-stream-verdict-flash briefly so the user
   perceives the change. Reverts to the verdict-colored underline that
   renderDocumentWithHighlights already applies inline.
   ============================================================================ */

.s5-claim-highlight.s5-stream-verdict-flash {
  animation: s5-stream-verdict-flash 420ms ease;
}

@keyframes s5-stream-verdict-flash {
  0%   { filter: brightness(1.0) saturate(1.0); }
  40%  { filter: brightness(1.6) saturate(1.4); text-decoration-thickness: 3px; }
  100% { filter: brightness(1.0) saturate(1.0); }
}

/* Pending highlights pulse gently while waiting for verdicts */
.s5-claim-highlight[data-verdict="PENDING"] {
  animation: s5-stream-pending-pulse 1800ms ease-in-out infinite;
}

@keyframes s5-stream-pending-pulse {
  0%, 100% { text-decoration-color: rgba(255, 255, 255, 0.25); }
  50%      { text-decoration-color: rgba(255, 255, 255, 0.55); }
}

@media (prefers-reduced-motion: reduce) {
  .s5-claim-highlight.s5-stream-verdict-flash,
  .s5-claim-highlight[data-verdict="PENDING"] {
    animation: none;
  }
}
