/* ============================================================
   EsencialGPS · Blog (home, archive, single post)
   Usa los tokens de marketing.css (--accent, --bg-1, --fg-1, etc.)
   Auto-adapta a tema oscuro/claro vía [data-theme="dark"].
   ============================================================ */

/* ---------- Wrapper del blog: respiro contra el footer ----------
   Defensivo: aunque el grid y la paginación tengan sus márgenes,
   asegura que cuando termine el contenido haya espacio antes del
   footer oscuro (consistente entre home.php, archive.php, page-blog.php
   y single.php). */
.eg-blog-wrap {
    padding-bottom: 64px;
}

/* ---------- HERO del blog feed/archive ---------- */
.blog-hero {
    padding: 64px 0 32px;
    text-align: center;
    border-bottom: 1px solid var(--border-1);
    margin-bottom: 48px;
}
.blog-hero .eyebrow-light {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(29, 111, 229, 0.10);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    border-radius: 999px;
    margin-bottom: 16px;
}
.blog-hero h1 {
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin: 0 0 16px;
    color: var(--fg-1);
}
.blog-hero p {
    font-size: clamp(15px, 1.6vw, 18px);
    color: var(--fg-3);
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ---------- Breadcrumb (single + archive) ---------- */
.blog-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--fg-3);
    margin-bottom: 24px;
}
.blog-breadcrumb a {
    color: var(--fg-3);
    text-decoration: none;
    transition: color .15s var(--ease);
}
.blog-breadcrumb a:hover { color: var(--accent); }
.blog-breadcrumb .sep { opacity: 0.5; }
.blog-breadcrumb .current { color: var(--fg-1); font-weight: 600; }

/* ---------- Tabs de categorías destacadas (opcional) ----------
   Se renderiza solo si el admin asignó un menú a la location `blog_nav`.
   Layout: pills horizontales con scroll horizontal en mobile. */
.blog-tabs {
    display: flex;
    gap: 8px;
    margin: -16px 0 32px;
    padding-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
}
.blog-tabs::-webkit-scrollbar { height: 4px; }
.blog-tabs::-webkit-scrollbar-thumb { background: var(--border-1); border-radius: 2px; }
.blog-tab {
    flex-shrink: 0;
    padding: 8px 18px;
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    border-radius: 999px;
    color: var(--fg-2);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all .15s var(--ease);
    white-space: nowrap;
}
.blog-tab:hover {
    background: var(--bg-2);
    border-color: var(--accent);
    color: var(--accent);
}
.blog-tab.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ---------- Grid de posts ---------- */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 28px;
    margin: 0 0 64px;
}

/* Card de post */
.blog-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    transition: all .22s var(--ease);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.blog-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 16px 32px rgba(29, 111, 229, 0.15), 0 4px 12px rgba(0,0,0,0.05);
}
.blog-card-image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-2) 0%, var(--bg-3, var(--bg-2)) 100%);
    position: relative;
}
.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .4s var(--ease);
}
.blog-card:hover .blog-card-image img {
    transform: scale(1.04);
}
.blog-card-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    opacity: 0.4;
    background: linear-gradient(135deg, var(--bg-2) 0%, rgba(29,111,229,0.08) 100%);
}
.blog-card-body {
    padding: 22px 24px 24px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 12px;
}
.blog-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--fg-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.blog-card-meta .cat {
    color: var(--accent);
}
.blog-card-meta .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--fg-3);
    opacity: 0.5;
}
.blog-card-title {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--fg-1);
    margin: 0;
    letter-spacing: -0.01em;
    /* Limitar a 3 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.blog-card-excerpt {
    font-size: 14px;
    line-height: 1.55;
    color: var(--fg-3);
    margin: 0;
    /* Limitar a 2 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.blog-card-cta {
    margin-top: auto;
    padding-top: 8px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.blog-card-cta svg {
    width: 14px;
    height: 14px;
    transition: transform .22s var(--ease);
}
.blog-card:hover .blog-card-cta svg {
    transform: translateX(4px);
}

/* ---------- Mensaje empty state ---------- */
.blog-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--fg-3);
}
.blog-empty svg {
    width: 64px;
    height: 64px;
    opacity: 0.35;
    margin: 0 auto 20px;
    color: var(--accent);
}
.blog-empty p {
    font-size: 16px;
    margin: 0;
}

/* ---------- Paginación ----------
   margin top da aire respecto al último card; margin bottom evita
   que pegue al footer (era 0 → se veía aplastada con la franja oscura). */
