:root {
    --radial-gradient-right: radial-gradient(ellipse at right, #1a3449 0%, #000000 110%);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    width: 100%;
    font-family: 'Source Sans Pro', 'Atkinson Hyperlegible', system-ui, sans-serif;
    color: #eee;
    background-color: #09131a;
}

body {
    background-image: var(--radial-gradient-right);
    padding: 50px 0 50px 0;
}


main {
    margin: auto;
    max-width: min(800px, 90vw);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    /* width: 100%; */
    /* height: 100%; */
    z-index: 1;
    border-radius: 20px;
    backdrop-filter: blur(100px);
}

header-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    > a {
        text-decoration: none;
        color: #92d8c6;
        font-weight: 600;
        font-size: 1.5em;
        margin-right: 20px;

    }
}

avatar-container {
    img {
        clip-path: circle(50%);
        max-height: 32px;
    }

    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;

    font-weight: 500;
    font-size: 1.4em;

}

.unresolved {
    color: #ccc;
    font-style: italic;
    font-weight: 400;
    font-size: 0.8em;
}

.frosty::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 3px;
    /* control the border thickness */
    backdrop-filter: blur(5px) brightness(2.2) contrast(1.2) saturate(0.7);
    mask:
        conic-gradient(#000 0 0) content-box,
        conic-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
    z-index: -1;
}

