/* =====================================================
   Tips Saludables – Hoja de estilos principal
   Prefijo: .ts-
   Paleta: --ts-primary, --ts-secondary, --ts-pastel
   ===================================================== */

/* --- Variables CSS --- */
:root {
  --ts-primary:    #0B5736;
  --ts-secondary:  #3BB77E;
  --ts-pastel:     #F9F4A5;
  --ts-white:      #ffffff;
  --ts-gray-light: #f4f6f8;
  --ts-gray:       #6b7280;
  --ts-text:       #1a202c;
  --ts-radius:     10px;
  --ts-shadow:     0 2px 12px rgba(0, 0, 0, 0.08);
  --ts-shadow-hover: 0 8px 28px rgba(11, 87, 54, 0.18);
  --ts-font:       'Quicksand', sans-serif;
  --ts-transition: transform .18s ease, box-shadow .18s ease;
}

/* --- Reset básico --- */
.ts-wrapper *,
.ts-wrapper *::before,
.ts-wrapper *::after {
  box-sizing: border-box;
}

.ts-wrapper {
  font-family: var(--ts-font);
  color: var(--ts-text);
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.ts-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 90px;
  background: var(--ts-white);
  border-radius: var(--ts-radius);
  box-shadow: var(--ts-shadow);
  overflow: hidden;
  border-top: 4px solid var(--ts-primary);
  align-self: flex-start;
}

.ts-sidebar__toggle {
  display: none; /* Oculto en desktop */
  width: 100%;
  background: var(--ts-primary);
  color: var(--ts-white);
  border: none;
  padding: .85rem 1.2rem;
  font-family: var(--ts-font);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  transition: background .2s ease;
}

.ts-sidebar__toggle:hover,
.ts-sidebar__toggle:focus-visible {
  background: var(--ts-secondary);
  outline: 3px solid var(--ts-pastel);
  outline-offset: 2px;
}

.ts-sidebar__toggle-icon {
  display: flex;
  transition: transform .25s ease;
}

.ts-sidebar__toggle[aria-expanded="true"] .ts-sidebar__toggle-icon {
  transform: rotate(180deg);
}

.ts-sidebar__panel {
  padding: 1.2rem;
}

.ts-sidebar__heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ts-primary);
  margin: 0 0 .85rem 0;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--ts-gray-light);
  display: none; /* Se muestra solo en desktop */
}

.ts-sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.ts-sidebar__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem .85rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ts-text);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}

.ts-sidebar__link:hover,
.ts-sidebar__link:focus-visible {
  background: var(--ts-gray-light);
  color: var(--ts-primary);
  outline: 2px solid var(--ts-secondary);
  outline-offset: 1px;
}

.ts-sidebar__link[aria-current="page"] {
  background: var(--ts-primary);
  color: var(--ts-white);
  font-weight: 700;
}

.ts-sidebar__link--all {
  color: var(--ts-primary);
  font-weight: 700;
  border: 1px solid var(--ts-gray-light);
}

.ts-sidebar__count {
  background: var(--ts-pastel);
  color: var(--ts-primary);
  font-size: .75rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 20px;
  min-width: 1.5rem;
  text-align: center;
}

.ts-sidebar__link[aria-current="page"] .ts-sidebar__count {
  background: rgba(255,255,255,.25);
  color: var(--ts-white);
}

/* =====================================================
   ÁREA PRINCIPAL
   ===================================================== */
.ts-main {
  flex: 1;
  min-width: 0;
}

/* =====================================================
   GRID DE POSTS
   ===================================================== */
.ts-grid {
  display: grid;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ts-grid--cols-3  { grid-template-columns: repeat(3, 1fr); }
.ts-grid--cols-4  { grid-template-columns: repeat(4, 1fr); }
.ts-grid--cols-5  { grid-template-columns: repeat(5, 1fr); }

/* =====================================================
   CARD
   ===================================================== */
.ts-card {
  background: var(--ts-white);
  border-radius: var(--ts-radius);
  box-shadow: var(--ts-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--ts-transition);
  height: 100%;
}

.ts-card:hover {
  transform: translateZ(0) scale(1.03);
  box-shadow: var(--ts-shadow-hover);
}

/* Imagen */
.ts-card__img-link {
  display: block;
  overflow: hidden;
  border-radius: calc(var(--ts-radius)) calc(var(--ts-radius)) 0 0;
  text-decoration: none;
}

.ts-card__img-wrap {
  aspect-ratio: 1200 / 492;
  overflow: hidden;
}

.ts-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}

.ts-card:hover .ts-card__image {
  transform: scale(1.06);
}

.ts-card__image-placeholder {
  width: 100%;
  aspect-ratio: 1200 / 492;
  background: linear-gradient(135deg, var(--ts-gray-light) 60%, var(--ts-pastel));
}

/* Cuerpo */
.ts-card__body {
  padding: 1.1rem 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  border-radius: 0 0 var(--ts-radius) var(--ts-radius);
}

.ts-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 .5rem 0;
  line-height: 1.3;
}

.ts-card__title-link {
  color: var(--ts-text);
  text-decoration: none;
  transition: color .15s ease;
}

.ts-card__title-link:hover,
.ts-card__title-link:focus-visible {
  color: var(--ts-primary);
  outline: 2px solid var(--ts-secondary);
  outline-offset: 3px;
  border-radius: 3px;
}

