/* ═══════════════════════════════════════════════
   CATEGORY PAGE STYLES
   ═══════════════════════════════════════════════ */

/* ─── Fullscreen 3D Model Background ─── */
#model-bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.3;
    pointer-events: none;
}

#model-bg-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ─── Scroll-driven Image Background (Code & Pixels) ─── */
[data-category="code"] #hero-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ─── Active Nav Link ─── */
.nav-link.active-link {
    color: var(--text-primary) !important;
    position: relative;
}

.nav-link.active-link::after {
    width: 100% !important;
}

/* ─── Category Hero ─── */
.category-hero {
    position: relative;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8rem 2rem 4rem;
    text-align: center;
    overflow: hidden;
    z-index: 2;
}

.category-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.15;
}

/* Category-specific gradient backgrounds */
.code-hero .category-hero-bg {
    background: radial-gradient(ellipse at 30% 50%, rgba(96, 165, 250, 0.3) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 50%, rgba(167, 139, 250, 0.2) 0%, transparent 60%);
}

.digital-hero .category-hero-bg {
    background: radial-gradient(ellipse at 30% 50%, rgba(52, 211, 153, 0.3) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 50%, rgba(16, 185, 129, 0.2) 0%, transparent 60%);
}

.english-hero .category-hero-bg {
    background: radial-gradient(ellipse at 30% 50%, rgba(251, 146, 60, 0.3) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 50%, rgba(245, 158, 11, 0.2) 0%, transparent 60%);
}

.category-hero-content {
    position: relative;
    z-index: 2;
    max-width: 700px;
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    margin-bottom: 1.5rem;
}

.code-hero .category-badge {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
}

.digital-hero .category-badge {
    background: rgba(52, 211, 153, 0.12);
    color: #34d399;
}

.english-hero .category-badge {
    background: rgba(251, 146, 60, 0.12);
    color: #fb923c;
}

.category-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
}

