/* Video card in the post composer: layout/story/frepali-video-form.phtml.
   Everything is scoped under #video-form.fpvc so the theme's generic
   .publisher-hidden-option rules (borderless square inputs etc.) lose. */

#video-form.fpvc {
    --fpvc-accent: #1a9bd7;
    --fpvc-surface: #fff;
    --fpvc-field: #fff;
    --fpvc-subtle: #f2f3f5;
    --fpvc-border: #e2e4e8;
    --fpvc-strong: #cfd3d9;
    --fpvc-text: #1c1e21;
    --fpvc-muted: #65676b;
    --fpvc-danger: #d23b3b;
    container-type: inline-size;
    margin: 10px 12px 4px;
    padding: 12px 14px 14px;
    border: 1px solid var(--fpvc-border);
    border-radius: 12px;
    background: var(--fpvc-surface);
    color: var(--fpvc-text);
    font-size: 14px;
    line-height: 1.4;
    text-align: start;
}

html:has(#night-mode-css) #video-form.fpvc {
    --fpvc-surface: transparent;
    --fpvc-field: #333;
    --fpvc-subtle: rgba(255, 255, 255, .07);
    --fpvc-border: rgba(255, 255, 255, .12);
    --fpvc-strong: rgba(255, 255, 255, .22);
    --fpvc-text: #e8e8e8;
    --fpvc-muted: #a9abaf;
    --fpvc-danger: #ff6b6b;
}

#video-form.fpvc [hidden] {
    display: none !important;
}

#video-form.fpvc button {
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}

/* ---- header ---- */

#video-form.fpvc .fpvc-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

#video-form.fpvc .fpvc-head-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    color: var(--fpvc-accent);
    background: color-mix(in srgb, var(--fpvc-accent) 12%, transparent);
}

#video-form.fpvc .fpvc-file {
    flex: 1;
    min-width: 0;
}

#video-form.fpvc .fpvc-name {
    overflow: hidden;
    /* Filenames keep their own direction but align with the card. */
    unicode-bidi: plaintext;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: left;
}

#video-form.fpvc[dir="rtl"] .fpvc-name {
    text-align: right;
}

#video-form.fpvc .fpvc-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 17px;
    margin-top: 1px;
    color: var(--fpvc-muted);
    font-size: 12.5px;
}

#video-form.fpvc .fpvc-tag {
    padding: 0 7px;
    border-radius: 999px;
    color: var(--fpvc-accent);
    background: color-mix(in srgb, var(--fpvc-accent) 13%, transparent);
    font-size: 11px;
    font-weight: 600;
    line-height: 17px;
}

#video-form.fpvc .fpvc-remove {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--fpvc-muted);
    background: transparent;
    cursor: pointer;
    transition: background-color .15s, color .15s;
}

#video-form.fpvc .fpvc-remove:hover {
    color: var(--fpvc-text);
    background: var(--fpvc-subtle);
}

/* ---- preview player ---- */

#video-form.fpvc .fpvc-player {
    position: relative;
    margin-top: 12px;
    overflow: hidden;
    border-radius: 10px;
    background: #000;
}

/* Full width, but never taller than this: a portrait video sits in the
   middle with black at the sides, as it will in the feed. */
#video-form.fpvc .fpvc-player-video {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(62vh, 460px);
    background: #000;
    outline: none;
}

#video-form.fpvc .fpvc-player-close {
    position: absolute;
    z-index: 2;
    top: 8px;
    inset-inline-end: 8px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    cursor: pointer;
    transition: background-color .15s;
}

#video-form.fpvc .fpvc-player-close:hover {
    background: rgba(0, 0, 0, .78);
}

/* ---- title ---- */

#video-form.fpvc .fpvc-field {
    margin-top: 12px;
}

#video-form.fpvc .fpvc-label {
    display: block;
    margin: 0 0 5px;
    color: var(--fpvc-text);
    font-size: 13px;
    font-weight: 600;
}

#video-form.fpvc .fpvc-title {
    display: block;
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--fpvc-border);
    border-radius: 8px;
    color: var(--fpvc-text);
    /* !important: dark.css forces every input to #333; the field's text and
       background must come from the same token set or the title is
       dark-on-dark wherever :has() (night detection) is unsupported. */
    background: var(--fpvc-field) !important;
    box-shadow: none;
    font-size: 14.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

#video-form.fpvc .fpvc-title:placeholder-shown {
    direction: inherit;
}

#video-form.fpvc .fpvc-title::placeholder {
    color: var(--fpvc-muted);
    opacity: .8;
}

#video-form.fpvc .fpvc-title:focus {
    border-color: var(--fpvc-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fpvc-accent) 18%, transparent);
}

