/**
 * Edris Player CSS — Video.js themed modal + RTL layout.
 * Overrides Video.js defaults for Persian/RTL UI.
 */

/* ── Modal layout ── */
.edris-player-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    direction: rtl;
}

.edris-player-modal {
    background: #1e1e1e;
    color: #fff;
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0,0,0,0.6);
}

.edris-player-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #333;
}

.edris-player-title { font-size: 1.1rem; font-weight: 600; }

.edris-player-close {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}
.edris-player-close:hover { color: #fff; }

.edris-player-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.edris-player-main {
    flex: 1;
    position: relative;
    background: #000;
}

.edris-player-main video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.edris-player-sidebar {
    width: 300px;
    min-width: 260px;
    background: #252525;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.edris-player-tabs {
    display: flex;
    border-bottom: 1px solid #333;
}

.edris-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #aaa;
    padding: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color .2s, background .2s;
}
.edris-tab-btn:hover { color: #fff; background: #2a2a2a; }
.edris-tab-btn.active { color: #fff; background: #2a2a2a; border-bottom: 2px solid #2563eb; }

.edris-tab-panel {
    display: none;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}
.edris-tab-panel.active { display: block; }

.edris-quality-list, .edris-subtitle-list, .edris-audio-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edris-quality-item, .edris-subtitle-item, .edris-audio-item,
.edris-subtitle-btn, .edris-audio-btn {
    background: #2a2a2a;
    border: 1px solid #333;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s, border-color .2s;
    width: 100%;
    text-align: right;
    font-family: inherit;
    color: inherit;
}
.edris-quality-item:hover, .edris-subtitle-item:hover, .edris-audio-item:hover,
.edris-subtitle-btn:hover, .edris-audio-btn:hover {
    background: #333;
    border-color: #2563eb;
}
.edris-quality-item.active, .edris-subtitle-item.active, .edris-audio-item.active,
.edris-subtitle-btn.active, .edris-audio-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.edris-player-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 12px;
    border-top: 1px solid #333;
    background: #1e1e1e;
}

.edris-ctrl-btn {
    background: #2a2a2a;
    border: 1px solid #333;
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, border-color .2s;
}
.edris-ctrl-btn:hover {
    background: #2563eb;
    border-color: #2563eb;
    accent-color: #2563eb;
}
.edris-ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Player error panel ── */
.video-js .vjs-error-display { display: none !important; } /* custom .edris-player-error used instead */
.edris-artplayer .art-error { display: none; }
.edris-player-error {
    padding: 2rem;
    /* Reserve the top-left corner the sidebar toggle occupies, so the first
       message line never sits under it (mobile/tablet drawer toggle). */
    padding-top: 4.25rem;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 8px;
    margin: 1rem;
    max-width: 90%;
    box-sizing: border-box;
    /* Absolute overlay: as a plain flex child of .edris-player-page-main it took
       layout width from the player (390px row => 239px player + 135px error),
       which is the "player got tiny" report. */
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: auto;
    z-index: 100;
}
.edris-player-error p {
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}
.edris-player-error .edris-error-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.edris-player-error button {
    width: auto;
    height: auto;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    min-width: 110px;
    box-sizing: border-box;
}
.edris-player-error button.edris-ctrl-btn {
    background: #3a3a3a;
    border-color: #444;
}
.edris-player-error button.edris-ctrl-btn:hover {
    background: #2563eb;
    border-color: #2563eb;
}
/* VLC hand-off links styled as buttons (MKV/AVI fallback). */
.edris-player-error a.edris-ctrl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    min-width: 110px;
    padding: 8px 16px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #3a3a3a;
    color: #fff;
    font-size: 0.9rem;
    text-decoration: none;
    box-sizing: border-box;
}
.edris-player-error a.edris-ctrl-btn:hover {
    background: #2563eb;
    border-color: #2563eb;
}
.edris-player-error .edris-vlc-note {
    margin: 0 0 0.75rem;
    font-weight: 600;
}
.edris-player-error .edris-vlc-hint {
    margin: 0.75rem 0 0;
    font-size: 0.82rem;
    opacity: 0.85;
}

