/* ======================================================
   BLOG & POST — LinkeContrata (mobile-first, minimal)
   Usa variables definidas en /index.css
   ====================================================== */

/* ====== Contenedores principales ====== */
.blog-page .content,
.post-page .content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* ====== Layout con sidebars de anuncios ====== */
.layout {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 160px;
  gap: 16px;
  align-items: start;
}
.left-ad,
.right-ad {
  position: sticky;
  top: 84px;
  height: fit-content;
  z-index: 5;
}
@media (max-width: 1200px) {
  .layout { grid-template-columns: 1fr; }
  .left-ad, .right-ad { display: none; }
}

/* Evita scroll horizontal accidental en móvil */
html, body { overflow-x: hidden; }

/* ======================================================
   LISTADO (Blog)
   ====================================================== */

/* ---------- HERO ---------- */
.blog-page .blog-hero {
  text-align: center;
  margin-bottom: 20px;
}
.blog-page .blog-hero h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 8px;
  color: var(--lc-primary-dark);
}
.blog-page .blog-hero p {
  color: var(--lc-text-muted);
  font-size: 1rem;
}
@media (min-width: 601px) {
  .blog-page .blog-hero h1 { font-size: 2.2rem; }
}

/* ---------- Filtros (chips) ---------- */
.blog-page .blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 16px 0 8px;
}
@media (max-width: 900px) {
  .blog-page .blog-filters {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 6px;
    mask-image: linear-gradient(to right, transparent 0, black 24px, black calc(100% - 24px), transparent 100%);
  }
}
.blog-page .chip {
  border: 1px solid var(--lc-border);
  background: var(--lc-surface);
  color: var(--lc-text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: box-shadow .2s, transform .1s, border-color .2s, background .2s, color .2s;
  flex: 0 0 auto;
}
.blog-page .chip:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .07); }
.blog-page .chip.active {
  border-color: transparent;
  background: var(--lc-primary);
  color: #fff;
  box-shadow: 0 2px 12px rgba(10, 102, 194, .25);
}
.blog-page .chip:focus-visible {
  outline: 3px solid var(--lc-accent);
  outline-offset: 2px;
}
.blog-page .chip.active:hover { background: #0b5db0; }

/* ---------- Grid de tarjetas ---------- */
.blog-page .blog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}
@media (min-width: 521px) {
  .blog-page .blog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}
@media (min-width: 1025px) {
  .blog-page .blog-grid {
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 22px;
  }
}

/* Tarjeta */
.blog-page .blog-card {
  background: var(--lc-surface);
  border: 1px solid var(--lc-border);
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
  outline: none;
}
@media (hover: hover) and (pointer: fine) {
  .blog-page .blog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(10, 102, 194, 0.14);
  }
}

.blog-page .blog-card .thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #e9eef6;
  transition: transform .25s ease;
}
@media (hover: hover) and (pointer: fine) {
  .blog-page .blog-card:hover .thumb { transform: scale(1.01); }
}

.blog-page .blog-card .card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 1025px) {
  .blog-page .blog-card .card-body { padding: 14px 14px 16px; }
}

.blog-page .pill {
  align-self: flex-start;
  background: rgba(10, 102, 194, .10);
  color: var(--lc-primary-dark);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 6px 10px;
  border-radius: 999px;
  letter-spacing: .2px;
  margin-right: 6px;
}

.blog-page .blog-card h2 {
  font-size: 1.02rem;
  line-height: 1.35;
}
@media (min-width: 1025px) {
  .blog-page .blog-card h2 { font-size: 1.1rem; }
}
.blog-page .blog-card h2 a {
  color: var(--lc-text);
  text-decoration: none;
}
.blog-page .blog-card h2 a:hover {
  color: var(--lc-primary);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.blog-page .excerpt {
  color: var(--lc-text-muted);
  font-size: .92rem;
}
@media (min-width: 1025px) {
  .blog-page .excerpt { font-size: .95rem; }
}

.blog-page .meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--lc-text-muted);
  font-size: .85rem;
}

/* CTA */
.blog-page .btn-go {
  display: inline-block;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--lc-primary);
  color: #fff !important;
  text-align: center;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  transition: transform .1s, background .2s, box-shadow .2s;
  box-shadow: 0 6px 12px rgba(10, 102, 194, .2);
}
.blog-page .btn-go:hover {
  background: #0b5db0;
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(10, 102, 194, .28);
}
.blog-page .btn-go:active { transform: scale(0.98); }

