:root {
    --hue1: 255;
    --hue2: 222;
    --border: 1px;
    --border-color: hsl(var(--hue2), 12%, 20%);
    --radius: 7px;
    --ease: cubic-bezier(0.5, 1, 0.89, 1);
}

body {
    margin: 0;
    font-family: 'Asap', sans-serif;
    background: #08090d;
    background-image: url(../images/abstract-light.jpg), linear-gradient(to right in oklab, hsl(var(--hue2) 50% 75%), hsl(var(--hue1) 50% 75%));
    background-size: cover;
    background-position: center;
    background-blend-mode: hard-light;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2svw;
    position: relative;
    box-sizing: border-box;
}

#login-container svg {
    fill: none;
    stroke-width: 1;
    height: 20px;
}

#login-container {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition-property: visibility, opacity, filter;
    transition-duration: 0s, 0.25s, 0.25s;
    transition-delay: 0s, 0s, 0s;
    transition-timing-function: var(--ease);
    filter: blur(0px);
    
    font-family: 'Asap', sans-serif;
    color: #737985;

    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    min-width: 320px;
    max-width: 400px;
    width: auto;
    border-radius: var(--radius);
    border: var(--border) solid var(--border-color);
    padding: 1em;
    background: linear-gradient(235deg, hsl(var(--hue1) 50% 10% / 0.8), hsl(var(--hue1) 50% 10% / 0) 33%), linear-gradient(45deg , hsl(var(--hue2) 50% 10% / 0.8), hsl(var(--hue2) 50% 10% / 0) 33%), linear-gradient(hsl(220deg 25% 4.8% / 0.66));
    backdrop-filter: blur(12px);
    box-shadow: hsl(var(--hue2) 50% 2%) 0px 10px 16px -8px, hsl(var(--hue2) 50% 4%) 0px 20px 36px -14px;
    overflow: hidden;
    box-sizing: border-box;
}

#login-container:not(.open)::before,
#login-container:not(.open)::after,
#login-container:not(.open) .glow {
    opacity: 0;
    pointer-events: none;
    animation: glowoff 0.25s var(--ease) both;
}

#login-container.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
    filter: blur(0px);
    
    &::before,
    &::after,
    & .glow,
    & .shine {
        animation: glow 1s var(--ease) both;
    }
    & .shine {
        animation-delay: 0s;
        animation-duration: 2s;
    }
    & .glow {
        animation-delay: 0.2s;
    }
    & .glow-bright {
        animation-delay: 0.1s;
        animation-duration: 1.5s;
    }
    & .shine-bottom {
        animation-delay: 0.1s;
        animation-duration: 1.8s;
    }
    & .glow-bottom {
        animation-delay: 0.3s;
    }
    & .glow-bright.glow-bottom {
        animation-delay: 0.3s;
        animation-duration: 1.1s;
    }
}

/* Shine effects - based on neonglass implementation */
#login-container .shine,
#login-container .glow {
    --hue: var(--hue1);
}

#login-container .shine-bottom,
#login-container .glow-bottom {
    --hue: var(--hue2);
    --conic: 135deg;
}

#login-container .shine,
#login-container .shine::before,
#login-container .shine::after {
    /* shine is the bright white-ish inner pixel-wide lights */
    pointer-events: none;
    border-radius: 0;
    border-top-right-radius: inherit;
    border-bottom-left-radius: inherit;
    border: 1px solid transparent;
    width: 75%;
    height: auto;
    min-height: 0px;
    aspect-ratio: 1;
    display: block;
    position: absolute;
    right: calc(var(--border) * -1);
    top: calc(var(--border) * -1);
    left: auto;
    z-index: 1;
    --start: 12%;
    background: conic-gradient(
        from var(--conic, -45deg) at center in oklch,
        transparent var(--start,0%), hsl( var(--hue), var(--sat,80%), var(--lit,60%)), transparent  var(--end,50%) 
    ) border-box;
    mask: linear-gradient(transparent), linear-gradient(black);
    mask-repeat: no-repeat;
    mask-clip: padding-box, border-box;
    mask-composite: subtract;
}

#login-container .shine::before,
#login-container .shine::after {
    content: "";
    width: auto;
    inset: -2px;
    mask: none;
}

#login-container .shine::after {
    z-index: 2;
    --start: 17%;
    --end: 33%;
    background: conic-gradient(
        from var(--conic, -45deg) at center in oklch,
        transparent var(--start,0%), hsl( var(--hue), var(--sat,80%), var(--lit,85%)), transparent var(--end,50%) 
    );
}

