/**
 * TechHub Block Patterns & Sections Stylesheet
 * 
 * Quản lý kiểu dáng cho 16 Sections nội dung trang chủ của Hybrid AI Learning Hub.
 */

/* Loại bỏ triệt để padding mặc định của WordPress Core cho Group có background */
:where(.wp-block-group.has-background),
.wp-block-group.has-background {
    padding: 0;
}

/* ==========================================================================
   UNIFIED CONTAINER SYSTEM - Thống nhất độ rộng & căn lề toàn bộ Section
   Mọi khối nội dung từ tiêu đề, danh sách, lưới card đến query block đều nằm
   trong khung container 1360px đồng nhất, căn giữa màn hình với padding 1.5rem.
   ========================================================================== */
.th-home-section {
    width: 100% !important;
    max-width: 100% !important;
    padding-top: 3.5rem !important;
    padding-bottom: 3.5rem !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
}

.th-home-section.has-alt-bg {
    background-color: var(--wp--preset--color--surface-light);
}

.th-home-section > *,
.th-home-section > .th-section-header,
.th-home-section > .th-topics-grid,
.th-home-section > .th-tools-grid,
.th-home-section > .th-services-grid,
.th-home-section > .th-newsletter-banner,
.th-home-section > .wp-block-query,
.th-home-section > .th-query-4col,
.th-home-section > .alignwide,
.th-home-section > :where(:not(.alignfull)),
.th-category-grid-section > *,
.th-category-grid-section > .th-section-header,
.th-category-grid-section > .wp-block-query,
.wp-block-group.th-home-section > :not(.alignfull),
.th-footer-inner,
.th-site-footer > .alignwide,
.th-site-footer > .wp-block-group,
.th-site-footer > * {
    max-width: 1360px !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    box-sizing: border-box !important;
}

@media (max-width: 640px) {
    .th-home-section {
        padding-top: 2.25rem !important;
        padding-bottom: 2.25rem !important;
    }
    .th-home-section > *,
    .th-category-grid-section > * {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

.th-section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.th-section-eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--wp--preset--color--blue-electric);
    margin-bottom: 0.35rem;
}

.th-section-eyebrow.purple {
    color: var(--wp--preset--color--purple-ai);
}

.th-section-eyebrow.teal {
    color: var(--wp--preset--color--teal-tech);
}

.th-section-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    color: var(--wp--preset--color--navy-primary);
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.th-section-desc {
    font-size: 0.95rem;
    color: var(--wp--preset--color--text-muted);
    margin: 0.35rem 0 0 0;
    max-width: 600px;
}

.th-section-view-all {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--wp--preset--color--blue-electric);
    text-decoration: none;
    transition: transform 0.15s ease;
}

.th-section-view-all:hover {
    transform: translateX(3px);
}

/* SECTION 03: Topic Pills Grid */
.th-topics-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 1.25rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.th-topic-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 12px;
    text-decoration: none;
    color: var(--wp--preset--color--navy-primary);
    transition: all 0.2s ease;
}

