@use 'base.scss';

@mixin hooked($height) {
    bottom: -$height;
    min-height: $height;
    max-height: $height;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
    border-right: none;
    border-bottom: none;
    border-left: none;

    > .top-hook {
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        align-items: center;
        transition-duration: 0.2s;

        > div {
            @extend %vertical;
            align-items: center;
            color: white;
            text-shadow: 0 0 3px #000,
                         0 0 8px #000a;
            padding: 8px 0;
        }
    }
    &:hover, &.hovered {
        bottom: 0;
        > .top-hook {
            opacity: 0;
        }
    }
    &:not(:hover, .hovered) {
        box-shadow: none !important;
    }
}

#overlay .panel {
    min-width: min-content;
    width: 30rem;
    max-width: calc(100vw - 2rem);
}

.panel {
    @extend %vertical;
    background-color: var(--color-header);
    box-shadow: var(--shadow-panel);
    box-sizing: border-box;
    border: 2px solid var(--color-panel-border);
    border-radius: base.$radius;
    padding: 24px 32px 16px 32px;
    gap: 16px;
    pointer-events: all;

    h2 {
        text-align: center;
    }

    > div {
        @extend %vertical;
        gap: 4px;
    }

    > span {
        display: flex;
        justify-content: space-evenly;

        &.center {
            justify-content: center;
        }
    }

    > button {
        align-self: center;
    }

    textarea {
        height: 100px;
    }

    &.dialog {
        min-width: calc(20vw + 250px);
        max-width: 500px;
        text-align: center;
        align-items: center;
    }
}

.wrapper {
    display: contents;
}

.popup-container {
    position: relative;
}

.popup-panel {
    position: absolute;
    z-index: 1;
    width: auto;
    padding: 8px;

    opacity: 0;
    pointer-events: none;
    transition: 0.2s;

    &.show {
        opacity: 1;
        pointer-events: all;
        animation: fade-in 0.2s;
    }
}

.anchor-left {
    right: 100%;
    margin-right: 8px;
}

#editGamePanel {
    &.upload {
        pointer-events: none !important;
        filter: brightness(0.5);
    }

    &.prepare {
        .no-prepare { display: none; }
    }

    > div > span {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        user-select: none;
    }

    #editChars {
        display: grid;
        grid-template-columns: calc(50% - 2px) calc(50% - 2px);
        grid-auto-rows: min-content;
        gap: 4px;
        min-width: 600px;
        min-height: calc(30vh - 80px);
        max-height: 25vh;
        overflow-y: auto;
        overflow-x: hidden;

        > li {
            border-radius: base.$radius;
            animation: popup 0.1s cubic-bezier(0.165, 0.84, 0.44, 1) backwards;
        }

        img {
            width: 56px;
            height: 56px;
        }

        input { width: 100%; }

        &:empty {
            display: flex;
            align-items: center;
            justify-content: center;
        }
        &:empty:after {
            content: "No characters added.";
            color: var(--color-note);
        }
    }

    #startingScene {
        background-color: var(--color-background);
        width: 100%;
        max-width: 40vw;
        min-height: 100px;
        max-height: 20vh;
        margin-top: 4px;
        overflow: hidden;
        align-self: center;
    }
}

.left-col {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    gap: 8px;
}

#joinPanel {
    width: 36rem;
    align-items: center;
    text-align: center;

    input {
        width: 240px;
        text-align: center;
        align-self: center;
    }
    #joinError:not(:empty) {
        align-self: center;
        margin: 8px 0;
    }
}

#charPick {
    max-width: 70%;
    align-items: center;

    b {
        margin-left: 3px;
    }

    .char {
        @extend %responsive;
        cursor: pointer;
        width: 80px;

        img { height: 80px; }

        &.reserved {
            pointer-events: none;
            opacity: 0.5;
        }
    }
    .char:hover {
        text-decoration: underline;
    }
}

.panel {
    section {
        position: initial;
        overflow: hidden;
        display: none;
        gap: inherit;
        flex-direction: inherit;
        align-items: center;
    }
    section.show {
        height: 100%;
        display: inherit;
        pointer-events: none;
    }
    &.show > section.show {
        pointer-events: all;
    }
}

#registerPanel, #resetPanel {
    form {
        display: inherit;
        gap: inherit;
        flex-direction: inherit;
        align-items: center;
    }

    table {
        border-collapse: collapse;
        white-space: nowrap;

        tr > td + td {
            padding-left: 16px;
        }
        tr + tr > td {
            padding-top: 12px;
        }

        input {
            min-width: 300px;
        }
    }

    .code {
        width: 160px;
        font-size: 24px;
        text-align: center;
    }
}

#overlay {
    @extend %center;
    position: fixed;
    pointer-events: none;
    z-index: 100;
    transition-duration: 0.5s;

    &.block {
        pointer-events: all;
        background-color: #000a;
    }

    > * {
        position: fixed;
        opacity: 0;
        pointer-events: none;
        transition-duration: 0.2s;
        transform: translateY(20px);
    }
    > .show {
        opacity: 1;
        pointer-events: all;
        transform: none;
    }
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    animation: spin 1.8s linear infinite;
    font-size: 20px;
}