:root {
    --red: hsl(4, 100%, 67%);
    --red-placeholder: hsl(3, 100%, 89%);
    --red-light: hsl(3, 100%, 93%);
    --blue-800: hsl(234, 29%, 20%);
    --blue-700: hsl(235, 18%, 26%);
    --grey: hsl(0, 0%,58%);
    --transparent-grey: hsla(0, 0%, 58%, 0.6);
    --white: hsl(0, 0%, 100%);

    --bittersweet: #FF5C61ff;
    --coral: #FE8A55ff;
}

@font-face {
    font-family: "Roboto Regular";
    src: url("./assets/fonts/Roboto-Regular.ttf");
}

@font-face {
    font-family: "Roboto Bold";
    src: url("./assets/fonts/Roboto-Bold.ttf");
}


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


body {
    font-family: "Roboto Regular";
    background-color: var(--blue-700);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

main {
    display: flex;
    justify-content: center;
    flex-direction: column; 
    flex-grow: 1;
    width: 100%;
    height: 100%;
}

button {
    font-family: "Roboto Regular";
}

/* --- THE MAIN BUTTON CONTAINER --- */
.newsletter-btn {
    border: none;
    padding: 0; /* Remove padding here, we'll control size with the layers */
    cursor: pointer;
    background-color: transparent; /* The button itself should be invisible */
    width: 100%;
    height: 3.5rem;
    position: relative; /* This is the anchor for all the absolute layers inside */
    border-radius: 10px; /* Keep the radius on the parent */
    overflow: hidden; /* This clips any children that stick out */
}

/* --- THE BASE BACKGROUND (Dark Blue) --- */
.newsletter-btn .newsletter-btn__bg {
    position: absolute;
    background-color: var(--blue-800);
    height: 100%;
    width: 100%;
    transition: opacity 0.2s ease-out;
    z-index: 1; /* Layer 1: At the bottom */
}

/* --- THE HOVER GRADIENT (The ::after pseudo-element) --- */
.newsletter-btn .newsletter-btn__bg::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* This is the gradient that will appear */
    background: linear-gradient(90deg, hsl(347, 100%, 66%) 0%, hsl(13, 100%, 64%) 90%);
    
    opacity: 0; /* Start invisible */
    z-index: 2; /* Layer 2: On top of the dark blue */
    
    /* THE FIX #1: Tell it WHAT and HOW to transition */
    transition: opacity 0.4s ease-out;
}

/* --- THE MAGIC: This happens on hover or focus --- */
.newsletter-btn:hover .newsletter-btn__bg::after,
.newsletter-btn:focus-within .newsletter-btn__bg::after {
    /* THE FIX #2: We are targeting the ::after element directly */
    opacity: 1; /* Make the gradient visible */
}


/* --- THE TEXT --- */
.newsletter-btn .newsletter-btn__text {
    position: relative; /* Needs to be positioned to use z-index */
    color: white;
    font-weight: bold;
    
    /* This ensures the text is centered within the button */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 17px;
    /* THE FIX #3: Put the text on top of everything! */
    z-index: 3; /* Layer 3: On the very top */
}


.newsletter__text-header {
    font-size: 3rem;
    font-family: "Roboto Bold";
    color: var(--blue-800);
}

.invisible {
    display: none !important;
}

.hidden {
    visibility: hidden;
    opacity: 0;
    width: 1;
    height: 1;
}

.newsletter-component {
    display: flex;
    flex-grow: 1;
}

.newsletter {
    padding: 20px;
    background-color: var(--white);
    flex-grow: 1;
    display: grid;
    grid-template-rows: 1fr 2fr;
}

.newsletter__img {
    border-radius: 20px;
    object-fit: fill;
    background: url("assets/images/illustration-sign-up-mobile.svg");
    background-position: center;
    background-repeat: repeat;
    background-size: cover;
}

.newsletter__content {
    flex-grow: 1;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.newsletter__content__header {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.newsletter__content ul div{
    display: flex;
    gap: 1rem;
    align-items: start;
}

.newsletter__content form {
    margin-top: 30px;
}

.newsletter__content form label
{
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.newsletter__content form label div {
    font-weight: bold;
    font-size: 0.9rem;
}

.newsletter__form__input {
    width: 100%;
    height: 3rem;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    border: 2px solid var(--transparent-grey);
}

.newsletter__form__input:focus {
    outline: none;
    border-color: var(--blue-700);
}    

.newsletter__form__input::placeholder {
    color: var(--grey);
}

.newsletter__content form button {
    margin-top: 30px;
}

.newsletter__success {
    background-color: var(--white);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 30px;
}

.newsletter__success-text {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.newsletter__success-text h2 {
    font-size: 3rem;
    font-family: "Roboto Bold";
    color: var(--blue-800);
}

.newsletter__success-text p {
    color: var(--blue-800);
}

/* HOW THE FUCK DO I PUT THIS ON THE BOTTOM OF THE CONTAINER  
WITHOUT AFFECTING THE SUCCESS-TEXT? */
.newsletter__success-btn {
    width: 100%;
    margin-top: 30px;
}

.newsletter__form__input-error {
    width: 100%;
    height: 3rem;
    border-radius: 10px;
    padding: 1rem 1.5rem;

    border: 2px solid var(--red);
    color: var(--red);
    background-color: var(--red-placeholder);
}

.newsletter__form__input-error::placeholder {
    color: var(--red);
}

.newsletter__form__input-error:focus {
    outline: none;
    width: 100%;
    height: 3rem;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    border: 2px solid var(--red);
}

.newsletter__form__label-error-msg {
    display: flex;
    justify-content: space-between;
}

.newsletter__form__label-error-msg .error-state-msg {
    color: var(--red);
}

/* Desktop media queries */
@media (min-width: 586px)
{
    main {
        padding: 40px 20px;
        justify-content: center;
        align-items: center;
    }

    .newsletter-component {
        flex-grow: 0;
    }

    .newsletter {
        height: auto;
        border-radius: 20px;
        width: fit-content;
        max-width: 900px;
        gap: 30px;
        padding: 20px;
        
        display: grid;
        grid-template-rows: 1fr;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "left right";        
    }

    .newsletter__content {
        grid-area: left;
        padding-top: 30px;
        padding-bottom: 30px;
    }

    .newsletter__img {
        grid-area: right;
        background: url("assets/images/illustration-sign-up-desktop.svg");
        background-position: center;
        background-repeat: repeat;
        background-size: cover;
    }

    .newsletter__img img {
        height: 100%;
        background-image: url("assets/images/illustration-sign-up-desktop.svg");
    }
    .newsletter__success {
        border-radius: 20px;
        padding: 60px;
        max-width: 500px;
    }
}

@media (max-width: 400px) {
    .newsletter {
        padding: 20px;
    }
}