/* ── Loading overlay ── */
/* Same bug class as the error panel: as a plain flex child of
   .edris-player-page-main it took layout width from the player (390px row =>
   223px player + 167px message), i.e. "the player breaks while loading".
   Absolute overlay = zero layout impact, and the player keeps its size. */
.edris-player-loading {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 4.25rem; /* clear the sidebar toggle, same as the error panel */
    box-sizing: border-box;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.65);
    pointer-events: none; /* never block the controls underneath */
}
.edris-player-loading p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ── ArtPlayer RTL overrides ── */
/* ArtPlayer sizes .art-video-player to its own width/height 100%. The watch page
   puts that inside a flex column, so the wrapper must stretch to the full column
   height — otherwise the player collapses to its intrinsic 239px width band
   (the "player is tiny on mobile" report). object-fit keeps the frame letterboxed. */
.edris-artplayer,
.edris-artplayer .art-video-player {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: #fff;
}
.edris-artplayer video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
/* ArtPlayer ships `direction: ltr` on .art-video-player, which is what every
   player does: play on the left, fullscreen on the right. The RTL page used to
   be forced back onto the control bar here — removed, so the bar is normal.
   The Persian-only overlays (settings panel, notices) keep RTL so their text
   reads right-to-left. */
.edris-artplayer .art-settings,
.edris-artplayer .art-contextmenus {
    direction: rtl;
}
.edris-artplayer .art-setting-item-left,
.edris-artplayer .art-contextmenu {
    direction: rtl;
}
/* Theme colour comes from the ArtPlayer `theme` option (it writes the custom
   property inline, which no stylesheet rule can override). */

/* Modal state: ArtPlayer owns the <video> it creates. */
.edris-player-main .edris-artplayer,
.edris-player-main .edris-artplayer video {
    display: block;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .edris-player-modal {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .edris-player-sidebar {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-top: 1px solid #333;
    }
    .edris-player-body {
        flex-direction: column;
    }
    .edris-player-controls {
        flex-wrap: wrap;
    }
}

/* ── Dedicated player page layout (/watch/<type>/<id>/) ── */
/* The theme's global `body { min-height: 100vh }` plus WP's admin-bar
   `html { margin-top }` stack up, making the document taller than the viewport
   (the "stretched screen" on phones). The player page is a standalone
   full-screen surface, so let the body hug its content. */
body.edris-player-body {
    min-height: 0;
    height: auto;
}

.edris-player-page {
    direction: rtl;
    background: #121212;
    color: #fff;
    /* The WP admin bar (logged-in) is fixed on top and the theme offsets the
       content by its height — subtract it, otherwise the player overflows the
       viewport by 32/46px and the page scrolls ("stretched screen"). */
    height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px));
    min-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px));
    display: flex;
    flex-direction: column;
}
/* Desktop: series pages carry a 320px sidebar that belongs BESIDE the body,
   not below it. The base column layout puts the sidebar under the video and
   the list overflows the viewport (1652px tall in a 900px window). Movies are
   .no-sidebar and stay column — their header is a direct child of the page. */
@media (min-width: 1101px) {
    .edris-player-page:not(.no-sidebar) {
        flex-direction: row;
    }
}

.edris-player-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #222;
    background: #1a1a1a;
    flex-shrink: 0;
}