.blog-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 56px 0 80px;
    flex-wrap: wrap;
}
.blog-pagination a,
.blog-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    color: var(--fg-2);
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
    transition: all .15s var(--ease);
}
.blog-pagination a:hover {
    background: var(--bg-2);
    border-color: var(--accent);
    color: var(--accent);
}
.blog-pagination .current {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ============================================================
   SINGLE POST — layout editorial estilo Medium/Notion/Substack
   Usamos .eg-single-post (NO .single-post) porque WordPress añade
   automáticamente la clase `single-post` al <body> en posts indi-
   viduales — un max-width sobre eso achicaría toda la página.
   ============================================================ */
.eg-single-post {
    max-width: 720px;        /* ancho confortable de lectura (~70 chars) */
    margin: 0 auto;
    padding: 48px 0 96px;
}

/* Breadcrumb más arriba — un poco más compacto */
.eg-single-post > .blog-breadcrumb {
    margin-bottom: 36px;
}

/* Header */
.eg-single-post-header {
    margin-bottom: 40px;
}
.eg-single-post-meta-top {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--fg-3);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.eg-single-post-meta-top .cat {
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 12px;
    text-decoration: none;
    padding: 4px 10px;
    background: rgba(29, 111, 229, 0.10);
    border-radius: 999px;
    transition: all .15s var(--ease);
}
.eg-single-post-meta-top .cat:hover {
    background: var(--accent);
    color: #fff;
}
.eg-single-post-meta-top .sep { opacity: 0.4; }
.eg-single-post-title {
    font-size: clamp(32px, 4.8vw, 56px);
    font-weight: 800;
    letter-spacing: -0.028em;
    line-height: 1.08;
    margin: 0 0 24px;
    color: var(--fg-1);
}
.eg-single-post-author {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
    border-top: 1px solid var(--border-1);
    border-bottom: 1px solid var(--border-1);
    margin-bottom: 40px;
}
.eg-single-post-author-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover, var(--accent)) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(29, 111, 229, 0.25);
}
.eg-single-post-author-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}
.eg-single-post-author-name {
    font-weight: 700;
    color: var(--fg-1);
    font-size: 15px;
}
.eg-single-post-author-meta {
    font-size: 12px;
    color: var(--fg-3);
    letter-spacing: 0.01em;
}

/* ===== Featured image hero =====
   Aspect-ratio responsive: 16/9 en desktop, 4/3 en mobile para
   que imágenes "casi cuadradas" no queden cortadas extrañas.
   Si la imagen real es cuadrada/vertical, contain en lugar de cover. */
.eg-single-post-hero {
    margin: 0 -40px 48px;    /* ligeramente más ancho que el texto, look editorial */
    border-radius: 18px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--bg-2) 0%, rgba(29,111,229,0.04) 100%);
    position: relative;
    box-shadow: 0 12px 32px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
}
.eg-single-post-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.eg-single-post-hero-caption {
    font-size: 13px;
    color: var(--fg-3);
    text-align: center;
    margin: -32px -40px 48px;
    padding: 0 20px;
    font-style: italic;
}

/* ===== Contenido editorial (prose) ===== */
.eg-single-post-content {
    font-size: 18px;
    line-height: 1.78;
    color: var(--fg-2);
    /* Mejor renderizado de tipografía en cuerpos largos */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
.eg-single-post-content > * + * { margin-top: 1.4em; }

/* Lead paragraph: el primer párrafo, ligeramente más grande y prominente */
.eg-single-post-content > p:first-of-type {
    font-size: 21px;
    line-height: 1.6;
    color: var(--fg-1);
    font-weight: 400;
    letter-spacing: -0.005em;
}

/* Headings con buen "respiro" y scroll-margin para anchor links */
.eg-single-post-content h2,
.eg-single-post-content h3,
.eg-single-post-content h4 {
    scroll-margin-top: 100px;
    letter-spacing: -0.02em;
    color: var(--fg-1);
}
.eg-single-post-content h2 {
    font-size: 32px;
    font-weight: 800;
    margin: 2.4em 0 0.7em;
    line-height: 1.22;
}
.eg-single-post-content h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 2em 0 0.5em;
    line-height: 1.28;
}
.eg-single-post-content h4 {
    font-size: 19px;
    font-weight: 700;
    margin: 1.7em 0 0.4em;
}
.eg-single-post-content p {
    margin: 0 0 1.2em;
}
.eg-single-post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1.5px;
    text-decoration-color: rgba(29, 111, 229, 0.4);
    transition: text-decoration-color .15s var(--ease);
}
.eg-single-post-content a:hover {
    text-decoration-thickness: 2px;
    text-decoration-color: var(--accent);
}

