/* ==========================================
   Qué Cocino Hoy — Estilos custom
   Tailwind CDN cubre el 90%; aquí van
   los casos que no se pueden hacer inline.
   ========================================== */

/* ==========================================
   VARIABLES
   ========================================== */
:root {
  --naranja: #FF6B35;
  --naranja-dark: #e55a25;
  --crema:   #F7C59F;
  --fondo:   #EFEFD0;
  --azul:    #004E89;
  --azul-dark: #003d6b;
}

/* ==========================================
   BASE
   ========================================== */
html {
  scroll-behavior: smooth;
  /* Compensa el nav sticky (~60px) en navegación por anclas */
  scroll-padding-top: 68px;
}

/* Quitar outline por defecto y poner uno de marca */
*:focus-visible {
  outline: 3px solid var(--naranja);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Color de selección de texto */
::selection {
  background: var(--naranja);
  color: white;
}

/* Input: fondo blanco explícito (el body es #EFEFD0) */
input[type="text"] {
  background-color: white;
}

/* ==========================================
   HERO
   ========================================== */
.hero-section {
  position: relative;
  background-color: var(--naranja); /* fallback sólido */
  background-image:
    linear-gradient(
      160deg,
      rgba(255, 107, 53, 0.88) 0%,
      rgba(0, 78, 137, 0.60) 100%
    ),
    url('../img/hero-bg.jpg');
  background-size: cover;
  background-position: center;
  min-height: 380px;
}

/* Textura sutil sobre el hero cuando no hay imagen */
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
    circle at 20% 80%,
    rgba(255, 255, 255, 0.06) 0%,
    transparent 50%
  );
  pointer-events: none;
}

/* ==========================================
   SEPARADORES DE SECCIÓN
   ========================================== */

/* Sección buscador: fondo ligeramente más claro */
#buscador {
  background-color: white;
  border-radius: 0 0 2rem 2rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}

/* Sección inspiración: fondo del body */
#inspiracion {
  background-color: var(--fondo);
}

/* Sección menú: fondo blanco */
#menu {
  background-color: white;
}

/* ==========================================
   FILTROS DE DIETA
   ========================================== */
.btn-filtro {
  padding: 0.4rem 1.1rem;
  border-radius: 9999px;
  border: 2px solid var(--crema);
  background: white;
  color: #6b7280;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease,
              background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn-filtro:hover {
  border-color: var(--naranja);
  color: var(--naranja);
  transform: translateY(-1px);
}

.btn-filtro:active {
  transform: translateY(0);
}

.btn-filtro.activo {
  background: var(--naranja);
  border-color: var(--naranja);
  color: white;
}

/* ==========================================
   TARJETA DE RECETA
   ========================================== */
.tarjeta-receta {
  background: white;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  outline: none; /* gestionado por :focus-visible */
}

.tarjeta-receta:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.13);
}

.tarjeta-receta:active {
  transform: translateY(-2px);
}

/* Focus para navegación por teclado */
.tarjeta-receta:focus-visible {
  outline: 3px solid var(--naranja);
  outline-offset: 3px;
}

.tarjeta-receta img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background-color: var(--crema); /* placeholder mientras carga */
}

.tarjeta-receta .tarjeta-info {
  padding: 0.85rem 1rem 1rem;
}

.tarjeta-receta .tarjeta-nombre {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  color: #1f2937;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.tarjeta-receta .tarjeta-meta {
  font-size: 0.74rem;
  color: #9ca3af;
  line-height: 1.4;
}

/* ==========================================
   TAGS — SELECCIONADOS (nevera)
   ========================================== */
.tag-seleccionado {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--naranja);
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: 9999px;
  animation: popIn 0.15s ease;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.tag-seleccionado button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  opacity: 0.75;
  transition: opacity 0.1s;
}

.tag-seleccionado button:hover {
  opacity: 1;
}

/* ==========================================
   TAGS — NUBE DE POPULARES
   ========================================== */
.tag-nube {
  padding: 0.28rem 0.8rem;
  border-radius: 9999px;
  border: 1.5px solid var(--crema);
  background: white;
  color: #6b7280;
  font-size: 0.77rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease,
              background 0.12s ease;
}

.tag-nube:hover {
  background: #FFF5EE;
  border-color: var(--naranja);
  color: var(--naranja);
}

.tag-nube.activo {
  background: #FFF0E5;
  border-color: var(--naranja);
  color: var(--naranja);
  font-weight: 700;
}

/* ==========================================
   MODAL
   ========================================== */

/* El overlay solo anima cuando NO tiene la clase 'hidden' */
#modal-overlay:not(.hidden) {
  animation: fadeIn 0.18s ease forwards;
}

#modal-overlay:not(.hidden) #modal-box {
  animation: slideUp 0.22s ease forwards;
}

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

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Imagen del modal */
#modal-contenido .modal-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 1rem 1rem 0 0;
  display: block;
  background-color: var(--crema);
}

/* Scrollbar dentro del modal */
#modal-box {
  scrollbar-width: thin;
  scrollbar-color: var(--crema) transparent;
}

#modal-box::-webkit-scrollbar {
  width: 5px;
}

#modal-box::-webkit-scrollbar-track {
  background: transparent;
}

#modal-box::-webkit-scrollbar-thumb {
  background-color: var(--crema);
  border-radius: 9999px;
}

/* iOS: prevenir scroll del body bajo el modal */
body.modal-abierto {
  overflow: hidden;
  /* Safari móvil necesita esto */
  position: fixed;
  width: 100%;
}

/* ==========================================
   SPINNER DE CARGA
   ========================================== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

#spinner-grid > div {
  animation: spin 0.8s linear infinite;
}

/* ==========================================
   ANUNCIOS — PLACEHOLDERS
   ========================================== */
#ad-top  > div,
#ad-mid  > div {
  /* Reservar espacio fijo para evitar layout shift (CLS) */
  min-width: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px dashed #e5e7eb;
  border-radius: 4px;
}

/* En desktop mostrar el banner de 728px */
@media (min-width: 768px) {
  #ad-top > div,
  #ad-mid > div {
    width: 728px;
    height: 90px;
    min-width: 728px;
  }
}

/* ==========================================
   RESPONSIVE — AJUSTES MOBILE
   ========================================== */

/* Buscador: más cómodo con una mano */
@media (max-width: 480px) {
  #buscador {
    border-radius: 0;
  }

  .hero-section {
    min-height: 320px;
    padding-top: 4rem;
    padding-bottom: 4rem;
  }

  /* Botón cocinar: ancho completo en mobile */
  #btn-cocinar {
    width: 100%;
  }

  /* Modal: sin border-radius arriba en mobile (ocupa toda la pantalla) */
  #modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  #modal-box {
    border-radius: 1.25rem 1.25rem 0 0;
    max-height: 92vh;
  }

  #modal-contenido .modal-img {
    height: 180px;
    border-radius: 1.25rem 1.25rem 0 0;
  }
}

/* ==========================================
   UTILIDADES
   ========================================== */

/* Texto truncado a 2 líneas para nombres largos */
.tarjeta-nombre {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