/* ---------- Paginación ---------- */
.blog-page .pager {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  row-gap: 6px;
}
.blog-page .pager a {
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid var(--lc-border);
  background: var(--lc-surface);
  color: var(--lc-text);
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}
.blog-page .pager a.active,
.blog-page .pager a:hover {
  background: var(--lc-primary);
  color: #fff;
  border-color: transparent;
}

/* ======================================================
   DETALLE (Post)
   ====================================================== */

/* ---------- Encabezado ---------- */
.post-page .article-header {
  max-width: 820px;
  margin: 0 auto 14px;
  padding-left: 8px;
  padding-right: 8px;
}
.post-page .breadcrumb {
  font-size: .9rem;
  color: var(--lc-text-muted);
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.post-page .breadcrumb a { color: var(--lc-primary); }

.post-page .post-title {
  font-size: 1.6rem;
  line-height: 1.2;
  margin-bottom: 6px;
  color: var(--lc-primary-dark);
}
@media (min-width: 601px) {
  .post-page .post-title { font-size: 2rem; }
}

.post-page .post-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--lc-text-muted);
  font-size: .9rem;
  flex-wrap: wrap;
  row-gap: 4px;
}

/* ---------- Hero (corrige inline max-height en móvil) ---------- */
.post-page figure { margin: 16px 0; }
#hero-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e9eef6;
  border-radius: 12px;
}
@media (max-width: 900px) {
  #hero-img {
    max-height: none !important; /* sobreescribe style inline del HTML */
    height: auto !important;
    width: 100% !important;
  }
}
.post-page figcaption {
  text-align: center;
  font-size: .9rem;
  color: var(--lc-text-muted);
  margin-top: 6px;
}

/* ---------- Cuerpo del artículo ---------- */
.post-page .article-body {
  max-width: 820px;
  margin: 8px auto 0;
  color: var(--lc-text);
  font-size: 1.02rem;
  line-height: 1.75;
  letter-spacing: .1px;
  padding: 0 8px;
}
@media (min-width: 801px) {
  .post-page .article-body {
    font-size: 1.05rem;
    line-height: 1.75;
    padding: 0;
  }
}
.post-page .article-body p { margin: 12px 0; }

.article-body a { color: var(--lc-primary); }

.article-body h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 6px;
  color: var(--lc-primary-dark);
}
.post-page .article-body h2 {
  font-size: 1.32rem;
  line-height: 1.3;
  margin: 20px 0 10px;
  color: var(--lc-primary-dark);
}
@media (min-width: 801px) {
  .post-page .article-body h2 { font-size: 1.45rem; }
}
.post-page .article-body h3 {
  font-size: 1.12rem;
  margin: 16px 0 8px;
  color: var(--lc-primary-dark);
}
@media (min-width: 801px) {
  .post-page .article-body h3 { font-size: 1.2rem; }
}

.post-page .article-body ul,
.post-page .article-body ol {
  padding-left: 1.1rem;
  margin: 10px 0 14px;
}
.post-page .article-body li { margin: 6px 0; }

/* Imágenes del cuerpo */
.post-page .article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

