/* ==========================================
   BLOG UI - Modern Space Theme
   Optimizado - Hero centrado y rendimiento mejorado
   ========================================== */

/* ==============================
   1. VARIABLES Y RESET GLOBAL
   ============================== */
:root {
    --bg-deep: #0b0f1a;
    --bg-surface: #111827;
    --bg-card-solid: #1a1f2e;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.12);
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --accent: #5c6eff;
    --accent-glow: rgba(92, 110, 255, 0.3);
    --accent-orange: #ff5e5e;
    --accent-cyan: #00d4ff;
    --success: #22c55e;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ==============================
   2. HERO SECTION - CENTRADO PERFECTO
   ============================== */
.blog-hero {
    position: relative;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: 2rem 0;
    /* GPU acceleration */
    transform: translateZ(0);
}

/* Fondo decorativo SVG - Renderizado optimizado */
.blog-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800"><circle cx="400" cy="400" r="200" fill="none" stroke="rgba(92,110,255,0.05)" stroke-width="1"/><circle cx="400" cy="400" r="300" fill="none" stroke="rgba(92,110,255,0.03)" stroke-width="1"/><circle cx="400" cy="400" r="100" fill="none" stroke="rgba(255,94,94,0.04)" stroke-width="1"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    opacity: 0.5;
    pointer-events: none;
    will-change: transform;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

/* ==============================
   3. HERO TITLE - >_HNZXY.dev - Blog
   ============================== */
.hero-title {
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #fff, var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

/* Prompt (>_) */
.hero-title .prompt {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    color: #ff2ea6;
    text-shadow: 0 0 6px rgba(255, 46, 166, 0.5);
}

.hero-title .symbol {
    margin-right: 1px;
}

/* Cursor animado - Optimizado con will-change */
.hero-title .cursor {
    display: inline-block;
    animation: blink 1s step-end infinite;
    will-change: opacity;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.15; }
}

/* Brand HNZXY.dev */
.hero-title .brand {
    color: #ffffff;
    margin-right: 4px;
}

/* .dev con gradiente - Sin animación para rendimiento */
.hero-title .dev {
    margin-left: 2px;
    background: linear-gradient(90deg, #5b6cff, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Suffix - Blog */
.hero-title .suffix {
    color: #a0a8c0;
    font-weight: 500;
    margin-left: 4px;
}

/* Hover micro-interaction */
.hero-title:hover .cursor {
    animation-duration: 0.6s;
}

.hero-subtitle {
    font-size: 16px;
    line-height: 1.6;
    color: #a0a8c0;
    max-width: 600px;
    margin: 0 auto 28px;
}

.hero-cta {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==============================
   4. BOTONES
   ============================== */
.btn-primary,
.btn-outline {
    padding: 0.85rem 2rem;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-orange));
    color: white;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-2px);
}

/* ==============================
   5. BLOG GRID (MASONRY STYLE)
   ============================== */
.blog-layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 180px;
    margin: 2.5rem 0;
}

.card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s ease;
    /* GPU acceleration */
    transform: translateZ(0);
}

.card:hover {
    transform: translateY(-4px);
}

.card a {
    display: block;
    height: 100%;
    color: white;
    text-decoration: none;
}

.card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.85) 0%,
            rgba(0, 0, 0, 0.5) 40%,
            transparent 100%);
    z-index: 1;
    border-radius: var(--radius-lg);
}

.card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.2rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* Tarjeta destacada - 2x2 */
.card.featured {
    grid-column: span 2;
    grid-row: span 2;
}

.card.featured .card-content h2 {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
}

/* Tarjeta lateral - 1x2 */
.card.side {
    grid-row: span 2;
}

.card.side .card-content h3 {
    font-size: 1.1rem;
}

/* Tarjetas normales */
.card:not(.featured):not(.side) .card-content h3 {
    font-size: 0.95rem;
}

.meta {
    font-size: 0.65rem;
    opacity: 0.85;
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.meta i {
    margin-right: 0.2rem;
}

/* ==============================
   6. CATEGORIES SECTION
   ============================== */
.categories-section {
    margin: 2rem 0 1rem;
}

.categories-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
}

