<header class="npc-dossier-header" style="--npc-accent: {{profile.accent}};">
    <div class="npc-dossier-portrait nexus-entity-image is-person" {{#if profile.canDrag}}draggable="true" data-npc-dossier-drag="true" title="Drag {{profile.name}}"{{/if}}>
        {{#if profile.imageSrc}}
        <img src="{{profile.imageSrc}}" alt="{{profile.name}}" draggable="false">
        {{else}}
        <i class="fas fa-user"></i>
        {{/if}}
    </div>
    <div class="npc-dossier-title">
        <h2>{{profile.name}}</h2>
        <p>{{profile.subtitle}}</p>
        {{#if profile.showTabs}}
        <nav class="npc-dossier-tabs" aria-label="Person dossier tabs">
            <button type="button" class="{{#if profile.tabs.isProfileTab}}active{{/if}}" data-action="setNpcDossierTab" data-tab="profile">Profile</button>
            <button type="button" class="{{#if profile.tabs.isJournalTab}}active{{/if}}" data-action="setNpcDossierTab" data-tab="journal">Journal</button>
            <button type="button" class="npc-dossier-tab-icon {{#if profile.tabs.isConnectionsTab}}active{{/if}}" data-action="setNpcDossierTab" data-tab="connections" title="Connections" aria-label="Connections"><i class="fas fa-share-nodes"></i></button>
            {{#if profile.hasChronicle}}<button type="button" class="npc-dossier-tab-icon {{#if profile.tabs.isChronicleTab}}active{{/if}}" data-action="setNpcDossierTab" data-tab="chronicle" title="Chronicle" aria-label="Chronicle"><i class="fas fa-scroll"></i></button>{{/if}}
            {{#if profile.linkedActor}}
            <button type="button" class="npc-dossier-tab-icon" data-action="openNpcLinkedActor" title="Open linked Actor" aria-label="Open linked Actor">
                <i class="fas fa-user-circle"></i>
            </button>
            {{/if}}
        </nav>
        {{/if}}
    </div>
    {{#if profile.showHeaderActions}}
    <div class="npc-dossier-header-actions">
        {{#if profile.showCompactToggle}}
        <button type="button" class="npc-dossier-compact-toggle" data-action="toggleNpcDossierCompact" title="{{#if profile.compactMode}}Expand person dossier{{else}}Compact person dossier{{/if}}" aria-label="{{#if profile.compactMode}}Expand person dossier{{else}}Compact person dossier{{/if}}">
            <i class="fas {{#if profile.compactMode}}fa-expand{{else}}fa-compress{{/if}}"></i>
        </button>
        {{/if}}
        {{#if profile.showActions}}
        <button type="button" class="npc-dossier-action" data-action="openNpcActions" title="Person actions" aria-label="Person actions"><i class="fas fa-ellipsis"></i></button>
        {{/if}}
    </div>
    {{/if}}
</header>

{{#if profile.showBody}}
<section class="npc-dossier-section">
    {{#if profile.identityChips.length}}
    <div class="npc-dossier-chip-row npc-dossier-chip-row-primary">
        {{#each profile.identityChips}}
        <span><em>{{label}}</em><strong>{{value}}</strong></span>
        {{/each}}
    </div>
    {{/if}}

    {{#if profile.chips.length}}
    <div class="npc-dossier-chip-row">
        {{#each profile.chips}}
        <span><em>{{label}}</em><strong>{{value}}</strong></span>
        {{/each}}
    </div>
    {{/if}}

    {{#if profile.showCore}}
    {{#if profile.compactMode}}<h3 class="npc-profile-section-heading"><span><i class="fas fa-masks-theater"></i> Personality</span></h3>{{/if}}
    {{#if profile.hasTraits}}
    <div class="npc-trait-row">
        {{#each profile.traits}}
        <span class="npc-trait-chip {{#if missing}}missing{{/if}}" title="{{label}}">
            {{#if iconSrc}}<img src="{{iconSrc}}" alt="{{label}}">{{else}}<i class="fas fa-user"></i>{{/if}}
            <span>{{label}}</span>
        </span>
        {{/each}}
    </div>
    {{else}}
    <div class="npc-dossier-empty compact">{{profile.emptyTraitsLabel}}</div>
    {{/if}}

    {{#if profile.compactMode}}
    {{#if profile.hasImportance}}
    <h3 class="npc-profile-section-heading is-importance"><span><i class="fas fa-crown"></i> Importance</span></h3>
    <div class="npc-profile-importance-row">
        {{#each profile.importance}}
        <button type="button" class="npc-profile-importance-card" data-npc-life-node="{{nodeId}}" draggable="true" title="{{role}} — {{name}}">
            <span class="npc-profile-importance-image nexus-entity-image {{#if isEmblem}}is-emblem{{else}}{{#if isSquare}}is-place{{else}}is-person{{/if}}{{/if}}">{{#if imageSrc}}<img src="{{imageSrc}}" alt="">{{else}}<i class="{{icon}}"></i>{{/if}}</span>
            <span class="npc-profile-importance-copy"><em><i class="{{icon}}"></i> {{role}}</em><strong>{{name}}</strong></span>
        </button>
        {{/each}}
    </div>
    {{/if}}
    {{/if}}

    {{#if profile.compactMode}}<h3 class="npc-profile-section-heading"><span><i class="fas fa-compass"></i> Beliefs</span></h3>{{/if}}
    {{#if profile.hasIdeology}}
    <div class="faction-ideology-panel">
        <div class="faction-ideology-grid">
            {{#each profile.ideology}}
            <article class="faction-ideology-card">
                <div class="faction-ideology-title" title="{{topicQuestion}}">
                    <span class="faction-ideology-topic">
                        <i class="{{topicIcon}}"></i>
                        <span>{{topicLabel}}</span>
                    </span>
                    <span class="faction-ideology-separator">-</span>
                    <strong>{{tenetLabel}}</strong>
                </div>
                <p>{{tenetDescription}}</p>
            </article>
            {{/each}}
        </div>
    </div>
    {{/if}}
    {{/if}}

    {{#if profile.profileRows.length}}
    <h3 class="npc-profile-section-heading npc-profile-information"><span><i class="fas fa-feather-pointed"></i> Information</span></h3>
    <div class="npc-dossier-custom-row">
        {{#each profile.profileRows}}
        <span><em>{{label}}</em><strong>{{value}}</strong></span>
        {{/each}}
    </div>
    {{/if}}

    {{#if profile.hasCurrentThread}}
    <section class="npc-profile-current-thread">
        <h3 class="npc-profile-section-heading is-thread">
            <span><i class="fas fa-wand-sparkles"></i> Current Thread</span>
            {{#if profile.canRerollCurrentThread}}
            <button type="button" class="faction-current-thread-reroll" data-action="rerollNpcCurrentThread" title="Reroll Current Thread" aria-label="Reroll Current Thread"><i class="fas fa-dice"></i></button>
            {{/if}}
        </h3>
        <div class="faction-current-thread-grid">
            {{#each profile.currentThread}}
            <article>
                <span><i class="{{icon}}"></i> {{label}}</span>
                <strong>{{value}}</strong>
            </article>
            {{/each}}
        </div>
    </section>
    {{/if}}

    {{#unless profile.showCore}}
    {{#unless profile.identityChips.length}}
    {{#unless profile.chips.length}}
    {{#unless profile.profileRows.length}}
    {{#unless profile.hasCurrentThread}}
    <div class="npc-dossier-empty">No additional profile details have been recorded.</div>
    {{/unless}}
    {{/unless}}
    {{/unless}}
    {{/unless}}
    {{/unless}}
</section>
{{/if}}