#video-form.fpvc .fpvc-title[aria-invalid="true"] {
    border-color: var(--fpvc-danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fpvc-danger) 14%, transparent);
}

#video-form.fpvc .fpvc-error {
    margin-top: 5px;
    color: var(--fpvc-danger);
    font-size: 12.5px;
}

/* ---- thumbnail picker ---- */

#video-form.fpvc .fpvc-thumb {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    grid-template-areas:
        "cover head"
        "cover frames"
        "cover note"
        "cover scrub";
    grid-template-rows: auto auto auto 1fr;
    column-gap: 14px;
    margin-top: 14px;
}

#video-form.fpvc .fpvc-cover {
    grid-area: cover;
    position: relative;
    align-self: start;
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: 10px;
    background: var(--fpvc-subtle);
}

#video-form.fpvc .fpvc-cover-img,
#video-form.fpvc .fpvc-cover-live {
    position: absolute;
    z-index: 1;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#video-form.fpvc .fpvc-cover-badge {
    position: absolute;
    z-index: 2;
    inset-inline-start: 6px;
    bottom: 6px;
    max-width: calc(100% - 12px);
    overflow: hidden;
    padding: 2px 8px;
    border-radius: 999px;
    color: #fff;
    background: rgba(0, 0, 0, .58);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* The whole cover is the play button; the round mark says so. */
#video-form.fpvc .fpvc-play {
    position: absolute;
    z-index: 3;
    inset: 0;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: transparent;
    cursor: pointer;
}

#video-form.fpvc .fpvc-play > span {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: #fff;
    background: rgba(0, 0, 0, .52);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
    transition: transform .15s, background-color .15s;
}

/* Optical centre of the triangle, which points right in every language. */
#video-form.fpvc .fpvc-play svg {
    margin-left: 3px;
}

#video-form.fpvc .fpvc-play:hover > span {
    background: rgba(0, 0, 0, .7);
    transform: scale(1.06);
}

#video-form.fpvc .fpvc-spinner {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 50%;
    display: none;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2px solid var(--fpvc-strong);
    border-top-color: var(--fpvc-accent);
    border-radius: 50%;
    animation: fpvc-spin .8s linear infinite;
}

#video-form.fpvc.is-loading .fpvc-spinner {
    display: block;
}

#video-form.fpvc.is-nopreview .fpvc-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: center / 30px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='23 7 16 12 23 17 23 7'/%3E%3Crect x='1' y='5' width='15' height='14' rx='2'/%3E%3C/svg%3E");
}

#video-form.fpvc .fpvc-thumb-head {
    grid-area: head;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px;
}

#video-form.fpvc .fpvc-thumb-text {
    min-width: 0;
}

#video-form.fpvc .fpvc-thumb-text .fpvc-label {
    margin-bottom: 1px;
}

#video-form.fpvc .fpvc-hint {
    display: block;
    color: var(--fpvc-muted);
    font-size: 12.5px;
}

#video-form.fpvc .fpvc-upload {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border: 1px solid var(--fpvc-border);
    border-radius: 999px;
    color: var(--fpvc-text);
    background: var(--fpvc-surface);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .15s, background-color .15s, color .15s;
}

#video-form.fpvc .fpvc-upload:hover {
    background: var(--fpvc-subtle);
}

#video-form.fpvc .fpvc-upload[aria-pressed="true"] {
    border-color: var(--fpvc-accent);
    color: var(--fpvc-accent);
    background: color-mix(in srgb, var(--fpvc-accent) 8%, transparent);
}

#video-form.fpvc .fpvc-frames {
    grid-area: frames;
    display: grid;
    grid-template-columns: repeat(var(--fpvc-count, 7), minmax(0, 1fr));
    gap: 6px;
}

#video-form.fpvc .fpvc-frame {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 7px;
    background: var(--fpvc-subtle);
    cursor: pointer;
}

#video-form.fpvc .fpvc-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity .15s;
}

#video-form.fpvc .fpvc-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
    pointer-events: none;
    transition: box-shadow .15s;
}

#video-form.fpvc .fpvc-frame:hover img {
    opacity: .85;
}

#video-form.fpvc .fpvc-frame[aria-pressed="true"]::after {
    box-shadow: inset 0 0 0 2px var(--fpvc-accent), inset 0 0 0 4px rgba(255, 255, 255, .85);
}

#video-form.fpvc .fpvc-frame:focus-visible,
#video-form.fpvc .fpvc-upload:focus-visible,
#video-form.fpvc .fpvc-remove:focus-visible,
#video-form.fpvc .fpvc-player-close:focus-visible {
    /* !important: the theme has `a, button { outline: 0 !important }`. */
    outline: 2px solid var(--fpvc-accent) !important;
    outline-offset: 2px;
}