/* Imágenes inline — cualquier <img> dentro del contenido se centra,
   redondea y respeta su aspect ratio nativo. Las alineadas a izq/der
   con clases de WP (alignleft, alignright) flotan correctamente. */
.eg-single-post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
    margin: 2em auto;
    display: block;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.eg-single-post-content .alignleft  { float: left;  margin: 0.5em 24px 1em 0; max-width: 50%; }
.eg-single-post-content .alignright { float: right; margin: 0.5em 0 1em 24px; max-width: 50%; }
.eg-single-post-content .aligncenter { margin-left: auto; margin-right: auto; }
.eg-single-post-content .wp-caption,
.eg-single-post-content figure {
    margin: 2em 0;
    max-width: 100% !important;
}
.eg-single-post-content figure img { margin: 0 auto; }
.eg-single-post-content figcaption,
.eg-single-post-content .wp-caption-text {
    font-size: 13px;
    color: var(--fg-3);
    text-align: center;
    margin-top: 10px;
    font-style: italic;
    line-height: 1.5;
}
/* Galería WP nativa */
.eg-single-post-content .wp-block-gallery img {
    margin: 0;
    box-shadow: none;
}

/* Blockquote estilo pull-quote editorial */
.eg-single-post-content blockquote {
    border: none;
    border-left: 4px solid var(--accent);
    background: linear-gradient(90deg, rgba(29, 111, 229, 0.06) 0%, transparent 100%);
    margin: 2em 0;
    padding: 20px 28px;
    border-radius: 0 12px 12px 0;
    font-size: 19px;
    line-height: 1.55;
    font-style: italic;
    color: var(--fg-1);
    font-weight: 500;
}
.eg-single-post-content blockquote p { margin: 0 0 0.5em; }
.eg-single-post-content blockquote p:last-child { margin-bottom: 0; }
.eg-single-post-content blockquote cite {
    display: block;
    font-style: normal;
    font-size: 14px;
    color: var(--fg-3);
    margin-top: 10px;
    font-weight: 600;
}

/* Listas */
.eg-single-post-content ul,
.eg-single-post-content ol {
    padding-left: 1.6em;
    margin: 0 0 1.2em;
}
.eg-single-post-content ul li,
.eg-single-post-content ol li {
    margin: 0.5em 0;
    padding-left: 0.3em;
}
.eg-single-post-content ul li::marker { color: var(--accent); }

/* Code y pre */
.eg-single-post-content code {
    background: var(--bg-2);
    color: var(--accent);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.9em;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-weight: 600;
}
.eg-single-post-content pre {
    background: var(--bg-2);
    color: var(--fg-1);
    padding: 22px 24px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 2em 0;
    font-size: 14px;
    line-height: 1.55;
    border: 1px solid var(--border-1);
}
.eg-single-post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-weight: 400;
}

/* Separadores y tablas */
.eg-single-post-content hr {
    border: none;
    margin: 3em auto;
    width: 60px;
    height: 4px;
    background: var(--border-1);
    border-radius: 2px;
}
.eg-single-post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 15px;
    border: 1px solid var(--border-1);
    border-radius: 10px;
    overflow: hidden;
}
.eg-single-post-content th,
.eg-single-post-content td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-1);
}
.eg-single-post-content tr:last-child td { border-bottom: none; }
.eg-single-post-content th {
    background: var(--bg-2);
    font-weight: 700;
    color: var(--fg-1);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Tags */
.eg-single-post-tags {
    margin-top: 40px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.eg-single-post-tags .tag {
    padding: 6px 14px;
    background: var(--bg-2);
    color: var(--fg-2);
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    text-decoration: none;
    transition: all .15s var(--ease);
    border: 1px solid var(--border-1);
}
.eg-single-post-tags .tag:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Share buttons */
.eg-single-post-share {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 40px 0 0;
    padding: 24px 0;
    border-top: 1px solid var(--border-1);
    border-bottom: 1px solid var(--border-1);
}
.eg-single-post-share-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 6px;
}
.eg-single-post-share a {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    color: var(--fg-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all .15s var(--ease);
}
.eg-single-post-share a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-2px);
}
.eg-single-post-share svg {
    width: 16px;
    height: 16px;
}

