/* =========================================
   1. FONTS & VARIABLES
   ========================================= */

@font-face {
    font-family: "Minecraft";
    src: url("/public/fonts/minecraft.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Mcten";
    src: url("/public/fonts/mcten.ttf") format("truetype"),
         url("/public/fonts/minecraft.otf") format("opentype");
}

:root {
    /* Colors */
    --background: rgb(23, 21, 22);
    --surface: #161b22;
    --border: #30363d;
    --primary: #2f81f7;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --shadow: rgba(0, 0, 0, 0.2);
    --border-color: rgb(255 55 22);

    /* Card Gradient Variables (Cho hiệu ứng mượt mà) */
    --card-overlay-start: rgba(0, 0, 0, 0.6);      /* Đáy tối vừa phải khi thường */
    --card-overlay-end: transparent;               /* Đỉnh trong suốt */
    --card-overlay-hover-start: rgba(0, 0, 0, 0.6); /* Đáy rất tối khi hover */
    --card-overlay-hover-end: rgba(0, 0, 0, 0.2);    /* Đỉnh tối nhẹ khi hover */
}

[data-theme="light"] {
    --background: #ffffff;
    --surface: #f0f2f5;
    --border: #d0d7de;
    --primary: #0969da;
    --text-primary: #1f2328;
    --text-secondary: #57606a;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* =========================================
   2. GLOBAL STYLES & LAYOUT
   ========================================= */

* {
    box-sizing: border-box;
}

body {
    font-family: "Manrope", sans-serif;
    background-attachment: fixed;
    background-size: cover;
    background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.7)),
                      url("/public/assets/mc_wallpaper_3.jpg");
    color: var(--text-primary);
    margin: 0;
    font-size: 16px;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vw;
    overflow-x: hidden;
    overflow-anchor: none;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 24px;
}

/* Animations */
@keyframes fadeInSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   3. HEADER & CONTROLS
   ========================================= */

.site-header {
    padding: 100px 0 0;
    text-align: center;
    position: relative;
}

.site-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    font-family: "Mcten", Sans-Serif;
    animation: fadeInSlideUp 1s forwards;
    animation-delay: 0.5s;
    opacity: 0;
}

.site-header p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin: 0;
    animation: fadeInSlideUp 1s forwards;
    animation-delay: 0.8s;
    opacity: 0;
}

.controls-bar {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* =========================================
   4. CARD GRID & STYLES (NEW DESIGN 16:9)
   ========================================= */

#cardsContainer {
    padding: 32px 0;
    display: grid;
    grid-template-columns: repeat(1, 1fr); /* Mobile: 1 cột */
    gap: 20px;
}

.card-article {
    position: relative;
    
    width: 100%;
    
    /* Tỷ lệ 16:9 (Height = 56.25% Width) */
   /* aspect-ratio: 16/9;*/
    height: auto; 
    
    border-radius: 4px;
    overflow: hidden;
    text-decoration: none;
    background: rgb(35, 35, 35);
    border: 2px solid rgb(30, 30, 30);
    
    opacity: 0;
    transform: scale(0.95);
    animation: fadeInSlideUp 0.5s ease-out forwards;
    
    image-rendering: pixelated;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
}

/* Ảnh nền (Absolute để fill khung 16:9) */
.card-img {
  width: 100%;
  height: auto;
  overflow: hidden;
  
}
.card-img-bg {
    /* position: absolute; */
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.3s ease;
    
}

.card-article:hover .card-img-bg {
    transform: scale(1.1);
  /*  filter: brightness(0.6);  Tối đi khi hover để nổi bật chữ */
}

/* Lớp phủ nội dung + Gradient */
.card-content {
  /*  position: absolute;*/
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Phủ toàn bộ để gradient chạy từ trên xuống */
    padding: 5px;
    z-index: 2;
    box-sizing: border-box;
    
    display: flex;
    flex-direction: column;
    
    
    /* Gradient mặc định */
    background: linear-gradient(
        to top, 
        rgb(0 0 0) 0%, 
        #ffffff00 30%
    );
    transition: background 0.3s ease; /* Chuyển màu mượt mà */
}



/* Tiêu đề */
.card-title {
    margin: 0;
    padding: 0;
    color: #ffffff;
  
    font-size: 1.2rem; /* Mobile font size */
    line-height: 1.3;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: all 0.2s ease;
}

/* Phần thông tin ẩn (Meta + Desc) */
.card-hidden-info {

    overflow: hidden;
    transition: max-height 0.7s ease-in-out, opacity 0.5s ease-in-out, margin-top 0.4s ease-in-out;
}

/* .card-article:hover .card-hidden-info {
   transition: max-height 0.5s ease-in-out, opacity 0.7s ease-in-out;
    max-height: 200px;
    opacity: 1;
    margin-top: 5px;
} */