.edris-player-page-title {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.edris-player-page-type {
    font-size: 0.85rem;
    padding: 2px 8px;
    border: 1px solid #444;
    border-radius: 4px;
    color: #aaa;
    margin-left: 8px;
}

/* Real <button>: a bare text link was hard to hit with a TV remote (no box, no
   focus ring). Chrome = border + padding so D-pad focus is visible. */
.edris-player-page-back {
    color: #fff;
    background: #262626;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 6px 12px;
    min-height: 36px;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.edris-player-page-back:hover {
    background: #333;
    border-color: #3b82f6;
    color: #3b82f6;
}
.edris-player-page-back:focus-visible,
.edris-player-page-back:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    background: #333;
}

/* Short "بازگشت" label — swapped in on phones so the header stays one line. */
.edris-player-page-back-short { display: none; }

/* Dedicated page body: video + sidebar side by side, toolbar under them.
   The toolbar is a sibling of -main inside the body; a row keeps it beside
   the video (floating over the picture), so the body wraps the two in a row
   and the toolbar sits below as its own row. */
.edris-player-page-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}
.edris-player-stage {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.edris-player-page-main {
    flex: 1 1 auto;
    position: relative;
    background: #000;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.edris-player-page-main video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
/* The mount div has inline width/100% height/100% but height:100% resolves to 0
   when the flex parent has no definite height — the player area collapses to a
   0x0 sliver and the video never renders. Make it a flex grow child of the
   stage so it fills the available space. */
.edris-player-stage #edris-player-mount {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.edris-player-page-sidebar {
    width: 320px;
    min-width: 280px;
    background: #1a1a1a;
    border-right: 1px solid #222;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.25s ease;
}

/* Collapsed sidebar state */
.edris-player-page-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: hidden;
}

/* Episode arrows now live inside ArtPlayer's control bar (see
   artAddEpisodeNav in player-init.js) so they survive fullscreen. */
.edris-player-sidebar-toggle { transition: opacity 0.25s ease; }

/* Movies have no sidebar — the video takes the whole width. */
.edris-player-page.no-sidebar .edris-player-page-main { margin-right: 0; width: 100%; }

