@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');

@property --gradient-num {
    syntax: "<number>";
    inherits: false;
    initial-value: -0.3;
}

:root {
    --primary-color: #E6F0FF;
    --primary-hover: #93C5FD;
    --primary-light: #7e97c0;
    
    --secondary-color: #3B82F6;
    --secondary-dark: #2563eb;
    --secondary-light: #1B2735;
    --secondary-hover: #60a5fa;
    --secondary-shadow: rgba(59, 130, 246, 0.16);
    --secondary-background: rgba(59, 130, 246, 0.14);
    --secondary-dark-shadow: rgba(147, 197, 253, 0.3);
    
    --background-color: #0B0F14;
    --background-hover: #16202E;
}

*, ::after, ::before, ::backdrop, ::file-selector-button {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0 solid;
}

body {
    background-color: var(--background-color);
    color: var(--primary-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
    font-family: "Inter", sans-serif;
}
a {
    text-decoration: none;
}
#background {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.03;
}
#logo {
    position: fixed;
    width: 10vw;
    height: auto;
    top: 2%;
    left: 2%;
}
#input-phase {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5vh;
    gap: 5dvh;
    width: 100%;
    height: 100%;
}

#title {
    margin-top: 10vh;
    margin-top: 10dvh;
    font-size: clamp(1rem, 4vw, 2.5rem);
    color: var(--primary-color);
    text-align: center;
}
#main {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10vw;
    overflow: hidden;
    width: 100%;
    height: 100%;
}
.guide-step {
    display: flex;
    align-items: left;
    gap: 12px;
    background: color-mix(in srgb, var(--secondary-color) 6%, transparent);
    border: 1px solid color-mix(in srgb, var(--secondary-color) 18%, transparent);
    border-radius: 10px;
    padding: 10px 14px;
}

.guide-title {
    color: var(--primary-light);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
    margin: 0;
    font-family: system-ui, sans-serif;
}

.guide-step-desc {
    color: var(--primary-color);
    font-size: 13px;
    font-family: system-ui, sans-serif;
    line-height: 1.4;
}

.guide-icon {
    width: 5vw;
}

#image-upload {
    width: clamp(200px, 40vw, 450px);
    aspect-ratio: 1 / 1;
    background: color-mix(in srgb, var(--secondary-color) 8%, transparent);
    border: 2px solid color-mix(in srgb, var(--secondary-color) 55%, transparent);
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, border-color 0.15s;
}
#image-upload:hover, #image-upload.file-hover {
    background-color: color-mix(in srgb, var(--secondary-color) 25%, transparent);
    border-color: color-mix(in srgb, var(--secondary-hover) 80%, transparent);
    cursor: pointer;
}

#camera-input {
    display: none;
}

#guide-container {
    width: 25vw; 
    display: flex; 
    flex-direction: column; 
    gap: 1vw;
}

footer {
    display: flex;
    align-items: center;
    display: flex;
    padding: 20px 0;
    width: 100%;
    justify-content: center;
    gap: 10vw;  
    background-color: var(--background-color);
    color: var(--primary-color);
}

footer p a {
    color: var(--primary-color);
    position: relative;
    transition: color 0.15s;
}

footer p a:hover {
    color: color-mix(in srgb, var(--secondary-hover) 80%, transparent);
}

footer p a::after {
    content: "";
    display: inline-block;
    width: 0px;
    height: 5px;
    background-color: var(--primary-color);
    position: absolute;
    bottom: -20%;
    border-radius: 2000px;
    left: 50%;
    transform: translateX(-50%);
    transition: width 0.15s, background-color 0.15s;
}

footer p a:hover::after{
    background-color: color-mix(in srgb, var(--secondary-hover) 80%, transparent);
    width: 45px;
}

.dot {
    max-width: 10px;
    max-height: 10px;
}

#processing-phase, #output-phase {
    display: none;
}

#processing-phase {
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#processing-image {
    position: relative;
    width: 50vw;
    max-height: 50vh;
    max-height: 50dvh;
    height: auto;
    filter: blur(5px);
}
#processing-image-container {
    overflow: hidden;
    position: relative;
    width: 50vw;
    max-height: 50vh;
    max-height: 50dvh;
    height: auto;
}
#file-name {
    text-align: center;
}

#processing-image-container::before {
    z-index: 1;
    content: "";
    position: absolute;
    height: 100%;
    width: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(
        45deg, 
        rgba(255, 255, 255, 0) calc((var(--gradient-num) * 100%) - 20%), 
        var(--secondary-hover) calc(var(--gradient-num) * 100%), 
        rgba(255, 255, 255, 0) calc((var(--gradient-num) * 100%) + 20%)
    );
    animation: 2.5s ease-in-out 0.2s infinite gradientAnimation;
}

#output-phase {
    position: fixed;
    z-index: 2;
    top: 5%;
    left: 5%;
    right: 5%;
    bottom: 5%;
    padding: 0 10px;
    border: 10px solid var(--primary-color);
    border-radius: 20px;
    /* display: flex; */
    flex-direction: row;
    justify-content: center;
    align-items: center;
    background-color: color-mix(in srgb, var(--background-color) 80%, transparent);
}

#output-image {
    flex-basis: 0;
    flex-grow: 1;
    min-width: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 2px solid var(--primary-color);
}

#divider {
    background-color: var(--primary-color) 75%;
    height: 90%;
    min-width: 2px;
    margin: 0 10px;
}

