/* ==========================================================================
   blog.css — Estilos compartidos del blog y las publicaciones de 4d3.
   Reutiliza el sistema de diseño de index.html (ver DESIGN-SYSTEM.md):
   tricromía pastel rotativa, tipografía IBM Plex Sans/Mono, geometría del
   rombo y firma de barra de color. Lo usan /blog y las páginas de
   /publicaciones/.
   ========================================================================== */

:root {
    --pastel-green: #8BC990;
    --pastel-blue: #7BA3D8;
    --pastel-coral: #E8837B;
    --dark-green: #5A9960;
    --dark-blue: #5B83B8;
    --dark-coral: #C8635B;
    --white: #FFFFFF;
    --off-white: #FAFAFA;
    --gray-light: #E8E8E8;
    --gray-mid: #888888;
    --gray-dark: #333333;
    /* fallback; el JS lo ajusta a la altura real del navbar */
    --nav-h: 77px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overscroll-behavior-y: none;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    background: var(--white);
    color: var(--gray-dark);
    line-height: 1.6;
    overflow-x: hidden;
    /* deja hueco al navbar fijo (se ajusta por JS a la altura real) */
    padding-top: var(--nav-h);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ==========================================================================
   Navegación (idéntica a la landing)
   ========================================================================== */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

nav.scrolled {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
}

.nav-logo {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.nav-logo-img {
    height: 40px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--gray-dark);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color 0.3s ease;
}

.nav-links li:nth-child(1) a { color: var(--dark-green); }
.nav-links li:nth-child(1) a:hover { color: var(--pastel-green); }
.nav-links li:nth-child(2) a { color: var(--dark-blue); }
.nav-links li:nth-child(2) a:hover { color: var(--pastel-blue); }
.nav-links li:nth-child(3) a { color: var(--dark-coral); }
.nav-links li:nth-child(3) a:hover { color: var(--pastel-coral); }
.nav-links li:nth-child(4) a { color: var(--dark-green); }
.nav-links li:nth-child(4) a:hover { color: var(--pastel-green); }
.nav-links li:nth-child(5) a { color: var(--dark-blue); }
.nav-links li:nth-child(5) a:hover { color: var(--pastel-blue); }
.nav-links li:nth-child(6) a {
    background: linear-gradient(90deg, var(--pastel-green), var(--pastel-blue), var(--pastel-coral));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}
.nav-links li:nth-child(6) a:hover { animation: gradientShift 1s ease infinite; }

/* Enlace de la página actual: un rombo a su izquierda */
.nav-links a[aria-current="page"]::before {
    content: '◇';
    margin-right: 0.4em;
    font-size: 0.7em;
    vertical-align: middle;
}

/* Hamburguesa móvil (idéntica a la landing) */
.hamburger {
    display: none;
    background: var(--white);
    cursor: pointer;
    width: 44px;
    height: 44px;
    position: relative;
    z-index: 1100;
    transform: rotate(45deg);
    border: 2px solid var(--gray-mid);
    padding: 0;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--gray-dark);
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    transition: all 0.3s ease;
}

.hamburger span:nth-child(1) { top: 35%; }
.hamburger span:nth-child(2) { top: 50%; }
.hamburger span:nth-child(3) { top: 65%; }

