"""Render the live thought card as HTML.""" from __future__ import annotations from card_engine import ActiveCard, CardState def render_card(active: ActiveCard) -> str: """Render the thought card HTML based on current state.""" if active.state == CardState.IDLE: return "" card = active.card sections = [] # Situation + Thought (always visible once triggered) if active.state.value != "idle": thought_text = card.automatic_thought or "..." sections.append(f"""
AUTOMATIC THOUGHT
"{thought_text}"
""") # Distortion tags if card.distortions: tags = "".join( f'{d}' for d in card.distortions ) sections.append(f"""
{tags}
""") # Evidence FOR if card.evidence_for: items = "".join(f'
  • {e}
  • ' for e in card.evidence_for) sections.append(f"""
    EVIDENCE FOR
    """) # Evidence AGAINST if card.evidence_against: items = "".join(f'
  • {e}
  • ' for e in card.evidence_against) sections.append(f"""
    EVIDENCE AGAINST
    """) # Balanced thought (reframe) if card.balanced_thought: sections.append(f"""
    🔄 BALANCED THOUGHT
    "{card.balanced_thought}"
    """) # Complete state border_style = "border-color:rgba(34,197,94,0.5); box-shadow:0 0 20px rgba(34,197,94,0.15);" if active.state == CardState.COMPLETE else "" return f"""
    📋 Live Thought Card
    {''.join(sections)}
    """ def render_empty_card() -> str: """Render a minimal waiting state after user starts chatting.""" return """
    Listening... a thought card will appear here once a thinking pattern is detected.
    """ def render_intro_card() -> str: """Render the benefit-focused 'how it helps you' explanation for the How it works tab.""" return """
    A calmer way to untangle your thoughts
    When you're caught in a worry or a harsh thought, it's hard to see it clearly from the inside. REFRAME is a gentle, judgment-free space to talk it through — and watch an unhelpful thought become a fairer, kinder one.
    How it helps you:
    See the thinking trap
    It gently names patterns like catastrophizing or all-or-nothing thinking — the ones that are hard to spot in your own head.
    Questions, not lectures
    Rather than telling you what to think, it asks — what supports this thought, and what doesn't? You stay in control.
    Reframes you actually believe
    The balanced thought is yours, in your own words — which is exactly why it sticks with you.
    See yourself grow
    Saved cards and your pattern tracker reveal what keeps coming up — and noticing is where change begins.
    💬 Just talk — by voice or text. No jargon, no pressure. It's grounded in Cognitive Behavioral Therapy (CBT), the most evidence-based approach for reshaping unhelpful thinking.
    A supportive companion — not a replacement for professional care. If you're ever in crisis, it will surface helplines right away.
    """