#output-text {
    display: flex;
    flex-direction: column;
    height: 90%;
    flex-basis: 0;
    flex-grow: 1;
    color: var(--primary-color);
    font-size: 1rem;
    min-width: 0;
}
#gap {
    flex-grow: 1;
}
#gap2 {
    flex-grow: 1;
}
#prediction {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--secondary-color);
}
#score {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--secondary-color);
}
#close-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    cursor: pointer;
}
#info {
    font-size: 1rem;
}

#time-notice {
    opacity: 0;
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--primary-light) 50%, transparent);
    text-align: center;
    margin-top: 10px;
    transition: opacity 1s linear;
}
#time-notice.show {
    opacity: 1;
}

@keyframes gradientAnimation {
    0% {
        --gradient-num: -0.3;
    }
    100% {
        --gradient-num: 1.3;
    }
}

#setting-icon {
    width: clamp(10px, 10vw, 60px);
    position: fixed;
    top: 10px;
    right: 10px;
    transition: transform 0.2s ease-in-out;
}
#setting-icon:hover {
    cursor: pointer;
}
#inverted {
    display: none;
}
#switch {
    position: relative;
    display: flex;
    align-items: center;
    width: 50px;
    height: 24px;
    background-color: white;
    border-radius: 12px;
    transition: background-color 0.2s ease-in-out;
}
#switch-circle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: var(--background-color);
    border-radius: 50%;
    transition: transform 0.2s ease-in-out, background-color 0.2s ease-in-out;
}
#switch-circle.checked {
    transform: translateX(26px);
    background-color: var(--primary-color);;
}
body:has(#switch-circle.checked) #switch {
    background-color: var(--secondary-color);
}
#settings-menu {
    position: fixed;
    top: clamp(15px, 13vw, 75px);
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: clamp(160px, 20vw, 200px);
    height: clamp(200px, 20vh, 400px);
    gap: 10px;
    padding: 10px;
    background-color: color-mix(in srgb, var(--background-color) 80%, transparent);
    border: 1px solid var(--primary-color);
    border-radius: 5px;
    display: none;
}
#settings-menu.show {
    display: flex;
}

body:has(#settings-menu.show) #setting-icon {
    transform: rotateZ(20deg);
}

#scale-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
}
#scale-container #thresh-label {
    text-align: center;
    border-bottom: 1px solid var(--primary-color);
    width: 100%;
}

#inverted-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 5px;
}
#inverted-container p {
    display: inline-block;
    text-align: center;
    border-bottom: 1px solid var(--primary-color);
    width: 100%;
}

#scale-input {
    width: 100%;
    font-size: 0.8rem;
    text-align: center;
}

#scale {
    width: 90%;
}

#reset-button {
    width: 50%;
    text-align: center;
    font-size: 0.8rem;
    padding: 5px;
    margin: 10px;
    background-color: var(--secondary-color);
    color: var(--primary-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}
#reset-button:hover {
    background-color: var(--secondary-hover);
}

@media (max-width: 700px) {
    a {
        text-decoration: none;
    }
    #logo {
        width: 10vh;
        width: 10dvh;
        left: 50%;
        top: 4vh;
        top: 4dvh;
        transform: translateX(-50%);
    }
    #input-phase {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5vh;
        gap: 5dvh;
        width: 100%;
        height: 100%;
    }

    #title {
        font-size: clamp(1rem, 2.75vh, 2.5rem);
        font-size: clamp(1rem, 2.75dvh, 2.5rem);
    }
    #main {
        flex-direction: column;
        gap: 3vh;
        gap: 3dvh;
    }

    #image-upload {
        width: clamp(150px, 80vw, 450px);
        height: clamp(150px, 30vh, 450px);
        height: clamp(150px, 30dvh, 450px);
    }

    #guide-container {
        width: 75vw; 
        gap: 1vh;
        gap: 1dvh;
    }

    footer {
        gap: 3.5vw;  
        font-size: clamp(0.5rem, 5vw, 1rem);
    }

    footer p a::after {
        width: clamp(20px, 15vw, 50px);
    }

    footer p a:hover::after{
        background-color: color-mix(in srgb, var(--secondary-hover) 80%, transparent);
        width: clamp(25px, 20vw, 60px);
    }

    .dot {
        max-width: clamp(5px, 2vw, 10px);
    }

    .guide-title {
        font-size: clamp(7px, 5vw, 11px);
    }

    .guide-step-desc {
        font-size: clamp(9px, 5vw, 13px);
        line-height: 1.05;
    }

    #processing-image {
        width: 70vw;
    }
    #processing-image-container {
        width: 70vw;
    }

    #output-phase {
        padding: 0 5px;
        border: 6px solid var(--primary-color);
        border-radius: 5px;;
        flex-direction: column;
    }

    #divider {
        width: 90%;
        height: auto;
        min-height: 2px;
        min-width: auto;
        margin: 10px 0;
    }
    #prediction {
        margin-bottom: 5px;
    }
    #score {
        margin-bottom: 5px;
    }
    #close-icon {
        top: 5px;
        right: 5px;
        width: 40px;
        height: 40px;
    }
    #info {
        font-size: 0.7rem;
        line-height: 1;
        padding-bottom: 5px;
    }

    #time-notice {
        font-size: clamp(0.6rem, 3.5vw, 0.8rem);
        margin-top: 5px;
    }

    #file-name {
        font-size: clamp(0.8rem, 3.5vw, 1rem);
    }
}