.sf-contact {
    position: relative;
    padding: 6rem 1.5rem 4rem;
    /* max-width: 900px; */
    /* margin: 0 auto; */
    color: white;
    isolation: isolate;

    &::before {
        content: "";
        position: absolute;
        inset: 0;
        background: radial-gradient(700px 400px at 20% 10%,
                rgba(127, 82, 255, 0.15),
                transparent 70%),
            radial-gradient(700px 400px at 80% 90%,
                rgba(0, 194, 255, 0.1),
                transparent 70%);
        opacity: 0.4;
        pointer-events: none;
        z-index: 0;
    }

    .contact-container {
        max-width: min(400px, 80vw);
        margin: 0 auto;
    }

    section {
        position: relative;
        z-index: 1;
    }

    .contact-hero {
        text-align: center;
        margin-bottom: 3rem;

        h1 {
            font-size: 2.3rem;
            font-weight: 600;
            margin-bottom: 0.6rem;
        }

        p {
            color: rgba(255, 255, 255, 0.75);
            font-weight: 300;
            max-width: 640px;
            margin: 0 auto;
            line-height: 1.6;
        }
    }

    .contact-cards {
        display: grid;
        gap: 1rem;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        margin-bottom: 3rem;

        .card {
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 16px;
            padding: 1.5rem;
            text-align: center;
            transition: transform 0.25s ease, box-shadow 0.25s ease;

            &:hover {
                transform: translateY(-3px);
                box-shadow: 0 0 0 2px rgba(127, 82, 255, 0.25),
                    0 14px 35px rgba(0, 0, 0, 0.45);
            }

            span {
                font-size: 2rem;
                color: #9cb6ff;
            }

            h3 {
                margin: 0.8rem 0 0.3rem 0;
                font-weight: 500;
                font-size: 1.1rem;
            }

            p {
                margin: 0;
                color: rgba(255, 255, 255, 0.7);
                font-weight: 300;

                a {
                    color: #9cb6ff;
                    text-decoration: none;

                    &:hover {
                        text-decoration: underline;
                    }
                }
            }
        }
    }

    .contact-form {
        form {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;

            .field {
                display: flex;
                flex-direction: column;
                gap: 0.4rem;

                label {
                    font-size: 0.9rem;
                    color: rgba(255, 255, 255, 0.7);
                }

                input,
                textarea,
                select {
                    font-family: inherit;
                    font-size: 1rem;
                    background: rgba(255, 255, 255, 0.05);
                    border: 1px solid rgba(255, 255, 255, 0.1);
                    border-radius: 10px;
                    padding: 0.65rem 0.8rem;
                    color: #fff;
                    resize: none;
                    transition: border-color 0.2s ease, background 0.2s ease;

                    &:focus {
                        outline: none;
                        border-color: rgba(127, 82, 255, 0.5);
                        background: rgba(255, 255, 255, 0.07);
                    }

                    &::placeholder {
                        color: rgba(255, 255, 255, 0.4);
                    }
                }

                select {
                    appearance: none;
                    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='white' width='16' height='16' viewBox='0 0 24 24'><path d='M7 10l5 5 5-5H7z'/></svg>");
                    background-repeat: no-repeat;
                    background-position: right 0.6rem center;
                    background-size: 14px;
                }
            }

            .submit-btn {
                align-self: center;
                border: none;
                border-radius: 10px;
                background: ghostwhite;
                color: black;
                padding: 0.75rem 1.6rem;
                font-weight: 500;
                cursor: pointer;
                transition: transform 0.2s ease, opacity 0.2s ease;

                &:hover {
                    transform: translateY(-2px);
                    opacity: 0.9;
                }
            }

            .field {
                position: relative;

                .error {
                    display: block;
                    color: #ff8a8a;
                    font-size: 0.8rem;
                    margin-top: 0.25rem;
                    font-weight: 400;
                }
            }

            .form-success {
                margin-top: 1rem;
                text-align: center;
                font-size: 0.95rem;
                color: #9cb6ff;
                opacity: 0;
                transition: opacity 0.3s ease;
            }

            .form-success.show {
                opacity: 1;
            }

            .form-success.error-msg {
                color: #ff8a8a;
            }

            /* Disabled button state */
            button.submit-btn:disabled {
                opacity: 0.65;
                cursor: wait;
            }
        }

        .note {
            text-align: center;
            margin-top: 1rem;
            color: rgba(255, 255, 255, 0.6);
            font-size: 0.9rem;
        }
    }
}

/* error text */
.field .error {
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: #ff9d9d;
    letter-spacing: 0.02em;
    opacity: 0.9;
    transform-origin: top;
}

/* subtle fade/slide on new errors */
@keyframes errorIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 0.9;
        transform: translateY(0);
    }
}

.error.animate-in {
    animation: errorIn 0.25s ease-out;
}

/* red glow + shake for invalids */
.invalid {
    border-color: rgba(255, 90, 90, 0.6) !important;
    box-shadow: 0 0 0 2px rgba(255, 90, 90, 0.15);
}

@keyframes fieldShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-4px);
    }

    40%,
    80% {
        transform: translateX(4px);
    }
}

.shake {
    animation: fieldShake 0.4s ease;
}

/* success + error general messages */
.form-feedback {
    margin-top: 1.2rem;
    text-align: center;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.3s ease;
    transform: translateY(4px);
}

.form-feedback.show {
    opacity: 1;
    transform: translateY(0);
}

.form-feedback.ok {
    color: #9cb6ff;
}

.form-feedback.err {
    color: #ff8a8a;
}

/* fancy button feedback */
.submit-btn {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, opacity 0.3s ease, box-shadow 0.3s;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(127, 82, 255, 0.35);
}

.submit-btn.sending::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #3b67ce, #7f52ff);
    animation: progressFlow 1.2s linear infinite;
    opacity: 0.25;
}

@keyframes progressFlow {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 300% 0;
    }
}


@media screen and (min-width: 640px) {
    .sf-contact .contact-container {
        max-width: min(640px, 80vw);
    }
}

@media screen and (min-width: 768px) {
    .sf-contact .contact-container {
        max-width: min(768px, 80vw);
    }
}

@media screen and (min-width: 1024px) {
    .sf-contact .contact-container {
        max-width: min(840px, 80vw);
    }
}

@media screen and (min-width: 1280px) {
    .sf-contact .contact-container {
        max-width: min(900px, 80vw);
    }
}
