@import "common.css";

body > header {
    grid-template-columns: auto 1fr auto auto;

    .menu {
        align-self: end;
        appearance: none;
        border: none;
        font: inherit;
        display: flex;
        gap: 1em;
        align-items: center;
        justify-content: center;

        input {
            color: inherit;
            cursor: pointer;
            margin-bottom: -1px;
            position: absolute;
            inset: 0;
            appearance: none;
            border: solid rgb(from currentColor r g b / .75);
            border-width: 0 0 .1em 0;

            &:checked {
                border-width: 0 0 .2em 0;
            }
        }

        label {
            text-align: center;
            position: relative;
            justify-self: stretch;
            padding: .5em 1em;
            user-select: none;
            min-width: 5em;

            &:has(input:checked) {
                color: var(--accent-color);
                font-weight: 600;
            }
        }
    }
}

section {
    display: grid;
    place-items: stretch;
    grid-area: 1/1;
    pointer-events: none;
    scrollbar-gutter: stable;
    opacity: 0;
    transition: opacity 120ms ease-in-out;
    min-height: 0;

    &.import, &.queue, &.list {
        overflow-y: auto;

        [role="button"] {
            margin-inline: auto;
        }
    }

    &.import {
        gap: 2em;
        padding: 2em 1em;

        #import-form {
            display: flex;
            flex-flow: column nowrap;

            > p:first-child {
                font-stretch: 125%;
                font-weight: 700;
                font-size: 1.5em;
                margin: 0;
                text-align: center;

                + span {
                    font-size: .75em;
                    margin-bottom: 1em;
                    text-align: center;
                }
            }
        }

        #import-instructions {
            max-width: 1024px;
            margin-inline: auto;

            > p:first-child {
                font-weight: 600;
                margin-bottom: .5em;
            }

            pre {
                font-size: 0.75rem;
                background-color: var(--background-color);
                padding: 1rem;
                border-radius: .5rem;
                white-space: pre-wrap;
            }
        }

        #from-google {
            display: flex;
            flex-flow: column nowrap;
            align-items: center;
            gap: .5em;
            text-align: center;

            input[type="submit"] {
                margin-bottom: 1rem;
            }

            .update-from-google-warning {
                padding: 1em 2em;
                background-color: rgb(from #e8c709 r g b / .1);
                text-align: center;
                border-radius: .5em;
            }
        }
    }

    &.queue,
    &.list {
        align-content: start;
        padding-top: .5rem;

        > p:first-child {
            margin-left: calc(1em + 1em / 3);
            font-size: calc(1em - 1em / 3);
            font-stretch: 75%;
            font-weight: 400;
            text-align: left;
        }

        ul {
            display: grid;
            gap: .5em;
            margin: 0;
            padding: 1em;

            li {
                background: rgb(from color-mix(in oklch, var(--background-color) 95%, #888 5%) r g b / .9);
                border-radius: 1em;
                box-shadow: 0 0 .5em .25em rgb(from color-mix(in oklch, var(--background-color) 90%, #000 10%) r g b / .9);
                grid-column: 1/-1;
                height: fit-content;
            }
        }
    }

    &.queue {
        container: queue-section / scroll-state;

        > ul {
            grid-template-columns: repeat(4, auto);
        }

        li.pending-tile {
            display: grid;
            grid-template-columns: subgrid;
            position: relative;
            align-items: center;
            gap: .5em;
            padding: .5em 1em .5em 2em;

            &:hover {
                background: rgb(from color-mix(in oklch, var(--background-color) 85%, var(--accent-color) 15%) r g b / .9);
            }

            .value {
                width: fit-content;

                &:hover {
                    color: var(--accent-color);
                }

                svg {
                    width: 1em;
                    height: 1em;
                    transform: translateY(.125em);
                }
            }

            .startTime, .retries {
                font-size: calc(1em - 1em / 3);
                font-weight: 400;
                font-stretch: 75%;
            }

            .startTime {
                grid-column: 2;
            }

            .retries {
                grid-column: 3;
            }

            .reset {
                grid-column: 4;
                margin-inline: unset;
                justify-self: end;
            }
        }
    }

    &.list {
        container: list-section / scroll-state;

        ul {
            grid-template-columns: auto auto auto auto 1fr auto auto auto;
        }

        li.sheet-tile {
            display: grid;
            grid-template-columns:subgrid;
            grid-template-rows: 1.2fr 1fr;
            gap: .5em;
            line-height: 1;
            align-content: center;
            padding: 0 1em 0 .5em;

            &:hover {
                background: rgb(from color-mix(in oklch, var(--background-color) 85%, var(--accent-color) 15%) r g b / .9);
            }

            .name, .id, .address, .city {
                text-overflow: ellipsis;
                overflow: hidden;
                white-space: nowrap;
            }

            .thumbnail {
                grid-column: 1;
                grid-row: 1/span 2;
                width: 3em;
                height: 3em;
                border-radius: 1em 0 0 1em;
                margin: 0 1em 0 -.5em;
            }

            .name {
                grid-column: 2/span 2;
                grid-row: 1;
                font-stretch: 85%;
                font-weight: 400;
                margin-right: 1em;
                align-self: end;
            }

            .id {
                grid-column: 3;
                grid-row: 2;
                font-size: .5em;
                font-stretch: 100%;
                font-weight: 400;
                opacity: .5;
                margin-right: 1em;
                align-self: baseline;
            }

            .category {
                grid-column: 2;
                grid-row: 2;
                font-size: .75em;
                font-weight: 300;
                opacity: .5;
                margin-right: 1em;
                align-self: baseline;
            }

            .address {
                grid-column: 4;
                grid-row: 1;
                font-size: calc(1em - 1em / 3);
                font-stretch: 75%;
                font-weight: 400;
                align-self: end;
            }

            .city {
                grid-column: 4;
                grid-row: 2;
                font-size: .8em;
                font-stretch: 85%;
                font-weight: 600;
                align-self: start;
            }

            svg[role="button"] {
                grid-row: 1/span 2;
                align-self: center;

                &.link {
                    grid-column: 6
                }

                &.edit {
                    grid-column: 7
                }

                &.delete {
                    grid-column: 8;
                }
            }
        }
    }
}

@container queue-section scroll-state(scrollable: top) {
    section.queue > p:first-child {
        opacity: 0;
    }
}

@container list-section scroll-state(scrollable: top) {
    section.list > p:first-child {
        opacity: 0;
    }
}