@if (scene) {
  <div class="view-page">
    <header class="view-header">
      <div>
        <h1>
          @if (scene.icon) {
            <lucide-icon [img]="resolveCampaignIcon(scene.icon)" [size]="22" class="title-icon"></lucide-icon>
          }
          {{ scene.name }}
        </h1>
        <p class="view-subtitle">{{ 'sceneView.subtitle' | translate }}</p>
      </div>
      <div class="view-actions">
        <button type="button" class="btn-primary" (click)="editMode()">
          <lucide-icon [img]="Pencil" [size]="14"></lucide-icon>
          {{ 'common.edit' | translate }}
        </button>
        <button type="button" class="btn-danger" (click)="deleteScene()" [title]="'sceneView.deleteTitleAttr' | translate">
          <lucide-icon [img]="Trash2" [size]="14"></lucide-icon>
          {{ 'common.delete' | translate }}
        </button>
      </div>
    </header>
    <!-- Illustrations (rendu editorial magazine) -->
    @if ((scene.illustrationImageIds?.length ?? 0) > 0) {
      <section class="view-section">
        <app-image-gallery [imageIds]="scene.illustrationImageIds ?? []" [layout]="'EDITORIAL'"></app-image-gallery>
      </section>
    }
    <!-- Description courte -->
    <section class="view-section">
      <h2 class="view-section-title"><span class="view-section-icon">📝</span> {{ 'sceneView.descriptionSectionTitle' | translate }}</h2>
      @if (scene.description?.trim()) {
        <p class="view-section-body">{{ scene.description }}</p>
      } @else {
        <p class="view-section-empty">{{ 'sceneView.empty' | translate }}</p>
      }
    </section>
    <!-- Contexte et ambiance -->
    @if (scene.location?.trim() || scene.timing?.trim()) {
      <div class="view-row">
        @if (scene.location?.trim()) {
          <section class="view-section">
            <h2 class="view-section-title"><span class="view-section-icon">📍</span> {{ 'sceneView.locationSectionTitle' | translate }}</h2>
            <p class="view-section-body">{{ scene.location }}</p>
          </section>
        }
        @if (scene.timing?.trim()) {
          <section class="view-section">
            <h2 class="view-section-title"><span class="view-section-icon">⏰</span> {{ 'sceneView.timingSectionTitle' | translate }}</h2>
            <p class="view-section-body">{{ scene.timing }}</p>
          </section>
        }
      </div>
    }
    @if (scene.atmosphere?.trim()) {
      <section class="view-section">
        <h2 class="view-section-title"><span class="view-section-icon">🌫️</span> {{ 'sceneView.atmosphereSectionTitle' | translate }}</h2>
        <p class="view-section-body">{{ scene.atmosphere }}</p>
      </section>
    }
    <!-- Narration pour les joueurs -->
    @if (scene.playerNarration?.trim()) {
      <section class="view-section">
        <h2 class="view-section-title"><span class="view-section-icon">📖</span> {{ 'sceneView.narrationSectionTitle' | translate }}</h2>
        <p class="view-section-body">{{ scene.playerNarration }}</p>
      </section>
    }
    <!-- Choix et conséquences -->
    @if (scene.choicesConsequences?.trim()) {
      <section class="view-section">
        <h2 class="view-section-title"><span class="view-section-icon">🔀</span> {{ 'sceneView.choicesSectionTitle' | translate }}</h2>
        <p class="view-section-body">{{ scene.choicesConsequences }}</p>
      </section>
    }
    <!-- Combat ou rencontre -->
    @if (scene.combatDifficulty?.trim() || scene.enemies?.trim() || linkedEnemies.length > 0) {
      @if (scene.combatDifficulty?.trim()) {
        <section class="view-section">
          <h2 class="view-section-title"><span class="view-section-icon">⚔️</span> {{ 'sceneView.combatDifficultySectionTitle' | translate }}</h2>
          <p class="view-section-body">{{ scene.combatDifficulty }}</p>
        </section>
      }
      @if (scene.enemies?.trim() || linkedEnemies.length > 0) {
        <section class="view-section">
          <h2 class="view-section-title"><span class="view-section-icon">🐲</span> {{ 'sceneView.enemiesSectionTitle' | translate }}</h2>
          @if (linkedEnemies.length > 0) {
            <div class="view-chips">
              @for (e of linkedEnemies; track e.id) {
                <a class="view-chip"
                  [routerLink]="['/campaigns', campaignId, 'enemies', e.id]">
                  {{ enemyLabel(e) }}
                </a>
              }
            </div>
          }
          @if (scene.enemies?.trim()) {
            <p class="view-section-body">{{ scene.enemies }}</p>
          }
        </section>
      }
    }
    <!-- Notes et secrets du MJ (privé) -->
    @if (scene.gmSecretNotes?.trim()) {
      <section class="view-section view-section--private">
        <h2 class="view-section-title">
          <span class="view-section-icon">🔒</span>
          {{ 'sceneView.gmNotesSectionTitle' | translate }}
        </h2>
        <p class="view-section-body">{{ scene.gmSecretNotes }}</p>
      </section>
    }
    <!-- Pages Lore liées -->
    @if (loreId && (scene.relatedPageIds?.length ?? 0) > 0) {
      <section class="view-section">
        <h2 class="view-section-title"><span class="view-section-icon">🔗</span> {{ 'sceneView.loreSectionTitle' | translate }}</h2>
        <div class="view-chips">
          @for (relId of scene.relatedPageIds; track relId) {
            <a class="view-chip"
              [routerLink]="['/lore', loreId, 'pages', relId]">
              {{ titleOfRelated(relId) }}
            </a>
          }
        </div>
      </section>
    }
    <!-- Lieu explorable : pièces (mode donjon) -->
    @if ((scene.rooms?.length ?? 0) > 0) {
      <section class="view-section">
        <h2 class="view-section-title"><span class="view-section-icon">🏰</span> {{ 'sceneView.roomsSectionTitle' | translate }}</h2>
        <div class="rooms-readonly">
          @for (r of scene.rooms; track r; let i = $index) {
            <article class="room-readonly">
              <header class="room-readonly-head">
                <span class="room-readonly-index">#{{ i + 1 }}</span>
                <span class="room-readonly-name">{{ r.name }}</span>
                @if (r.floor !== null && r.floor !== undefined) {
                  <span class="room-readonly-floor">
                    {{ 'sceneView.roomFloor' | translate:{ floor: r.floor } }}
                  </span>
                }
              </header>
              @if (r.description?.trim()) {
                <p class="room-readonly-desc">{{ r.description }}</p>
              }
              <div class="room-readonly-grid">
                @if (r.enemies?.trim() || roomLinkedEnemies(r).length > 0) {
                  <div>
                    <strong>{{ 'sceneView.roomEnemies' | translate }}</strong>
                    @if (roomLinkedEnemies(r).length > 0) {
                      <div class="view-chips">
                        @for (e of roomLinkedEnemies(r); track e.id) {
                          <a class="view-chip"
                            [routerLink]="['/campaigns', campaignId, 'enemies', e.id]">
                            {{ enemyLabel(e) }}
                          </a>
                        }
                      </div>
                    }
                    @if (r.enemies?.trim()) {
                      <p>{{ r.enemies }}</p>
                    }
                  </div>
                }
                @if (r.loot?.trim()) {
                  <div>
                    <strong>{{ 'sceneView.roomLoot' | translate }}</strong>
                    <p>{{ r.loot }}</p>
                  </div>
                }
                @if (r.traps?.trim()) {
                  <div>
                    <strong>{{ 'sceneView.roomTraps' | translate }}</strong>
                    <p>{{ r.traps }}</p>
                  </div>
                }
                @if (r.gmNotes?.trim()) {
                  <div class="room-readonly-private">
                    <strong>{{ 'sceneView.roomGmNotes' | translate }}</strong>
                    <p>{{ r.gmNotes }}</p>
                  </div>
                }
              </div>
              @if ((r.branches?.length ?? 0) > 0) {
                <div class="room-readonly-branches">
                  <strong>{{ 'sceneView.roomExits' | translate }}</strong>
                  <ul>
                    @for (b of r.branches; track b) {
                      <li>
                        <em>{{ b.label }}</em> → {{ roomNameById(scene, b.targetRoomId) }}
                        @if (b.condition?.trim()) {
                          <span class="branch-cond">{{ 'sceneView.roomExitCondition' | translate:{ condition: b.condition } }}</span>
                        }
                      </li>
                    }
                  </ul>
                </div>
              }
            </article>
          }
        </div>
      </section>
    }
  </div>
}
