@import url('modules/base.css');
@import url('modules/header.css');
@import url('modules/content.css');
@import url('modules/footer.css');

html {
    scroll-behavior: smooth;
}

::selection {
    background: var(--primary-color);
    color: white;
}

.page-content {
    background: var(--background-white);
    border-radius: var(--border-radius-2xl);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.page-content h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 24px 0 12px;
}

.page-content p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-light);
    margin-bottom: 12px;
}

.page-content ul {
    margin-left: 20px;
    margin-bottom: 16px;
}

.page-content li {
    margin-bottom: 8px;
    color: var(--text-light);
    line-height: 1.5;
}

.article-detail {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.article-detail-image {
    width: 100%;
    height: 360px;
    object-fit: cover;
    border-radius: var(--border-radius-2xl) var(--border-radius-2xl) 0 0;
    display: block;
}

.article-detail-header {
    background: var(--background-white);
    border-radius: 0 0 var(--border-radius-2xl) var(--border-radius-2xl);
    padding: 28px 32px;
    border: 1px solid var(--border-color);
    border-top: none;
}

.article-detail-category {
    display: inline-block;
    padding: 4px 14px;
    background: linear-gradient(135deg, #f97316, #eab308);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 16px;
    margin-bottom: 16px;
    text-decoration: none;
    width: fit-content;
}

.article-detail-category:hover {
    text-decoration: none;
    color: white;
}

.article-detail-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.3;
    margin-bottom: 12px;
}

.article-detail-subtitle {
    font-size: 16px;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 20px;
}

.article-detail-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.author-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.author-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #16a34a, #f97316);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 700;
}

.author-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

.author-bio {
    font-size: 13px;
    color: var(--text-light);
}

.article-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 8px 18px;
    border: 1px solid var(--border-color);
    background: var(--background-white);
    border-radius: var(--border-radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.article-content {
    background: var(--background-white);
    border-radius: var(--border-radius-2xl);
    padding: 32px;
    border: 1px solid var(--border-color);
    margin-top: 24px;
    line-height: 1.8;
    font-size: 15px;
    color: var(--text-dark);
}

.article-content h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 28px 0 16px;
}

.article-content p {
    margin-bottom: 16px;
}

.article-content ul {
    margin: 16px 0;
    padding-left: 20px;
}

.article-content li {
    margin-bottom: 8px;
}

.article-related {
    margin-top: 24px;
}

.article-related-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--secondary-color);
}

.related-articles {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.related-article-card {
    background: var(--background-white);
    border-radius: var(--border-radius-lg);
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.related-article-card:hover {
    border-color: var(--primary-light);
    transform: translateX(4px);
}

.related-article-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
    line-height: 1.4;
}

.related-article-title a:hover {
    color: var(--primary-color);
}

.related-article-category {
    font-size: 12px;
    color: var(--secondary-color);
    font-weight: 500;
}

.category-page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-dark);
}

.category-page-title .total-count {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 400;
}

.carousel-wrapper {
    margin: 12px 0;
}

.carousel-container {
    position: relative;
    background: var(--background-light);
    border-radius: var(--border-radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.carousel-slides {
    position: relative;
    min-height: 240px;
}

.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: flex;
    flex-direction: column;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
}

.carousel-slide.active {
    opacity: 1;
    z-index: 1;
}

.carousel-slide img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: var(--border-radius-md);
    margin-bottom: 8px;
}

.carousel-slide-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.carousel-slide-time {
    font-size: 12px;
    color: var(--text-light);
}

.carousel-slide-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 40px 20px 20px;
    color: white;
}

.carousel-category {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    margin-bottom: 10px;
}

.carousel-slide-overlay .carousel-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.3;
    color: white;
}

