from django.db import models


class TooltipContent(models.Model):
    """
    Static tooltip content for game objects — planets, signs, houses, cards, etc.

    Required: slug (unique lookup key), title (display name).
    All other fields are optional; omitted fields render nothing in the template.

    extras (JSONField) stores structured data that varies by tooltip type:
      dignities  — dict  {role: body/sign string, …}
      aspects    — list  [{symbol, type, body, orb}, …]
      keywords_up / keywords_rev — list of strings (card upright/reversed keywords)
      cautions   — list  [{title, type_label, shoptalk, effect}, …]
      nav        — dict  {prv: slug, nxt: slug}  for PRV/NXT navigation
    """

    slug        = models.SlugField(unique=True)
    title       = models.CharField(max_length=200)

    # Optional display fields
    type_label  = models.CharField(max_length=100, blank=True)
    symbol      = models.CharField(max_length=10,  blank=True)
    degree_str  = models.CharField(max_length=40,  blank=True)
    description = models.TextField(blank=True)
    shoptalk    = models.TextField(blank=True)
    expiry      = models.CharField(max_length=200, blank=True)
    effect      = models.TextField(blank=True)

    # Structured data for tabular / list / nav sections
    extras      = models.JSONField(default=dict)

    class Meta:
        ordering = ['slug']

    def __str__(self):
        return self.title
