* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --green-200: hsl(148, 38%, 91%);
    --green-600: hsl(169, 82%, 27%);
    --red: hsl(0, 66%, 54%);

    --white: hsl(0, 0%, 100%);
    --grey-500: hsl(186, 15%, 59%);
    --grey-900: hsl(187, 24%, 22%);
}

body {
    font-family: 'Karla', sans-serif;
    background-color: var(--green-200);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 8rem;
}

main {
    background-color: var(--white);
    padding: 2rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 750px;
}

main h1 {
    text-align: left;
    color: var(--grey-900);
    margin-bottom: 1rem;
}

form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

input {
    border: 1px solid var(--grey-500);
    border-radius: 0.5rem;
    padding: 0.7rem;
    width: 100%;
    color: var(--green-600);
}

label:not(fieldset label)::after {
    content: " *";
    color: var(--green-600);
}

.namesfield {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.emailfield {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

fieldset {
    display: flex;
    flex-direction: column;
    grid-column: 1 / -1;
    border: none;
    padding: 0;
    gap: 1.5rem;
}

legend {
    margin-bottom: 1.2rem;
}

legend::after {
    content: " *";
    color: var(--green-600);
}

.radiofix {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 0.7rem;
    width: 100%;
}

.radioption {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid var(--grey-500);
    border-radius: 0.5rem;
    padding: 0.7rem;
    padding-left: 1.7rem;
    width: 100%;
}

.radioption label {
    font-size: 1.125rem;
}

input[type="radio"] {
    width: auto;
}

.radioption:has(input:checked) {
    border-color: var(--green-600);
    background-color: var(--green-200);
}

.commentfield {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.commentfield textarea {
    border: 1px solid var(--grey-500);
    border-radius: 0.5rem;
    padding: 0.7rem;
    width: 100%;
    min-height: 9rem;
    resize: none;
    color: var(--green-600);
}

.checkboxfield {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

input[type="checkbox"] {
    width: auto;
}

button {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: row;
    background-color: var(--green-600);
    color: var(--white);
    border: none;
    border-radius: 0.5rem;
    padding: 0.7rem;
    font-size: 1.125rem;
    cursor: pointer;
    width: 100%;
    min-height: 3rem;
    transition: 0.3s;
}

button:hover {
    background-color: var(--grey-900);
}

input:focus, textarea:focus, button:focus {
    outline: 2px solid var(--green-600);
    border-color: var(--green-600);
}

.success {
    text-align: left;
    flex-direction: column;
    gap: 1rem;
    color: var(--white);
    background-color: var(--grey-900);
    border-radius: 0.5rem;
    padding: 1.7rem;
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    animation: slideDown 0.5s ease;
}

.success.visible {
    display: flex;
}

.success img {
    width: 1rem;
}

.success-bg {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.progress-bar {
    height: 5px;
    background-color: var(--green-600);
    width: 100%;
    animation: shrink 5s linear forwards;
    border-radius: 0.5rem 0.5rem 0 0;
    margin: -1.7rem -1.7rem 0 -1.7rem;
}

@keyframes shrink {
    from {
        width: 100%;
    }
    to {
        width: 0;
    }
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }
}

.error {
    display: none;
}

.error.visible {
    display: block;
    color: var(--red);
}

input.error-input, textarea.error-input {
    border-color: var(--red);
}

.attribution { font-size: 0.6875rem; text-align: center; margin-top: 1rem; }
.attribution a { color: var(--red); }


/*Responsive*/


@media (max-width: 23.4375em) {
    body {
        padding: 2rem;
    }

    form {
        grid-template-columns: 1fr;
    }

    .namesfield {
        grid-column: 1 / -1;
    }

    .radiofix {
        flex-direction: column;
    }

    .success {
        width: 75%;
        padding: 1rem;
    }

    .progress-bar {
        width: 100%;
        margin: -1rem -1rem 0 -1rem;
    }
}