/*
Theme Name: FastPress Minimal
Theme URI: https://github.com/fastpress-theme/fastpress-minimal
Author: Senior WordPress Core & Performance Team
Author URI: https://fastpress.dev
Description: WordPress theme phong cách Minimalist được tinh gọn tối đa, đạt tốc độ siêu nhanh (Core Web Vitals < 2.0s Mobile, 0 CLS, INP < 200ms), tối ưu cấu trúc SEO On-page chuẩn Schema JSON-LD và bố trí vị trí đặt quảng cáo Google AdSense mang lại CTR cao nhất.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: fastpress-minimal
Tags: blog, news, grid-layout, one-column, two-columns, custom-menu, featured-images, translation-ready, accessibility-ready
*/

/* ==========================================================================
   1. CSS VARIABLES & DESIGN TOKENS
   ========================================================================== */
:root {
  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  /* Color Palette - Minimalist High Contrast */
  --bg-color: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --ad-bg: #f8fafc;
  --ad-border: #e2e8f0;
  --ad-label-color: #94a3b8;
  
  /* Layout Sizing */
  --max-width: 1200px;
  --content-width: 760px;
  --sidebar-width: 320px;
  --gap: 2.5rem;
  --radius: 8px;
  --radius-sm: 4px;
  --transition: all 0.2s ease-in-out;
  
  /* Typography Scale */
  --font-size-base: 1.0625rem; /* 17px */
  --line-height-base: 1.75;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --border-color: #334155;
    --primary-color: #38bdf8;
    --primary-hover: #7dd3fc;
    --ad-bg: #1e293b;
    --ad-border: #334155;
    --ad-label-color: #64748b;
  }
}

/* ==========================================================================
   2. MODERN CSS RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-system);
  font-size: 16px;
  text-rendering: optimizeSpeed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--primary-color);
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  z-index: 100000;
  border-radius: var(--radius-sm);
  transition: top 0.2s ease;
  text-decoration: none;
}
.skip-link:focus {
  top: 1rem;
}

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
}

h1:first-child, h2:first-child, h3:first-child {
  margin-top: 0;
}

h1 { font-size: clamp(1.875rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.2rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; text-transform: uppercase; }

p {
  margin-bottom: 1.5rem;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover, a:focus {
  color: var(--primary-hover);
  text-decoration: underline;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

ul, ol {
  margin-left: 1.75rem;
  margin-bottom: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

blockquote {
  border-left: 4px solid var(--primary-color);
  padding-left: 1.25rem;
  margin: 1.75rem 0;
  color: var(--text-muted);
  font-style: italic;
}

pre, code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background-color: var(--bg-secondary);
  padding: 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

code:not(pre code) {
  background-color: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 2.5rem 0;
}

/* ==========================================================================
   3. SITE HEADER & NAVIGATION
   ========================================================================== */
.site-header {
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.95);
}

@media (prefers-color-scheme: dark) {
  .site-header {
    background-color: rgba(15, 23, 42, 0.95);
  }
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-branding {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
}

.site-title a {
  color: var(--text-main);
  text-decoration: none;
}

.site-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  display: none;
}

@media (min-width: 768px) {
  .site-description {
    display: block;
  }
}

/* Primary Menu */
.main-navigation ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
}

.main-navigation a {
  color: var(--text-main);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.5rem 0;
}

.main-navigation a:hover,
.main-navigation .current-menu-item > a {
  color: var(--primary-color);
  text-decoration: none;
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: var(--text-main);
  font-size: 1rem;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }
  
  .main-navigation {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  }
  
  .main-navigation.is-active {
    display: block;
  }
  
  .main-navigation ul {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

/* ==========================================================================
   4. LAYOUT & GRID (CORE WEB VITALS OPTIMIZED)
   ========================================================================== */
.site-content {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

.content-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
}

@media (min-width: 992px) {
  .content-wrapper.has-sidebar {
    grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  }
}

.site-main {
  min-width: 0; /* Prevents grid blowout */
}

/* ==========================================================================
   5. ADSENSE AD CONTAINER ARCHITECTURE (ZERO CLS GUARANTEED)
   ========================================================================== */
.ad-slot-wrapper {
  margin: 1.75rem auto;
  text-align: center;
  position: relative;
  background-color: var(--ad-bg);
  border: 1px dashed var(--ad-border);
  border-radius: var(--radius-sm);
  padding: 8px 4px 6px 4px;
  box-sizing: border-box;
  contain: layout style;
  width: 100%;
}

.ad-slot-label {
  display: block;
  font-size: 0.6875rem; /* 11px */
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ad-label-color);
  margin-bottom: 6px;
  font-weight: 500;
  user-select: none;
}

/* Reserved Dimensions to prevent Cumulative Layout Shift */
.ad-slot-header {
  min-height: 110px; /* Label + 90px ad */
  max-width: 728px;
}
@media (max-width: 768px) {
  .ad-slot-header {
    min-height: 70px; /* 50px ad + label */
    max-width: 320px;
  }
}

.ad-slot-before-content {
  min-height: 275px; /* Label + 250px ad */
  max-width: 100%;
}

.ad-slot-incontent {
  min-height: 275px; /* 250px box or 280px responsive */
  margin: 2.25rem auto;
}

.ad-slot-after-content {
  min-height: 275px;
  margin-top: 2.5rem;
}

.ad-slot-sidebar {
  min-height: 620px; /* 600px half-page ad + label */
  max-width: 300px;
}
@media (max-width: 991px) {
  .ad-slot-sidebar {
    min-height: 275px; /* 250px rectangle */
    max-width: 300px;
  }
}