#login-container .shine-bottom {
    top: auto;
    bottom: calc(var(--border) * -1);
    left: calc(var(--border) * -1);
    right: auto;
}

/* Glow effects */
#login-container .glow {
    /* glow is the sparse colour bleed with noise */
    pointer-events: none;
    border-top-right-radius: calc(var(--radius) * 2.5);
    border-bottom-left-radius: calc(var(--radius) * 2.5);
    border: calc(var(--radius) * 1.25) solid transparent;
    inset: calc(var(--radius) * -2);
    width: 75%;
    height: auto;
    min-height: 0px;
    aspect-ratio: 1;
    display: block;
    position: absolute;
    left: auto;
    bottom: auto;
    mask: url('../images/noise-base.png');
    mask-mode: luminance;
    mask-size: 29%;
    opacity: 1;
    filter: blur(12px) saturate(1.25) brightness(0.5);
    mix-blend-mode: plus-lighter;
    z-index: 3;
    
    &.glow-bottom {
        inset: calc(var(--radius) * -2);
        top: auto;
        right: auto;
    }
    
    &::before, 
    &::after {
        content: "";
        position: absolute;
        inset: 0;
        border: inherit;
        border-radius: inherit;
        background: conic-gradient(
            from var(--conic, -45deg) at center in oklch,
            transparent var(--start,0%), hsl( var(--hue), var(--sat,95%), var(--lit,60%)), transparent  var(--end,50%) 
        ) border-box;
        mask: linear-gradient(transparent), linear-gradient(black);
        mask-repeat: no-repeat;
        mask-clip: padding-box, border-box;
        mask-composite: subtract;
        filter: saturate(2) brightness(1);
    }
    
    &::after {
        --lit: 70%;
        --sat: 100%;
        --start: 15%;
        --end: 35%;
        border-width: calc(var(--radius) * 1.75);
        border-radius: calc(var(--radius) * 2.75);
        inset: calc(var(--radius) * -0.25);
        z-index: 4;
        opacity: 0.75;
    }
}

#login-container .glow-bright {
    /* glow-bright is a sharper colour outline to accentuate the shine */
    --lit: 80%;
    --sat: 100%;
    --start: 13%;
    --end: 37%;
    border-width: 5px;
    border-radius: calc(var(--radius) + 2px);
    inset: -7px;
    left: auto;
    filter: blur(2px) brightness(1);
    z-index: 5;
    mix-blend-mode: plus-lighter;
    
    &::after {
        content: none;
    }
    
    &.glow-bottom {
        inset: -7px;
        right: auto;
        top: auto;
    }
}

#login-container h1 {
    margin: 0 0 1.5em 0;
    font-size: 1.75rem;
    font-weight: 300;
    color: hsl(var(--hue1) 50% 70%);
    text-align: center;
    position: relative;
    z-index: 2;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1em;
    position: relative;
    z-index: 2;
}

.error-message {
    color: hsl(0 70% 60%);
    font-size: 0.875rem;
    padding: 0.5em;
    background: hsl(0 50% 10% / 0.3);
    border-radius: calc(var(--radius) * 0.33333);
    border: 1px solid hsl(0 50% 30% / 0.5);
    text-align: center;
}

.input-field {
    --tint2: hsl(var(--hue2) 50% 90% / 0.1);
    color: hsl(0 0 100% / 0.5);
    font-family: 'Asap', sans-serif;
    font-weight: 300;
    font-size: 0.875rem;
    box-shadow: 0 0 0 1px transparent;
    border: 1px solid hsl(var(--hue2) 13% 18.5% / 0.5);
    background: linear-gradient(to bottom, hsl(var(--hue1) 20% 20% / 0.1) 50%, hsl(var(--hue1) 50% 50% / 0.8) 180%);
    background-size: 100% 300%;
    background-position: 0% 0%;
    background-repeat: no-repeat;
    border-radius: calc(var(--radius) * 0.33333);
    padding: 0.75em 1em;
    transition: all 0.3s var(--ease);
    width: 100%;
    box-sizing: border-box;
    
    &:focus {
        outline: none;
        border-color: hsl(var(--hue1) 20% 70% / 0.5);
        background-position: 0% 50%;
        color: hsl(var(--hue1) 20% 80% / 1);
    }
    
    &::placeholder {
        color: hsl(0 0 100% / 0.4);
    }
}

