<section class="tab proficiencies major" data-group="primary" data-tab="proficiencies">
    <header>{{localize "PF2E.CoreSkillsHeader"}}</header>
    <ul class="proficiencies-list">
        {{!-- Core Skills --}}
        {{#each data.skills as |skill key|}}
            {{#unless skill.lore}}
                <li data-statistic="{{skill.slug}}">
                    <a class="d20" data-action="roll-check">
                        {{> "systems/pf2e/templates/actors/character/icons/d20.hbs"}}
                    </a>
                    <a class="modifier hover" data-tooltip-content="#{{@root.options.id}}-{{skill.slug}}-modifiers" data-tooltip="{{skill.breakdown}}">
                        {{numberFormat skill.value decimals=0 sign=true}}
                    </a>
                    <div class="name">{{localize skill.label}}</div>
                    <select
                        class="skill-proficiency pf-rank"
                        data-property="system.skills.{{key}}.rank"
                        data-rank="{{skill.rank}}"
                        data-dtype="Number"
                    >
                        {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=skill.rank}}
                    </select>
                    {{#with skill}}
                        {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" abpEnabled=@root.abpEnabled title=label}}
                    {{/with}}
                </li>
            {{/unless}}
        {{/each}}
    </ul>

    {{!-- Lore Header --}}
    <header>
        {{localize "PF2E.LoreSkillsHeader"}}
        <div class="controls">
            <button type="button" data-action="create-item" data-tooltip="PF2E.CreateSkillTitle" data-type="lore">
                <i class="fa-solid fa-fw fa-plus"></i>{{localize "PF2E.AddShortLabel"}}
            </button>
        </div>
    </header>

    <ul class="proficiencies-list lores-list">
        {{!-- Lore Skills --}}
        {{#each data.skills as |skill idx|}}
            {{#if skill.lore}}
                <li class="item" data-item-id="{{skill.itemId}}" data-item-type="lore" data-statistic="{{skill.slug}}">
                    <a class="d20" data-action="roll-check" data-tooltip="{{skill.breakdown}}">
                        {{> "systems/pf2e/templates/actors/character/icons/d20.hbs"}}
                    </a>
                    <a class="modifier" data-action="roll-check">{{numberFormat skill.value decimals=0 sign=true}}</a>
                    <input class="name" data-item-id="{{skill.itemId}}" data-item-property="name" type="text" value="{{skill.label}}" />
                    <select class="skill-proficiency pf-rank adjust-item-stat-select" data-item-property="system.proficient.value" data-tooltip="{{skill.breakdown}}" data-rank="{{skill.rank}}">
                        {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=skill.rank}}
                    </select>
                    {{#if ../editable}}
                        <div class="item-controls">
                            <a data-action="delete-item" data-tooltip="PF2E.DeleteItemTitle"><i class="fa-solid fa-fw fa-trash"></i></a>
                        </div>
                    {{/if}}
                </li>
            {{/if}}
        {{/each}}
    </ul>

    {{!-- Attacks --}}
    <header class="attacks-defenses">
        {{localize "PF2E.Actor.Character.Proficiency.Attack.Title"}}
        <div class="controls">
            <button type="button" data-action="add-attack-proficiency" data-tooltip="PF2E.AddCombatProficiency.Title">
                <i class="fa-solid fa-fw fa-plus"></i>{{localize "PF2E.AddShortLabel"}}
            </button>
        </div>
    </header>

    <ul class="proficiencies-list combat-list">
        {{#each martialProficiencies.attacks as |proficiency key|}}
            <li{{#if proficiency.custom}} class="custom"{{/if}} data-slug="{{key}}">
                {{#if (and proficiency.custom @root.editable)}}
                    <a class="delete" data-action="delete-attack-proficiency"><i class="fa-solid fa-fw fa-trash"></i></a>
                {{/if}}
                <span class="modifier" data-tooltip="{{proficiency.breakdown}}">{{numberFormat proficiency.value decimals=0 sign=true}}</span>
                <span class="name">{{localize proficiency.label}}</span>
                <select
                    class="skill-proficiency pf-rank{{#unless proficiency.custom}} readonly{{/unless}}"
                    data-property="system.proficiencies.attacks.{{key}}.rank"
                    data-rank="{{proficiency.rank}}"
                    data-dtype="Number"
                >
                    {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=proficiency.rank}}
                </select>
            </li>
        {{/each}}
    </ul>

    {{!-- Defenses --}}
    <header class="attacks-defenses">
        {{localize "PF2E.Actor.Character.Proficiency.Defense.Title"}}
    </header>
    <ul class="proficiencies-list combat-list">
        {{#each martialProficiencies.defenses as |proficiency key|}}
            <li{{#if (and @first @last)}} class="all-by-myself"{{/if}} data-slug="{{key}}">
                <span class="modifier" data-tooltip="{{proficiency.breakdown}}">{{numberFormat proficiency.value decimals=0 sign=true}}</span>
                <span class="name">{{localize proficiency.label}}</span>
                <span class="pf-rank" data-rank="{{proficiency.rank}}">{{lookup @root.numberToRank proficiency.rank}}</span>
            </li>
        {{/each}}
    </ul>

    {{!-- Spellcasting --}}
    {{#if (gt actor.system.proficiencies.spellcasting.rank 0)}}
        <header>{{localize "PF2E.Item.Spell.Plural"}}</header>
        <ul class="proficiencies-list">
            {{#with document.spellcasting.base as |spellcasting|}}
                <li class="all-by-myself" data-slug="spellcasting">
                    <span class="modifier" data-tooltip="{{spellcasting.breakdown}}">{{numberFormat spellcasting.mod decimals=0 sign=true}}</span>
                    <span class="name">{{localize spellcasting.label}}</span>
                    <span class="pf-rank" data-rank="{{spellcasting.rank}}">{{lookup @root.numberToRank spellcasting.rank}}</span>
                </li>
            {{/with}}
        </ul>
    {{/if}}

    {{!-- Class DCs --}}
    {{#if classDCs.dcs}}
        <header>{{localize "PF2E.Actor.Character.ClassDC.Plural"}}</header>
        <ul class="proficiencies-list">
            {{#each classDCs.dcs as |classDC|}}
                <li{{#if (and @first @last)}} class="all-by-myself"{{else if (not classDC.primary)}} class="secondary"{{/if}}>
                    <a class="dc hover" data-tooltip-content="#{{../options.id}}-{{classDC.slug}}-modifiers" data-tooltip="{{classDC.breakdown}}">{{classDC.dc}}</a>
                    <span class="name">{{classDC.label}}</span>
                    <span class="pf-rank" data-rank="{{classDC.rank}}">{{lookup @root.numberToRank classDC.rank}}</span>
                    {{#with classDC}}
                        {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" title="PF2E.Actor.Character.ClassDC.Label"}}
                    {{/with}}
                </li>
            {{/each}}
        </ul>
    {{/if}}
</section>