/* Citas y código */
.post-page .article-body blockquote {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--lc-primary);
  background: rgba(10,102,194,.06);
  border-radius: 8px;
  color: var(--lc-primary-dark);
}
.post-page .article-body pre,
.post-page .article-body code,
.post-page .article-body kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.post-page .article-body pre {
  background: #0b0f14;
  color: #e4e9ef;
  padding: 14px;
  border-radius: 10px;
  overflow: auto;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.post-page .article-body code:not(pre code) {
  background: rgba(10,102,194,.1);
  color: var(--lc-primary-dark);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Tablas responsivas (scroll horizontal interno) */
.post-page .article-body table {
  display: block;
  width: max-content; /* permite que sea más ancha que el contenedor */
  max-width: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: separate;
  border-spacing: 0;
  margin: 14px 0;
  border: 1px solid var(--lc-border);
  border-radius: 12px;
}
.post-page .article-body thead th {
  text-align: left;
  background: rgba(10,102,194,.08);
  color: var(--lc-primary-dark);
  padding: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.post-page .article-body tbody td {
  padding: 10px;
  border-top: 1px solid var(--lc-border);
  white-space: nowrap;
}
.post-page .article-body tbody tr:nth-child(even) {
  background: rgba(0,0,0,.02);
}

/* details/summary (FAQs/plantillas) */
.post-page .article-body details {
  border: 1px solid var(--lc-border);
  background: var(--lc-surface);
  border-radius: 12px;
  margin: 12px 0;
  overflow: hidden;
}
.post-page .article-body summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 700;
  list-style: none;
  position: relative;
}
.post-page .article-body summary::marker { display: none; }
.post-page .article-body summary::after {
  content: "▾";
  position: absolute;
  right: 14px;
  transition: transform .2s ease;
}
.post-page .article-body details[open] summary::after {
  transform: rotate(180deg);
}
.post-page .article-body details > *:not(summary) {
  padding: 0 14px 14px;
}

/* Compartir */
.post-page .share {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.post-page .share a {
  border: 1px solid var(--lc-border);
  border-radius: 10px;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--lc-text);
  background: var(--lc-surface);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  min-height: 40px;
  min-width: 44px; /* tap target */
  transition: background .2s, color .2s, transform .1s, box-shadow .2s;
}
.post-page .share a:hover {
  background: rgba(10,102,194,.1);
  color: var(--lc-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(10,102,194,.12);
}

/* Relacionados */
.post-page .related {
  max-width: 1000px;
  margin: 28px auto 0;
  padding-left: 16px;
  padding-right: 16px;
}
.post-page .related h3 {
  font-size: 1.4rem;
  margin-bottom: 10px;
  color: var(--lc-primary-dark);
}
.post-page .related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
@media (min-width: 521px) {
  .post-page .related-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
}
.post-page .related-card {
  background: var(--lc-surface);
  border: 1px solid var(--lc-border);
  border-radius: 12px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .08);
  overflow: hidden;
}
.post-page .related-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}
.post-page .related-card a {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--lc-text);
  border-top: 1px solid var(--lc-border);
  transition: color .2s, background .2s;
}
.post-page .related-card a:hover,
.post-page .related-card a:focus-visible {
  background: rgba(10,102,194,.06);
  color: var(--lc-primary-dark);
  text-decoration: none;
}

/* Botón volver */
.post-page .btn-back {
  display: inline-block;
  margin-top: 22px;
  padding: 10px 14px;
  background: var(--lc-primary);
  color: #fff !important;
  font-weight: 700;
  border-radius: 10px;
  text-decoration: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  transition: background .2s, transform .1s;
}
.post-page .btn-back:hover { background: #0b5db0; }
.post-page .btn-back:active { transform: translateY(0); }
.post-page .btn-back:focus-visible {
  outline: 3px solid var(--lc-accent);
  outline-offset: 2px;
}

/* ======================================================
   ADS — In-article (reserva de espacio sin CLS)
   ====================================================== */
.ads-in-article {
  background: linear-gradient(180deg, #fafbfd, #f7f9fc);
  margin: 20px 0;
  padding: 20px 0;
  text-align: center;
  border: 1px solid var(--lc-border);
  border-radius: 12px;
  display: grid;
  place-items: center;
  min-height: 260px; /* 300x250 */
}
@media (max-width: 480px) {
  .ads-in-article {
    min-height: 120px; /* 320x100 */
    padding: 14px 0;
  }
}

/* ======================================================
   Accesibilidad y preferencias
   ====================================================== */
.blog-page a:focus-visible,
.blog-page button:focus-visible,
.post-page a:focus-visible,
.post-page button:focus-visible {
  outline: 3px solid var(--lc-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Modo oscuro — si index.css ya cambia variables, sólo refinamos */
@media (prefers-color-scheme: dark) {
  .post-page .article-body pre {
    background: #0a0d12;
    color: #e7edf6;
  }
  .post-page .article-body blockquote { background: rgba(10,102,194,.14); }
  .blog-page .chip.active { box-shadow: 0 2px 12px rgba(10, 102, 194, .35); }
  .post-page .related-card { box-shadow: 0 5px 14px rgba(0,0,0,.35); }
}

/* ===== HOTFIX LAYOUT (añadir al final) ===== */

/* 1) Permitir que el área de contenido se encoja dentro del grid */
.main-content,
.content { min-width: 0; }

/* 2) Evitar scroll lateral global causado por elementos anchos */
html, body { overflow-x: hidden; }

/* 3) Héroe: forzar ratio y anular max-height inline en móvil */
#hero-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e9eef6;
  border-radius: 12px;
}
@media (max-width: 900px) {
  #hero-img {
    max-height: none !important; /* anula lo que haya quedado cacheado */
    height: auto !important;
    width: 100% !important;
  }
}

/* 4) Grids del post: permitir wraps y evitar desbordes largos */
.post-page .article-header,
.post-page .article-body { overflow-wrap: anywhere; }

/* 5) Tablas y pre: si son más anchos, que scrolleen en su propio contenedor */
.post-page .article-body table,
.post-page .article-body pre {
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* 6) Por si alguna sombra/borde provoca “empuje” del grid */
.layout > * { min-width: 0; }
