/* Side rails: the Uploads pane and the Live rail. Only one is open at a time (Services/SideRailSlot.cs).

   A rail hangs under the 48px top bar on the right edge, so the indicator that opens it stays visible and
   in reach. In a wide window the page gives up the rail's width and the two sit side by side. In a
   narrower one the rail lies over the page. Under the modal drawers, the file drop overlay, and toasts. */

.side-rail {
    position: fixed;
    top: 48px;
    right: 0;
    bottom: 0;
    z-index: 900;
    box-sizing: border-box;
    width: min(var(--side-rail-width), 100vw);
    box-shadow: var(--side-rail-shadow, none);
    clip-path: var(--side-rail-clip, none);
    animation: var(--side-rail-enter, none);
}

.side-rail-wide {
    --side-rail-width: 440px;
}

.side-rail-narrow {
    --side-rail-width: 340px;
}

/* Beside the page: only while the page keeps about 900px for itself. */

@media (min-width: 1240px) {
    body:has(.side-rail-narrow) {
        --side-rail-inset: 340px;
    }
}

@media (min-width: 1340px) {
    body:has(.side-rail-wide) {
        --side-rail-inset: 440px;
    }
}

.fluent-layout-item[area="content"] {
    margin-right: var(--side-rail-inset, 0px);
}

/* Over the page: the rail slides in and casts a shadow on the page, not on the top bar. */

body {
    --side-rail-over-shadow: var(--shadow-panel);
}

body:not([data-theme="dark"]) {
    --side-rail-over-shadow: -12px 0 40px color-mix(in srgb, var(--text-primary) 16%, transparent);
}

@media (max-width: 1239.98px) {
    .side-rail-narrow {
        --side-rail-shadow: var(--side-rail-over-shadow);
        --side-rail-clip: inset(0 0 0 -60px);
        --side-rail-enter: side-rail-in var(--dur-slide) var(--ease-out);
    }
}

@media (max-width: 1339.98px) {
    .side-rail-wide {
        --side-rail-shadow: var(--side-rail-over-shadow);
        --side-rail-clip: inset(0 0 0 -60px);
        --side-rail-enter: side-rail-in var(--dur-slide) var(--ease-out);
    }
}

@keyframes side-rail-in {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .side-rail {
        animation: none;
    }
}