.ts-card__excerpt {
  font-size: .88rem;
  color: var(--ts-gray);
  line-height: 1.65;
  margin: 0 0 .9rem 0;
  flex: 1;
}

/* Chips / tags */
.ts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .9rem;
}

.ts-chip {
  background: var(--ts-pastel);
  color: var(--ts-primary);
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 20px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .02em;
  transition: background .15s ease, color .15s ease;
}

.ts-chip:hover,
.ts-chip:focus-visible {
  background: var(--ts-secondary);
  color: var(--ts-white);
  outline: 2px solid var(--ts-primary);
  outline-offset: 2px;
}

.ts-chip--cat {
  background: rgba(59, 183, 126, 0.12);
  color: var(--ts-secondary);
}

/* =====================================================
   BOTÓN "LEER MÁS"
   ===================================================== */
.ts-btn {
  display: inline-block;
  font-family: var(--ts-font);
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  padding: .65rem 1.4rem;
  border-radius: 50px;
  border: 2px solid currentColor;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .12s ease;
  cursor: pointer;
  align-self: flex-start;
}

.ts-btn:focus-visible {
  outline: 3px solid var(--ts-secondary);
  outline-offset: 3px;
}

.ts-btn--primary {
  background: var(--ts-primary);
  color: var(--ts-white);
  border-color: var(--ts-primary);
}

.ts-btn--primary:hover {
  background: var(--ts-secondary);
  border-color: var(--ts-secondary);
  color: var(--ts-white);
  box-shadow: 0 4px 16px rgba(59, 183, 126, 0.35);
  transform: translateY(-1px);
}

/* =====================================================
   PAGINACIÓN
   ===================================================== */
.ts-pagination {
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
}

.ts-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 .7rem;
  border-radius: 6px;
  text-decoration: none;
  font-family: var(--ts-font);
  font-size: .88rem;
  font-weight: 600;
  color: var(--ts-primary);
  background: var(--ts-white);
  border: 1.5px solid var(--ts-gray-light);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.ts-pagination .page-numbers:hover,
.ts-pagination .page-numbers:focus-visible {
  background: var(--ts-primary);
  color: var(--ts-white);
  border-color: var(--ts-primary);
  outline: 2px solid var(--ts-secondary);
  outline-offset: 2px;
}

.ts-pagination .page-numbers.current {
  background: var(--ts-primary);
  color: var(--ts-white);
  border-color: var(--ts-primary);
}

.ts-no-posts {
  font-family: var(--ts-font);
  color: var(--ts-gray);
  text-align: center;
  padding: 3rem 1rem;
}

/* =====================================================
   SCROLL INFINITO – Sentinel, Spinner, Estados
   ===================================================== */

/* Sentinel: contenedor del spinner */
.ts-sentinel {
  display: none;         /* El JS lo muestra según tenga más */
  align-items: center;
  justify-content: center;
  padding: 2rem 0 1rem;
  width: 100%;
}

/* Spinner de tres puntos animados */
.ts-spinner {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.ts-spinner span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ts-secondary);
  animation: ts-bounce 1.2s ease-in-out infinite both;
  display: block;
}

.ts-spinner span:nth-child(1) { animation-delay: 0s;    }
.ts-spinner span:nth-child(2) { animation-delay: .16s;  }
.ts-spinner span:nth-child(3) { animation-delay: .32s;  }

@keyframes ts-bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1;  }
}

/* Mensaje "Has visto todas las publicaciones" */
.ts-end-message {
  font-family: var(--ts-font);
  font-size: .85rem;
  color: var(--ts-gray);
  text-align: center;
  padding: .5rem 0;
}

/* Fade del grid al cambiar de categoría */
.ts-grid--fading {
  opacity: 0;
  transition: opacity .2s ease;
}

/* Categoría activa en sidebar */
.ts-sidebar__link--active {
  background: var(--ts-primary) !important;
  color: var(--ts-white) !important;
  font-weight: 700 !important;
}
.ts-sidebar__link--active .ts-sidebar__count {
  background: rgba(255,255,255,.25) !important;
  color: var(--ts-white) !important;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* Tablet: ≤1024px — 2 columnas + sidebar en fila */
@media (max-width: 1024px) {
  .ts-wrapper {
    gap: 1.5rem;
  }
  .ts-sidebar {
    width: 220px;
  }
  .ts-grid--cols-4,
  .ts-grid--cols-5 {
    grid-template-columns: repeat(2, 1fr);
  }
  .ts-grid--cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Móvil: ≤768px — 1 columna + sidebar como drawer */
@media (max-width: 768px) {
  .ts-wrapper {
    flex-direction: column;
    padding: 1rem .6rem;
    gap: 1rem;
  }

  .ts-sidebar {
    width: 100%;
    position: static;
    border-top: none;
    border-radius: var(--ts-radius);
  }

  .ts-sidebar__toggle {
    display: flex;
  }

  .ts-sidebar__heading {
    display: none;
  }

  /* Panel colapsado por defecto en móvil */
  .ts-sidebar__panel {
    display: none;
    padding: .8rem 1rem 1rem;
  }

  .ts-sidebar__panel.is-open {
    display: block;
  }

  .ts-grid--cols-3,
  .ts-grid--cols-4,
  .ts-grid--cols-5 {
    grid-template-columns: 1fr;
  }
}

/* Desktop grande: ≥1280px — layout sidebar a la derecha */
@media (min-width: 1280px) {
  .ts-sidebar__heading {
    display: block;
  }
}
