/* Text and UI colors share theme-aware roles; layout and content stay unchanged. */
html[data-theme] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

/* 1. Global Section Tags & Badges (Solid background eliminates low-contrast gradient leakage) */
html[data-theme="light"] .section-tag {
    background: #eff6ff !important;
    border: 1px solid #bfdbfe !important;
    color: #1d4ed8 !important;
}
html[data-theme="dark"] .section-tag {
    background: #0f1d38 !important;
    border: 1px solid #1e3a8a !important;
    color: #93c5fd !important;
}

html[data-theme] :is(.portfolio-tag, .project-category, .project-badge-tag, .badge-icon-box) {
    color: var(--link-color);
}
html[data-theme="dark"] :is(.portfolio-tag, .project-category, .project-badge-tag) {
    background: #0f1d38 !important;
    border-color: #1e3a8a !important;
    color: #93c5fd !important;
}
html[data-theme="dark"] .portfolio-card {
    background: #0d1222 !important;
    border-color: #1e293b !important;
}

html[data-theme] .pricing-features svg { color: var(--accent-emerald); }
html[data-theme] .vietqr-info .section-tag { color: var(--link-color) !important; }

/* 2. Form Inputs & Placeholders */
html[data-theme] :is(input, textarea)::placeholder {
    color: var(--placeholder-color) !important;
    opacity: 1;
}
html[data-theme] :is(.archive-search-form input, .archive-search-input, .search-input-wrap input, .search-input-field)::placeholder {
    color: var(--placeholder-color) !important;
}
html[data-theme] .contact-form-input::placeholder { color: var(--placeholder-color) !important; }
html[data-theme="light"] .contact-form-input {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}
html[data-theme="dark"] .contact-form-input {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

html[data-theme] .cat-tab.active { background: var(--action-bg) !important; color: #fff !important; }
html[data-theme] .testimonial-avatar { background: var(--action-bg) !important; color: #fff !important; }

html[data-theme] :is(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), textarea, select) {
    color: var(--text-main);
    border-color: var(--control-border) !important;
}
html[data-theme] :is(.archive-search-form, .search-input-wrap) { border-color: var(--control-border) !important; }
html[data-theme] :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--link-color) !important;
    outline-offset: 4px;
}
html[data-theme] :is(.archive-search-form, .search-input-wrap):focus-within {
    outline: 2px solid var(--link-color);
    outline-offset: 3px;
}

/* 3. Primary Action Buttons */
html[data-theme] :is(.btn-nav-hotline, .btn-hero-primary, .btn-bubble-primary, .btn-bubble-lime,
    .pricing-badge, .popular-badge, .wct-pagination .page-link.active) {
    background: var(--action-bg) !important;
    color: #fff !important;
    border-color: var(--action-bg) !important;
}
html[data-theme] :is(.btn-nav-hotline, .btn-hero-primary, .btn-bubble-primary, .btn-bubble-lime):hover {
    background: var(--action-hover) !important;
    color: #fff !important;
}
html[data-theme] :is(.btn-nav-hotline, .btn-hero-primary, .btn-bubble-primary, .btn-bubble-lime) :is(span, svg) {
    color: inherit !important;
}

/* 4. Secondary Action Buttons (Bubble & Hero Secondary) */
html[data-theme="light"] :is(.btn-bubble:not(.btn-bubble-primary):not(.btn-bubble-lime), .btn-hero-secondary) {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}
html[data-theme="light"] :is(.btn-bubble:not(.btn-bubble-primary):not(.btn-bubble-lime), .btn-hero-secondary):hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}
html[data-theme="light"] :is(.btn-bubble:not(.btn-bubble-primary):not(.btn-bubble-lime), .btn-hero-secondary) :is(span, svg) {
    color: inherit !important;
}