.category-card {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.category-card:hover,
.category-card.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.category-icon {
    font-size: 0.8rem;
}

/* ==============================
   7. PAGINACIÓN
   ============================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0 3rem;
    flex-wrap: wrap;
}

.page-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.8rem;
    background: var(--bg-card-solid);
    border-radius: 40px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.page-item.active {
    background-color: var(--accent);
    color: white;
}

.page-item:hover:not(.active) {
    background-color: var(--bg-surface);
    color: white;
}

/* ==============================
   8. FONDO EXCLUSIVO BLOG Y SINGLE
   ============================== */
body.blog-page,
body.single-page {
    position: relative;
}

body.blog-page::before,
body.single-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 500px;
    background-image: url('../img/fondo/blog_bg.webp');
    background-size: auto 500px;
    background-position: top center;
    background-repeat: no-repeat;
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
    mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

/* Legibilidad del contenido */
body.blog-page .content-wrapper,
body.single-page .content-wrapper,
body.blog-page main,
body.single-page main {
    position: relative;
    z-index: 1;
    background-color: transparent;
}

/* ==============================
   9. LOAD MORE BUTTON
   ============================== */
.load-more-wrapper {
    text-align: center;
    margin: 2.5rem 0 3rem;
}

.load-more-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-orange) 100%);
    color: white;
    border: none;
    padding: 0.9rem 2.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    box-shadow: 0 4px 15px var(--accent-glow);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.load-more-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.load-more-btn:active {
    transform: translateY(0);
}

.load-more-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.load-more-btn .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.load-more-btn.loading .spinner {
    display: block;
}

.load-more-btn.loading span {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.end-message {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin: 2rem 0;
    padding: 1rem;
    border-top: 1px solid var(--border-subtle);
}

/* ==============================
   10. RESPONSIVE - TABLET
   ============================== */
@media (max-width: 900px) {
    .blog-layout {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 180px;
        gap: 1rem;
    }
    
    .card.featured,
    .card.side {
        grid-column: auto;
        grid-row: auto;
    }
    
    .card.featured .card-content h2,
    .card.side .card-content h3 {
        font-size: 1.1rem;
    }
}

/* ==============================
   11. RESPONSIVE - MÓVIL
   ============================== */
@media (max-width: 768px) {
    /* Hero compacto y centrado */
    .blog-hero {
        min-height: 280px;
        padding: 1.5rem 0;
        margin-bottom: 0.5rem;
    }
    
    .hero-content {
        padding: 0 16px;
    }
    
    .hero-title {
        font-size: clamp(28px, 6vw, 36px);
        justify-content: center;
    }
    
    /* En móvil, suffix en nueva línea para mejor lectura */
    .hero-title .suffix {
        display: block;
        width: 100%;
        margin-left: 0;
        margin-top: 4px;
        font-size: 0.9em;
    }
    
    .hero-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }
    
    .btn-primary,
    .btn-outline {
        padding: 0.6rem 1.2rem;
        font-size: 0.8rem;
    }
    
    /* Grid: 1 columna */
    .blog-layout {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        gap: 1.2rem;
    }
    
    .card,
    .card.featured,
    .card.side {
        min-height: 220px;
        height: auto;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .card.featured .card-content h2,
    .card.side .card-content h3,
    .card .card-content h3 {
        font-size: 1.2rem;
    }
    
    .meta {
        font-size: 0.7rem;
        gap: 1rem;
    }
    
    /* Categorías compactas */
    .categories-grid {
        gap: 0.5rem;
    }
    
    .category-card {
        font-size: 0.75rem;
        padding: 0.4rem 0.9rem;
    }
}

/* ==============================
   12. RESPONSIVE - MÓVIL PEQUEÑO
   ============================== */
@media (max-width: 480px) {
    .blog-hero {
        min-height: 250px;
    }
    
    .hero-title {
        font-size: clamp(24px, 5vw, 28px);
    }
    
    .hero-subtitle {
        font-size: 13px;
    }
    
    .blog-layout {
        gap: 1rem;
    }
    
    .card,
    .card.featured,
    .card.side {
        min-height: 200px;
    }
    
    .card-content h3,
    .card.featured .card-content h2 {
        font-size: 1.1rem;
    }
    
    .meta {
        font-size: 0.65rem;
    }
    
    /* Ocultar autor en móvil pequeño para ahorrar espacio */
    .meta span:last-child {
        display: none;
    }
}