/* Inside the cover, which clips anything drawn outside it. */
#video-form.fpvc .fpvc-play:focus-visible {
    outline: 2px solid var(--fpvc-accent) !important;
    outline-offset: -2px;
}

#video-form.fpvc .fpvc-frame.is-loading {
    cursor: default;
    background: linear-gradient(90deg, var(--fpvc-subtle) 25%, color-mix(in srgb, var(--fpvc-subtle) 40%, var(--fpvc-surface)) 50%, var(--fpvc-subtle) 75%);
    background-size: 300% 100%;
    animation: fpvc-shimmer 1.3s ease-in-out infinite;
}

#video-form.fpvc .fpvc-frame.is-empty {
    cursor: default;
    opacity: .5;
}

#video-form.fpvc .fpvc-note {
    grid-area: note;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--fpvc-muted);
    background: var(--fpvc-subtle);
    font-size: 12.5px;
}

#video-form.fpvc .fpvc-frames:not([hidden]) ~ .fpvc-note {
    margin-top: 8px;
}

#video-form.fpvc .fpvc-note.is-error {
    color: var(--fpvc-danger);
}

#video-form.fpvc .fpvc-scrub {
    grid-area: scrub;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

/* Styled by hand: Chrome's accent-color range draws a near-black track for
   light accents, which is far heavier than the rest of the card. --fill is
   kept in step with the value by the script. */
#video-form.fpvc .fpvc-range {
    --fill: 0%;
    flex: 1;
    min-width: 0;
    height: 20px;
    margin: 0;
    padding: 0;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

#video-form.fpvc .fpvc-range:focus {
    outline: none;
}

#video-form.fpvc .fpvc-range::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--fpvc-accent) var(--fill), var(--fpvc-strong) var(--fill));
}

#video-form.fpvc[dir="rtl"] .fpvc-range::-webkit-slider-runnable-track {
    background: linear-gradient(to left, var(--fpvc-accent) var(--fill), var(--fpvc-strong) var(--fill));
}

#video-form.fpvc .fpvc-range::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--fpvc-accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    -webkit-appearance: none;
    appearance: none;
}

#video-form.fpvc .fpvc-range::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: var(--fpvc-strong);
}

#video-form.fpvc .fpvc-range::-moz-range-progress {
    height: 4px;
    border-radius: 999px;
    background: var(--fpvc-accent);
}

#video-form.fpvc .fpvc-range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--fpvc-accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

#video-form.fpvc .fpvc-range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--fpvc-accent) 25%, transparent);
}

/* Separate rule: a selector list mixing -webkit- and -moz- pseudo-elements
   is invalid as a whole. */
#video-form.fpvc .fpvc-range:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--fpvc-accent) 25%, transparent);
}

#video-form.fpvc .fpvc-range:disabled {
    opacity: .5;
    cursor: default;
}

#video-form.fpvc .fpvc-time {
    flex: none;
    min-width: 34px;
    color: var(--fpvc-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: end;
}

/* ---- upload status ---- */

#video-form.fpvc .fpvc-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    color: var(--fpvc-muted);
    font-size: 12.5px;
}

#video-form.fpvc .fpvc-bar {
    flex: 1;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--fpvc-subtle);
}

#video-form.fpvc .fpvc-bar > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--fpvc-accent);
    transition: width .25s ease;
}

#video-form.fpvc .fpvc-status.is-finishing .fpvc-bar > span {
    animation: fpvc-pulse 1.1s ease-in-out infinite;
}

#video-form.fpvc .fpvc-status.is-error {
    color: var(--fpvc-danger);
}

#video-form.fpvc .fpvc-status.is-error .fpvc-bar {
    display: none;
}

/* Background upload finished: a full bar, quieter than the accent. */
#video-form.fpvc .fpvc-status.is-done .fpvc-bar > span {
    background: color-mix(in srgb, var(--fpvc-accent) 55%, var(--fpvc-subtle));
}

#video-form.fpvc .fpvc-retry {
    flex: none;
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--fpvc-border);
    border-radius: 999px;
    color: var(--fpvc-text);
    background: var(--fpvc-surface);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

#video-form.fpvc .fpvc-retry:hover {
    background: var(--fpvc-subtle);
}

#video-form.fpvc .fpvc-retry:focus-visible {
    outline: 2px solid var(--fpvc-accent) !important;
    outline-offset: 2px;
}