/* ===== Prev/Next nav con thumbnail =====
   Layout: thumb 80x80 + (label + título) en columna.
   En .next el thumb va a la derecha invirtiendo el flexbox. */
.eg-single-post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin: 56px 0 0;
}
.eg-single-post-nav a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--border-1);
    border-radius: 14px;
    text-decoration: none;
    color: var(--fg-2);
    background: var(--bg-1);
    transition: all .2s var(--ease);
    overflow: hidden;
    min-width: 0;
}
.eg-single-post-nav a:hover {
    border-color: var(--accent);
    background: var(--bg-2);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(29, 111, 229, 0.10);
}
.eg-single-post-nav a.next {
    flex-direction: row-reverse;
    text-align: right;
}
.eg-single-post-nav .nav-thumb {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--bg-2) 0%, rgba(29,111,229,0.10) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    opacity: 0.85;
    transition: opacity .2s var(--ease);
}
.eg-single-post-nav a:hover .nav-thumb { opacity: 1; }
.eg-single-post-nav .nav-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.eg-single-post-nav .nav-thumb svg {
    width: 28px;
    height: 28px;
    opacity: 0.5;
}
.eg-single-post-nav .nav-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.eg-single-post-nav .nav-label {
    font-size: 11px;
    color: var(--fg-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}
.eg-single-post-nav a.next .nav-label { justify-content: flex-end; }
.eg-single-post-nav a:hover .nav-label { color: var(--accent); }
.eg-single-post-nav .nav-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg-1);
    line-height: 1.35;
    letter-spacing: -0.005em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Posts relacionados */
.related-posts {
    margin-top: 80px;
    padding-top: 56px;
    border-top: 1px solid var(--border-1);
}
.related-posts h2 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.015em;
    margin: 0 0 28px;
    color: var(--fg-1);
}
.related-posts .blog-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 22px;
    margin-bottom: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .blog-hero { padding: 48px 0 24px; margin-bottom: 32px; }
    .blog-grid { grid-template-columns: 1fr; gap: 22px; }
    .eg-single-post { padding: 28px 0 64px; }
    .eg-single-post-title { font-size: clamp(26px, 6.4vw, 38px); }
    /* En mobile el hero pierde el "outdent" para no producir overflow horizontal.
       Mantenemos 16:9 (no 4:3) para que las fotos —que la Routine descarga ya
       recortadas a 16:9— no pierdan los lados con object-fit: cover. */
    .eg-single-post-hero { margin-left: 0; margin-right: 0; border-radius: 14px; aspect-ratio: 16 / 9; }
    .eg-single-post-hero-caption { margin-left: 0; margin-right: 0; }
    .eg-single-post-content { font-size: 17px; line-height: 1.72; }
    .eg-single-post-content > p:first-of-type { font-size: 19px; }
    .eg-single-post-content h2 { font-size: 26px; }
    .eg-single-post-content h3 { font-size: 20px; }
    .eg-single-post-content img { margin: 1.5em auto; border-radius: 10px; }
    .eg-single-post-content blockquote { padding: 16px 20px; font-size: 17px; }
    .eg-single-post-nav { grid-template-columns: 1fr; gap: 12px; }
    /* Avatar más compacto */
    .eg-single-post-author { padding: 16px 0; margin-bottom: 32px; }
    .eg-single-post-author-avatar { width: 40px; height: 40px; font-size: 15px; }
}

/* ============================================================
   Dark mode (data-theme="dark" en <html>)
   Los tokens del marketing.css ya se auto-adaptan, esto es solo
   ajuste fino para sombras y blends.
   ============================================================ */
[data-theme="dark"] .blog-card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
[data-theme="dark"] .blog-card:hover {
    box-shadow: 0 16px 32px rgba(29, 111, 229, 0.25), 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .blog-card-image-placeholder {
    background: linear-gradient(135deg, var(--bg-2) 0%, rgba(29,111,229,0.15) 100%);
}
[data-theme="dark"] .eg-single-post-content blockquote {
    background: rgba(29, 111, 229, 0.08);
}
[data-theme="dark"] .eg-single-post-content code {
    background: rgba(29, 111, 229, 0.12);
}
[data-theme="dark"] .eg-single-post-content pre {
    background: rgba(0, 0, 0, 0.3);
}