/* Mobile Sticky Footer Ad Unit */
.ad-slot-sticky-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 99999;
  background-color: var(--bg-color);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  padding: 4px 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  transition: transform 0.3s ease;
}

.ad-slot-sticky-footer.is-hidden {
  transform: translateY(100%);
  pointer-events: none;
}

.ad-close-btn {
  position: absolute;
  top: -24px;
  right: 12px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1.4;
  font-weight: bold;
}

/* ==========================================================================
   6. ARTICLE & BLOG CARDS (LIST / ARCHIVE)
   ========================================================================== */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 640px) {
  .posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.post-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.05);
  border-color: var(--primary-color);
}

.post-card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: var(--bg-secondary);
}

.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.post-card:hover .post-card-thumb img {
  transform: scale(1.03);
}

.post-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-card-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.post-card-title {
  font-size: 1.25rem;
  margin: 0 0 0.75rem 0;
  line-height: 1.35;
}

.post-card-title a {
  color: var(--text-main);
}

.post-card-title a:hover {
  color: var(--primary-color);
  text-decoration: none;
}

.post-card-excerpt {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex: 1;
}

.read-more-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Numeric Pagination */
.pagination-nav {
  margin-top: 3rem;
  text-align: center;
}

.pagination-nav .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.75rem;
  margin: 0 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9375rem;
}

.pagination-nav .page-numbers.current {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
}

.pagination-nav .page-numbers:hover:not(.current) {
  border-color: var(--primary-color);
  color: var(--primary-color);
  text-decoration: none;
}

/* ==========================================================================
   7. SINGLE POST TEMPLATE (READABILITY & CTR FOCUS)
   ========================================================================== */
.single-article {
  max-width: var(--content-width);
  margin: 0 auto;
}

.post-header {
  margin-bottom: 2rem;
}

.breadcrumbs {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.breadcrumbs a {
  color: var(--text-muted);
}
.breadcrumbs a:hover {
  color: var(--primary-color);
}

.post-category-badge {
  display: inline-block;
  background-color: var(--bg-secondary);
  color: var(--primary-color);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-color);
}

.post-headline {
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.post-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.post-author-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.author-avatar {
  border-radius: 50%;
  width: 32px;
  height: 32px;
}

.post-featured-media {
  margin: 1.75rem 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.post-featured-media img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* Post Body Content */
.entry-content {
  font-size: 1.125rem; /* 18px */
  line-height: 1.8;
}

.entry-content p {
  margin-bottom: 1.75rem;
}

.entry-content img {
  border-radius: var(--radius-sm);
  margin: 1.75rem auto;
}

.entry-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.post-tags a {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.8125rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.post-tags a:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  text-decoration: none;
}

/* Author Bio Box */
.author-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 2.5rem 0;
}

.author-box-avatar {
  border-radius: 50%;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.author-box-name {
  font-size: 1.125rem;
  margin: 0 0 0.4rem 0;
}

.author-box-bio {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* Related Posts */
.related-posts {
  margin: 3rem 0;
}

.related-posts-title {
  font-size: 1.35rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.related-posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 600px) {
  .related-posts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.related-post-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-card);
}

.related-post-thumb {
  aspect-ratio: 16 / 9;
  background-color: var(--bg-secondary);
}

.related-post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-post-title {
  font-size: 0.9375rem;
  padding: 0.75rem;
  margin: 0;
  line-height: 1.4;
}

.related-post-title a {
  color: var(--text-main);
}

/* Post Navigation (Prev / Next) */
.post-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2rem 0;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.nav-previous, .nav-next {
  display: flex;
  flex-direction: column;
}

.nav-next {
  text-align: right;
}

.nav-subtitle {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.nav-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ==========================================================================
   8. SIDEBAR & WIDGETS
   ========================================================================== */
.widget-area {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sticky-sidebar-container {
  position: sticky;
  top: 90px;
}

.widget {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.widget-title {
  font-size: 1.125rem;
  margin: 0 0 1rem 0;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
}

.widget ul {
  list-style: none;
  margin: 0;
}

.widget li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}
.widget li:last-child {
  border-bottom: none;
}

/* Search Form */
.search-form {
  display: flex;
  gap: 0.5rem;
}

.search-form input[type="search"] {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-color);
  color: var(--text-main);
  font-size: 0.9375rem;
}

.search-form button {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

.search-form button:hover {
  background-color: var(--primary-hover);
}

/* ==========================================================================
   9. COMMENTS (CLEAN & ACCESSIBLE)
   ========================================================================== */
.comments-area {
  margin-top: 3rem;
  content-visibility: auto; /* Browser render optimization */
}

.comments-title {
  font-size: 1.35rem;
  margin-bottom: 1.5rem;
}

.comment-list {
  list-style: none;
  margin: 0 0 2.5rem 0;
}

.comment-body {
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  background-color: var(--bg-card);
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.comment-author .fn {
  font-weight: 700;
  color: var(--text-main);
}

.comment-metadata {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.comment-content p:last-child {
  margin-bottom: 0;
}

.comment-respond {
  margin-top: 2rem;
}

.comment-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.comment-form textarea,
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9375rem;
}

.comment-form input[type="submit"] {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
}

/* ==========================================================================
   10. SITE FOOTER
   ========================================================================== */
.site-footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
  content-visibility: auto;
}

.footer-widgets {
  max-width: var(--max-width);
  margin: 0 auto 2.5rem auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .footer-widgets {
    grid-template-columns: repeat(3, 1fr);
  }
}

.footer-bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

@media (min-width: 768px) {
  .footer-bottom {
    flex-direction: row;
  }
}

/* Back to Top Floating Button */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--primary-color);
  color: #ffffff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 999;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
}