.hamburger.active { border-color: var(--pastel-coral); }
.hamburger.active span:nth-child(1) { top: 50%; transform: translate(-50%, -50%) rotate(0deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { top: 50%; transform: translate(-50%, -50%) rotate(90deg); }

.nav-links.mobile-open {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: var(--white);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
}

.nav-links.mobile-open li {
    opacity: 0;
    transform: translateY(20px);
    animation: menuItemIn 0.4s ease forwards;
}

.nav-links.mobile-open li:nth-child(1) { animation-delay: 0.05s; }
.nav-links.mobile-open li:nth-child(2) { animation-delay: 0.1s; }
.nav-links.mobile-open li:nth-child(3) { animation-delay: 0.15s; }
.nav-links.mobile-open li:nth-child(4) { animation-delay: 0.2s; }
.nav-links.mobile-open li:nth-child(5) { animation-delay: 0.25s; }
.nav-links.mobile-open li:nth-child(6) { animation-delay: 0.3s; }

@keyframes menuItemIn {
    to { opacity: 1; transform: translateY(0); }
}

.nav-links.mobile-open a {
    font-size: 1.2rem;
    letter-spacing: 0.15em;
}

/* ==========================================================================
   Botones (idénticos a la landing)
   ========================================================================== */
.btn {
    display: inline-block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 1rem 2rem;
    border: 2px solid var(--pastel-blue);
    background: transparent;
    color: var(--dark-blue);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        var(--pastel-blue) 0px,
        var(--pastel-blue) 2px,
        transparent 2px,
        transparent 4px
    );
    transition: left 0.3s ease;
    z-index: -1;
}

.btn:hover::before { left: 0; }
.btn:hover { border-color: var(--pastel-blue); }

.btn-coral {
    border-color: var(--pastel-coral);
    color: var(--dark-coral);
}

.btn-coral::before {
    background: repeating-linear-gradient(
        0deg,
        var(--pastel-coral) 0px,
        var(--pastel-coral) 2px,
        var(--dark-coral) 2px,
        var(--dark-coral) 4px
    );
}

.btn-coral:hover { border-color: var(--pastel-coral); color: var(--white); }

/* ==========================================================================
   Cabecera común de blog / artículo
   ========================================================================== */
.section-number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--gray-mid);
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
    display: block;
}

.blog-hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem 2rem;
    text-align: center;
    position: relative;
}

.blog-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, var(--pastel-green), var(--pastel-blue), var(--pastel-coral));
}

.blog-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 300;
    line-height: 1.2;
    margin-bottom: 1.25rem;
}

.blog-title strong {
    font-weight: 600;
    background: linear-gradient(90deg, var(--pastel-green), var(--pastel-blue), var(--pastel-coral));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

.blog-subtitle {
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    color: var(--gray-mid);
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================================================
   Rejilla de publicaciones (índice del blog)
   ========================================================================== */
.blog-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem 6rem;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 2rem;
}

.post-card {
    display: flex;
    flex-direction: column;
    background: var(--white);
    padding: 2.5rem;
    border: 1px solid var(--gray-light);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    min-height: 260px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Barra de color izquierda que crece en hover (rotación verde-azul-coral) */
.post-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 0;
    transition: height 0.3s ease;
}

.post-card:nth-child(3n+1)::before { background: var(--pastel-green); }
.post-card:nth-child(3n+2)::before { background: var(--pastel-blue); }
.post-card:nth-child(3n)::before { background: var(--pastel-coral); }

.post-card:hover { transform: translateY(-5px); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08); }
.post-card:hover::before { height: 100%; }

.post-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.post-card-cat {
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--gray-light);
    color: var(--gray-dark);
}

.post-card:nth-child(3n+1) .post-card-cat { border-color: var(--pastel-green); color: var(--dark-green); }
.post-card:nth-child(3n+2) .post-card-cat { border-color: var(--pastel-blue); color: var(--dark-blue); }
.post-card:nth-child(3n) .post-card-cat { border-color: var(--pastel-coral); color: var(--dark-coral); }

.post-card-date { color: var(--gray-mid); }

.post-card-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

.post-card-excerpt {
    font-size: 0.95rem;
    color: var(--gray-mid);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.post-card-more {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.post-card:nth-child(3n+1) .post-card-more { color: var(--dark-green); }
.post-card:nth-child(3n+2) .post-card-more { color: var(--dark-blue); }
.post-card:nth-child(3n) .post-card-more { color: var(--dark-coral); }

.post-card-more svg { width: 15px; height: 15px; transition: transform 0.3s ease; }
.post-card:hover .post-card-more svg { transform: translateX(4px); }

/* Estados vacío / error / carga */
.posts-status {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--gray-mid);
    font-size: 1rem;
}

.posts-status[hidden] { display: none; }

/* ==========================================================================
   Página de artículo (/publicaciones/*.html)
   ========================================================================== */
.article {
    padding: 3rem 2rem 5rem;
}

.article-container {
    max-width: 760px;
    margin: 0 auto;
}

.article-back {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-mid);
    text-decoration: none;
    margin-bottom: 2.5rem;
    transition: color 0.3s ease, gap 0.2s ease;
}

