{{#if document.title.show}}
<header>
    <h{{ title.level1 }}>{{ document.name }}</h{{ title.level1 }}>
</header>
{{/if}}

{{#if linked.document}}

<section class="journal-page-content">
    {{#if modernStyle}}{{> "dnd5e.journal-modern-traits" }}{{/if}}

    {{{ enriched.value }}}

    <h{{ title.level2 }}>{{ localize "JOURNALENTRYPAGE.DND5E.Class.Features.Header" }}</h{{ title.level2 }}>

    {{#if modernStyle}}
    <p>
        {{ localize "JOURNALENTRYPAGE.DND5E.Class.Features.DescriptionModern" name=linked.name
           lowercaseName=linked.lowercaseName }}
    </p>
    {{else}}
    {{#if (and primaryAbility (not modernStyle))}}
    <strong>{{ localize "DND5E.CLASS.FIELDS.primaryAbility.value.label" }}:</strong> {{ primaryAbility }}
    {{/if}}

    <p>
        {{ localize "JOURNALENTRYPAGE.DND5E.Class.Features.DescriptionLegacy" name=linked.name
           lowercaseName=linked.lowercaseName }}
    </p>

    {{> "dnd5e.journal-legacy-traits" }}
    {{/if}}

    {{> "dnd5e.journal-table" table=table level=title.level3
        caption=(localize "JOURNALENTRYPAGE.DND5E.Class.TableCaption" class=linked.name) }}

    {{#each features}}
    <h{{ @root.title.level4 }}>{{ this.name }}</h{{ @root.title.level4 }}>
    {{{ this.description }}}
    {{/each}}

    {{#if optionalTable}}
    <h{{ title.level2 }}>{{ localize "JOURNALENTRYPAGE.DND5E.Class.OptionalFeaturesCaption" }}</h{{ title.level2 }}>
    <p>{{ localize "JOURNALENTRYPAGE.DND5E.Class.OptionalFeaturesDescription" class=linked.lowercaseName }}</p>

    {{> "dnd5e.journal-table" table=optionalTable level=title.level3
        caption=(localize "JOURNALENTRYPAGE.DND5E.Class.TableOptionalCaption" class=linked.name) }}

    {{#each optionalFeatures}}
    <h{{ @root.title.level4 }}>{{ this.name }}</h{{ @root.title.level4 }}>
    {{{ this.description }}}
    {{/each}}
    {{/if}}

    {{#if (or enriched.subclass subclasses)}}
    <h{{title.level2}}>
        {{#if system.subclassHeader}}{{ system.subclassHeader }}
        {{else}}{{ localize "JOURNALENTRYPAGE.DND5E.Class.FIELDS.subclassItems.label" }}{{/if}}
    </h{{title.level2}}>
    {{{ enriched.subclass }}}

    {{#each subclasses}}
    <h{{ @root.title.level3 }}>{{ this.name }}</h{{ @root.title.level3 }}>
    {{{this.description}}}

    {{#if this.table}}
    {{> "dnd5e.journal-table" table=this.table level=title.level4
        caption=(localize "JOURNALENTRYPAGE.DND5E.Class.TableCaption" class=this.name) }}
    {{/if}}

    {{#each this.features}}
    <h{{ @root.title.level4 }}>{{ this.name }}</h{{ @root.title.level4 }}>
    {{{ this.description }}}
    {{/each}}
    {{/each}}
    {{/if}}
</section>

{{else}}
<section>
    {{ localize "JOURNALENTRYPAGE.DND5E.Class.NoValidClass" }}
</section>
{{/if}}