/* Meta info (Author, Date, Views) */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.7rem;
    color: #bbb;
    font-family: "Minecraft", sans-serif;
    margin-bottom: 2px;
    align-items: center;
}

/* Mô tả ngắn */
.description {
    color: #ddd;
    font-size: 0.85rem;
    line-height: 1.4;
    font-family: "Manrope", sans-serif;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 300;
    margin-top: -10px;
}

/* Badge (Tin tức) */
.card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(251, 146, 60, 1);
    color: white;
    padding: 4px 8px;
    font-family: "Mcten", sans-serif;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 3;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

/* =========================================
   5. PAGINATION
   ========================================= */

#pagination {
    display: flex;
    justify-content: center;
    padding: 16px 0 48px 0;
    gap: -2px;
}

#pagination a, #pagination span {
    display: inline-block;
    padding: 8px 14px;
    text-decoration: none;
    border-radius: 0;
    
    /* Minecraft button style */
    border: 1px solid rgb(30, 30, 30);
    background: rgb(60, 61, 65);
    color: #e6edf3;
    font-weight: 600;
    
    image-rendering: pixelated;
    box-shadow: inset 0 -4px 0 0 rgb(49, 50, 52),
                inset -2px -6px 0 0 rgba(90, 91, 93, 0.8),
                inset 2px 2px 0 0 rgba(109, 109, 109, 1);
    
    transition: color 0.2s ease;
}

#pagination a:hover {
    color: var(--primary);
}

#pagination .active {
    font-weight: bold;
    background: rgb(35, 35, 35);
    box-shadow: inset -2px -2px 0 0 rgba(90, 91, 93, 0.8),
                inset 2px 2px 0 0 rgba(109, 109, 109, 1);
    color: #fff;
    cursor: default;
}

/* =========================================
   6. TOOLBAR (Floating Bottom)
   ========================================= */

.toolbar {
    padding: 5px 10px;
    width: fit-content;
    position: fixed;
    bottom: 15px;
    right: 0;
    left: 0;
    margin: 0 auto;
    background: rgb(72 73 75);
    border: 2px solid rgb(30 30 30);
    height: 60px;
    z-index: 11;
    image-rendering: pixelated;
    box-shadow: inset -2px 0 0 0 rgba(50, 51, 53, 1),
                inset 0 -2px 0 0 rgba(35, 37, 36, 1),
                inset 2px 2px 0 0 rgba(109, 109, 109, 1);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: .8;
    transition: opacity 0.3s;
}

.toolbar:hover { opacity: 1; }

.toolbar svg {
    width: 22px;
    height: 22px;
    fill: white;
    flex-shrink: 0;
    display: block;
}

.toolbar-textbox {
    width: 85%;
    padding: 5px 5px;
    background: rgb(49 50 52);
    height: 45px;
    display: flex;
    align-items: center;
    border: 2px solid rgb(30 30 30);
    box-shadow: inset 0 3px 0 0 rgba(36, 36, 36, 1);
    flex-shrink: 0;
}

.textbox-field {
    background: transparent;
    outline: none;
    border: none;
    width: 100%;
    height: 100%;
    flex-grow: 1;
    color: white;
    font-family: "Minecraft", Sans-Serif;
    font-size: 0.75rem;
}

/* =========================================
   8. TRENDING SECTION (HORIZONTAL SCROLL)
   ========================================= */

.trending-section {
    margin-top: 40px;
    margin-bottom: 20px;
    padding: 0 24px;
}

/* Tiêu đề section với đường kẻ ngang */
.section-title-wrap {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.section-title {
    font-family: "Mcten", sans-serif;
    color: #fff;
    font-size: 1.5rem;
    margin: 0;
    text-shadow: 2px 2px 0 #000;
}

.section-line {
    height: 2px;
    background: #333;
    flex-grow: 1;
    box-shadow: 0 1px 0 rgba(255,255,255,0.1);
}

/* Container cuộn ngang */
.trending-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 15px; /* Để chừa chỗ cho thanh scrollbar */
    
    /* Snap effect */
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    
    /* Ẩn thanh cuộn mặc định trên Firefox/IE */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #222;
}

/* Custom Scrollbar Webkit */
.trending-scroll::-webkit-scrollbar {
    height: 8px;
}
.trending-scroll::-webkit-scrollbar-track {
    background: #222;
    border: 1px solid #444;
}
.trending-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border: 1px solid #000;
    cursor: pointer;
}
.trending-scroll::-webkit-scrollbar-thumb:hover {
    background: #5eb6ff;
}

/* Card trong phần Trending */
.trending-card {
    flex: 0 0 280px; /* Chiều rộng cố định */
    display: flex;
    flex-direction: column;
    text-decoration: none;
    
    background: rgb(30, 30, 30);
    border: 2px solid rgb(40, 40, 40);
    border-radius: 4px;
    overflow: hidden;
    scroll-snap-align: start;
    
    transition: transform 0.2s, border-color 0.2s;
}

