/* --- ESTILOS GENERALES --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: sans-serif; background: #fdfaf6; padding: 20px; color: #333; }
h1 { text-align: center; color: #5d4037; margin-bottom: 20px; }

/* --- CONTROLES (Buscador y Filtros) --- */
.controles { max-width: 1156px; margin: 0 auto 30px auto; display: flex; flex-direction: column; align-items: center; gap: 15px; }
#buscador { padding: 12px 20px; width: 100%; max-width: 500px; border: 1px solid #ccc; border-radius: 25px; font-size: 16px; outline: none; transition: border-color 0.3s; }
#buscador:focus { border-color: #5d4037; }
#filtros { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.btn-filtro { padding: 8px 15px; cursor: pointer; border: 1px solid #d7ccc8; background: white; border-radius: 20px; font-size: 14px; transition: all 0.2s; }
.btn-filtro:hover { background: #efebe9; }
.btn-filtro.activo { background: #5d4037; color: white; border-color: #5d4037; }

/* --- GRID DE RECETAS (Flexbox 3 columnas exactas) --- */
.grid-recetas { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 48px; /* Gutter exacto solicitado */
    max-width: 1156px; 
    margin: 0 auto; 
}

.receta-card { 
    background: white; 
    padding: 15px; 
    border-radius: 12px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    /* Calcula: 100% menos los dos gaps de 48px (96px total) dividido entre 3 */
    width: calc((100% - 96px) / 3); 
}
.receta-card:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.1); }

.grid-foto-plato { width: 100%; height: 250px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; }
.receta-card h3 { font-size: 1.2rem; margin-bottom: 8px; color: #4e342e; }
.tag { font-size: 0.8em; background: #e0f2f1; color: #00695c; padding: 4px 10px; border-radius: 12px; display: inline-block; font-weight: bold; }

/* --- MODAL / OVERLAY --- */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    opacity: 0; visibility: hidden;
    transition: opacity 0.4s ease;
    z-index: 998;
}
.modal-backdrop.visible { opacity: 1; visibility: visible; }

.modal {
    position: fixed;
    bottom: 0; left: 0; width: 100%; height: 80vh;
    background: white;
    z-index: 999;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
    overflow-y: auto; /* Permite scroll interno */
    transform: translateY(100%); /* Oculto abajo por defecto */
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}
.modal.visible { transform: translateY(0); }

/* Botón cerrar sticky */
.btn-cerrar {
    position: sticky;
    top: 20px;
    right: 20px;
    float: right;
    width: 40px; height: 40px;
    background: #f5f5f5;
    border: none; border-radius: 50%;
    font-size: 24px; color: #333;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 1000;
}
.btn-cerrar:hover { background: #e0e0e0; }

.modal-content { padding: 40px; max-width: 1000px; margin: 0 auto; clear: both; }

/* Layout interior del modal */
.modal-top { display: flex; gap: 40px; margin-bottom: 40px; }
.modal-col-izq { flex: 1; }
.modal-col-der { flex: 1; display: flex; flex-direction: column; justify-content: center; }

#modal-img-plato { width: 100%; border-radius: 12px; object-fit: cover; max-height: 400px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
#modal-titulo { font-size: 2rem; color: #3e2723; margin-bottom: 10px; }
#modal-categoria { margin-bottom: 25px; align-self: flex-start; }
.modal-col-der h3 { font-size: 1.2rem; color: #5d4037; margin-bottom: 15px; border-bottom: 2px solid #eee; padding-bottom: 5px; }
#modal-lista-ingredientes { list-style-position: inside; color: #555; line-height: 1.8; font-size: 1.1rem; }

.modal-bottom h3 { font-size: 1.5rem; color: #3e2723; margin-bottom: 20px; text-align: center; }
#modal-img-manuscrita { width: 100%; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 1px solid #eee; }

/* --- RESPONSIVE BASICO --- */
@media (max-width: 900px) {
    .receta-card { width: calc((100% - 48px) / 2); } /* 2 columnas en tablets */
    .modal-top { flex-direction: column; }
}
@media (max-width: 600px) {
    .receta-card { width: 100%; } /* 1 columna en móviles */
    .modal-content { padding: 20px; }
}