/* ==========================================================================
   BLOG — estilos propios de blog.php (usa los tokens de styles.css y web.css)
   ========================================================================== */

/* ---------- Hero (lista, artículo y 404) ---------- */
.blog-hero { padding-bottom: clamp(56px, 7vw, 96px); }
.blog-hero-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: clamp(32px, 6vw, 80px); align-items: center; }
.blog-hero-inner { position: relative; max-width: 880px; }

/* Último artículo en el hero: tarjeta clara inclinada, como la de perfil de Ingeniería */
.blog-hero-feature {
  --fg: #0d1626; --fg-2: #3a4658; --fg-3: #687384; --bd: #e6e2d8;
  position: relative; display: block; padding: 12px; border-radius: var(--r-lg);
  background: var(--surface); color: var(--fg); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.7);
  transform: rotate(1.2deg); transition: transform 600ms var(--ease-out);
  animation: rise 1000ms var(--ease-out) 240ms backwards;   /* "backwards": conserva la inclinación al terminar */
}
.blog-hero-feature:hover { transform: rotate(0deg) translateY(-4px); }
.blog-hero-feature-cover {
  position: relative; display: block; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 12px;
  background: radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--tone) 55%, transparent), transparent 60%), var(--navy);
}
.blog-hero-feature-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 900ms var(--ease-out); }
.blog-hero-feature:hover .blog-hero-feature-cover img { transform: scale(1.05); }
.blog-hero-feature-cover .hud-status { position: absolute; left: 12px; bottom: 12px; }
.blog-hero-feature-body { display: grid; gap: 10px; padding: 16px 10px 8px; }
.blog-hero-feature .post-tag { background: var(--tone-soft); color: var(--tone); }
.blog-hero-feature-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: var(--fg); }
.blog-hero-feature:hover .post-card-more .icon { transform: translateX(4px); }
.blog-hero .status-badge { display: inline-flex; animation: rise 900ms var(--ease-out) both; }
.blog-hero .hero-bio { max-width: 60ch; animation: rise 900ms var(--ease-out) 300ms both; }
.blog-post-title {
  margin: 18px 0 0; font-size: clamp(2rem, 1.2rem + 3vw, 3.4rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.03em;
  text-wrap: balance; animation: rise 900ms var(--ease-out) 120ms both;
}
.blog-not-found .contact-badge { font-size: 0.9rem; }

.blog-back {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 26px;
  font-size: 0.9rem; font-weight: 600; color: var(--fg-2); transition: color var(--dur) var(--ease-out);
}
.blog-back .icon { transition: transform var(--dur) var(--ease-spring); }
.blog-back:hover { color: #fff; }
.blog-back:hover .icon { transform: translateX(-4px); }

/* Categoría por color (mismo código que los servicios) */
.tone-build { --tone: var(--accent); --tone-soft: var(--accent-soft); --tone-on-dark: var(--accent-on-dark); }
.tone-grow { --tone: var(--signal); --tone-soft: var(--signal-soft); --tone-on-dark: #f5a524; }
.tone-run { --tone: var(--live); --tone-soft: var(--live-soft); --tone-on-dark: #3ddc84; }

.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.04em; color: var(--fg-3); }
.post-meta-hero { margin-top: 4px; }
.post-tag { padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: var(--tone-on-dark); font-weight: 500; }
.post-translation {
  padding: 3px 10px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 999px; color: #fff;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.post-translation:hover { border-color: var(--accent-on-dark); background: rgba(255, 255, 255, 0.08); }
.post-lang { padding: 2px 7px; border-radius: var(--r-sm); background: var(--navy); color: #fff; font-weight: 500; letter-spacing: 0.08em; }

.post-author { display: flex; align-items: center; gap: 12px; margin-top: 28px; font-size: 0.9rem; color: var(--fg-2); animation: rise 900ms var(--ease-out) 420ms both; }
.post-author img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--bd-strong); }
.post-author strong { color: var(--fg); font-weight: 600; }

/* ---------- Lista ---------- */
.blog-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.blog-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.blog-filter {
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--bd-strong);
  background: var(--surface); font-size: 0.9rem; font-weight: 500; color: var(--fg-2);
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.blog-filter:hover { border-color: var(--accent); color: var(--accent-strong); }
.blog-filter:active { transform: scale(0.96); }
.blog-filter.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.blog-count { font-family: var(--font-mono); font-size: 0.78rem; color: var(--fg-3); }
.blog-empty { padding: 40px 0; font-size: 1.1rem; color: var(--fg-2); }

.posts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.post-card[hidden] { display: none; }
.post-card {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--bd); border-radius: var(--r-md);
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.post-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--bd-strong); }
.post-card-link { display: flex; flex-direction: column; height: 100%; }
.post-card-link:focus-visible { border-radius: var(--r-md); }

/* Portada tipográfica: no depende de fotos */
.post-cover {
  position: relative; display: block; overflow: hidden; aspect-ratio: 16 / 9;
  background:
    radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--tone) 55%, transparent), transparent 60%),
    linear-gradient(rgba(139, 167, 255, 0.07) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(139, 167, 255, 0.07) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--navy);
}
.post-cover-cat {
  position: absolute; left: 18px; top: 16px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: var(--tone-on-dark);
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
}
.post-cover-mark {
  position: absolute; right: -6px; bottom: -0.28em;
  font-family: var(--font-display); font-weight: 800; font-size: clamp(7rem, 5rem + 6vw, 10rem); line-height: 1;
  color: transparent; -webkit-text-stroke: 1.5px color-mix(in srgb, var(--tone-on-dark) 60%, transparent);
  transition: transform 900ms var(--ease-out);
}
.post-card:hover .post-cover-mark { transform: translate(-10px, -6px) rotate(-4deg); }