html[data-theme="dark"] :is(.btn-bubble:not(.btn-bubble-primary):not(.btn-bubble-lime), .btn-hero-secondary) {
    background: #111c35 !important;
    border: 1px solid #1e3a8a !important;
    color: #93c5fd !important;
}
html[data-theme="dark"] :is(.btn-bubble:not(.btn-bubble-primary):not(.btn-bubble-lime), .btn-hero-secondary):hover {
    background: #1e3a8a !important;
    color: #ffffff !important;
}
html[data-theme="dark"] :is(.btn-bubble:not(.btn-bubble-primary):not(.btn-bubble-lime), .btn-hero-secondary) :is(span, svg) {
    color: inherit !important;
}

/* 5. Topbar, Navigation Links & Hot Tag */
html[data-theme="light"] .wct-topbar { background: #f8fafc !important; }
html[data-theme="light"] :is(.topbar-link, .topbar-phone-number) { color: #334155 !important; }
html[data-theme="dark"] .wct-topbar { background: #050811 !important; }
html[data-theme="dark"] :is(.topbar-link, .topbar-phone-number) { color: #cbd5e1 !important; }

html[data-theme="light"] .wct-nav-link > span:not(.nav-hot-tag) { color: #1e293b !important; }
html[data-theme="light"] .wct-nav-link.active > span:not(.nav-hot-tag) { color: #1d4ed8 !important; font-weight: 700; }
html[data-theme="dark"] .wct-nav-link > span:not(.nav-hot-tag) { color: #e2e8f0 !important; }
html[data-theme="dark"] .wct-nav-link.active > span:not(.nav-hot-tag) { color: #93c5fd !important; font-weight: 700; }

html[data-theme="light"] :is(.btn-search-trigger > svg, #theme-toggle-btn svg) { color: #334155 !important; }
html[data-theme="dark"] :is(.btn-search-trigger > svg, #theme-toggle-btn svg) { color: #cbd5e1 !important; }

html[data-theme] .nav-hot-tag {
    background: #b91c1c !important;
    color: #ffffff !important;
    font-weight: 800 !important;
}

/* Category Filter Active Pill */
html[data-theme] .archive-filter-pill {
    background: #1d4ed8 !important;
    color: #ffffff !important;
}

/* 6. Post Cards & Archive Views */
html[data-theme="light"] .post-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
}
html[data-theme="dark"] .post-card {
    background: #0d1222 !important;
    border: 1px solid #1e293b !important;
}

html[data-theme="light"] :is(.post-meta-row > span, .post-meta-item, .post-meta-row svg) { color: #475569 !important; }
html[data-theme="dark"] :is(.post-meta-row > span, .post-meta-item, .post-meta-row svg) { color: #94a3b8 !important; }

html[data-theme="light"] .post-title > a { color: #0f172a !important; }
html[data-theme="dark"] .post-title > a { color: #f8fafc !important; }

html[data-theme="light"] .post-excerpt { color: #334155 !important; }
html[data-theme="dark"] .post-excerpt { color: #cbd5e1 !important; }

html[data-theme="light"] .post-category-badge {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
    border: 1px solid #bfdbfe !important;
}
html[data-theme="dark"] .post-category-badge {
    background: #0f1d38 !important;
    color: #93c5fd !important;
    border: 1px solid #1e3a8a !important;
}

html[data-theme="light"] :is(.post-footer > span, .post-footer > a) { color: #475569 !important; }
html[data-theme="dark"] :is(.post-footer > span, .post-footer > a) { color: #94a3b8 !important; }

/* 7. Post Detail Content (Typography & Captions) */
html[data-theme="light"] .article-content :is(figcaption, .wct-figcaption, .wp-caption-text) {
    color: #334155 !important;
}
html[data-theme="dark"] .article-content :is(figcaption, .wct-figcaption, .wp-caption-text) {
    color: #cbd5e1 !important;
}

html[data-theme="light"] .article-content a:not(.btn) {
    color: #1d4ed8 !important;
    text-decoration: underline;
    text-underline-offset: 3px;
}
html[data-theme="dark"] .article-content a:not(.btn) {
    color: #93c5fd !important;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* 8. Pagination Elements */
html[data-theme="light"] .wct-pagination .page-link {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #1e293b !important;
}
html[data-theme="dark"] .wct-pagination .page-link {
    background: #0d1222 !important;
    border: 1px solid #334155 !important;
    color: #e2e8f0 !important;
}
html[data-theme] .wct-pagination .page-link svg { color: inherit !important; }
html[data-theme] .wct-pagination .page-dots { color: var(--text-muted) !important; }

/* 9. Projects Page (/du-an) */
html[data-theme="dark"] .project-card {
    background: #0d1222 !important;
    border: 1px solid #1e293b !important;
}
html[data-theme="dark"] .project-title > a { color: #f8fafc !important; }
html[data-theme="dark"] .project-desc { color: #cbd5e1 !important; }
html[data-theme="dark"] .btn-card-action {
    background: #111c35 !important;
    color: #93c5fd !important;
    border: 1px solid #1e3a8a !important;
}

/* 10. Footer Links & Email */
html[data-theme="light"] :is(.footer-col a, .footer-links a) { color: #334155 !important; }
html[data-theme="light"] :is(.footer-col a:hover, .footer-links a:hover) { color: #1d4ed8 !important; }
html[data-theme="dark"] :is(.footer-col a, .footer-links a) { color: #cbd5e1 !important; }
html[data-theme="dark"] :is(.footer-col a:hover, .footer-links a:hover) { color: #93c5fd !important; }

/* Keep outline SVGs hollow */
html[data-theme] svg[fill="none"],
html[data-theme] svg[fill="none"] :is(path, rect, circle, polyline, polygon, line):not([fill]) {
    fill: none !important;
}
html[data-theme] .article-content :is(.hljs-tag, .hljs-comment, .hljs-quote) {
    color: #a1a9b7 !important;
}
html[data-theme="light"] .article-content .text-accent { color: #0369a1 !important; }
html[data-theme="light"] .article-content .text-success { color: #047857 !important; }
html[data-theme="light"] .article-content .text-warning { color: #92400e !important; }
html[data-theme="light"] .article-content .text-gradient {
    background-image: linear-gradient(135deg, #1d4ed8, #0369a1, #047857);
}

/* Expanded mobile navigation must use the same color roles as its parent. */
.section-tag { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
html[data-theme] :is(.nav-item-arrow, .accordion-chevron) { color: var(--text-muted); }
html[data-theme] :is(.mobile-nav-item.active, .mobile-nav-item:hover, .mobile-accordion-arrow.is-open, .mobile-accordion-arrow:hover) :is(.nav-item-arrow, .accordion-chevron) { color: var(--link-color); }
html[data-theme] .mobile-accordion-row .sub-count-badge {
    color: var(--text-main);
    background: var(--bg-surface);
}
html[data-theme] .mobile-accordion-row.is-open .sub-count-badge {
    color: #fff;
    background: var(--action-bg);
}
html[data-theme] .search-input-wrap .kbd-badge {
    color: var(--text-main);
    background: var(--bg-surface);
    border: 1px solid var(--control-border);
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    cursor: pointer;
    font-family: inherit;
}
.search-input-field { min-width: 0; }
html[data-theme] :is(.search-result-cat, .search-view-all-link) { color: var(--link-color) !important; }
.search-result-item > div { flex-wrap: wrap; }
.search-result-item h5 { min-width: 0; overflow-wrap: anywhere; }
.search-result-item .search-result-cat { max-width: 100%; white-space: normal !important; }
/* Legacy rich text inside a code block sits on the same dark code surface in both themes. */
html[data-theme] .article-content pre code.language-plaintext :is(span, strong, em, b, i) { color: inherit !important; }
html[data-theme] .article-content pre code :is(a:not(.btn), a:not(.btn) *) { color: #93c5fd !important; }
html[data-theme] .article-content pre a { text-decoration: underline; }
.search-modal-card { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.search-input-wrap { flex-shrink: 0; }
.search-results-list { min-height: 0; overscroll-behavior: contain; }
@media (max-width: 480px) {
    .search-input-wrap { padding: .75rem; gap: .5rem; }
}
@media (max-height: 600px) {
    .search-modal { padding-top: 16px; align-items: flex-start; }
}