.frosty-solid::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 3px;
    background-image: radial-gradient(ellipse at right, #345a77 0%, #192a3a 80%);
    /* control the border thickness */
    mask:
        conic-gradient(#000 0 0) content-box,
        conic-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
    z-index: -1;
}

owned-item-tree {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;

    item-name {
        padding-top: 3px;
        padding-bottom: 3px;
    }

    & ul {
        grid-column: span 2;
        padding: 0;

        & li {
            item-name[data-tree-depth="1"] {
                padding-left: 30px;
            }
            item-name[data-tree-depth="2"] {
                padding-left: 60px;
            }
            item-name[data-tree-depth="3"] {
                padding-left: 90px;
            }
            item-name[data-tree-depth="4"] {
                padding-left: 120px;
            }
            item-name[data-tree-depth="5"] {
                padding-left: 150px;
            }
            display: grid;
            grid-template-columns: 2fr 1fr;
            gap: 10px;
            position: relative;
        }

        li::before {
            content: '─';
            padding-top: 3px;
            display: block;
            position: absolute;
            width: 10px;
            height: 100%;
            border-left: 2px solid #8fc5c5;
            color: #8fc5c5;
        }

        li:has(> item-name[data-tree-depth="1"])::before {
            left: 10px;
        }
        li:has(> item-name[data-tree-depth="2"])::before {
            left: 40px;
        }
        li:has(> item-name[data-tree-depth="3"])::before {
            left: 70px;
        }
        li:has(> item-name[data-tree-depth="4"])::before {
            left: 100px;
        }
        li:has(> item-name[data-tree-depth="5"])::before {
            left: 130px;
        }

        li:last-child::before {
            height: 0.73em;
        }

    }

    avatar-container {
        min-width: 35%;
        /* justify-content: end; */
        & img {
            max-height: 20px;
        }
        & span {
            font-size: 0.8em;
            display: inline-block;
            padding: 0;
            margin: 0;
            text-align: left;
            color: #a7b4b4;
            font-style: italic;
        }
    }
}
@media screen and (width <=600px) {
    owned-item-tree {
        grid-template-columns: 1fr;

        & ul {
            grid-column: span 1;

            & li {
                grid-template-columns: 1fr;
            }
        }

        avatar-container {
            justify-content: start;
            margin-top: -15px;
        }

        item-name[data-tree-depth="0"] + avatar-container {
            margin-left: 30px;
        }
        item-name[data-tree-depth="1"] + avatar-container {
            margin-left: 60px;
        }
        item-name[data-tree-depth="2"] + avatar-container {
            margin-left: 90px;
        }
        item-name[data-tree-depth="3"] + avatar-container {
            margin-left: 120px;
        }
        item-name[data-tree-depth="4"] + avatar-container {
            margin-left: 150px;
        }
    }
    
}

item-name {
    font-size: 1.1em;

    a {
        i {
            margin: 2px;
            color: rgb(117, 129, 173);
        }

        color: #a4c9c9;
        text-decoration: none;
    }

    .not-within-box {
        font-style: italic;
        color: #798686;
    }
}

item-tree {
    & ul {
        width: 100%;
        margin: 0;
        margin-top: 5px;
        padding-top: 5px;
        padding-left: 30px;
        list-style: none;
        transition: max-height 0.5s;
        overflow: hidden;

        li {
            position: relative;
        }

        li::before {
            content: '─';
            display: block;
            position: absolute;
            left: -20px;
            width: 10px;
            height: 100%;
            border-left: 2px solid #8fc5c5;
            color: #8fc5c5;
        }

        li:last-child::before {
            height: 0.73em;
        }
    }
}

item-card {
    display: grid;
    grid-template-columns: 7fr 4fr;
    align-items: center;
    gap: 10px;
    width: 100%;
    position: relative;
    z-index: 2;
    padding: 20px;

    item-info {
        display: flex;
        flex-direction: column;
        grid-column: 1 / 2;

        item-name {
            font-weight: 600;
            font-size: 1.8em;
        }

        item-strid {
            color: #aaa;
        }
    }

    item-owner {
        display: flex;
        flex-direction: column;

        background: #1a2429;
        padding: 10px 20px 10px 20px;
        border-radius: 20px;

        width: fit-content;
        height: fit-content;
        margin-left: auto;

        p {
            margin-top: 10px;
            line-height: 0.2em;
            color: #aaa;
        }

    }

    item-owner.you {
        border: 1px solid #92d8c6;
    }


    actions {
        grid-column: 1 / span 2;
        border-radius: 20px;
        padding: 30px;
        display: flex;
        width: 100%;
        justify-content: space-evenly;

        form>button {
            height: 100%;
            color: #92d8c6;
            border: 1px solid #92d8c6;
            padding: 3px 12px 3px 12px;
            border-radius: 20px;
            background-color: transparent;
            cursor: pointer;
            transition: all 0.1s;
            min-width: 150px;
            height: 40px;
            display: flex;
            align-items: center;
            gap: 10px;
            position: relative;
            text-wrap: nowrap;
            min-width: 250px;
            justify-content: center;

            &:hover {
                outline: 1px solid #92d8c6;
                background-color: #283138;
            }

            h4 {
                font-weight: 600;
                margin: 0;
                font-size: 0.8em;
            }


            avatar-container {
                font-size: 0.8em;
                font-weight: 600;

                img {
                    max-height: 22px;
                }
            }
        }

    }

    borrow-update-section {
        grid-column: 1 / span 2;
        display: flex;
        flex-direction: column;
        align-items: center;
        position: relative;
        margin: 30px 0 30px 0;
        min-height: 200px;

        &>img {
            overflow: hidden;
            position: absolute;
            height: 300px;
            top: -50px;
            width: auto;
            z-index: 3;
            animation: spin 128s linear infinite;
        }


        borrow-update {
            border-radius: 20px;
            min-width: 50%;
            z-index: 4;

            h2 {
                font-size: 2.2em;
                font-weight: 400;
                margin: 0;
                text-align: center;
                text-shadow: 0 0 10px #a0dcff77;
                text-wrap: balance;

                span {
                    font-weight: 800;
                }
            }

            transfer {
                background-color: #09131a22;
                backdrop-filter: blur(15px);
                display: block;
                padding: 5px 20px 0 20px;
                border-radius: 20px;
                display: block;
                max-width: 500px;

                h5 {
                    margin: 0;
                }

                transfer-flex {
                    display: grid;
                    grid-template-columns: 1fr 20px 1fr;
                    align-items: center;
                    gap: 20px;
                    justify-content: space-evenly;
                    padding: 0;

                    arrow {
                        font-size: 2em;
                    }
                }
            }

            additional-items {
                background-color: #09131a22;
                backdrop-filter: blur(15px);
                display: block;
                border-radius: 20px;
                margin-top: 10px;
                padding: 10px;

                details {
                    cursor: pointer;
                    margin: 4px 0 4px 0;

                    h5 {
                        margin: 4px 0 4px 0;
                        font-weight: 600;
                        font-size: 1.1em;
                        color: #89acac;
                        position: absolute;
                        top: 5px;
                        left: 25px;

                        i {
                            font-weight: 400;
                            font-size: 0.9em;
                            padding: 5px;
                        }
                    }
                }

                item-tree {
                    display: block;
                    width: fit-content;
                    margin: auto;

                    max-height: 0;
                    overflow: hidden;
                    transition: max-height 0.5s;
                }

                details[open]+item-tree {
                    max-height: 500px;
                }

            }

            present-updates-section {
                background-color: #09131a22;
                backdrop-filter: blur(15px);
                display: block;
                border-radius: 20px;
                margin-top: 10px;
                padding: 10px;

                details {
                    cursor: pointer;

                    h5 {
                        margin: 4px 0 4px 0;
                        font-weight: 600;
                        font-size: 1.1em;
                        color: #89acac;
                        position: absolute;
                        top: 5px;
                        left: 25px;

                        i {
                            font-weight: 400;
                            font-size: 0.9em;
                            padding: 5px;
                        }
                    }
                }

                present-updates {
                    display: grid;
                    grid-template-columns: auto 20px auto;
                    row-gap: 4px;
                    column-gap: 2px;

                    .in-box {
                        color: rgb(117, 255, 202);
                    }

                    .out-box {
                        color: rgb(255, 168, 109)
                    }

                    item-name {
                        text-align: right;
                        margin-right: 4px;
                    }

                    max-height: 0;
                    transition: max-height 0.5s;
                    overflow: hidden;
                }

                details[open]+present-updates {
                    max-height: 500px;
                }
            }


        }
    }

    box-contents {
        grid-column: 1 / span 2;

        h2 {
            margin-left: min(80px, 10vw);
            font-size: 1.7em;
        }

        item-tree-container {
            width: 100%;
            display: block;
            margin-bottom: 20px;

            item-tree {
                margin: auto;
                display: block;
                width: fit-content;
                border-radius: 20px;
                padding: 20px 60px 20px 60px;
                background-color: #09131a22;
                backdrop-filter: blur(15px);

                item-name {
                    font-size: 1.2em;
                }
            }
        }

    }

    borrow-history-container {
        grid-column: 1 / span 2;

        h2 {
            margin: 0;
            margin-left: min(80px, 10vw);
            font-size: 1.4em;
        }

        borrow-history {
            display: grid;
            grid-template-columns: 3fr 20px 8fr;
            column-gap: 10px;
            align-items: center;

            borrow-date {
                color: #aaa;
                text-align: right;
            }

            borrow-timeline {
                display: flex;
                flex-direction: column;
                align-items: center;
                height: 100%;
                position: relative;

                borrow-dot {
                    top: calc(50% - 6px);
                    height: 12px;
                    width: 12px;
                    background: #aaa;
                    border-radius: 50%;
                    display: inline-block;
                    position: absolute;
                }

                borrow-star {
                    img {
                        height: 20px;
                        width: 20px;
                        display: block;
                    }

                    top: calc(50% - 10px);
                    position: absolute;
                }


                borrow-line {
                    position: absolute;
                    width: 2px;
                    background: #aaa;
                    flex-grow: 1;
                    height: 100%;
                    top: calc(50% - 6px);
                }
            }

            borrow-owner {
                padding: 10px 0 10px 0;
                align-items: center;
                
                avatar-container {
                    font-size: 1.2em;
                }
            }
        }
    }
}

@media screen and (width <=800px) {
    item-card {
        grid-template-columns: 1fr;

        item-info {
            text-align: center;
            grid-column: 1/1;
        }

        item-owner {
            z-index: 4;
            margin: auto;
            grid-column: 1/1;
        }
    }

    actions {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
}

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