// Ensure width/height HTML attributes used for aspect-ratio hinting don't
// override CSS scaling. height: auto lets max-width control the display size.
.FoFUpload--Upl-Image-Preview-Link {
    display: inline-block;
}

.FoFUpload--Upl-Image-Preview {
    display: block;
    height: auto;
    max-width: 100%;
}

.fof-download.row {
    margin: 10px auto 0;
    min-height: 280px;

    .card {
        float: left;
        padding: 0 1.7rem;
        width: 50%;

        .menu-content {
            &::before,
            &::after {
                content: "";
                display: table;
            }

            &::after {
                clear: both;
            }

            float: right;
            margin: 0;
            padding: 0;
            list-style-type: none;

            li {
                display: inline-block;
                margin: 0 5px;
                position: relative;

                > div {
                    color: var(--text-color);

                    > span {
                        position: absolute;
                        left: 50%;
                        top: 0;
                        font-size: 10px;
                        font-weight: 700;
                        transform: translate(-50%, 0);
                        transition: all 0.3s;
                        opacity: 0;
                    }
                }
            }
        }

        .wrapper {
            background-color: var(--body-bg);
            min-height: 250px;
            position: relative;
            overflow: hidden;

            box-shadow: 0 0 10px 1px var(--shadow-color);

            &:hover {
                .data {
                    background-color: var(--body-bg);
                    transform: translateY(0);
                }

                .header {
                    background-color: var(--body-bg);

                    .menu-content {
                        span {
                            transform: translate(-50%, -10px);
                            opacity: 1;
                        }
                    }
                }
            }
        }

        .data {
            position: absolute;
            bottom: 0;
            width: 100%;
            transition: transform 0.3s;

            .content {
                padding: 1em;
                position: relative;
                z-index: 1;
            }

            color: var(--text-color);
            transform: translateY(calc(70px + 14em));
        }

        .title {
            margin-top: 2px;
            text-align: center;
        }

        .header {
            &::before,
            &::after {
                content: "";
                display: table;
            }

            &::after {
                clear: both;
            }

            color: white;
            padding: 1em 1em 0.1em;
        }
    }
}

// The label body is a TEXT token, so in a block context TextFormatter wraps it
// in <p>; the post's paragraph margin then stretches the button and pushes the
// label to the top. The templates now wrap the label in an inline <span>, which
// stops the <p> being created, but posts saved on 2.0.0-beta.7 already have it
// stored in their XML.
[data-fof-upload-download-uuid] .fof-upload-download-label > p {
    margin: 0;
}

// The file template reuses core's `.ButtonGroup`, which is `inline-flex`.
// TextFormatter treats the tag as block-level, so the newlines a writer puts
// between several attachments are dropped rather than turned into <br>, and
// the downloads flowed onto one row like words in a sentence. Make each one
// its own line, still only as wide as its content.
.ButtonGroup[data-fof-upload-download-uuid] {
    display: flex;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 6px;
}

// A download the viewer has no permission to use. The control keeps its normal
// colours — greying it out reads as "broken" rather than "locked" — and states
// the reason instead. The padlock alone carries the locked meaning.
//
// The icon element is swapped to a padlock in JS rather than by overriding the
// glyph here: a forum can force a FontAwesome style globally, which rewrites
// every icon's classes, so a rule keyed to `.fas.fa-download` would silently
// stop matching.
.fof-upload-download-denied {
    cursor: not-allowed;

    .Button {
        cursor: not-allowed;
    }

    // Appended as its own element so the file name and size keep rendering —
    // a locked download still needs to say what it is.
    .fof-upload-download-reason {
        color: var(--muted-color);
        font-style: italic;
    }
}

// Display name prompt shown before inserting a labelled download.
.fof-upload-display-name-modal {
    .fof-upload-display-name-actions {
        display: flex;
        gap: 8px;
        margin-bottom: 0;
    }
}