.trending-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.trending-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-bottom: 2px solid #000;
}

.trending-thumb img {
    width: 100%;
    height: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    image-rendering: pixelated;
}

.trending-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #ff4757;
    color: #fff;
    font-size: 0.6rem;
    font-family: "Mcten", sans-serif;
    padding: 2px 6px;
    border: 1px solid #000;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.trending-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.trending-title {
    margin: 0;
    color: #eee;
    font-size: 0.95rem;
    font-family: "Manrope", sans-serif;
    font-weight: 700;
    
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.trending-card:hover .trending-title {
    color: var(--primary);
}

.trending-meta {
    font-size: 0.75rem;
    color: #888;
    font-family: "Minecraft", sans-serif;
}

/* Responsive Mobile */
@media (max-width: 600px) {
    .trending-card {
        flex: 0 0 220px; /* Thu nhỏ card trên mobile */
    }
    .trending-title {
        font-size: 0.85rem;
    }
}
/* =========================================
   7. RESPONSIVE MEDIA QUERIES
   ========================================= */

@media (min-width: 640px) {
    #cardsContainer { grid-template-columns: repeat(1, 1fr); }
    .card-title { font-size: 1.2rem; }
}

@media (min-width: 768px) {
    #cardsContainer { grid-template-columns: repeat(1, 1fr); gap: 24px; }
    .card-title { font-size: 1.3rem; }
}

@media (min-width: 1024px) {
    #cardsContainer { grid-template-columns: repeat(2, 1fr); }
    .card-title { font-size: 1.3rem; }
}

@media (min-width: 1280px) {
    #cardsContainer { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================
   9. RESPONSIVE LAYOUT V5 (Sidebar & Compact List)
   ========================================= */

/* --- Default Mobile Layout (Giữ nguyên thanh cuộn ngang) --- */
.blog-layout {
    display: flex;
    flex-direction: column;
}

/* Đưa Sidebar (Trending) lên đầu ở Mobile */
.blog-sidebar {
    order: -1; 
    margin-bottom: 20px;
}

/* Fix lại Toolbar ở Mobile để nó dính dưới Trending */

/* --- DESKTOP LAYOUT (Sidebar bên phải) --- */
@media (min-width: 1024px) {
    
    .blog-layout {
        display: grid;
        grid-template-columns: 1fr 300px; /* Cột chính và Sidebar 300px */
        gap: 40px;
        align-items: start;
    }

    /* Đưa Sidebar về đúng vị trí bên phải */
    .blog-sidebar {
        order: 2; /* Quay lại vị trí sau content */
        margin-bottom: 0;
        position: sticky; /* Sidebar chạy theo khi cuộn */
        top: 20px;
    }

    /* Style lại phần Trending trong Sidebar */
    .trending-section {
        margin-top: 0;
        padding: 0;
    }

    /* Biến thanh cuộn ngang thành danh sách dọc */
    .trending-scroll {
        flex-direction: column; /* Xếp dọc */
        overflow-x: visible;
        overflow-y: visible;
        gap: 15px;
        padding-bottom: 0;
        scroll-snap-type: none;
    }

    /* Biến Card to thành Card nhỏ (Compact List) */
    .trending-card {
        flex: 0 0 auto; /* Bỏ chiều rộng cố định của mobile */
        width: 100%;
        flex-direction: row; /* Ảnh bên trái, Chữ bên phải */
        height: 80px; /* Chiều cao cố định nhỏ gọn */
        background: transparent;
        border: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        border-radius: 0;
    }
    
    .trending-card:hover {
        transform: translateX(5px); /* Hiệu ứng đẩy sang phải */
        background: transparent;
        border-color: rgba(255,255,255,0.2);
    }

    /* Ảnh nhỏ lại */
    .trending-thumb {
        width: 80px; /* Vuông hoặc chữ nhật nhỏ */
        height: 100%;
        aspect-ratio: auto;
        border-bottom: none;
        border-right: 2px solid #000;
        flex-shrink: 0;
    }

    .trending-badge {
        font-size: 0.5rem;
        padding: 1px 4px;
        top: 2px; left: 2px;
    }

    /* Thông tin gọn lại */
    .trending-info {
        justify-content: center;
        padding: 0 0 0 10px;
    }

    .trending-title {
        font-size: 0.9rem;
        line-height: 1.3;
        margin-bottom: 4px;
    }
    
    /* Toolbar trên Desktop */
  
    
    /* Chỉnh lại Grid bài viết chính cho cân đối */
    #cardsContainer {
        grid-template-columns: repeat(2, 1fr); /* 2 cột bài viết + 1 cột sidebar */
    }
}

@media (min-width: 1280px) {
    #cardsContainer {
        grid-template-columns: repeat(2, 1fr); /* Màn hình cực lớn thì 3 cột */
    }
}