/* Variable declarations */

:root {
    --form-width: 350px;
    font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --background-image: url(svg/hero.svg);
    --mobile-background-image: url(svg/hero-mobile.svg);
    --valid-icon: url(svg/valid.svg);
    --invalid-icon: url(svg/invalid.svg);
    --background-color: #fbfbfe;
    --primary-color: #fbfbfe;
    --secondary-color: #242424;
    --transparent-color: rgba(0, 0, 0, 0.7);
    color: var(--secondary-color);
}

/* Dark theme */

:root.dark {
    --background-image: url(svg/hero-dark.svg);
    --mobile-background-image: url(svg/hero-mobile-dark.svg);
    --valid-icon: url(svg/valid-dark.svg);
    --invalid-icon: url(svg/invalid-dark.svg);
    --primary-color: #242424;
    --secondary-color: #fbfbfe;
    --transparent-color: rgba(255, 255, 255, 0.7)
}

body {
    min-height: calc(100vh - 20px);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--background-color);
}

/* Theme toggler */

.themes {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    border: none;
}

.themes>label {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0px 0px 15px -3px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.themes>label.light_theme-label {
    --theme-color: #fbfefc;
    background-color: var(--theme-color);
}

.themes>label.dark_theme-label {
    --theme-color: #242424;
    background-color: var(--theme-color);
}

.themes>label>input {
    position: absolute;
    appearance: none;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: inherit;
}

.themes>label>input#light {
    background-color: #242424;
}

.themes>label>input#dark {
    background-color: #fbfbfe;
}

.themes>label>input:before {
    content: "";
    position: absolute;
    top: 2.5px;
    left: 2.5px;
    width: 15px;
    height: 15px;
    background-color: var(--theme-color);
    border-radius: 50%;
    transform: scale(0);
}

.themes>label>input:checked:before {
    transform: scale(1);
}

.main-container {
    display: flex;
    box-shadow: 0px 0px 15px -3px rgba(0, 0, 0, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.form-hero {
    width: 300px;
    display: flex;
    justify-content: center;
    background-image: var(--background-image);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    border-right: 5px solid var(--secondary-color);
    border-radius: 0.5rem 0 0 0.5rem;
}

.form-hero>svg {
    width: 200px;
    fill: var(--secondary-color);
}

form {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--primary-color);
    padding: 2rem 3rem 2rem 3rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

form>header {
    width: var(--form-width);
    font-size: 0.8rem;
    margin-bottom: 2rem;
}


form>fieldset {
    width: var(--form-width);
    display: flex;
    flex-flow: column;
    gap: 2.7rem;
    margin-bottom: 3rem;
    border: 0;
}

/* Hide fieldset legends and label names for sighted users but allow the elements to still be recognized by screen readers */

fieldset>legend {
    position: absolute;
    left: -9999px;
    overflow: hidden;
}

fieldset>div>label {
    position: absolute;
    left: -9999px;
    overflow: hidden;
}

.themes>label>span {
    position: absolute;
    left: -9999px;
    overflow: hidden;
}

/* --------------------------------------------------------- */

/* The container for each individual input and its corresponding icon, format, and additional information (eg. 'required') */

fieldset>div>.input-field {
    position: relative;
    display: flex;
    padding: 0.5rem;
    border-bottom: 2px solid var(--secondary-color);
}


.input-field>svg {
    width: 40px;
    fill: var(--secondary-color);
}

.input-field>input {
    position: relative;
    width: 100%;
    height: 100%;
    appearance: none;
    background-color: transparent;
    color: var(--secondary-color);
    margin-top: 5px;
    margin-left: 10px;
    margin-right: 30px;
    border: 0;
}

.input-field>input:focus {
    outline: 0;
}

.input-field>input::placeholder {
    color: var(--transparent-color);
}

.input-field>input+span {
    transform: scale(0);
}

.input-field>input+span::before {
    position: absolute;
    top: 2px;
    left: -20px;
}

.input-field>input:valid+span::before,
.input-field>input:invalid+span::before {
    content: "";
    width: 25px;
    height: 25px;
}

.input-field>input:valid+span::before {
    background-image: var(--valid-icon);
}

.input-field>input:invalid+span::before {
    background-image: var(--invalid-icon);
}

.input-field>span.required {
    position: absolute;
    top: 120%;
    right: 0;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--transparent-color);
}

/* Contains the required format for each individual input and is shown under each individual input while the
'focus' event is triggered */

#name-format,
#email-format,
#phone-format,
#password-format,
#confirm_password-format {
    position: absolute;
    font-size: 0.9rem;
    color: var(--transparent-color);
    margin-top: 0.5rem;
    transform: scale(0);
}

/* Disables autofill background color */

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    transition-delay: 9999s;
    -webkit-transition-delay: 9999s;
}

/* ---------------------------------- */

form>footer {
    width: var(--form-width);
}

form>footer>button {
    width: 100%;
    font-weight: bold;
    background-color: transparent;
    color: var(--secondary-color);
    padding: 1rem 2rem;
    margin-bottom: 0.2rem;
    border: 0;
    border-radius: 0.3rem;
    box-shadow: 0px 0px 0px 2px var(--secondary-color);
    cursor: pointer;
}

form>footer>button:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

form>footer>button:focus {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

form>footer a {
    text-decoration: none;
    font-weight: bolder;
    color: var(--secondary-color);
}

@media (max-width: 850px) {

    :root {
        --form-width: 100%;
    }

    body {
        padding: 1rem;
    }

    .themes {
        margin-top: 0;
    }

    .main-container {
        flex-direction: column;
        margin-bottom: 0;
    }

    .form-hero {
        width: 100%;
        height: 100px;
        background-image: var(--mobile-background-image);
        border-right: 0;
        border-bottom: 5px solid var(--secondary-color);
        border-radius: 0.5rem 0.5rem 0 0;
    }

    form {
        padding: 2rem 2rem 1rem 2rem;
        border-radius: 0;
    }

}