.glow-button {
    --item-hue: var(--hue1);
    position: relative;
    padding: 0.75em 1.5em;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    border-radius: calc(var(--radius) * 0.33333);
    border: 1px solid transparent;
    transition: all 0.3s ease-in, --item-opacity 0.3s ease-in;
    background: linear-gradient(
        90deg in oklch, 
        hsl(var(--item-hue) 29% 13% / var(--item-opacity, 0.5)),
        hsl(var(--item-hue) 30% 15% / var(--item-opacity, 0.5)) 24% 32%, 
        hsl(var(--item-hue) 5% 7% / 0) 95%
    ) border-box;
    color: white;
    font-family: 'Asap', sans-serif;
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
    margin-top: 0.5em;
    
    &::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        border: inherit;
        background: linear-gradient(
            90deg in oklch, 
            hsl(var(--item-hue) 15% 16% / var(--item-opacity, 0.5)),
            hsl(var(--item-hue) 40% 24% / var(--item-opacity, 0.5)) 20% 32%, 
            hsl(var(--item-hue) 2% 12% / 0) 95%
        ) border-box;
        mask: linear-gradient(transparent), linear-gradient(to right, black, transparent);
        mask-repeat: no-repeat;
        mask-clip: padding-box, border-box;
        mask-composite: subtract;
    }
    
    &:hover,
    &:focus {
        --item-opacity: 0.7;
        transition: all 0.1s ease-out, --item-opacity 0.1s ease-out;
        outline: none;
    }
    
    &:active {
        transform: scale(0.98);
    }
}

.footer {
    margin-top: 1.5em;
    font-size: 0.75rem;
    color: hsl(var(--hue2) 30% 50%);
    text-align: center;
    position: relative;
    z-index: 2;
}

@keyframes glowoff {
    to {
        opacity: 0;
    }
}

@keyframes glow {
    0% {
        opacity: 0;
    }
    3% {
        opacity: 1;
    }
    10% {
        opacity: 0;
    }
    12% {
        opacity: 0.7;
    }
    16% {
        opacity: 0.3;
        animation-timing-function: var(--ease);
    }
    100% {
        opacity: 1;
        animation-timing-function: var(--ease);
    }
}

@property --item-opacity {
    syntax: "<number>";
    inherits: false;
    initial-value: 0.5;
}

@media (max-width: 480px) {
    body {
        padding: 1rem;
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #login-container {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        padding: 1.5em;
        min-width: 0;
        max-width: calc(100% - 2rem);
        width: calc(100% - 2rem);
        
        h1 {
            font-size: 1.5rem;
        }
    }

    .input-field {
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    body {
        padding: 0.75rem;
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #login-container {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        padding: 1.25em;
        max-width: calc(100% - 1.5rem);
        width: calc(100% - 1.5rem);
        
        h1 {
            font-size: 1.25rem;
            margin-bottom: 1em;
        }
    }

    .input-field {
        padding: 0.65em 0.85em;
    }

    .glow-button {
        padding: 0.65em 1.25em;
    }
}

body, #app {
    min-height: 100svh;
}

#app {
    padding: 2svw;
}

#app > header {
    display: flex;
    gap: 0.5em;
    flex-direction: column;
}

#app > header h1,
#app > header p {
    margin: 0;
    color: color-mix(in oklab, var(--fg) 70%, hsl(var(--hue1) 50% 50%));
}

#app > header p {
    color: color-mix(in oklab, var(--fg) 40%, hsl(var(--hue2) 50% 50%));
}

#app > footer {
    align-self: end;
    max-width: calc(96svw - 200px);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
}

#app > footer h2 {
    width: 100%;
    font-size: 1em;
}

#app > footer [type=range] {
    --tint: hsl( var(--hue2) 66% 50% );
    --tint2: hsl( var(--hue1) 66% 50% );
    width: 320px;
    margin: 0;
}
#app > footer #h1 {
    --tint: hsl( var(--hue1) 66% 50% );
    --tint2: hsl( var(--hue1) 66% 50% );
    --hue: var(--hue1);
    width: 320px;
}
#app > footer #h2 {
    --tint: hsl( var(--hue2) 66% 50% );
    --tint2: hsl( var(--hue2) 66% 50% );
    --hue: var(--hue2);
    width: 320px;
}

@media screen and (max-width: 480px) {
    #app > footer {
        gap: 1em;
    }
}

#app input[type="range"]::-webkit-slider-thumb {
    box-shadow: 0 1px 2px 1px hsl(var(--hue) 66% 20% / 0.5);
}

#app input[type="range"]::-moz-range-thumb {
    box-shadow: 0 1px 2px 1px hsl(var(--hue) 66% 20% / 0.5);
}

#app input[type="range"]::-ms-thumb {
    box-shadow: 0 1px 2px 1px hsl(var(--hue) 66% 20% / 0.5);
}
