*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

:root {
    /* spacing */
    --space-100: 0.5rem;
    --space-150: 0.75rem;
    --space-200: 1rem;
    --space-300: 1.5rem;
    --space-400: 2rem;
    --space-500: 2.5rem;
    --space-1600: 8rem;
    /* color */
    --gray-900: #2a4144;
    --gray-500: #86a2a5;
    --white: #ffffff;
    --green-600: #0c7d69;
    --green-200: #e0f1e8;
    --red: #d73c3c;
    /* typography */
    --heading: bold 2rem/1 "Karla";
    --body-medium-bold: bold 1.125rem/1.5 "Karla";
    --body-medium: normal 1.125rem/1.5 "Karla";
    --body-small: normal 1rem/1.5 "Karla";
}

:focus {
    outline-color: var(--green-600);
}

html {
    height: 100%;
    background: var(--green-200);
}

body {
    height: 100%;
}

main {
    height: 100%;
    margin-block: auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

section {
    width: 100%;
    margin-block: auto;
    background: var(--white);
    max-width: 690px;
    border-radius: 1rem;
    padding: 1.5rem;
}

form {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    color: var(--gray-900);
}

input,
label {
    cursor: pointer;
}

.info {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

h1 {
    font: var(--heading);
}

.content {
    max-width: 100%;
    display: grid;
    flex-direction: column;
    gap: 1.5rem;
}

.name {
    display: flex;
    flex-direction: column;
    row-gap: 1.5rem;
    column-gap: 1rem;
}

.column {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font: var(--body-small);
}

.required {
    color: var(--green-600);
}

input[type="text"] {
    min-width: 0;
    width: 100%;
    padding: 0.75rem 1.5rem;
    font: var(--body-medium);
    border-radius: 0.5rem;
    border: 1px solid var(--gray-500);
}

fieldset {
    border: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

legend {
    font: var(--body-small);
    margin-block-end: 1rem;
}

.query__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.query__list--item {
    width: 100%;
    border: 1px solid var(--gray-500);
    border-radius: 0.5rem;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.query__list--item:has(.query__button:checked) {
    background: var(--green-200);
    border-color: var(--green-600);
}

.query__button {
    appearance: none;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0.25rem;
    border: 1px solid var(--gray-500);
    border-radius: 100%;
}

.query__button:checked {
    background-image: url("./assets/images/icon-radio-selected.svg");
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

.message {
    font: var(--body-medium);
    resize: none;
    padding: 0.75rem 1.5rem;
    height: 15rem;
    border-radius: 0.5rem;
    border: 1px solid var(--gray-500);
}

.consent {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.consent__check {
    appearance: none;
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0.375rem;
    border: 1px solid var(--gray-500);
    border-radius: 0.125rem;
}

.consent__check:checked {
    background-image: url("./assets/images/icon-checkbox-check.svg");
    background-position: center;
    border: none;
}

.submit {
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 0.5rem;
    font: var(--body-medium-bold);
    background: var(--green-600);
    color: var(--white);
}

.submit:hover,
.submit:focus {
    background: var(--gray-900);
}

input:hover {
    border-color: var(--green-600);
}

footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
}

.attribution {
    font-size: 0.6875rem;
    text-align: center;
}
.attribution a {
    color: hsl(228, 45%, 44%);
}

.error {
    font: var(--body-small);
    color: var(--red);
}

.error__outline {
    border: 1px solid var(--red) !important;
}

.invisible {
    display: none;
}

.sr {
    clip-path: inset(100%);
    clip: rect(0 0 0 0);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@media screen and (min-width: 40rem) {
    section {
        padding: 2.5rem;
    }

    .name {
        flex-direction: row;
    }

    .query__list {
        flex-direction: row;
    }

    .message {
        height: 8.25rem;
    }
}

@media screen and (min-width: 48rem) {
    section {
        max-width: 46rem;
    }

    .message {
        height: 6.5625rem;
    }
}

/* The snackbar - position it at the bottom and in the middle of the screen */
#toast {
    visibility: hidden;
    width: calc(100% - 3rem);
    max-width: 31.25rem;
    background-color: var(--gray-900);
    color: var(--white);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin: 1.5rem;
    position: fixed; 
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1; 
    left: calc(50%);
    top: 0;
    transform: translateX(calc(-50% - 1.5rem));
}

.success {
    display: flex;
    gap: 0.5rem;
}

.success__message {
    font: var(--body-medium-bold);
}

.success__description {
    font: var(--body-small);
    color: var(--green-200);
}

/* Show the snackbar when clicking on a button (class added with JavaScript) */
#toast.show {
    visibility: visible; /* Show the snackbar */
    /* Add animation: Take 0.5 seconds to fade in and out the snackbar.
    However, delay the fade out process for 2.5 seconds */
    -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

/* Animations to fade the snackbar in and out */
@-webkit-keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@-webkit-keyframes fadeout {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes fadeout {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