.gradient-text-code {
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-digital {
    background: linear-gradient(135deg, #34d399, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-english {
    background: linear-gradient(135deg, #fb923c, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.category-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1.5rem;
    max-width: 550px;
    margin-left: auto;
    margin-right: auto;
}

.category-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.cat-stat strong {
    color: var(--text-primary);
    font-weight: 700;
}

.cat-divider {
    opacity: 0.3;
}

/* ═══════════════════════════════════════════════
   BLOG POSTS — SCROLL-REVEAL SECTIONS
   ═══════════════════════════════════════════════ */

.blog-posts-section {
    position: relative;
    z-index: 2;
    padding: 0;
}

.posts-container {
    display: flex;
    flex-direction: column;
}

/* ─── Each post = one full-viewport screen ─── */
.blog-post-card {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

/* ─── Half-circle Image: starts hidden off-screen right ─── */
.blog-post-image {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateX(105%) translateY(-50%);
    width: 55vw;
    height: 92vh;
    border-radius: 92vh 0 0 92vh;
    overflow: hidden;
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 1s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.6s ease;
    box-shadow: none;
    opacity: 0;
    z-index: 1;
    will-change: transform, opacity;
}

/* Glowing ring around the half-circle */
.blog-post-image::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 2px solid rgba(15, 23, 42, 0.06);
    pointer-events: none;
    z-index: 3;
    transition: border-color 0.6s ease;
}

.blog-post-card.is-visible .blog-post-image::after {
    border-color: rgba(15, 23, 42, 0.12);
}

.blog-post-card:hover .blog-post-image {
    transform: translateX(0) translateY(-50%) scale(1.03);
    box-shadow: -40px 0 120px rgba(0, 0, 0, 0.8);
}

/* "New" badge inside image */
.blog-post-image .post-badge {
    position: absolute;
    top: 2.5rem;
    left: 3.5rem;
    background: #22d3ee;
    color: #0f172a;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.3rem 0.8rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    z-index: 2;
}

/* ─── Text block: starts hidden & shifted left ─── */
.blog-post-content {
    position: absolute;
    left: 8vw;
    top: 50%;
    transform: translateY(-50%) translateX(-70px);
    opacity: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 40vw;
    pointer-events: none;
    transition: transform 1s 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.8s 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
}

/* Animated accent line above title */
.blog-post-content::after {
    content: '';
    display: block;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg,
            var(--accent-color, #60a5fa),
            transparent);
    margin-bottom: 1.5rem;
    order: -1;
    /* appears above h3 */
    transition: width 0.8s 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 2px;
}

.blog-post-card.is-visible .blog-post-content::after {
    width: 60px;
}

/* Post number */
.blog-post-content::before {
    content: attr(data-index);
    font-size: 8rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.05em;
    opacity: 0.04;
    color: #0f172a;
    position: absolute;
    top: -3rem;
    left: -1rem;
    pointer-events: none;
    user-select: none;
}

.blog-post-content h3 {
    font-size: clamp(2rem, 4vw, 4.2rem);
    font-weight: 700;
    line-height: 1.1;
    margin: 0 0 1.25rem 0;
    letter-spacing: -0.03em;
    color: #0f172a;
}

.blog-post-content p {
    font-size: 1rem;
    line-height: 1.75;
    color: rgba(15, 23, 42, 0.68);
    margin: 0;
    display: block !important;
}

/* Hide things we don't need */
.blog-post-date,
.read-more {
    display: none !important;
}

/* ─── VISIBLE state: triggered by IntersectionObserver ─── */
.blog-post-card.is-visible .blog-post-image {
    transform: translateX(0) translateY(-50%);
    box-shadow: -40px 0 120px rgba(0, 0, 0, 0.7);
    opacity: 1;
}

.blog-post-card.is-visible .blog-post-content {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

/* Category accent colors */
[data-category="code"] {
    --accent-color: #60a5fa;
}

[data-category="digital"] {
    --accent-color: #34d399;
}

[data-category="english"] {
    --accent-color: #fb923c;
}

/* ─── Category accent glow on title ─── */
[data-category="code"] .blog-post-card.is-visible .blog-post-content h3 {
    text-shadow: none;
}

[data-category="digital"] .blog-post-card.is-visible .blog-post-content h3 {
    text-shadow: none;
}

[data-category="english"] .blog-post-card.is-visible .blog-post-content h3 {
    text-shadow: none;
}

/* ─── Paragraph reveal (delayed after title) ─── */
.blog-post-content p {
    transform: translateY(12px);
    opacity: 0;
    transition: transform 0.7s 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.7s 0.7s ease;
}

.blog-post-card.is-visible .blog-post-content p {
    transform: translateY(0);
    opacity: 1;
}

/* ─── Keyframes ─── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .blog-post-image {
        width: 65vw;
    }

    .blog-post-content {
        max-width: 52vw;
    }
}

@media (max-width: 768px) {
    /* Stack the hero section vertically */
    .cat-slider {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
    }
    
    .cat-slider-left {
        flex: none !important;
        padding: 6rem 1.5rem 2.5rem !important;
        text-align: center !important;
        align-items: center !important;
    }

    .cat-slider-back {
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: 2rem !important;
    }

    .cat-slider-title {
        font-size: clamp(2.2rem, 8vw, 3.5rem) !important;
        margin-bottom: 1rem !important;
    }

    .cat-slider-desc {
        margin: 0 auto 2rem !important;
    }

    .cat-slider-btn {
        margin-bottom: 2rem !important;
    }

    .cat-slider-stats {
        justify-content: center !important;
        width: 100% !important;
    }

    .cat-slider-right {
        flex: none !important;
        width: 100% !important;
        height: 320px !important;
        padding: 1rem 0 !important;
    }

    .cat-slider-bg {
        clip-path: none !important;
        border-radius: 0 0 40px 40px !important;
    }

    .cat-slider-scroll {
        display: none !important; /* Hide scroll text rotated on side */
    }

    #hero-3d-model {
        width: 260px !important;
        height: 260px !important;
        margin: 0 auto !important;
    }

    /* Change articles container to natural stacking with modern gap */
    .posts-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 2.5rem !important;
        padding: 2.5rem 1.25rem 4rem !important;
        max-width: 560px !important;
        margin: 0 auto !important;
    }

    /* Make each blog card a standard self-contained stacked card on mobile */
    .blog-post-card {
        height: auto !important;
        min-height: auto !important;
        flex-direction: column !important;
        align-items: stretch !important;
        border-radius: 18px !important;
        border: 1px solid rgba(15, 23, 42, 0.08) !important;
        box-shadow: 0 8px 30px rgba(15, 23, 42, 0.04) !important;
        padding: 0 !important;
        overflow: hidden !important;
        margin-bottom: 0 !important;
        opacity: 1 !important; /* Force visible on mobile */
        transform: none !important; /* Disable transitions */
        pointer-events: auto !important;
    }

    .blog-post-card:active {
        transform: scale(0.98) !important;
    }

    /* Reposition the image to the top of the card */
    .blog-post-image {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        width: 100% !important;
        height: 210px !important;
        border-radius: 0 !important; /* Remove half-circle radius */
        transform: none !important;
        opacity: 1 !important;
        display: block !important;
        box-shadow: none !important;
    }

    .blog-post-image img {
        opacity: 1 !important;
    }

    /* Adjust the category badge inside the image block */
    .blog-post-image .post-badge {
        position: absolute !important;
        top: 1rem !important;
        left: 1rem !important;
        font-size: 0.68rem !important;
        padding: 0.3rem 0.8rem !important;
        border-radius: 100px !important;
        background: var(--accent-color, #2563eb) !important;
        color: #ffffff !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    }

    /* Reposition content block below the image */
    .blog-post-content {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
        opacity: 1 !important;
        max-width: 100% !important;
        padding: 1.5rem !important;
        pointer-events: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Hide background number and accent line decoration on mobile */
    .blog-post-content::before {
        display: none !important;
    }

    .blog-post-content::after {
        display: none !important;
    }

    /* Mobile typography inside the card */
    .blog-post-content h3 {
        font-size: 1.35rem !important;
        font-weight: 800 !important;
        line-height: 1.35 !important;
        margin: 0 0 0.8rem 0 !important;
        color: #0f172a !important;
        text-shadow: none !important;
    }

    .blog-post-content p {
        font-size: 0.9rem !important;
        line-height: 1.6 !important;
        color: rgba(15, 23, 42, 0.65) !important;
        margin: 0 0 1.5rem 0 !important;
        transform: none !important;
        opacity: 1 !important;
    }

    /* Mobile search & filter controls scroll optimization */
    .posts-controls {
        padding: 1.2rem 1.25rem !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: stretch !important;
        background: rgba(15, 23, 42, 0.02) !important;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
    }
    .search-box {
        width: 100% !important;
        margin: 0 !important;
    }
    .tag-filters {
        display: flex !important;
        justify-content: flex-start !important;
        gap: 0.5rem !important;
        overflow-x: auto !important;
        padding-bottom: 0.4rem !important;
        margin: 0 !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    .tag-filters::-webkit-scrollbar {
        display: none !important;
    }
    .tag-btn {
        flex-shrink: 0 !important;
    }

    /* Mobile author and button layout */
    .blog-post-content > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
        margin-top: 1.25rem !important;
        padding-top: 1rem !important;
        border-top: 1px solid rgba(15, 23, 42, 0.06) !important;
        width: 100% !important;
    }
    
    .blog-post-content > div > div:first-child {
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }
    
    .blog-post-content > div > span {
        font-size: 0.8rem !important;
        color: rgba(15, 23, 42, 0.6) !important;
    }

    .blog-post-content > div > a {
        margin: 0 !important;
        text-align: center !important;
        display: block !important;
        width: 100% !important;
        padding: 0.65rem 1rem !important;
        box-sizing: border-box !important;
        border-radius: 100px !important;
        background: rgba(15, 23, 42, 0.04) !important;
        border: 1px solid rgba(15, 23, 42, 0.1) !important;
        color: #0f172a !important;
        font-size: 0.85rem !important;
        font-weight: 700 !important;
        transition: background 0.2s !important;
    }
    .blog-post-content > div > a:hover,
    .blog-post-content > div > a:active {
        background: rgba(15, 23, 42, 0.08) !important;
    }

    /* Mobile category redirects spacing overrides */
    #articles > div[style*="padding: 8rem 0"] {
        padding: 4rem 1.25rem 2rem !important;
        margin-top: 2rem !important;
    }
    #articles > div[style*="padding: 8rem 0"] > div.blog-section-heading {
        margin-bottom: 2rem !important;
        padding: 0 !important;
    }
    #articles > div[style*="padding: 8rem 0"] > div[style*="display: grid"] {
        gap: 1.5rem !important;
    }
    #articles > div[style*="padding: 8rem 0"] a[style*="padding: 4rem 3rem"] {
        padding: 2rem 1.5rem !important;
    }
    #articles > div[style*="padding: 8rem 0"] a[style*="padding: 4rem 3rem"] h3 {
        font-size: 1.6rem !important;
        margin-bottom: 0.75rem !important;
    }
    #articles > div[style*="padding: 8rem 0"] a[style*="padding: 4rem 3rem"] p {
        font-size: 0.95rem !important;
    }
    #articles > div[style*="padding: 8rem 0"] a[style*="padding: 4rem 3rem"] div {
        margin-top: 1.5rem !important;
        padding: 0.65rem 1.5rem !important;
        font-size: 0.9rem !important;
    }
}

/* ─── Pagination Controls ─── */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 0;
    margin: 2rem auto;
    max-width: 1200px;
}

.pagination-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: rgba(15, 23, 42, 0.04);
    color: #0f172a;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover {
    background: rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

.pagination-btn.active {
    background: var(--accent-color, #2563eb);
    border-color: var(--accent-color, #2563eb);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}