#video-form.fpvc.is-uploading .fpvc-field,
#video-form.fpvc.is-uploading .fpvc-thumb,
#video-form.fpvc.is-uploading .fpvc-remove {
    opacity: .55;
    pointer-events: none;
}

/* The card shows its own progress; the composer's generic bar would repeat it. */
.publisher-box.fpvc-active #progress {
    display: none !important;
}

#video-form.fpvc .fpvc-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- narrow composer (phones) ---- */

@container (max-width: 470px) {
    #video-form.fpvc .fpvc-thumb {
        grid-template-columns: 92px minmax(0, 1fr);
        grid-template-areas:
            "cover head"
            "frames frames"
            "note note"
            "scrub scrub";
        grid-template-rows: auto;
        column-gap: 12px;
    }

    #video-form.fpvc .fpvc-thumb-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #video-form.fpvc .fpvc-frames {
        margin-top: 10px;
    }

    #video-form.fpvc .fpvc-upload {
        max-width: 100%;
        height: auto;
        min-height: 30px;
        padding-block: 5px;
        line-height: 1.25;
        white-space: normal;
        text-align: start;
    }

    #video-form.fpvc .fpvc-upload svg {
        flex: none;
    }
}

@keyframes fpvc-spin {
    to { transform: rotate(360deg); }
}

@keyframes fpvc-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

@keyframes fpvc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}

@media (prefers-reduced-motion: reduce) {
    #video-form.fpvc *,
    #video-form.fpvc *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition: none !important;
    }
}

/* FREPALI_UPLOAD_LIMITS_V1: the upload-limit refusal box
   (frepali-video-composer.js showLimitBox). It sits on <body>, outside the
   card, so it carries its own colours; --fpul-accent is the card's accent. */
.fpul-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(16, 24, 40, 0.55);
    animation: fpul-fade 0.16s ease-out;
}
.fpul-box {
    --fpul-accent: #1a9bd7;
    box-sizing: border-box;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 28px 24px 20px;
    border-radius: 18px;
    background: #fff;
    color: #1d2939;
    text-align: center;
    font-size: 15px;
    line-height: 1.45;
    box-shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.3);
    animation: fpul-rise 0.2s ease-out;
}
.fpul-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #eaf5fb;
    background: color-mix(in srgb, var(--fpul-accent) 12%, transparent);
    color: var(--fpul-accent);
}
.fpul-icon svg {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.fpul-title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}
.fpul-message {
    margin: 0;
    color: #475467;
}
.fpul-next {
    margin: 8px 0 0;
    font-weight: 600;
    color: var(--fpul-accent);
}
.fpul-compare {
    margin: 18px 0 0;
    border: 1px solid #eaecf0;
    border-radius: 12px;
    overflow: hidden;
    text-align: start;
    font-size: 13.5px;
}
.fpul-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
}
.fpul-row > span {
    padding: 8px 12px;
}
.fpul-row + .fpul-row {
    border-top: 1px solid #eaecf0;
}
.fpul-row > span:last-child {
    color: var(--fpul-accent);
    font-weight: 600;
}
.fpul-row.is-head {
    background: #f9fafb;
    color: #667085;
    font-size: 12px;
    font-weight: 700;
}
.fpul-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}
.fpul-primary,
.fpul-secondary {
    display: block;
    box-sizing: border-box;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none !important;
    cursor: pointer;
}
.fpul-primary {
    background: var(--fpul-accent);
    color: #fff !important;
}
.fpul-primary:hover {
    filter: brightness(0.94);
}
.fpul-secondary {
    background: #fff;
    border-color: #d0d5dd;
    color: #344054;
}
.fpul-secondary:hover {
    background: #f9fafb;
}
.fpul-primary:focus-visible,
.fpul-secondary:focus-visible {
    outline: 3px solid rgba(26, 155, 215, 0.35);
    outline-offset: 2px;
}
html:has(#night-mode-css) .fpul-box {
    background: #242526;
    color: #e4e6eb;
}
html:has(#night-mode-css) .fpul-message {
    color: #b0b3b8;
}
html:has(#night-mode-css) .fpul-compare,
html:has(#night-mode-css) .fpul-row + .fpul-row {
    border-color: #3a3b3c;
}
html:has(#night-mode-css) .fpul-row.is-head {
    background: #2f3031;
    color: #b0b3b8;
}
html:has(#night-mode-css) .fpul-secondary {
    background: #3a3b3c;
    border-color: #4e4f50;
    color: #e4e6eb;
}
@keyframes fpul-fade {
    from { opacity: 0; }
}
@keyframes fpul-rise {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
}
@media (prefers-reduced-motion: reduce) {
    .fpul-backdrop,
    .fpul-box {
        animation: none;
    }
}