.carousel-slide-overlay .carousel-summary {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.carousel-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px 0;
    background: var(--background-white);
    border-top: 1px solid var(--border-color);
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-dot.active {
    background: var(--primary-color);
    width: 24px;
    border-radius: 4px;
}

.featured-section .carousel-container {
    border: none;
    box-shadow: var(--shadow-lg);
}

.featured-section .carousel-slides {
    min-height: 380px;
}

.featured-section .carousel-slide {
    position: relative;
    height: 380px;
    padding: 0;
}

.featured-section .carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius-xl);
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .featured-section {
        display: none;
    }
    .page-content {
        padding: 20px;
    }

    .page-title {
        font-size: 20px;
    }

    .category-page-title {
        font-size: 18px;
    }

    .carousel-slide img {
        height: 140px;
    }

    .article-detail-image {
        height: 220px;
        border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
    }

    .article-detail-header {
        padding: 20px;
    }

    .article-detail-title {
        font-size: 20px;
    }

    .article-detail-subtitle {
        font-size: 14px;
    }

    .article-detail-meta {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .article-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
        text-align: center;
    }

    .article-content {
        padding: 20px;
        font-size: 14px;
    }

    /* Mobile Home Grid */
    .mobile-home-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .desktop-home {
        display: grid;
        grid-template-columns: 1fr 300px;
        gap: 24px;
    }

    .mobile-module {
        width: 100%;
        min-height: 45vh;
        overflow: hidden;
        position: relative;
    }

    /* Module 1: Hero */
    .module-hero {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hero-slides {
        width: 100%;
        height: 100%;
        position: relative;
    }

    .hero-slide {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        position: relative;
        overflow: hidden;
    }

    .hero-bg {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-size: cover;
        background-position: center;
        transform: scale(1.1);
        transition: transform 0.8s ease;
    }

    .hero-slide:hover .hero-bg {
        transform: scale(1.2);
    }

    .hero-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, rgba(102,126,234,0.7) 0%, rgba(118,75,162,0.8) 50%, rgba(0,0,0,0.7) 100%);
    }

    .hero-content {
        position: relative;
        z-index: 2;
        color: white;
        padding: 20px;
    }

    .hero-category {
        display: inline-block;
        background: rgba(255,255,255,0.2);
        backdrop-filter: blur(10px);
        padding: 6px 16px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
        margin-bottom: 12px;
    }

    .hero-content h2 {
        font-size: 32px;
        font-weight: 700;
        margin-bottom: 8px;
        color: white;
    }

    .hero-content p {
        font-size: 14px;
        opacity: 0.9;
        margin-bottom: 20px;
    }

    .hero-btn {
        display: inline-block;
        background: white;
        color: #667eea;
        padding: 12px 32px;
        border-radius: 25px;
        font-weight: 600;
        text-decoration: none;
        transition: transform 0.3s ease;
    }

    .hero-btn:hover {
        transform: scale(1.05);
    }

    /* Module 2: Grid Cards - Optimized */
    .module-grid {
        background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
        padding: 20px 16px;
        display: flex;
        flex-direction: column;
        max-height: none;
        overflow: visible;
    }

    .module-header {
        margin-bottom: 16px;
    }

    .module-grid .module-header h3 {
        font-size: 20px;
        font-weight: 700;
        color: white;
    }

    .grid-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .grid-card {
        position: relative;
        background: white;
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 12px 32px rgba(0,0,0,0.3);
        text-decoration: none;
        display: flex;
        flex-direction: column;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        aspect-ratio: 3/4;
    }

    .grid-card:hover {
        transform: translateY(-6px) scale(1.03);
        box-shadow: 0 20px 48px rgba(0,0,0,0.4);
    }

    .grid-card-img {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        background-size: cover;
        background-position: center;
        transition: transform 0.6s ease;
    }

    .grid-card:hover .grid-card-img {
        transform: scale(1.1);
    }

    .grid-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 40%, transparent 70%);
        z-index: 1;
    }

    .grid-card-content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 16px 14px;
        z-index: 2;
    }

    .grid-card-content h4 {
        font-size: 14px;
        font-weight: 700;
        color: white;
        margin-bottom: 8px;
        line-height: 1.4;
        text-shadow: 0 2px 8px rgba(0,0,0,0.5);
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .grid-card-content span {
        font-size: 11px;
        color: rgba(255,255,255,0.85);
        font-weight: 600;
        background: rgba(255,255,255,0.15);
        backdrop-filter: blur(10px);
        padding: 4px 10px;
        border-radius: 12px;
        display: inline-block;
    }

    /* Module 3: Categories - Optimized */
    .module-categories {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
        padding: 20px 16px;
        display: flex;
        flex-direction: column;
    }

    .module-header {
        margin-bottom: 16px;
        text-align: center;
    }

    .module-header h3 {
        font-size: 20px;
        font-weight: 700;
        color: white;
        margin-bottom: 6px;
    }

    .module-header p {
        font-size: 13px;
        color: rgba(255,255,255,0.85);
        margin: 0;
    }

    .category-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        flex: 1;
        overflow-y: auto;
    }

    .category-card {
        position: relative;
        background: white;
        border-radius: 16px;
        overflow: hidden;
        text-decoration: none;
        box-shadow: 0 8px 24px rgba(0,0,0,0.15);
        transition: all 0.3s ease;
        aspect-ratio: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .category-card:hover {
        transform: translateY(-4px) scale(1.02);
        box-shadow: 0 12px 32px rgba(0,0,0,0.2);
    }

    .cat-bg {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-size: cover;
        background-position: center;
        opacity: 0.9;
    }

    .asia-bg {
        background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
    }

    .europe-bg {
        background: linear-gradient(135deg, #48dbfb 0%, #0abde3 100%);
    }

    .americas-bg {
        background: linear-gradient(135deg, #1dd1a1 0%, #00d2d3 100%);
    }

    .africa-bg {
        background: linear-gradient(135deg, #ff9ff3 0%, #f368e0 100%);
    }

    .cat-content {
        position: relative;
        z-index: 1;
        text-align: center;
        color: white;
        padding: 12px;
    }

    .cat-emoji {
        font-size: 36px;
        display: block;
        margin-bottom: 8px;
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    }

    .cat-content h4 {
        font-size: 16px;
        font-weight: 700;
        margin: 0 0 4px 0;
        text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }

    .cat-count {
        font-size: 12px;
        opacity: 0.95;
        font-weight: 500;
    }



    /* Module 4: Latest Articles - Redesigned */
    .module-timeline {
        background: linear-gradient(180deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
        padding: 20px 16px;
        display: flex;
        flex-direction: column;
        position: relative;
    }

    .module-timeline .module-header h3 {
        color: white;
    }

    .module-timeline .module-header p {
        color: rgba(255, 255, 255, 0.7);
    }

    .cards-stack {
        display: flex;
        flex-direction: column;
        gap: 16px;
        flex: 1;
        overflow-y: auto;
        padding: 8px 4px;
        perspective: 1000px;
    }

    .stack-card {
        position: relative;
        display: block;
        text-decoration: none;
        height: 160px;
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 10px 40px rgba(0,0,0,0.4);
        transform: translateZ(0);
        animation: cardEntry 0.6s ease-out var(--delay, 0s) both;
    }

    @keyframes cardEntry {
        from {
            opacity: 0;
            transform: translateY(30px) scale(0.95) rotateX(5deg);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1) rotateX(0);
        }
    }

    .stack-card:hover {
        transform: translateY(-6px) scale(1.02);
        box-shadow: 0 20px 60px rgba(0,0,0,0.5);
        transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .stack-card-bg {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-size: cover;
        background-position: center;
        transform: scale(1.1);
        transition: transform 0.6s ease;
    }

    .stack-card:hover .stack-card-bg {
        transform: scale(1.2);
    }

    .stack-card-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        opacity: 0.85;
        mix-blend-mode: overlay;
    }

    .stack-card-content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 20px;
        background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
        color: white;
    }

    .stack-card-tag {
        display: inline-block;
        padding: 4px 12px;
        background: rgba(255,255,255,0.2);
        backdrop-filter: blur(10px);
        border-radius: 20px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 10px;
        border: 1px solid rgba(255,255,255,0.3);
    }

    .stack-card-content h4 {
        font-size: 16px;
        font-weight: 700;
        color: white;
        margin: 0 0 12px 0;
        line-height: 1.3;
        text-shadow: 0 2px 8px rgba(0,0,0,0.5);
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .stack-card-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .stack-card-author {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .author-avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        font-weight: 700;
        color: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    .stack-card-author span {
        font-size: 13px;
        font-weight: 500;
        color: rgba(255,255,255,0.9);
    }

    .stack-card-time {
        font-size: 12px;
        color: rgba(255,255,255,0.7);
        background: rgba(255,255,255,0.15);
        padding: 4px 10px;
        border-radius: 12px;
        backdrop-filter: blur(10px);
    }

    .stack-card-arrow {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        background: rgba(255,255,255,0.2);
        backdrop-filter: blur(10px);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        transition: all 0.3s ease;
        border: 1px solid rgba(255,255,255,0.3);
    }

    .stack-card:hover .stack-card-arrow {
        background: rgba(255,255,255,0.4);
        transform: translateX(4px);
    }

    /* Hide mobile on desktop */
    @media (min-width: 769px) {
        .mobile-home-grid {
            display: none;
        }
    }

    /* Hide desktop on mobile */
    @media (max-width: 768px) {
        .desktop-home {
            display: none;
        }
    }
}