/* ========== CSS RESET ========== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============ BODY ============ */
body {
    font-family: 'Noto Serif', serif;
    margin: 0 auto;
    /* Hecho responsive */
    max-width: 1200px;
    width: 95%;
    min-height: 100dvh;
    background-color: #1a1a24;
    /* Color oscuro por si la imagen tarda en cargar */
    background-repeat: repeat-y;
    background-position: top center;
    background-image: url("assets/background.webp");
    color: #333;
    /* Texto principal oscuro */
}

/* =========== HEADER =========== */
.header {
    margin-bottom: 2rem;
    border-bottom: 2px solid #FDE68A;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.header__nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
}

.header__title {
    color: #FDE68A;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.header__cart {
    color: white;
    text-decoration: none;
    background: #d9534f;
    padding: 0.6rem 1.2rem;
    border-radius: 5px;
    font-weight: bold;
    font-family: system-ui, sans-serif;
    transition: background 0.3s;
}

.header__cart:hover {
    background: #c9302c;
}

.header__img {
    width: 100%;
    height: auto;
    display: block;
    border-top: 1px solid #333;
}

/* =========== SECTION =========== */
.section {
    display: flex;
    justify-content: center;
    margin: 2rem auto;
    /* Separa el buscador del header y de las cartas */
    width: 100%;
    max-width: 600px;
    padding: 0 1rem;
}

.section__input {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-family: inherit;
    color: #333;
    background-color: #FFFdf2;
    border: 3px solid #b58900;
    border-radius: 30px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.section__input:focus {
    outline: none;
    border-color: #FDE68A;
    box-shadow: 0 6px 15px rgba(253, 230, 138, 0.4);
    transform: translateY(-2px);
}

.section__input::placeholder {
    color: #888;
    font-style: italic;
}

/* ============ MAIN ============ */
.app {
    display: grid;
    /* Grid responsive: se adapta al ancho de la pantalla automáticamente */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
    justify-items: center;
    padding-bottom: 3rem;
}

/* ========= CARD COMPONENT ========= */
.app__article {
    border-radius: 12px;
    background: linear-gradient(145deg, #FFFdf2, #FDE68A);
    width: 100%;
    max-width: 320px;
    height: 580px;
    /* Altura fija para que la cuadrícula quede perfecta */
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.5);
    transition: transform 300ms ease, box-shadow 300ms ease;
    border: 4px solid #b58900;
}

.app__article:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0px 15px 25px rgba(0, 0, 0, 0.7);
}

.app__article__img {
    width: 75%;
    /* Ajustado para dar algo de aire a los lados */
    height: auto;
    border-radius: 5px;
    margin-bottom: 1rem;
    filter: drop-shadow(0px 5px 5px rgba(0, 0, 0, 0.4));
}

.app__article__h2 {
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 0.5rem;
    min-height: 2.5rem;
    /* Reserva espacio para títulos de 2 líneas */
    display: flex;
    align-items: center;
}

.app__article__p {
    font-size: 0.85rem;
    text-wrap: pretty;
    flex-grow: 1;
    /* Rellena el espacio vacío de la tarjeta */
    overflow-y: auto;
    /* Permite hacer scroll en descripciones muy largas */
    padding-right: 8px;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.6);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Estilizar la barra de scroll de la descripción */
.app__article__p::-webkit-scrollbar {
    width: 6px;
}

.app__article__p::-webkit-scrollbar-thumb {
    background-color: #b58900;
    border-radius: 10px;
}

/* ========================================================
   ESTILOS PARA EL BOTÓN (Para cuando modifiques tu JS)
   ======================================================== */
.app__article__button {
    width: 100%;
    padding: 12px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    margin-top: auto;
}

.app__article__btn:hover {
    background-color: #1a252f;
}

/* =========== DIALOG (MODAL) =========== */
.dialog {
    /* Centrado nativo en la pantalla cuando se abre con showModal() */
    margin: auto;
    padding: 0;
    border: 4px solid #b58900;
    border-radius: 12px;
    background: linear-gradient(145deg, #FFFdf2, #FDE68A);
    width: 90%;
    max-width: 750px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    color: #333;
}

/* Fondo oscuro y borroso detrás del modal */
.dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.dialog__wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2.5rem 2rem 2rem; /* Espacio extra arriba para la X */
    position: relative;
}

/* Diseño responsive: a partir de 600px, imagen izq y texto der */
@media (min-width: 600px) {
    .dialog__wrapper {
        flex-direction: row;
        align-items: flex-start;
    }
}

.dialog__close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #333;
    cursor: pointer;
    transition: color 0.3s, transform 0.2s;
    line-height: 1;
}

.dialog__close:hover {
    color: #d9534f;
    transform: scale(1.1);
}

.dialog__img {
    width: 100%;
    max-width: 260px;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    margin: 0 auto;
}

.dialog__info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
}

.dialog__title {
    font-size: 1.6rem;
    color: #1a1a24;
    border-bottom: 2px solid #b58900;
    padding-bottom: 0.5rem;
}

.dialog__desc-box {
    background: rgba(255, 255, 255, 0.6);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.dialog__desc {
    font-size: 1rem;
    line-height: 1.6;
    text-align: justify;
    max-height: 250px; /* Limita la altura del texto */
    overflow-y: auto;
    padding-right: 10px;
}

/* Barra de scroll personalizada para el texto del modal */
.dialog__desc::-webkit-scrollbar {
    width: 6px;
}
.dialog__desc::-webkit-scrollbar-thumb {
    background-color: #b58900;
    border-radius: 10px;
}

.dialog__btn {
    padding: 12px 24px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    margin-top: auto; /* Empuja el botón hacia abajo del todo */
    align-self: flex-start; /* Evita que el botón ocupe todo el ancho en PC */
}

.dialog__btn:hover {
    background-color: #1a252f;
}

/* =========== FOOTER =========== */
.footer {
    text-align: center;
    padding: 2rem;
    color: #FDE68A;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 10px 10px 0 0;
    margin-top: auto;
}