/* Portada con imagen (cover: en el .md) */
.post-cover.has-image { background: var(--navy); }
.post-cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 900ms var(--ease-out); }
.post-card:hover .post-cover-img { transform: scale(1.05); }
.post-cover-cat { z-index: 1; }
.post-cover.has-image .post-cover-cat { background: rgba(10, 19, 34, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* En el artículo: la portada se monta sobre el borde inferior del hero */
.blog-article:has(.has-cover) .blog-post-hero { padding-bottom: clamp(110px, 13vw, 180px); }
.blog-post-section.has-cover { padding-top: 0; }
.post-hero-figure {
  position: relative; z-index: 2; overflow: hidden;
  margin: calc(-1 * clamp(80px, 10vw, 140px)) 0 clamp(40px, 5vw, 64px);
  border-radius: var(--r-lg); border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: var(--shadow-lg);
  animation: rise 1000ms var(--ease-out) 350ms both;
}
.post-hero-figure img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

.post-card-body { display: flex; flex-direction: column; flex: 1; gap: 10px; padding: 22px 24px 24px; }
.post-card-title { font-family: var(--font-display); font-size: 1.24rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: var(--fg); }
.post-card-desc { font-size: 0.93rem; line-height: 1.55; color: var(--fg-2); flex: 1; }
.post-card-more { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-weight: 600; font-size: 0.92rem; color: var(--accent-strong); }
.post-card-more .icon { width: 16px; height: 16px; transition: transform var(--dur) var(--ease-spring); }
.post-card:hover .post-card-more .icon { transform: translateX(4px); }

/* El más reciente de la lista: grande y en horizontal */
#postsGrid > .post-card:first-child:not([hidden]) { grid-column: span 2; }
#postsGrid > .post-card:first-child .post-card-link { flex-direction: row; }
#postsGrid > .post-card:first-child .post-cover { flex: 0 0 46%; aspect-ratio: auto; min-height: 280px; }
#postsGrid > .post-card:first-child .post-card-body { justify-content: center; padding: 32px; }
#postsGrid > .post-card:first-child .post-card-title { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); }
#postsGrid > .post-card:first-child .post-card-desc { flex: none; }

/* ---------- Artículo ---------- */
.blog-post-section { padding-top: clamp(48px, 6vw, 80px); }
.blog-post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(32px, 5vw, 72px); align-items: start; }

.prose { max-width: 68ch; font-size: 1.08rem; line-height: 1.75; color: var(--fg-2); }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { margin-top: 2.2em; font-size: clamp(1.35rem, 1.1rem + 0.9vw, 1.7rem); color: var(--fg); scroll-margin-top: 100px; }
.prose h3 { margin-top: 1.8em; font-size: 1.22rem; color: var(--fg); }
.prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
.prose strong { color: var(--fg); font-weight: 600; }
.prose a { color: var(--accent-strong); font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: text-decoration-color var(--dur) var(--ease-out); }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { display: grid; gap: 0.5em; padding-left: 0; }
.prose ul { list-style: none; }
.prose ul li { position: relative; padding-left: 22px; }
.prose ul li::before { content: ""; position: absolute; left: 0; top: 0.8em; width: 10px; height: 2px; background: var(--accent); }
.prose ol { list-style: decimal; padding-left: 1.4em; }
.prose ol li::marker { font-family: var(--font-mono); color: var(--accent); }
.prose blockquote { padding: 16px 22px; border-left: 3px solid var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--accent-soft); color: var(--fg); }
.prose code { padding: 2px 6px; border-radius: 4px; background: var(--paper); border: 1px solid var(--bd); font-family: var(--font-mono); font-size: 0.88em; }
.prose figure img { border-radius: var(--r-md); border: 1px solid var(--bd); }
.prose .table-wrap { overflow-x: auto; border: 1px solid var(--bd); border-radius: var(--r-md); }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.94rem; line-height: 1.5; }
.prose th, .prose td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--bd); }
.prose th { background: var(--paper); color: var(--fg); font-weight: 600; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose td:first-child { color: var(--fg); font-weight: 500; }
.prose figcaption { margin-top: 8px; font-size: 0.86rem; color: var(--fg-3); }

/* Caja lateral de contacto (zona oscura) */
.post-cta {
  --fg: #eef2f8; --fg-2: #b8c3d4; --fg-3: #8492a8; --bd: rgba(255, 255, 255, 0.12); --bd-strong: rgba(255, 255, 255, 0.2); --elev: rgba(255, 255, 255, 0.04);
  --focus-ring: 0 0 0 2px var(--navy), 0 0 0 4px var(--accent-on-dark);
  position: sticky; top: 100px; display: grid; gap: 14px; padding: 28px;
  border-radius: var(--r-lg); background: var(--navy); color: var(--fg); overflow: hidden; isolation: isolate;
}
.post-cta::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(320px circle at 100% 0%, rgba(47, 91, 230, 0.45), transparent 65%);
}
.post-cta h2 { font-size: 1.4rem; color: var(--fg); }
.post-cta p { color: var(--fg-2); font-size: 0.95rem; }
.post-cta .btn-whatsapp { width: 100%; margin: 4px 0 0; }

/* Más artículos */
.blog-related { border-top: 1px solid var(--bd); }
.blog-related-title { margin-bottom: 28px; font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .blog-hero-grid { grid-template-columns: minmax(0, 1fr); }
  .blog-hero-feature { max-width: 440px; transform: none; }
  .posts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .blog-post-layout { grid-template-columns: minmax(0, 1fr); }
  .post-cta { position: static; max-width: 560px; }
}
@media (max-width: 720px) {
  .posts-grid { grid-template-columns: minmax(0, 1fr); }
  #postsGrid > .post-card:first-child:not([hidden]) { grid-column: auto; }
  #postsGrid > .post-card:first-child .post-card-link { flex-direction: column; }
  #postsGrid > .post-card:first-child .post-cover { flex: none; aspect-ratio: 16 / 9; min-height: 0; }
  #postsGrid > .post-card:first-child .post-card-body { padding: 22px 24px 24px; }
  .prose { font-size: 1.02rem; }
}
