/* ============================================================
   BLOG — Clínica Bastidas
   Listado (home/archive) + detalle (single). Diseño SOTA para blog de
   clínica premium, sobre los tokens del design system B-Premium.
   Orden canónico del detalle: título antes que imagen destacada.
============================================================ */

/* ---- Hero de cabecera (listado y archivo) ---- */
.blog-hero {
  background: var(--warm-100);
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

/* Hero con imagen — overlay verde + texto blanco (contenido centrado) */
.blog-hero--image {
  position: relative;
  overflow: hidden;
  background: var(--brand-700);
  padding-block: clamp(3.5rem, 8vw, 5.5rem);
}
.blog-hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.blog-hero__bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
}
.blog-hero__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(26, 36, 32, 0.84) 0%,
    rgba(47, 93, 80, 0.8) 100%
  );
}
.blog-hero--image .container {
  position: relative;
  z-index: 2;
}
.blog-hero--image .section-label {
  color: var(--brand-100);
}
.blog-hero--image .section-title {
  color: #fff;
}
.blog-hero--image .section-lead {
  color: rgba(255, 255, 255, 0.9);
}

.blog-list {
  padding-block: var(--section-y);
}

/* ============================================================
   LISTADO — featured + grid
============================================================ */

/* Featured post: imagen + texto, horizontal en desktop. */
.blog-featured {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: var(--space-8);
  align-items: stretch;
  background: var(--ground);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  margin-bottom: var(--space-12);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease;
}
.blog-featured:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.blog-featured__media {
  margin: 0;
  min-height: 280px;
}
.blog-featured__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.blog-featured__body {
  padding: clamp(1.5rem, 3vw, 2.75rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-3);
}
.blog-featured__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  color: var(--ink-900);
}
.blog-featured__excerpt {
  font-size: var(--fs-lead);
  color: var(--ink-700);
  line-height: var(--lh-normal);
}
.blog-featured__more {
  margin-top: var(--space-2);
  font-weight: var(--fw-semibold);
  color: var(--brand-600);
}

/* Grid de tarjetas. */
.blog-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-8);
}

.post-card {
  background: var(--ground);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.post-card__link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.post-card__media {
  position: relative;
  margin: 0;
  aspect-ratio: 3 / 2;
  background: var(--brand-050);
}
.post-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.post-card__media-fallback {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
}
.post-card__badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
}
.post-card__body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}
.post-card__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: var(--fw-semibold);
  line-height: 1.25;
  color: var(--ink-900);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card__excerpt {
  font-size: var(--fs-small);
  color: var(--ink-500);
  line-height: var(--lh-normal);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* ---- Badge de categoría (verde marca, premium) ---- */
.cat-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-700);
  background: var(--ground);
  border: 1px solid var(--brand-100);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  width: max-content;
}

/* ---- Meta compartida ---- */
.post-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  color: var(--ink-500);
  font-weight: var(--fw-medium);
}
.post-meta__sep {
  opacity: 0.5;
}

/* ---- Paginación ---- */
.blog-pagination,
.pagination {
  margin-top: var(--space-12);
  display: flex;
  justify-content: center;
  gap: var(--space-2);
}
.blog-pagination .page-numbers,
.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-sm);
  color: var(--ink-700);
  text-decoration: none;
  font-weight: var(--fw-medium);
}
.blog-pagination .page-numbers.current,
.pagination .page-numbers.current {
  background: var(--brand-700);
  color: #fff;
  border-color: var(--brand-700);
}

.blog-empty {
  text-align: center;
  color: var(--ink-500);
  padding-block: var(--space-16);
}

/* ============================================================
   DETALLE — orden canónico (título antes que imagen)
============================================================ */
.post {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 var(--space-6) var(--section-y);
}

.post-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  font-family: var(--font-body);
  font-size: var(--fs-small);
  color: var(--ink-500);
  margin: var(--space-12) 0 var(--space-6);
}
.post-breadcrumb a {
  color: var(--ink-500);
  text-decoration: none;
}
.post-breadcrumb a:hover {
  color: var(--brand-600);
}

