/*
 * Vertical "shorts" viewer — /videos/watch and /moments/watch (markup: Pages/Shared/_ShortsViewer.cshtml,
 * behaviour: wwwroot/js/vuexr.shorts.js). Hand-written: the precompiled Tailwind build can't produce
 * these arbitrary sizes. Colors come from the theme (.dark on <html>, --primary, .box cards).
 *
 * Layout (desktop, >=1200px):  [info]  [ 9:16 player ]  [actions]        [up/down arrows, far right]
 * Comments open:               player + actions slide left, the info block moves inside the player,
 *                              the comments panel takes ~480px on the right.
 * Tablet (768-1199px):         comments overlay from the right instead of pushing the player.
 * Phone (<768px):              full-screen player, actions overlaid, comments as a bottom sheet.
 */

html.shorts-no-scroll,
html.shorts-no-scroll body { overflow: hidden; }

.shorts {
    --sh-header: 3.75rem;
    --sh-gap: 8px;
    --sh-stage-h: calc(100vh - var(--sh-header));
    --sh-player-h: calc(var(--sh-stage-h) - 2 * var(--sh-gap));
    --sh-player-w: calc(var(--sh-player-h) * 9 / 16);
    --sh-panel-w: 480px;
    --sh-panel-right: 40px;
    --sh-btn-bg: rgb(0 0 0 / 0.06);
    --sh-btn-bg-hover: rgb(0 0 0 / 0.12);
    --sh-accent: rgb(var(--primary));
    position: relative;
    height: var(--sh-stage-h);
}
@supports (height: 100dvh) {
    .shorts { --sh-stage-h: calc(100dvh - var(--sh-header)); }
}
.dark .shorts {
    --sh-btn-bg: rgb(255 255 255 / 0.1);
    --sh-btn-bg-hover: rgb(255 255 255 / 0.18);
}

.shorts-stage { position: relative; height: 100%; display: flex; }

/* ---- the feed: one slide per screen, vertical snap, no scrollbar ---- */
.shorts-feed {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    container-type: inline-size;
    transition: padding-right 0.25s ease;
    outline: none;
}
.shorts-feed::-webkit-scrollbar { display: none; width: 0; height: 0; }

.shorts-slide {
    height: 100%;
    box-sizing: border-box;
    padding: var(--sh-gap) 0;
    display: flex;
    justify-content: center;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* ---- the player ---- */
.shorts-player {
    position: relative;
    flex: none;
    height: 100%;
    width: var(--sh-player-w);
    max-width: 100%;
}
.shorts-media {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    color: #fff;
    isolation: isolate;
}
.shorts-media > img,
.shorts-media > video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.shorts-media > video { z-index: 1; }
.shorts-tap { position: absolute; inset: 0; z-index: 2; cursor: pointer; background: none; border: 0; padding: 0; }

.shorts-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 4;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 12px;
    background: linear-gradient(to bottom, rgb(0 0 0 / 0.35), transparent);
    pointer-events: none;
}
.shorts-top > div { display: flex; gap: 8px; pointer-events: auto; }
.shorts-ctl {
    width: 36px; height: 36px;
    border: 0; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 18px; line-height: 1;
    color: #fff;
    background: rgb(0 0 0 / 0.4);
    cursor: pointer;
    transition: background 0.15s;
}
.shorts-ctl:hover { background: rgb(0 0 0 / 0.6); }
.shorts-ctl[hidden] { display: none; }