/* Sidebar panels wrapper (language tabs → single active panel) */
.edris-sidebar-panels {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar toggle button */
.edris-player-sidebar-toggle {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 120;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.edris-player-sidebar-toggle:hover {
    border-color: #2563eb;
    background: #333;
}
.edris-player-sidebar-toggle[aria-pressed="true"] {
    background: #2563eb;
    border-color: #2563eb;
}

/* When sidebar collapsed, hide the toggle's inner content and flip arrow */
.edris-player-page.collapsed-sidebar .edris-player-page-main {
    margin-right: 0;
}

/* Fullscreen: keep sidebar visible above Video.js fixed-position video */
.edris-player-page.in-fullscreen:not(.collapsed-sidebar) .edris-player-page-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    z-index: 2000;
}
.edris-player-page.in-fullscreen .edris-player-sidebar-toggle {
    z-index: 2001;
}

/* ── Tabs ── */
.edris-player-tabs {
    display: flex;
    border-bottom: 1px solid #333;
    gap: 2px;
    padding: 0 4px;
}

.edris-tab-btn {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #333;
    border-bottom: none;
    color: #aaa;
    padding: 10px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all .2s;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}
.edris-tab-btn:hover { color: #fff; border-color: #444; }
.edris-tab-btn.active { color: #fff; background: #2a2a2a; border-color: #444; border-bottom: 2px solid #2563eb; margin-bottom: -1px; }

/* ── Tab panels ── */
.edris-tab-panel {
    display: none;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}
.edris-tab-panel.active { display: block; }

.edris-quality-list,
.edris-season-list,
.edris-episode-list,
.edris-subtitle-list,
.edris-audio-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Quality / season / episode / track items ── */
.edris-quality-item,
.edris-season-item,
.edris-episode-item,
.edris-subtitle-item,
.edris-audio-item,
.edris-subtitle-btn,
.edris-audio-btn {
    background: #2a2a2a;
    border: 1px solid #333;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s, border-color .2s, color .2s;
    font-size: 0.9rem;
    color: #b0b0b0;
    width: 100%;
    text-align: right;
    font-family: inherit;
}
.edris-quality-item:hover,
.edris-season-item:hover,
.edris-episode-item:hover,
.edris-subtitle-item:hover,
.edris-audio-item:hover,
.edris-subtitle-btn:hover,
.edris-audio-btn:hover {
    background: #333;
    border-color: #2563eb;
    color: #fff;
}
.edris-quality-item:focus-visible,
.edris-season-item:focus-visible,
.edris-episode-item:focus-visible,
.edris-subtitle-item:focus-visible,
.edris-audio-item:focus-visible,
.edris-subtitle-btn:focus-visible,
.edris-audio-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.edris-quality-item.active,
.edris-season-item.active,
.edris-episode-item.active,
.edris-subtitle-item.active,
.edris-audio-item.active,
.edris-subtitle-btn.active,
.edris-audio-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* Season item has a sub-indicator */
.edris-season-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.edris-season-item .edris-season-count {
    font-size: 0.75rem;
    opacity: 0.6;
    background: #333;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Episode item: smaller, indented under season */
.edris-episode-item {
    background: #2a2a2a;
    padding-left: 16px;
    font-size: 0.85rem;
}
.edris-episode-item:hover {
    background: #333;
    border-color: #2563eb;
}
.edris-episode-item.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.edris-episode-item .edris-episode-no {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-left: 8px;
}

/* Season row: clickable header with expand/collapse */
.edris-season-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #242424;
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: background .2s, border-color .2s;
}
.edris-season-row:hover {
    background: #2a2a2a;
}
.edris-season-row .edris-season-item {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: #fff;
    cursor: inherit;
    flex: 1;
}
.edris-season-row .edris-season-item:hover {
    background: transparent;
    border-color: transparent;
}
.edris-season-row .edris-season-item.active {
    background: transparent;
    border-color: transparent;
    color: #2563eb;
}

/* Episode panel: nested under expanded season. Vertical stack of episode rows.
   The expand animation must NOT use a max-height cap: a season can hold 300+
   episodes (356 in production), and any cap clips the tail with no way to
   scroll to it. Plain display toggle — height always fits the content. */
.edris-episode-panel {
    display: none;
    padding-left: 16px;
    border-left: 2px solid #333;
    margin-top: 4px;
}
.edris-episode-panel.expanded {
    display: block;
}
.edris-episode-panel > div:first-child {
    width: 100%;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 6px;
}

/* Each episode is its own row; quality chips live under it. */
.edris-episode-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    width: 100%;
}
/* Inline quality chips under an episode — hidden by default, expanded on click.
   Same rule as the episode panel: no max-height cap, or the tail chips become
   unreachable (production has episodes with 22 chips = ~1100px on a phone). */
.edris-episode-qualities-inline {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    padding-left: 4px;
    border-left: 2px solid #444;
}
.edris-episode-qualities-inline.expanded {
    display: flex;
}

/* Quality item under episode */
.edris-quality-item {
    font-size: 0.85rem;
}

/* Flat episode list removed — episodes render only in .edris-episode-panel. */
.edris-episode-list {
    display: none;
}

/* ── Removed: edris-player-page-controls (prev/next) ── */
/* Controls block deleted from template; styles removed to avoid dead CSS. */

/* ── Responsive: tablet + mobile ──
   Under 1100px the 320px sidebar no longer fits beside the video (on a 1024px
   tablet it leaves 704px for the picture and turns the rest into black bands),
   and it must
   not overlay it either (an 88%-wide drawer hides the picture exactly when you
   are picking an episode). So the page stops being a fixed-height flex box:
   the video sits at the top at its natural 16:9 size and the sidebar
   (version tabs → seasons → episodes) flows underneath it and scrolls with
   the page. Nothing covers the video, and no black band eats the viewport. */
@media (max-width: 1100px) {
    .edris-player-page {
        height: auto;
        min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px));
        overflow-x: clip;
    }
    .edris-player-page-body {
        display: block;
        overflow: visible;
        position: relative;
    }
    .edris-player-page-main {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        /* Short landscape viewports: cap the video to one screen instead of
           pushing the list below the fold. */
        max-height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px) - 48px);
        align-items: stretch;
    }

    .edris-player-page-header {
        padding: 10px 14px;
        gap: 8px;
        flex-direction: row;
        align-items: center;
    }
    .edris-player-page-title {
        font-size: 1.05rem;
        gap: 8px;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    .edris-player-page-type { flex-shrink: 0; }
    .edris-player-page-back {
        font-size: 0.85rem;
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Sidebar = normal block under the video (no drawer, no backdrop). The JS
       still toggles .collapsed on it for desktop; on mobile both states are
       overridden so the list is always visible. */
    .edris-player-page-sidebar,
    .edris-player-page-sidebar.collapsed {
        position: static;
        width: 100%;
        min-width: 0;
        max-height: none;
        height: auto;
        overflow: visible;
        transform: none;
        transition: none;
        border-right: none;
        border-top: 1px solid #333;
        box-shadow: none;
    }
    /* The list is always on screen here, so the collapse button has nothing
       left to do. `!important` because the theme's global touch rule in
       style.css (`@media (hover:none)`: `button { display:inline-flex
       !important; min-width:48px }`) resurrects it on real phones. */
    .edris-player-page .edris-player-sidebar-toggle { display: none !important; }
    /* Tabs stay reachable while the episode list scrolls with the page (offset
       by the WP admin bar, which is fixed on top for logged-in users). */
    .edris-player-tabs {
        position: sticky;
        top: var(--wp-admin--admin-bar--height, 0px);
        z-index: 5;
        background: #1a1a1a;
    }
    .edris-tab-panel {
        overflow: visible;
        max-height: none;
    }
    /* Desktop clips its own scroll area in .edris-sidebar-panels; the page
       scrolls here instead. */
    .edris-sidebar-panels {
        overflow: visible;
        display: block;
        flex: none;
        min-height: auto;
    }
    /* Desktop keeps the document clipped (fixed-height flex layout). Here the
       list lives below the fold, so the document has to scroll — without this
       `overflow:hidden` on <body> swallows every touch scroll and the episodes
       are unreachable even though scrollHeight > viewport. */
    body.edris-player-body {
        display: block;
        overflow: visible;
        height: auto;
    }
}

/* Landscape phones: the video is capped to one screen, so the whole episode
   list sits below the fold with nothing hinting at it. There the toggle comes
   back as a «قسمتها» jump button (player-init.js scrolls the list into view). */
@media (max-width: 1100px) and (max-height: 560px) {
    .edris-player-page .edris-player-sidebar-toggle {
        display: inline-flex !important;
        width: auto;
        min-width: 0 !important;
        height: 36px;
        min-height: 0 !important;
        top: 8px;
        left: 8px;
        padding: 0 10px !important;
        font-size: 0.8rem;
        line-height: 1;
    }
    .edris-player-page .edris-player-sidebar-toggle::after { content: 'قسمت‌ها'; }
}

/* Phones: tighter chrome, larger touch targets, stacked error actions. */
@media (max-width: 560px) {
    .edris-player-page-header { padding: 8px 12px; }
    .edris-player-page-title { font-size: 0.95rem; }
    .edris-player-page-type { font-size: 0.7rem; padding: 1px 6px; }
    .edris-player-page-back { font-size: 0.78rem; }
    /* style.css forces 48px on every <button> for coarse pointers, which
       inflates the compact phone header to 65px. A 40px box is still a full
       tap target and keeps the chrome one line. */
    .edris-player-page .edris-player-page-back { min-height: 40px !important; }
    .edris-player-page-back-full { display: none; }
    .edris-player-page-back-short { display: inline; }

    .edris-tab-btn { padding: 11px 4px; font-size: 0.82rem; }
    .edris-tab-panel { padding: 10px 8px; }
    .edris-quality-item,
    .edris-season-item,
    .edris-episode-item,
    .edris-subtitle-item,
    .edris-audio-item,
    .edris-subtitle-btn,
    .edris-audio-btn { padding: 11px 12px; font-size: 0.86rem; }
    .edris-season-row { padding: 10px 12px; }
    .edris-episode-panel { padding-left: 10px; }

    /* Phone control bar: the full row needs ~376px inside a 370px box and bled
       past both edges. Drop what a touch screen does not need — PiP and the
       separate web-fullscreen button (both duplicate native fullscreen) and the
       volume button (hardware keys) — keeping play/next/time/settings/fullscreen.
       `!important`: ArtPlayer injects its own equally-specific rules at runtime,
       after this stylesheet. */
    .art-video-player .art-control-pip,
    .art-video-player .art-control-fullscreenWeb,
    .art-video-player .art-control-volume { display: none !important; }

    .edris-player-error { padding: 4.25rem 1rem 1.25rem; margin: 0.5rem; max-width: none; }
    .edris-player-error .edris-error-actions { flex-direction: column; }
    .edris-player-error button,
    .edris-player-error a.edris-ctrl-btn { width: 100%; min-width: 0; min-height: 44px; }
    .edris-player-loading { padding: 4.25rem 1rem 1.25rem; }
}

/* ── Movie pages on portrait phones/tablets: landscape stage ──
   A movie page has no episode sidebar, so the stacked mobile layout left a
   16:9 picture (390×219) at the top and ~570px of bare page under it — nothing
   to fill it with. Series pages keep that layout (their sidebar uses the
   space); movies turn the page into the picture instead: the page box is
   rotated 90° so the video fills the viewport as a landscape stage, and the
   header rides on top as an overlay so the back button stays reachable.
   Rotation is a transform on the existing box — no fullscreen API, no JS. */
@media (max-width: 1100px) and (orientation: portrait) {
    .edris-player-page.no-sidebar {
        position: fixed;
        /* not `inset: 0`: the page is RTL, so an over-constrained fixed box
           honours `right`, and left becomes 390 − 844 = −454 — the whole stage
           lands off-screen. Anchor the top-left corner only. */
        /* WP's admin bar sits across the top of the portrait screen, which is
           the LEFT edge of this rotated stage — exactly where the header and
           its «بازگشت» button are, so a logged-in user found them buried under
           it. Same treatment as `.moviedb-header`: offset by the bar's height
           and give up that much stage. The rotation maps local `x` onto the
           screen's y axis, so a shorter element plus a `top` offset is what
           moves content down; `translate(0,-100dvw)` only covers the x axis. */
        top: var(--wp-admin--admin-bar--height, 0px);
        left: 0;
        right: auto;
        bottom: auto;
        width: calc(100dvh - var(--wp-admin--admin-bar--height, 0px));
        height: 100dvw;
        /* the base rule sets min-height: 100vh — left alone it wins over the
           rotated height and the stage becomes a square that hangs off-screen */
        min-width: 0;
        min-height: 0;
        transform-origin: 0 0;
        transform: rotate(90deg) translate(0, -100dvw);
        overflow: hidden;
    }
    .edris-player-page.no-sidebar .edris-player-page-header {
        position: absolute;
        z-index: 3;
        top: 0;
        left: 0;
        right: 0;
        border-bottom: 0;
        background: linear-gradient(to bottom, rgba(0,0,0,0.85), rgba(0,0,0,0.3));
    }
    /* The ≤1100px block turns the body into a plain block, and block sizing
       stops here: .edris-player-stage is height:auto, so main's `height:100%`
       resolves against auto and the whole chain (stage → main → mount) collapses
       to 0px — the picture vanishes off the rotated stage. Keep the body a flex
       column so the stage's `flex:1` gives it a definite height again. */
    .edris-player-page.no-sidebar .edris-player-page-body {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
    .edris-player-page.no-sidebar .edris-player-page-main {
        aspect-ratio: auto;
        height: 100%;
        max-height: none;
        /* ArtPlayer's layers carry z-index up to 120 and `main` is only
           position:relative with z-index auto, so they escaped into the stage's
           stacking context and painted over the header (title + back button).
           Isolating main keeps them inside it. */
        isolation: isolate;
    }
    /* The install banner is fixed chrome for the portrait page; over the
       full-bleed rotated stage it just covers the picture. Movies only — the
       series page keeps it (its layout is the normal stacked one). */
    .is-movie .moviedb-pwa-banner { display: none !important; }
}



/* ── Series header: absolute overlay on the video area (same as movie mobile) ──
  The header lives inside .edris-player-page-main for series pages, so it
  overlays the top of the video instead of taking a horizontal bar at the
  top of the page. Gradient background matches the movie mobile overlay.
  The chrome wrapper holds the header and the sidebar toggle as a flex
  column so the two stack vertically — the toggle sits under the back button
  instead of overlapping it. */
.edris-player-page-chrome {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    /* Above the sidebar (z-index 0 in the page context): the sidebar is a
       sibling of the body in the row, and in RTL it paints over the left edge
       of the video — where the chrome lives. Without this the back button and
       the toggle sit under the episode list.
       Also above ArtPlayer: it does not create its own stacking context
       (.art-video-player is position:relative with z-index:auto), so its
       <video> (z-index 10), poster (11) and layers (up to 120) compete with
       this element in the SAME context. At z-index 1 the picture covered the
       whole chrome — invisible title, back button and toggle. 200 clears them
       and stays below ArtPlayer's web-fullscreen layer (9999). */
    z-index: 200;
    display: flex;
    flex-direction: column;
    /* RTL: flex-start aligns to the right edge, which is where the back button
       already sits — the toggle ends up off-screen past it. flex-end puts it
       on the left edge, next to the back button's corner. */
    align-items: flex-end;
    gap: 6px;
    /* Horizontal inset lives on the header and on the toggle below, so both
       share one edge. A 12px padding here TOO pushed the toggle 12px further
       out than the back button, and the two read as a broken column. */
    padding: 8px 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.85), rgba(0,0,0,0.3));
}
.edris-player-page-chrome .edris-player-page-header {
    width: 100%;
    /* content-box would make 100% + 24/48px of padding wider than the chrome,
       so the header bled past the right edge and clipped the title on phones. */
    box-sizing: border-box;
    position: static;
    border-bottom: 0;
    background: none;
}
/* The toggle's base rule (line 629) pins it absolute at top:12px/left:12px,
  which in RTL lands it on the right edge — off-screen on a 1440px viewport —
  and on top of the back button's corner. Inside the chrome it is a normal
  flow child, so it stacks under the header row. */
