/* ============================================================
   BLOG — componentes propios de la sección /blog
   Sobre los tokens de styles/styles.css. Sin dependencias nuevas.
   ============================================================ */

:root {
  --blog-nav-h: 74px;   /* altura de .nav__inner: la barra sticky se apoya debajo */
  --blog-bar-h: 60px;
}

/* ---------- Contenedor estrecho para lectura ---------- */
.container--narrow { max-width: 760px; }

/* ---------- Hero de blog: algo más bajo que el de FAQ ---------- */
.page-hero--blog { padding: clamp(8rem, 14vh, 10rem) 0 clamp(3rem, 5vw, 4.5rem); }
/* Los titulares de artículo son largos: reparte las líneas en vez de dejar
   una última línea huérfana. No afecta a las etiquetas cortas de categoría. */
.page-hero--blog h1 { max-width: 24ch; margin-inline: auto; text-wrap: balance; }
/* `.page-hero__eyebrow` vive en atlantepos.css: también lo usa /contacto/. */

/* ---------- Barra sticky de categorías + buscador ---------- */
.blog-bar {
  position: sticky;
  top: var(--blog-nav-h);
  z-index: 900;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.blog-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--blog-bar-h);
  padding: 0.6rem 0;
}
.blog-bar__cats {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.blog-bar__cats::-webkit-scrollbar { display: none; }

.cat-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t), background var(--t), border-color var(--t), transform var(--t);
}
.cat-pill:hover { border-color: rgba(0, 128, 181, 0.45); color: var(--brand); transform: translateY(-1px); }
.cat-pill.is-active { background: var(--brand-gradient); border-color: transparent; color: #fff; }

/* ---------- Buscador ---------- */
.blog-search { position: relative; flex: 0 0 auto; }
.blog-search__label {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap;
}
.blog-search__input {
  width: clamp(180px, 24vw, 280px);
  min-height: 38px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.blog-search__input::placeholder { color: var(--muted); }
.blog-search__input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 128, 181, 0.15);
}

/* Con búsqueda activa se oculta el contenido normal y solo quedan los resultados. */
body.blog-search-active .blog-main > *:not(#blog-search-results) { display: none; }
.blog-results { padding-top: clamp(2.5rem, 5vw, 4rem); }
.blog-results__status { margin: 0 0 1.5rem; color: var(--muted); font-size: 0.95rem; }

/* ---------- Rejilla y tarjetas ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

.post-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: rgba(0, 128, 181, 0.25); }

.post-card__media { display: block; aspect-ratio: 16 / 9; background: var(--bg-tint); overflow: hidden; }
.post-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.post-card:hover .post-card__media img { transform: scale(1.04); }

.post-card__body { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.35rem 1.5rem 1.6rem; }
.post-card__cat {
  align-self: flex-start;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  text-decoration: none;
}
.post-card__cat:hover { text-decoration: underline; }
.post-card__title { margin: 0; font-size: 1.2rem; line-height: 1.35; }
.post-card__title a { color: var(--text); text-decoration: none; }
.post-card__title a:hover { color: var(--brand); }
.post-card__excerpt { margin: 0; color: var(--muted); font-size: 0.98rem; }
.post-card__meta { margin: auto 0 0; padding-top: 0.4rem; color: var(--muted); font-size: 0.85rem; }

/* Primera tarjeta de la home: ocupa dos columnas cuando hay sitio. */
@media (min-width: 900px) {
  .post-card--featured { grid-column: span 2; flex-direction: row; }
  .post-card--featured .post-card__media { flex: 1 1 52%; aspect-ratio: auto; }
  .post-card--featured .post-card__body { flex: 1 1 48%; justify-content: center; padding: 2rem 2.25rem; }
  .post-card--featured .post-card__title { font-size: 1.55rem; }
}

/* ---------- Bloques por categoría en la home ---------- */
.blog-latest { background: var(--bg); }
.blog-cat-block:nth-of-type(even) { background: var(--bg-soft); }
.section-head--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  text-align: left;
}
.section-head--row .section-title,
.section-head--row .section-subtitle { margin-left: 0; margin-right: 0; }