.shorts-flash {
    position: absolute;
    top: 50%; left: 50%;
    z-index: 3;
    width: 72px; height: 72px;
    margin: -36px 0 0 -36px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 34px;
    color: #fff;
    background: rgb(0 0 0 / 0.5);
    opacity: 0;
    pointer-events: none;
}
.shorts-flash.is-on { animation: shorts-flash 0.55s ease-out; }
@keyframes shorts-flash {
    0% { opacity: 0.9; transform: scale(0.8); }
    100% { opacity: 0; transform: scale(1.25); }
}
.shorts-spinner {
    position: absolute;
    top: 50%; left: 50%;
    z-index: 3;
    margin: -20px 0 0 -20px;
    font-size: 40px;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.shorts-slide.is-buffering .shorts-spinner { opacity: 0.9; }
.shorts-error {
    position: absolute; inset: 0; z-index: 5;
    display: none;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; padding: 24px; text-align: center;
    background: rgb(0 0 0 / 0.78);
}
.shorts-slide.has-error .shorts-error { display: flex; }
.shorts-error a { color: #fff; text-decoration: underline; }

.shorts-progress {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 6;
    height: 3px;
    background: rgb(255 255 255 / 0.3);
    cursor: pointer;
    touch-action: none;
    transition: height 0.1s;
}
.shorts-progress::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; bottom: -4px; }
.shorts-progress:hover,
.shorts-progress.is-dragging { height: 6px; }
.shorts-progress-fill { height: 100%; width: 0; background: var(--sh-accent); pointer-events: none; }
.shorts-progress[hidden] { display: none; }

/* ---- info block (left of the player; inside it when the comments are open / the room is short) ---- */
.shorts-info {
    position: absolute;
    right: calc(100% + 24px);
    bottom: 0;
    z-index: 5;
    width: 320px;
    max-width: calc((100cqw - var(--sh-player-w)) / 2 - 36px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.shorts-creator { display: flex; align-items: center; gap: 10px; min-width: 0; }
.shorts-avatar {
    flex: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--sh-btn-bg);
}
.shorts-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shorts-creator-name {
    min-width: 0;
    font-weight: 600;
    color: inherit;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.shorts-follow {
    flex: none;
    border: 0; border-radius: 9999px;
    padding: 7px 14px;
    font-size: 13px; font-weight: 600; line-height: 1;
    cursor: pointer;
    text-decoration: none;
    color: #fff; background: #000;
}
.dark .shorts-follow { color: #000; background: #fff; }
.shorts-follow.is-following { color: inherit; background: var(--sh-btn-bg); }
.shorts-follow[hidden] { display: none; }
.shorts-title {
    display: block;
    width: 100%;
    margin: 0; padding: 0;
    border: 0; background: none;
    text-align: left;
    font-size: 15px; font-weight: 700; line-height: 1.35;
    color: inherit;
    cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.shorts-title.is-static { cursor: default; }
.shorts-info.is-expanded .shorts-title { white-space: normal; }
.shorts-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.shorts-chips:empty { display: none; }
.shorts-chip {
    display: inline-flex; align-items: center; gap: 4px;
    max-width: 100%;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px; font-weight: 500;
    color: inherit;
    background: var(--sh-btn-bg);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.shorts-desc {
    display: none;
    max-height: 32vh;
    overflow-y: auto;
    font-size: 13px; line-height: 1.5;
    overflow-wrap: anywhere;
    scrollbar-width: thin;
}
.shorts-info.is-expanded .shorts-desc { display: block; }

.shorts--info-inside .shorts-info {
    right: 0; left: 0; bottom: 3px;
    width: auto; max-width: none;
    padding: 64px 16px 14px;
    color: #fff;
    background: linear-gradient(to top, rgb(0 0 0 / 0.78), transparent);
    border-radius: 0 0 12px 12px;
    pointer-events: none;
}
.shorts--info-inside .shorts-info > * { pointer-events: auto; }
.shorts--info-inside .shorts-creator-name,
.shorts--info-inside .shorts-title,
.shorts--info-inside .shorts-chip,
.shorts--info-inside .shorts-follow.is-following { color: #fff; }
.shorts--info-inside .shorts-chip,
.shorts--info-inside .shorts-follow.is-following { background: rgb(255 255 255 / 0.2); }
.shorts--info-inside .shorts-follow:not(.is-following) { color: #000; background: #fff; }

/* ---- action column (right of the player) ---- */
.shorts-actions {
    position: absolute;
    left: calc(100% + 16px);
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.shorts-action {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    min-width: 56px;
    padding: 0;
    border: 0; background: none;
    font-size: 12px; font-weight: 500; line-height: 1.2;
    color: inherit;
    cursor: pointer;
    text-decoration: none;
}
.shorts-action-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 22px; line-height: 1;
    background: var(--sh-btn-bg);
    transition: background 0.15s;
}
.shorts-action:hover .shorts-action-icon { background: var(--sh-btn-bg-hover); }
.shorts-action.is-on .shorts-action-icon { color: var(--sh-accent); }
.shorts-action[disabled] { opacity: 0.55; cursor: progress; }
/* ---- up / down arrows ---- */
.shorts-nav {
    position: fixed;
    right: 16px; top: 50%;
    z-index: 20;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.shorts-nav button {
    width: 48px; height: 48px;
    border: 0; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 24px; line-height: 1;
    color: inherit;
    background: var(--sh-btn-bg);
    cursor: pointer;
    transition: background 0.15s;
}
.shorts-nav button:hover { background: var(--sh-btn-bg-hover); }
.shorts-nav button[hidden] { display: none; }

/* ---- comments panel ---- */
.shorts-comments.box {
    position: absolute;
    top: var(--sh-gap); bottom: var(--sh-gap);
    right: var(--sh-panel-right);
    z-index: 15;
    width: var(--sh-panel-w);
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    visibility: hidden;
    opacity: 0;
    transform: translateX(calc(100% + var(--sh-panel-right) + 24px));
    transition: transform 0.25s ease, opacity 0.25s ease, visibility 0s linear 0.25s;
}
.shorts--comments-open .shorts-comments.box {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
}
.shorts--comments-open .shorts-feed { padding-right: calc(var(--sh-panel-w) + var(--sh-panel-right) + 16px); }

.shorts-comments-head {
    flex: none;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 14px 20px;
    border-bottom: 1px solid rgb(0 0 0 / 0.08);
}
.dark .shorts-comments-head,
.dark .shorts-composer { border-color: rgb(255 255 255 / 0.1); }
.shorts-comments-title { margin: 0; font-size: 18px; font-weight: 700; }
.shorts-comments-title small { margin-left: 8px; font-size: 14px; font-weight: 500; opacity: 0.65; }
.shorts-icon-btn {
    width: 36px; height: 36px;
    border: 0; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 20px; line-height: 1;
    color: inherit; background: none;
    cursor: pointer;
}
.shorts-icon-btn:hover { background: var(--sh-btn-bg); }
.shorts-comments-list { flex: 1 1 auto; overflow-y: auto; padding: 8px 20px; scrollbar-width: thin; overscroll-behavior: contain; }
.shorts-comments-note { padding: 24px 0; text-align: center; opacity: 0.65; font-size: 14px; }
.shorts-comment { display: flex; gap: 12px; padding: 10px 0; }
.shorts-comment-body { min-width: 0; flex: 1; }
.shorts-comment-meta { font-size: 12px; opacity: 0.85; }
.shorts-comment-meta b { font-weight: 600; opacity: 1; }
.shorts-comment-meta span { margin-left: 6px; opacity: 0.65; }
.shorts-comment-text { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.shorts-comment-actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; font-size: 12px; }
.shorts-link-btn { padding: 2px 0; border: 0; background: none; font: inherit; font-weight: 600; color: inherit; opacity: 0.7; cursor: pointer; }
.shorts-link-btn:hover { opacity: 1; }
.shorts-link-btn.is-accent { color: var(--sh-accent); opacity: 1; }
.shorts-replies { margin-top: 6px; }
.shorts-replies .shorts-comment { padding: 6px 0; }
.shorts-replies .shorts-avatar { width: 28px; height: 28px; }
.shorts-reply-form { display: flex; gap: 8px; margin-top: 8px; }
.shorts-comment-more { align-self: flex-start; flex: none; }
/* editing and deleting a comment, in place (vuexr.shorts.js: startEdit, askDelete). A hidden part really is hidden: the flex rows would keep their display. */
.shorts-comment [hidden] { display: none !important; }
.shorts-input--area { display: block; width: 100%; border-radius: 14px; line-height: 1.4; resize: vertical; }
.shorts-comment-edit { margin-top: 4px; }
.shorts-comment-error { margin-top: 4px; font-size: 12px; color: #dc2626; }
.dark .shorts-comment-error { color: #fca5a5; }
.shorts-comment-error:empty { display: none; }
.shorts-comment-edit-bar { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.shorts-comment-confirm { flex-wrap: wrap; }
.shorts-link-btn.is-danger { color: #dc2626; opacity: 1; }
.shorts-link-btn.is-danger-hover:hover { color: #dc2626; opacity: 1; }
.shorts-composer {
    flex: none;
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px 12px 20px;
    border-top: 1px solid rgb(0 0 0 / 0.08);
}
.shorts-composer form { flex: 1; display: flex; gap: 8px; min-width: 0; }
.shorts-input {
    flex: 1; min-width: 0;
    padding: 9px 14px;
    border: 1px solid rgb(0 0 0 / 0.14);
    border-radius: 9999px;
    font: inherit; font-size: 14px;
    color: inherit; background: transparent;
    outline: none;
}
.dark .shorts-input { border-color: rgb(255 255 255 / 0.2); }
.shorts-input:focus { border-color: var(--sh-accent); }
.shorts-post {
    flex: none;
    padding: 8px 16px;
    border: 0; border-radius: 9999px;
    font-size: 14px; font-weight: 600;
    color: #fff; background: var(--sh-accent);
    cursor: pointer;
}
.shorts-post[disabled] { opacity: 0.45; cursor: default; }

/* ---- popup menus (more / player options / comment options) ---- */
.shorts-menu.box {
    position: fixed;
    z-index: 60;
    min-width: 220px;
    margin: 0;
    padding: 6px;
    border-radius: 12px;
}
.shorts-menu button,
.shorts-menu a {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0; border-radius: 8px;
    font-size: 14px; text-align: left;
    color: inherit; background: none;
    cursor: pointer;
    text-decoration: none;
}
.shorts-menu button:hover,
.shorts-menu a:hover { background: var(--sh-btn-bg); }
.shorts-menu i { font-size: 18px; opacity: 0.8; }
.shorts-menu .is-current { font-weight: 700; }

/* ---- empty / loading / unavailable ---- */
.shorts-status {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 24px; text-align: center;
    pointer-events: none;
}
.shorts-status[hidden] { display: none; }
.shorts-status a,
.shorts-status button { pointer-events: auto; }
.shorts-message {
    max-width: 520px;
    margin: 48px auto;
    padding: 40px 24px;
    text-align: center;
}

/* ---- tablet: comments overlay from the right instead of pushing the player ---- */
@media (max-width: 1199.98px) {
    .shorts { --sh-panel-w: min(420px, calc(100% - 16px)); --sh-panel-right: 8px; }
    .shorts--comments-open .shorts-feed { padding-right: 0; }
    .shorts-comments.box { box-shadow: 0 8px 32px rgb(0 0 0 / 0.35); }
}

/* ---- phone: full-screen player, actions overlaid, comments as a bottom sheet, swipe only ---- */
@media (max-width: 767.98px) {
    .shorts { margin-inline: -24px; --sh-gap: 0px; }
    .shorts-slide { padding: 0; }
    .shorts-player { width: 100%; }
    .shorts-media { border-radius: 0; }
    .shorts-actions {
        left: auto; right: 8px; bottom: 84px;
        color: #fff;
        gap: 12px;
        filter: drop-shadow(0 1px 3px rgb(0 0 0 / 0.5));
    }
    .shorts-action-icon { background: rgb(0 0 0 / 0.35); }
    .shorts-action:hover .shorts-action-icon { background: rgb(0 0 0 / 0.5); }
    .shorts-info { padding-right: 76px; }
    .shorts--info-inside .shorts-info { border-radius: 0; }
    .shorts-nav { display: none; }
    .shorts-comments.box {
        top: auto; left: 0; right: 0; bottom: 0;
        width: auto; height: 70%;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    .shorts--comments-open .shorts-comments.box { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .shorts *, .shorts *::before, .shorts *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* Moments are still images: no play / mute / seek controls. */
.shorts--image [data-video-only] { display: none !important; }
