@if (_isMinimized)
{
    <div class="minimized-dock" @ref="_miniDock">
        <LevelMeterFab OnClick="@ToggleMinimized" />
    </div>
}
else
{
    <div class="@PlayerModeClass d-flex flex-column" @ref="_playerRoot">
        <MudContainer MaxWidth="MaxWidth.Large" Class="player-inner-container">
            <MudPaper Elevation="8" Class="player-surface pa-3">

                @* Theater Mode "now showing" band (Phase 20 §5/§7, Wave 2 §2). Keyed off the playing
                   track's Release, not off any detail page (the bar reaches into no page; §6). The release
                   page is hidden in Theater Mode, so the bar carries its identity: cover, linked title,
                   release share. The band stays mounted whenever a release is playing and eases in/out via
                   the shared .dd-theater-collapsible wrapper — collapsed (zero height, faded) unless
                   Theater is ON — so the bar grows/shrinks smoothly instead of popping. *@
                @if (CurrentTrack?.Release is not null)
                {
                    var nowShowing = VisualizerControlState.TheaterMode;
                    <div class="dd-theater-collapsible @(nowShowing ? null : "dd-theater-collapsed")">
                        <div class="dd-theater-collapsible-inner">
                        <NowShowingPanel Release="CurrentTrack.Release" />
                        </div>
                    </div>
                }

                <div class="player-layout">
                    <PlayerTransportZone IsLoaded="IsLoaded"
                                         CanPlay="CanPlay"
                                         IsLoading="IsLoading"
                                         IsStreaming="IsStreaming"
                                         LoadProgress="LoadProgress"
                                         DisplayTime="DisplayTime"
                                         Duration="Duration"
                                         Fixed="Fixed"
                                         TogglePlayPause="@TogglePlayPause"
                                         Stop="@Stop"
                                         HasNext="HasNext"
                                         HasPrevious="HasPrevious"
                                         SkipNext="@SkipNext"
                                         SkipPrevious="@SkipPrevious"
                                         ShowQueueButton="ShowQueueButton"
                                         QueueOpen="QueueButtonOpen"
                                         QueueToggle="@ToggleQueue"
                                         Class="transport-zone"/>

                    <VolumeZone Volume="@Volume" VolumeChanged="@OnVolumeChange"/>

                    <div class="meta-zone">
                        <TrackMetaLabel Track="CurrentTrack" Fixed="Fixed"/>
                    </div>

                    <PlayerSeekZone OnSeekStart="@OnSeekStart"
                                    OnSeekEnd="@OnSeekEnd"
                                    OnSeekChange="@OnSeekChange"
                                    Class="seek-zone"/>
                </div>

                @* Fixed (embed) queue panel (§4 / AC5). A release embed shows the up-next inline below the
                   controls as a read-only list (Editable=false → no drag handles, no remove buttons; C3).
                   Jump-to-track is still allowed (OQ2) — routed through the same OnQueueJump as the docked
                   overlay, which calls JumpTo (moves the pointer and streams the row, clearing IsArmed).
                   Gated on ShowFixedPanel so a single-track embed (empty queue) stays panel-free (UC6). The
                   Queue button collapses/expands this panel (OQ1 Option A); collapse hides it and posts the
                   shrunken height to the host iframe. *@
                @if (ShowFixedPanel && _fixedPanelOpen)
                {
                    <div class="deepdrft-queue-embed-panel">
                        <QueueList Items="QueueItems"
                                   CurrentIndex="QueueCurrentIndex"
                                   Editable="false"
                                   OnJump="@OnQueueJump"/>
                    </div>
                }

                @* Minimize / close — positioned absolutely top-right *@
                @if (!Fixed)
                {
                    <PlayerWindowControls OnMinimize="@ToggleMinimized" OnClose="@Close"/>
                }
            </MudPaper>
        </MudContainer>
            
        @if (!string.IsNullOrEmpty(ErrorMessage))
        {
            <MudAlert Severity="Severity.Error"
                      ShowCloseIcon="true"
                      CloseIconClicked="ClearError"
                      Class="ma-2">
                @ErrorMessage
            </MudAlert>
        }

        @* Docked queue overlay (Phase 17 §3.2). MudOverlay portals to the body, so its position here in
           the dock subtree does not affect its screen-centered rendering. Only mounted in docked mode —
           the Fixed embed renders its own inline panel inside the surface above. *@
        @if (ShowDockedOverlay)
        {
            <QueueOverlay Visible="_queueOpen"
                          Items="QueueItems"
                          CurrentIndex="QueueCurrentIndex"
                          OnClose="@CloseQueue"
                          OnClear="@ClearUpcoming"
                          OnReorder="@OnQueueReorder"
                          OnRemove="@OnQueueRemove"
                          OnJump="@OnQueueJump"/>
        }
    </div>
}