/* ---------- Listado de categoría ---------- */
.blog-list__count { margin: 0 0 1.75rem; color: var(--muted); font-size: 0.95rem; }

/* ---------- Paginación ---------- */
.blog-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: clamp(2.5rem, 5vw, 4rem);
}
.blog-pagination__step {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.92rem;
  text-decoration: none;
  transition: border-color var(--t), color var(--t);
}
.blog-pagination__step:hover { border-color: var(--brand); color: var(--brand); }
.blog-pagination__step[rel="prev"] .icon { transform: rotate(180deg); }
.blog-pagination__step.is-disabled { opacity: 0.35; pointer-events: none; }

.blog-pagination__nums { display: inline-flex; gap: 0.35rem; }
.blog-pagination__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border-radius: var(--r-full);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.92rem;
  text-decoration: none;
  transition: background var(--t), color var(--t);
}
.blog-pagination__num:hover { background: var(--bg-tint); color: var(--brand); }
.blog-pagination__num.is-active { background: var(--brand-gradient); color: #fff; font-weight: 600; }

/* ---------- Artículo ---------- */
.blog-main--post { padding-top: 0; }

/* La miga y la fecha viven dentro del .page-hero oscuro (igual que en la vista
   de categoría), así que van en blanco translúcido, no en --muted. */
.page-hero--blog .post__meta {
  margin: 1rem 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.92rem;
}

.post__cover {
  margin: clamp(2.5rem, 5vw, 4rem) auto clamp(2rem, 4vw, 3rem);
  max-width: 1000px;
  padding: 0 1.5rem;
}
.post__cover img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

.post__body { font-size: 1.08rem; line-height: 1.75; color: var(--text); }
.post__body > * + * { margin-top: 1.35rem; }
.post__body h2 {
  margin-top: 2.75rem;
  font-size: clamp(1.35rem, 2.6vw, 1.7rem);
  line-height: 1.25;
}
.post__body h3 { margin-top: 2rem; font-size: 1.2rem; }
.post__body a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.post__body ul, .post__body ol { padding-left: 1.4rem; }
.post__body li + li { margin-top: 0.5rem; }
.post__body img { max-width: 100%; height: auto; border-radius: var(--r-md); }
.post__body figure { margin: 2rem 0; }
.post__body figure img { display: block; width: 100%; margin-inline: auto; }
.post__figure--sm { max-width: 520px; margin-inline: auto; }
.post__figure--shadow img { box-shadow: var(--shadow-md); }
.post__body figcaption {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}
.post__body blockquote {
  margin-left: 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--teal);
  color: var(--muted);
  font-style: italic;
}
.post__body code {
  padding: 0.15em 0.4em;
  border-radius: 0.35rem;
  background: var(--bg-tint);
  font-size: 0.92em;
}
.post__body table { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
.post__body th, .post__body td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }

.post__tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 2.5rem 0 0; padding: 0; list-style: none; }
.post__tag {
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-full);
  background: var(--bg-tint);
  color: var(--muted);
  font-size: 0.82rem;
}

.post__cta {
  margin: clamp(2.5rem, 5vw, 4rem) 0 0;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  border-radius: var(--r-lg);
  background: var(--brand-gradient-soft);
  border: 1px solid rgba(0, 128, 181, 0.18);
  text-align: center;
}
.post__cta h2 { margin: 0 0 0.6rem; font-size: clamp(1.25rem, 2.4vw, 1.6rem); }
.post__cta p { margin: 0 0 1.5rem; color: var(--muted); }

.blog-related { background: var(--bg-soft); margin-top: clamp(3rem, 6vw, 5rem); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .blog-bar__inner { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .blog-search__input { width: 100%; }
  .section-head--row { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px) {
  .post-grid { grid-template-columns: 1fr; }
  .blog-pagination { justify-content: center; }
  .blog-pagination__nums { order: -1; width: 100%; justify-content: center; }
}
