/*
 * FilmStorix side panel of a title (launch plan, step R5): #fs-side-panel, filled by js/title-panel.js.
 * From 1280px it sits in the layout's right slot and pushes the content; from 992px to 1279px it is a
 * drawer over the content with a dark backdrop; under 992px it covers the screen.
 * Colours, fonts and radii come only from design-tokens.css.
 */

.fs-panel-slot.is-open {
    display: flex;
    flex-direction: column;
    font-family: var(--fs-font-body);
    color: var(--fs-color-text-body);
    background: var(--fs-color-surface);
}

.fs-panel-slot.is-loading {
    opacity: 0.7;
}

.fs-panel-backdrop {
    display: none;
}

.fs-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    outline: none;
}

.fs-panel__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    padding: 12px 16px 0 20px;
}

.fs-panel__kind {
    color: var(--fs-color-accent-light);
    font-size: var(--fs-text-12);
    font-weight: var(--fs-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.fs-panel__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--fs-control-min-height);
    min-height: var(--fs-control-min-height);
    padding: 0;
    color: var(--fs-color-text);
    font-size: var(--fs-text-16);
    background: transparent;
    border: 1px solid var(--fs-color-border);
    border-radius: var(--fs-radius-10);
}

.fs-panel__close:hover {
    background: var(--fs-color-surface-2);
    border-color: var(--fs-color-border-strong);
}

.fs-panel__scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 20px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.fs-panel__head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.fs-panel__poster {
    flex: 0 0 92px;
    width: 92px;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: var(--fs-color-surface-2);
    border: 1px solid var(--fs-color-border);
    border-radius: var(--fs-radius-10);
}

.fs-panel__head .fs-title-header {
    min-width: 0;
    margin-bottom: 0;
}

.fs-panel__head .fs-title-header > h2 {
    font-size: var(--fs-text-22);
}

/* ---------- Tabs ---------- */
.fs-panel__tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--fs-color-divider);
}

.fs-panel__tab {
    min-height: var(--fs-control-min-height);
    padding: 8px 12px;
    color: var(--fs-color-text-muted);
    font-family: var(--fs-font-body);
    font-size: var(--fs-text-14);
    font-weight: var(--fs-weight-semibold);
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
}

.fs-panel__tab:hover {
    color: var(--fs-color-text);
}

.fs-panel__tab[aria-selected="true"] {
    color: var(--fs-color-text);
    border-bottom-color: var(--fs-color-accent);
}

.fs-panel__pane {
    display: grid;
    gap: 16px;
    justify-items: start;
    outline: none;
}

.fs-panel__pane[hidden] {
    display: none;
}

.fs-panel__pane > .fs-chartpos,
.fs-panel__pane > section {
    justify-self: stretch;
}

.fs-panel__pane .fs-chartpos {
    background: var(--fs-color-surface-2);
}

.fs-panel__pane .fs-trend__track {
    background: var(--fs-color-surface);
}

.fs-panel__pane .fs-cast__list {
    grid-template-columns: minmax(0, 1fr);
}

.fs-panel__description {
    /* The full text stays on the full page; the panel shows the first five lines (no ellipsis when it fits). */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    overflow: hidden;
    margin: 0;
    color: var(--fs-color-text-body);
    font-size: var(--fs-text-14);
    line-height: 1.6;
}

/* ---------- Foot ---------- */
.fs-panel__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 12px 20px;
    border-top: 1px solid var(--fs-color-divider);
}

.fs-panel__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.fs-panel__list-status {
    color: var(--fs-color-text-secondary);
    font-size: var(--fs-text-13);
}

.fs-panel__list-status:empty {
    display: none;
}

.fs-btn--ghost,
.fs-btn--ghost:visited {
    color: var(--fs-color-text);
    background: transparent;
    border-color: var(--fs-color-border-strong);
}

.fs-btn--ghost:hover {
    color: var(--fs-color-text);
    border-color: var(--fs-color-accent);
}

.fs-btn--ghost.is-done,
.fs-btn--ghost:disabled {
    color: var(--fs-color-rank-up);
    border-color: var(--fs-color-border);
    cursor: default;
}

.fs-panel__close:focus-visible,
.fs-panel__tab:focus-visible,
.fs-panel__pane:focus-visible,
.fs-panel:focus-visible {
    outline: 2px solid var(--fs-color-link);
    outline-offset: -2px;
}

/* ---------- 1280px and up: in the layout's slot, pushing the content ---------- */
@media (min-width: 1280px) {
    .fs-panel-slot.is-open {
        position: sticky;
        top: 0;
        flex: 0 0 420px;
        width: 420px;
        height: 100vh;
        border-left: 1px solid var(--fs-color-divider);
    }

    /* Only the content column gives way: its width is stated outright (window minus the 232px menu and
       the 420px panel), so nothing inside it can keep it wide and push the menu or the panel out.
       Content that cannot shrink is cut at the column's edge instead of sliding under the panel, and the
       frame never becomes wider than the window. */
    body.fs-panel-open .fs-shell {
        max-width: 100%;
        overflow-x: clip;
    }

    body.fs-panel-open .fs-shell__main {
        flex: 0 0 auto;
        width: calc(100% - 652px);
        max-width: calc(100% - 652px);
        overflow-x: clip;
    }

    body.fs-panel-open .fs-sidebar {
        flex: 0 0 232px;
    }
}

/* ---------- Under 1280px: over the content ---------- */
@media (max-width: 1279.98px) {
    .fs-panel-slot.is-open {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1050;
        width: min(420px, 100%);
        border-left: 1px solid var(--fs-color-divider);
    }

    .fs-panel-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1049;
        background: var(--fs-color-bg);
        opacity: 0.75;
    }
}

/* ---------- Under 992px: the whole screen, the page behind does not scroll ---------- */
@media (max-width: 991.98px) {
    .fs-panel-slot.is-open {
        left: 0;
        width: 100%;
        border-left: 0;
    }

    body.fs-panel-open {
        overflow: hidden;
    }
}

/* ---------- Connections tab (R6): groups of compact rows ---------- */
.fs-panel__group {
    justify-self: stretch;
    min-width: 0;
}

.fs-panel__group-title {
    margin: 0 0 8px;
    color: var(--fs-color-text);
    font-family: var(--fs-font-body);
    font-size: var(--fs-text-15);
    font-weight: var(--fs-weight-semibold);
}

.fs-panel__group .fs-title-list {
    gap: 8px;
}

.fs-panel__group .fs-title-card--row {
    gap: 12px;
    padding: 8px;
    background: var(--fs-color-surface-2);
}

.fs-panel__group .fs-title-card--row .fs-title-card__poster {
    flex-basis: 48px;
    width: 48px;
}

.fs-panel__group .fs-title-card--row .fs-title-card__title {
    font-size: var(--fs-text-14);
}

.fs-panel__group .fs-connections__more {
    margin: 4px 0 0;
}

/* Four tabs: each stays on one line; a very narrow panel scrolls the row instead of wrapping it. */
.fs-panel__tabs {
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.fs-panel__tab {
    flex: 0 0 auto;
    padding-left: 8px;
    padding-right: 8px;
    font-size: var(--fs-text-13);
    white-space: nowrap;
}

/* Under 400px the last tab shows its short label ("Watch"), so the four tabs fit without scrolling. */
.fs-panel__tab-short {
    display: none;
}

@media (max-width: 399.98px) {
    .fs-panel__tab-long {
        display: none;
    }

    .fs-panel__tab-short {
        display: inline;
    }

    .fs-panel__tab {
        padding-left: 7px;
        padding-right: 7px;
    }
}