.edris-player-page-chrome .edris-player-sidebar-toggle {
    position: static;
    width: 36px;
    height: 36px;
    /* RTL: margin-inline-start: auto pins the toggle to the end (left) edge,
       where the back button sits. margin-inline-end repeats the header's own
       horizontal padding so the toggle lines up exactly under the back
       button instead of hanging outside it. (Breakpoint values are at the
       end of this file: 14px ≤1100px, 12px ≤560px.) */
    margin-inline-start: auto;
    margin-inline-end: 24px;
}

/* Keep the toggle in the same column as the back button below the desktop
   breakpoint: match .edris-player-page-header's 10px 14px / 8px 12px padding.
   Declared last, after the chrome block, so it wins the cascade. */
@media (max-width: 1100px) {
    .edris-player-page-chrome .edris-player-sidebar-toggle { margin-inline-end: 14px; }
}
@media (max-width: 560px) {
    .edris-player-page-chrome .edris-player-sidebar-toggle { margin-inline-end: 12px; }
}

/* Fade the chrome together with the controls. player-init mirrors ArtPlayer's
   .art-control-show onto .is-hidden here. Visibility (not just opacity) is
   needed: a transparent bar would still swallow clicks aimed at the top of the
   picture. The class is only applied after the controls hide once, so the bar
   is visible on load. :focus-within keeps it reachable for keyboard users. */
.edris-player-page-chrome {
    transition: opacity .22s ease, visibility 0s linear 0s;
}
.edris-player-page-chrome.is-hidden {
    opacity: 0;
    visibility: hidden;
    /* Delay the visibility flip until the fade finishes; on the way back in,
       `0s` above makes it visible immediately so the fade is seen. */
    transition: opacity .22s ease, visibility 0s linear .22s;
}
.edris-player-page-chrome:focus-within {
    opacity: 1;
    visibility: visible;
    transition: opacity .22s ease, visibility 0s linear 0s;
}
@media (prefers-reduced-motion: reduce) {
    .edris-player-page-chrome,
    .edris-player-page-chrome.is-hidden,
    .edris-player-page-chrome:focus-within { transition: none; }
}

/* Landscape phones show the sidebar toggle as a «قسمت‌ها» jump button, pinned
  to the same top-left corner the back button sits in — so the back button
  buried it. Stack them: title row on top, the toggle one row under it.
  (The default chrome block above already stacks them; this block is kept
  only as a comment since the layout is identical across viewports.) */
