/* Atom: badge — base badge, sentiment variants, AI and user variants */

.badge {
    display: inline-block;
    font-family: var(--bn-font-mono);
    font-size: 0.72rem;
    padding: var(--bn-space-xs) 0.45rem;
    border-radius: var(--bn-radius-sm);
    background: var(--bn-colour-badge-bg);
    color: var(--bn-colour-badge-text);
}

/* Sentiment variants (v0.7+ taxonomy) — see docs/academic-sources.html */
.badge-frustration { background: var(--bn-sentiment-frustration-bg); color: var(--bn-sentiment-frustration); }
.badge-confusion { background: var(--bn-sentiment-confusion-bg); color: var(--bn-sentiment-confusion); }
.badge-doubt { background: var(--bn-sentiment-doubt-bg); color: var(--bn-sentiment-doubt); }
.badge-surprise { background: var(--bn-sentiment-surprise-bg); color: var(--bn-sentiment-surprise); }
.badge-satisfaction { background: var(--bn-sentiment-satisfaction-bg); color: var(--bn-sentiment-satisfaction); }
.badge-delight { background: var(--bn-sentiment-delight-bg); color: var(--bn-sentiment-delight); }
.badge-confidence { background: var(--bn-sentiment-confidence-bg); color: var(--bn-sentiment-confidence); }

/* Legacy variants (deprecated — kept for backward compat with old intermediate JSON) */
.badge-suggestion { background: var(--bn-colour-suggestion-bg); color: var(--bn-colour-suggestion); }
.badge-frustrated { background: var(--bn-sentiment-frustration-bg); color: var(--bn-sentiment-frustration); }
.badge-delighted { background: var(--bn-sentiment-delight-bg); color: var(--bn-sentiment-delight); }
.badge-confused { background: var(--bn-sentiment-confusion-bg); color: var(--bn-sentiment-confusion); }
.badge-amused { background: var(--bn-sentiment-delight-bg); color: var(--bn-sentiment-delight); }
.badge-critical { background: var(--bn-sentiment-frustration-bg); color: var(--bn-sentiment-frustration); }
.badge-sarcastic { background: var(--bn-colour-badge-bg); color: var(--bn-colour-badge-text); }
.badge-judgment { background: var(--bn-colour-badge-bg); color: var(--bn-colour-badge-text); }
.badge-narration { background: var(--bn-colour-badge-bg); color: var(--bn-colour-badge-text); }
.badge-task_management { background: var(--bn-colour-badge-bg); color: var(--bn-colour-badge-text); }

/* AI badge — deletable on hover */
.badge-ai {
    cursor: pointer;
    position: relative;
    transition: opacity var(--bn-transition-fast);
}

.badge-ai:hover {
    opacity: 0.8;
}

/* Delete circle — white floating chip with grey ×.
   Pure flexbox centering (10c-fix2 approach).
   TODO: replace × character with SVG icon for cross-platform consistency. */
.badge-ai::after {
    content: "\00d7";
    position: absolute;
    top: calc(-0.3rem - 1px);
    right: calc(-0.3rem - 1px);
    width: calc(0.875rem + 0.5px);   /* ~14.5px */
    height: calc(0.875rem + 0.5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--bn-colour-bg);
    color: var(--bn-colour-muted);
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    opacity: 0;
    transition: opacity var(--bn-transition-fast);
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16), 0 0 1px rgba(0, 0, 0, 0.06);
}

.badge-ai:hover::after {
    opacity: 1;
}

/* User tag — mode-dependent treatment.
   Light mode: dark text on washed codebook bg (pale tint).
   Dark mode: white text on saturated codebook bg.
   Background colour set via inline style from codebook.js.
   Falls back to --bn-colour-user-tag-bg when no codebook colour assigned. */
.badge-user {
    background: var(--bn-colour-user-tag-bg);
    color: var(--bn-colour-text);
    font-weight: 400;
    cursor: default;
    position: relative;
}

/* Dark mode: user tags switch to white-on-saturated */
@supports (color: light-dark(#000, #fff)) {
    [data-theme="dark"] .badge-user {
        color: #ffffff;
        font-weight: 500;
    }
    @media (prefers-color-scheme: dark) {
        :root:not([data-theme="light"]) .badge-user {
            color: #ffffff;
            font-weight: 500;
        }
    }
}

/* AI tag visibility toggle */
body.hide-ai-tags .badge-ai { display: none; }

.badge-user .badge-delete {
    position: absolute;
    top: calc(-0.3rem - 1px);
    right: calc(-0.3rem - 1px);
    width: calc(0.875rem + 0.5px);   /* ~14.5px */
    height: calc(0.875rem + 0.5px);
    background: var(--bn-colour-bg);
    border: none;
    border-radius: 50%;
    color: var(--bn-colour-muted);
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--bn-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16), 0 0 1px rgba(0, 0, 0, 0.06);
}

.badge-user:hover .badge-delete {
    opacity: 1;
    pointer-events: auto;
}

/* Add-tag ghost button */
.badge-add {
    border: 1px dashed var(--bn-colour-border);
    background: transparent;
    color: var(--bn-colour-muted);
    cursor: pointer;
    transition: border-color var(--bn-transition-fast), color var(--bn-transition-fast);
    user-select: none;
}

.badge-add:hover {
    border-color: var(--bn-colour-accent);
    color: var(--bn-colour-accent);
}

/* Badge animations */
@keyframes badge-fade-out {
    to { opacity: 0; transform: scale(0.8); }
}

.badge-removing {
    animation: badge-fade-out 0.15s ease-out forwards;
    pointer-events: none;
}

@keyframes badge-fade-in {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

.badge-appearing {
    animation: badge-fade-in 0.15s ease-out;
}