.th-topic-card:hover {
    border-color: var(--wp--preset--color--blue-electric);
    background: var(--wp--preset--color--blue-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.th-topic-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.th-topic-name {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
}

.th-topic-count {
    font-size: 0.75rem;
    color: var(--wp--preset--color--text-muted);
    margin: 0.15rem 0 0 0;
}

/* SECTION 04: Featured Tutorials (1 Large + 3 Stacked) */
.th-featured-layout {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 2rem;
}

.th-featured-main {
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.th-featured-main:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.th-featured-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

.th-featured-content {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.th-featured-side-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.th-side-post-card {
    display: flex;
    gap: 1.25rem;
    padding: 1.25rem;
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.th-side-post-card:hover {
    transform: translateX(4px);
    border-color: var(--wp--preset--color--blue-electric);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.th-side-thumb {
    width: 110px;
    height: 75px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #1e293b;
}

/* SECTION 06 & 07: Tools & Software Cards Grid */
.th-tools-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 1.25rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 1024px) {
    .th-tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 640px) {
    .th-tools-grid {
        grid-template-columns: 1fr !important;
    }
}

.th-tool-card {
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 14px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.th-tool-card:hover {
    transform: translateY(-4px);
    border-color: var(--wp--preset--color--blue-electric);
    box-shadow: 0 10px 20px -3px rgba(37, 99, 235, 0.08);
}

.th-tool-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.th-tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--wp--preset--color--surface-light);
    border: 1px solid var(--wp--preset--color--border-light);
    flex-shrink: 0;
}

.th-pricing-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.th-pricing-badge.free {
    background: var(--wp--preset--color--teal-light);
    color: var(--wp--preset--color--teal-tech);
}

.th-pricing-badge.freemium {
    background: var(--wp--preset--color--blue-light);
    color: var(--wp--preset--color--blue-electric);
}

.th-pricing-badge.opensource {
    background: var(--wp--preset--color--purple-light);
    color: var(--wp--preset--color--purple-ai);
}

/* SECTION 08: Games Showcase */
.th-game-card {
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    transition: all 0.2s ease;
}

.th-game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.1);
}

.th-game-badge-play {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(11, 19, 43, 0.85);
    backdrop-filter: blur(4px);
    color: #ffffff;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* SECTION 09: Device Review Score Radar/Card */
.th-review-card {
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 14px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.th-review-score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #ffffff;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* SECTION 10: Workflow & Agent Skill Preview */
.th-workflow-card {
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 14px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.th-workflow-code-preview {
    background: #0f172a;
    color: #38bdf8;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-family: var(--wp--preset--font-family--mono);
    font-size: 0.78rem;
    margin: 1rem 0;
    overflow-x: auto;
}

/* SECTION 14: Services 3-tier Pricing */
.th-services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.th-service-card {
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 16px;
    padding: 2.25rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: all 0.2s ease;
}

.th-service-card.is-popular {
    border-color: var(--wp--preset--color--blue-electric);
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.15);
}

.th-popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--wp--preset--color--blue-electric);
    color: #ffffff;
    padding: 0.2rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* SECTION 15: Newsletter Box */
.th-newsletter-banner {
    background: linear-gradient(135deg, #0b132b 0%, #1c2541 100%);
    border-radius: 20px;
    padding: 3.5rem 2.5rem;
    color: #ffffff;
    text-align: center;
    max-width: 860px;
    margin: 0 auto;
    box-shadow: 0 20px 30px -10px rgba(11, 19, 43, 0.3);
}

.th-newsletter-form {
    display: flex;
    max-width: 520px;
    margin: 1.5rem auto 0 auto;
    gap: 0.5rem;
}

.th-newsletter-input {
    flex: 1;
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    border: 1px solid #334155;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 0.95rem;
    outline: none;
}

.th-newsletter-input:focus {
    border-color: #3b82f6;
    background: rgba(255, 255, 255, 0.15);
}

.th-newsletter-submit {
    background: var(--wp--preset--color--blue-electric);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 0.85rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.th-newsletter-submit:hover {
    background: var(--wp--preset--color--blue-hover);
}

/* Responsive Rules */
@media (max-width: 900px) {
    .th-featured-layout {
        grid-template-columns: 1fr;
    }
    .th-newsletter-form {
        flex-direction: column;
    }
    .th-newsletter-banner {
        padding: 2.5rem 1.5rem;
    }
}

/* Dark Mode Overrides */
html.dark-mode .th-home-section.has-alt-bg {
    background-color: #070c1b;
}

html.dark-mode .th-topic-card,
html.dark-mode .th-featured-main,
html.dark-mode .th-side-post-card,
html.dark-mode .th-tool-card,
html.dark-mode .th-game-card,
html.dark-mode .th-review-card,
html.dark-mode .th-workflow-card,
html.dark-mode .th-service-card {
    background: #0f172a;
    border-color: #1e293b;
}

html.dark-mode .th-topic-card:hover {
    background: #172554;
    border-color: #3b82f6;
}

html.dark-mode .th-tool-icon {
    background: #1e293b;
    border-color: #334155;
}

html.dark-mode .th-section-title {
    color: #f8fafc;
}

html.dark-mode .th-topic-name {
    color: #f8fafc;
}

html.dark-mode .th-service-card.is-popular {
    border-color: #3b82f6;
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.2);
}

/* ==========================================================================
   4-Column Category Posts Grid (Lưới 4 Bài Viết Hàng Ngang Kéo Thả Widget)
   ========================================================================== */
.th-grid-4col ul.wp-block-post-template,
.th-category-grid-section ul.wp-block-post-template,
.th-home-section ul.wp-block-post-template,
ul.wp-block-post-template.columns-4,
ul.wp-block-post-template.is-layout-grid,
ul.wp-block-post-template.is-layout-flex,
.th-post-template-4col {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 1.25rem !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.th-grid-4col ul.wp-block-post-template > li,
.th-category-grid-section ul.wp-block-post-template > li,
.th-home-section ul.wp-block-post-template > li,
ul.wp-block-post-template > li,
.th-post-template-4col > li,
li.wp-block-post {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

.th-grid-4col ul.wp-block-post-template > li > .th-post-card,
.th-category-grid-section .th-post-card,
.th-home-section .th-post-card,
ul.wp-block-post-template > li > .th-post-card,
li.wp-block-post > .th-post-card {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 1024px) {
    .th-grid-4col ul.wp-block-post-template,
    ul.wp-block-post-template.columns-4,
    ul.wp-block-post-template.is-layout-grid,
    ul.wp-block-post-template.is-layout-flex,
    .th-post-template-4col {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
}

@media (max-width: 600px) {
    .th-grid-4col ul.wp-block-post-template,
    ul.wp-block-post-template.columns-4,
    ul.wp-block-post-template.is-layout-grid,
    ul.wp-block-post-template.is-layout-flex,
    .th-post-template-4col {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

.th-category-grid-section .th-post-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--border-light);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.th-category-grid-section .th-post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    border-color: var(--wp--preset--color--blue-electric);
}

.th-category-grid-section .wp-block-post-featured-image {
    margin: 0;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.th-category-grid-section .wp-block-post-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

/* Lưới chuyên mục động từ Cấu hình Admin (Homepage Dynamic Category Grid) */
.th-dynamic-category-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 1024px) {
    .th-dynamic-category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.25rem !important;
    }
}

@media (max-width: 640px) {
    .th-dynamic-category-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

.th-dynamic-category-grid .th-post-card,
.th-category-grid-section .th-post-card {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    background: #ffffff !important;
    border: 1px solid var(--wp--preset--color--border-light) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease !important;
}

.th-dynamic-category-grid .th-post-card:hover,
.th-category-grid-section .th-post-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04) !important;
    border-color: var(--wp--preset--color--blue-electric) !important;
}

.th-dynamic-category-grid .th-card-media-wrap,
.th-category-grid-section .wp-block-post-featured-image {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    aspect-ratio: 16 / 9 !important;
    width: 100% !important;
    background: #f1f5f9;
}

.th-dynamic-category-grid .th-card-media-wrap a,
.th-category-grid-section .wp-block-post-featured-image a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.th-dynamic-category-grid .th-card-media-wrap img,
.th-dynamic-category-grid .th-card-img,
.th-category-grid-section .wp-block-post-featured-image img {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 16 / 9 !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    transition: transform 0.35s ease !important;
}

.th-dynamic-category-grid .th-post-card:hover .th-card-media-wrap img,
.th-category-grid-section .th-post-card:hover .wp-block-post-featured-image img {
    transform: scale(1.05) !important;
}

.th-dynamic-category-grid .th-card-title a:hover {
    color: var(--wp--preset--color--blue-electric) !important;
}

html.dark-mode .th-dynamic-category-grid .th-post-card {
    background: #0f172a !important;
    border-color: #1e293b !important;
}

html.dark-mode .th-dynamic-category-grid .th-post-card:hover {
    border-color: var(--wp--preset--color--blue-electric) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35) !important;
}

html.dark-mode .th-dynamic-category-grid .th-card-title a {
    color: #f8fafc !important;
}

.th-category-grid-section .th-post-card:hover .wp-block-post-featured-image img {
    transform: scale(1.05);
}

.th-category-grid-section .th-post-card-body {
    padding: 0.85rem 1rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.th-category-grid-section .wp-block-post-title {
    font-size: 0.95rem !important;
    font-weight: 700;
    line-height: 1.35 !important;
    margin: 0.35rem 0 0.4rem 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.th-category-grid-section .wp-block-post-title a {
    color: var(--wp--preset--color--navy-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.th-category-grid-section .wp-block-post-title a:hover {
    color: var(--wp--preset--color--blue-electric);
}

.th-category-grid-section .wp-block-post-excerpt p {
    font-size: 0.825rem;
    line-height: 1.5;
    color: var(--wp--preset--color--text-muted);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.th-category-grid-section .th-post-card-meta {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--wp--preset--color--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--wp--preset--color--text-muted);
}

/* Dark Mode Overrides cho 4-Column Category Grid */
html.dark-mode .th-category-grid-section .th-post-card {
    background: #0f172a;
    border-color: #1e293b;
}

html.dark-mode .th-category-grid-section .th-post-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.2);
}

html.dark-mode .th-category-grid-section .wp-block-post-title a {
    color: #f8fafc;
}

html.dark-mode .th-category-grid-section .wp-block-post-title a:hover {
    color: #60a5fa;
}

html.dark-mode .th-category-grid-section .th-post-card-meta {
    border-top-color: #1e293b;
}

/* Chuẩn hóa Category Badge trên toàn bộ Card bài viết (Chống lệch do thẻ br) */
.th-card-cat-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1.2 !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
}

.th-card-cat-badge br {
    display: none !important;
}

.th-card-cat-badge p {
    margin: 0 !important;
    padding: 0 !important;
    display: inline !important;
}

/* Triệt tiêu thẻ br và thẻ p rác do wpautop chèn vào tiêu đề và thân card bài viết */
.th-card-title br,
.th-post-card-body > br {
    display: none !important;
}

.th-post-card-body > p:empty,
.th-post-card-body p:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