.article-back svg { width: 15px; height: 15px; }
.article-back:hover { color: var(--dark-blue); gap: 0.7rem; }

.article-header {
    border-bottom: 1px solid var(--gray-light);
    padding-bottom: 2rem;
    margin-bottom: 2.5rem;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-mid);
}

.article-cat {
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--pastel-blue);
    color: var(--dark-blue);
}

.article-meta-sep { color: var(--gray-light); }

.article-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    font-weight: 300;
    line-height: 1.2;
    margin-bottom: 1.25rem;
}

.article-title strong { font-weight: 600; }

.article-lead {
    font-size: clamp(1.05rem, 2.5vw, 1.2rem);
    color: var(--gray-mid);
    line-height: 1.7;
}

/* Prosa del cuerpo del artículo */
.article-body {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--gray-dark);
}

.article-body > * + * { margin-top: 1.5rem; }

.article-body h2 {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 500;
    line-height: 1.3;
    margin-top: 3rem;
}

.article-body h3 {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 2.5rem;
}

.article-body a {
    color: var(--dark-blue);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    transition: color 0.3s ease;
}

.article-body a:hover { color: var(--pastel-blue); }

.article-body ul,
.article-body ol {
    padding-left: 1.5rem;
}

.article-body li { margin-bottom: 0.5rem; }

.article-body ul li::marker { color: var(--pastel-blue); content: '◇  '; }

.article-body blockquote {
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    color: var(--gray-dark);
    padding: 1.25rem 0 1.25rem 1.5rem;
    border-left: 4px solid var(--pastel-coral);
}

.article-body img {
    max-width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--gray-light);
}

.article-body figure { margin: 2rem 0; }

.article-body figcaption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--gray-mid);
    text-align: center;
    margin-top: 0.5rem;
}

.article-body code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
    background: var(--off-white);
    border: 1px solid var(--gray-light);
    padding: 0.1em 0.4em;
}

.article-body pre {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    background: var(--gray-dark);
    color: var(--white);
    padding: 1.5rem;
    overflow-x: auto;
    line-height: 1.6;
}

.article-body pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

.article-footer {
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--gray-light);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.article-sign {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--gray-mid);
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Footer (idéntico a la landing)
   ========================================================================== */
footer {
    background: var(--white);
    border-top: 1px solid var(--gray-light);
    padding: 3rem 2rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-logo { display: flex; align-items: center; }
.footer-logo-img { height: 100px; width: auto; }
.footer-text { font-size: 0.85rem; color: var(--gray-mid); }

.footer-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.footer-links a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--gray-mid);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color 0.3s ease;
}

.footer-links a:hover { color: var(--pastel-blue); }

.footer-prodicoop {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 2rem 0;
    border-top: 1px solid var(--gray-light);
    margin-top: 1rem;
}

.footer-prodicoop span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-mid);
}

.footer-prodicoop-img { height: 48px; width: auto; }

.color-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--pastel-green), var(--pastel-blue), var(--pastel-coral));
}

/* ==========================================================================
   Animaciones de scroll
   ========================================================================== */
.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    nav { padding: 1rem; }
    nav.scrolled { background: var(--white); backdrop-filter: none; -webkit-backdrop-filter: none; }
    .hamburger { display: block; }
    .nav-links { display: none; }

    .blog-hero { padding: 2.5rem 1.5rem 1.5rem; }
    .blog-main { padding: 2rem 1.5rem 4rem; }
    .article { padding: 2rem 1.5rem 4rem; }
    .post-card { padding: 2rem; }

    .footer-container { flex-direction: column; text-align: center; }
    .footer-logo-img { height: 60px; }
    .footer-links { gap: 1rem; }
}

@media (max-width: 480px) {
    :root { --nav-h: 69px; }
    nav { padding: 0.75rem; }
    .nav-logo-img { height: 32px; }
    .blog-hero { padding: 2rem 1rem 1rem; }
    .blog-main { padding: 1.5rem 1rem 3.5rem; }
    .article { padding: 1.5rem 1rem 3.5rem; }
    .post-card { padding: 1.75rem; }
    .footer-logo-img { height: 48px; }
}

/* Accesibilidad: respeta la preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