.post .cat-badge {
  margin-bottom: var(--space-4);
}

.post-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: var(--fw-bold);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--ink-900);
  margin-bottom: var(--space-4);
}

.post-byline {
  margin-bottom: var(--space-8);
}
.post-byline__author {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.post-byline__avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  object-fit: cover;
}

/* Imagen destacada: DESPUÉS del título, acotada (nunca a pantalla completa). */
.post-featured {
  margin: 0 0 var(--space-12);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.post-featured img {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  display: block;
}

/* ---- Cuerpo del artículo: medida estrecha, tipografía de lectura ---- */
.post-body {
  max-width: 68ch;
  margin: 0 auto;
  font-family: var(--font-body);
  font-size: 1.1875rem; /* ~19px */
  line-height: 1.7;
  color: var(--ink-900);
}
.post-body > * + * {
  margin-top: 1.4em;
}
.post-body h1,
.post-body h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: var(--fw-bold);
  line-height: 1.25;
  color: var(--brand-700);
  margin-top: 2.4em;
  margin-bottom: 0.6em;
}
.post-body h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  color: var(--ink-900);
  margin-top: 1.8em;
  margin-bottom: 0.4em;
}
.post-body h4 {
  font-weight: var(--fw-semibold);
  color: var(--ink-900);
  margin-top: 1.4em;
}
.post-body a {
  color: var(--brand-600);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.post-body strong {
  font-weight: var(--fw-semibold);
}
.post-body ul,
.post-body ol {
  padding-left: 1.4em;
}
.post-body li {
  margin: 0.4em 0;
}
.post-body li::marker {
  color: var(--brand-600);
}
.post-body blockquote {
  border-left: 4px solid var(--brand-600);
  background: var(--brand-050);
  padding: var(--space-4) var(--space-6);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--brand-700);
}
.post-body img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}
.post-body figcaption {
  font-size: var(--fs-small);
  color: var(--ink-500);
  text-align: center;
  margin-top: var(--space-2);
}
/* Botón de descarga (casos clínicos con PDF). */
.post-body .wp-block-button__link,
.post-body .wp-element-button {
  display: inline-block;
  background: var(--brand-700);
  color: #fff;
  font-weight: var(--fw-semibold);
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
}

/* ---- CTA de cierre ---- */
.post-cta {
  max-width: 68ch;
  margin: var(--space-16) auto 0;
  background: var(--brand-700);
  color: #fff;
  border-radius: var(--radius-xl);
  /* Padding generoso y simétrico para que el contenido respire. */
  padding: clamp(2.5rem, 6vw, 3.5rem) clamp(1.5rem, 5vw, 3rem);
  /* Centrado robusto: columna centrada → distancias verticales armónicas y
     simétricas, no dependientes solo de text-align. */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-6);
}
.post-cta__title {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  line-height: 1.2;
  font-weight: var(--fw-bold);
  margin: 0;
  /* El CTA va sobre fondo verde: forzar blanco (gana a la regla .post-body h2,
     que pinta los h2 del cuerpo en verde y dejaría el título ilegible). */
  color: #fff;
}
.post-cta__lead {
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.0625rem;
  line-height: 1.6;
  max-width: 46ch;
  margin: 0;
}
/* El botón recibe un poco más de aire arriba para separarlo del lead. */
.post-cta .btn {
  margin-top: var(--space-2);
}

/* ---- Relacionados ---- */
.related {
  background: var(--ground-alt);
  padding-block: var(--section-y);
}
.related__title {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  color: var(--ink-900);
  text-align: center;
  margin-bottom: var(--space-8);
}

/* ---- Responsive ---- */
@media (max-width: 800px) {
  .blog-featured {
    grid-template-columns: 1fr;
  }
  .blog-featured__media {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }
}
@media (max-width: 600px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }
}

/* Avatar local con iniciales (sustituye a Gravatar — RGPD, sin terceros). */
.post-byline__avatar--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-700);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
